MCPcopy Create free account
hub / github.com/Kaggle/docker-python / get_secret

Method get_secret

patches/kaggle_secrets.py:50–68  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 3

get_gcloud_credentialMethod · 0.95
call_get_secretMethod · 0.95

Calls 3

BackendErrorClass · 0.90
ValidationErrorClass · 0.85
make_post_requestMethod · 0.80

Tested by 2

call_get_secretMethod · 0.76