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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

21 statements  

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 

6from c7n.utils import jmespath_search 

7 

8 

9@resources.register('cloudbilling-account') 

10class CloudBillingAccount(QueryResourceManager): 

11 

12 class resource_type(TypeInfo): 

13 service = 'cloudbilling' 

14 version = 'v1' 

15 component = 'billingAccounts' 

16 enum_spec = ('list', 'billingAccounts[]', None) 

17 get_requires_event = True 

18 scope = None 

19 name = id = 'name' 

20 default_report_fields = ['name', 'displayName'] 

21 asset_type = "cloudbilling.googleapis.com/BillingAccount" 

22 permissions = ('billing.accounts.list',) 

23 urn_component = "account" 

24 urn_id_segments = (-1,) # Just use the last segment of the id in the URN 

25 

26 @staticmethod 

27 def get(client, event): 

28 return client.execute_query( 

29 'get', {'name': jmespath_search( 

30 'protoPayload.response.billingAccountInfo.billingAccountName', event)})