Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/c7n_gcp/resources/notebook.py: 95%

19 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:51 +0000

1# Copyright The Cloud Custodian Authors. 

2# SPDX-License-Identifier: Apache-2.0 

3from c7n_gcp.provider import resources 

4from c7n_gcp.query import QueryResourceManager, TypeInfo 

5 

6 

7@resources.register('notebook') 

8class NotebookInstance(QueryResourceManager): 

9 """ GC resource: https://cloud.google.com/vertex-ai/docs/workbench/reference/rest 

10 

11 GCP Vertex AI Workbench has public IPs. 

12 

13 :example: GCP Vertex AI Workbench has public IPs 

14 

15 .. yaml: 

16 

17 policies: 

18 - name: gcp-vertex-ai-workbench-with-public-ips 

19 description: | 

20 GCP Vertex AI Workbench has public IPs 

21 resource: gcp.notebook 

22 filters: 

23 - type: value 

24 key: noPublicIp 

25 value: true 

26 """ 

27 class resource_type(TypeInfo): 

28 service = 'notebooks' 

29 version = 'v1' 

30 component = 'projects.locations.instances' 

31 enum_spec = ('list', 'instances[]', None) 

32 scope_key = 'parent' 

33 name = id = 'name' 

34 scope_template = "projects/{}/locations/-" 

35 permissions = ('notebooks.instances.list',) 

36 default_report_fields = ['name', 'createTime', 'state'] 

37 urn_id_segments = (-1,) 

38 urn_component = "instances" 

39 

40 @classmethod 

41 def _get_location(cls, resource): 

42 return resource['name'].split('/')[3]