Retrieves a user secret value by its label. This returns the value of the secret with the given label, if it attached to the current kernel. Example usage: client = UserSecretsClient() secret = client.get_secret('my_db_password')
(self, label)
| 48 | self.web_client = KaggleWebClient() |
| 49 | |
| 50 | def get_secret(self, label) -> str: |
| 51 | """Retrieves a user secret value by its label. |
| 52 | |
| 53 | This returns the value of the secret with the given label, |
| 54 | if it attached to the current kernel. |
| 55 | Example usage: |
| 56 | client = UserSecretsClient() |
| 57 | secret = client.get_secret('my_db_password') |
| 58 | """ |
| 59 | if label is None or len(label) == 0: |
| 60 | raise ValidationError("Label must be non-empty.") |
| 61 | request_body = { |
| 62 | 'Label': label, |
| 63 | } |
| 64 | response_json = self.web_client.make_post_request(request_body, self.GET_USER_SECRET_BY_LABEL_ENDPOINT) |
| 65 | if 'secret' not in response_json: |
| 66 | raise BackendError( |
| 67 | f'Unexpected response from the service. Response: {response_json}') |
| 68 | return response_json['secret'] |
| 69 | |
| 70 | def get_gcloud_credential(self) -> str: |
| 71 | """Retrieves the Google Cloud SDK credential attached to the current |