adding more specific metrics (#302)

Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
The Magician 2019-07-10 10:59:51 -07:00 committed by Alex Stephen
parent 5b92781ab0
commit c946e77783
2 changed files with 19 additions and 4 deletions

View file

@ -36,6 +36,12 @@ options:
description:
- Array of scopes to be used.
type: list
env_type:
description:
- Specifies which Ansible environment you're running this module within.
- This should not be set unless you know what you're doing.
- This only alters the User Agent string for any API requests.
type: str
notes:
- for authentication, you can set service_account_file using the
c(gcp_service_account_file) env variable.

View file

@ -165,9 +165,14 @@ class GcpSession(object):
self.module.fail_json(msg="Credential type '%s' not implemented" % cred_type)
def _headers(self):
return {
'User-Agent': "Google-Ansible-MM-{0}".format(self.product)
}
if self.module.params.get('env_type'):
return {
'User-Agent': "Google-Ansible-MM-{0}-{1}".format(self.product, self.module.params.get('env_type'))
}
else:
return {
'User-Agent': "Google-Ansible-MM-{0}".format(self.product)
}
def _merge_dictionaries(self, a, b):
new = a.copy()
@ -208,7 +213,11 @@ class GcpModule(AnsibleModule):
scopes=dict(
required=False,
fallback=(env_fallback, ['GCP_SCOPES']),
type='list')
type='list'),
env_type=dict(
required=False,
fallback=(env_fallback, ['GCP_ENV_TYPE']),
type='str')
)
)