Reputation: 127
How can I use the discovery build object? According to description it returns a resource with methods on calling the service.
On checking the available methods using dir
, I see there is customers
.
Where do I go from there? On checking the dir
on response.customers
there are dunder methods only. How do I go about listing the customers?
I tried looking here https://developers.google.com/explorer-help and search for this customers
method.
I tried the following to try to get something going
SCOPES = ['https://www.googleapis.com/auth/cloud-billing','https://www.googleapis.com/auth/business.manage']
SERVICE_ACCOUNT_FILE = os.environ['GOOGLE_APPLICATION_CREDENTIALS']
credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
response = googleapiclient.discovery.build('admin', 'directory_v1', credentials=credentials)
print(response)
print(dir(response))
print(dir(response.customers))
print(response.customers.get)
<googleapiclient.discovery.Resource object at 0x000001F692F71CC0>
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_add_basic_methods', '_add_nested_resources', '_add_next_methods', '_baseUrl', '_credentials_validated', '_developerKey', '_dynamic_attrs', '_http', '_model', '_requestBuilder', '_resourceDesc', '_rootDesc', '_schema', '_set_dynamic_attr', '_set_service_methods', '_universe_domain', '_validate_credentials', 'asps', 'channels', 'chromeosdevices', 'close', 'customer', 'customers', 'domainAliases', 'domains', 'groups', 'members', 'mobiledevices', 'new_batch_http_request', 'orgunits', 'privileges', 'resources', 'roleAssignments', 'roles', 'schemas', 'tokens', 'twoStepVerification', 'users', 'verificationCodes']
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__func__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__is_resource__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
Upvotes: 0
Views: 41