Retrieves the Google Cloud SDK credential attached to the current kernel. Example usage: client = UserSecretsClient() credential_json = client.get_gcloud_credential()
(self)
| 68 | return response_json['secret'] |
| 69 | |
| 70 | def get_gcloud_credential(self) -> str: |
| 71 | """Retrieves the Google Cloud SDK credential attached to the current |
| 72 | kernel. |
| 73 | Example usage: |
| 74 | client = UserSecretsClient() |
| 75 | credential_json = client.get_gcloud_credential() |
| 76 | """ |
| 77 | try: |
| 78 | return self.get_secret("__gcloud_sdk_auth__") |
| 79 | except BackendError as backend_error: |
| 80 | message = str(backend_error.args) |
| 81 | if message.find('No user secrets exist') != -1: |
| 82 | raise NotFoundError('Google Cloud SDK credential not found.') |
| 83 | else: |
| 84 | raise |
| 85 | |
| 86 | def set_gcloud_credentials(self, project=None, account=None): |
| 87 | """Set user credentials attached to the current kernel and optionally the project & account name to the `gcloud` CLI. |