databricks-sdk 0.57.0__py3-none-any.whl → 0.59.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of databricks-sdk might be problematic. Click here for more details.
- databricks/sdk/__init__.py +38 -9
- databricks/sdk/service/aibuilder.py +0 -163
- databricks/sdk/service/apps.py +53 -49
- databricks/sdk/service/billing.py +62 -223
- databricks/sdk/service/catalog.py +3052 -3707
- databricks/sdk/service/cleanrooms.py +5 -54
- databricks/sdk/service/compute.py +579 -2715
- databricks/sdk/service/dashboards.py +108 -317
- databricks/sdk/service/database.py +603 -122
- databricks/sdk/service/files.py +2 -218
- databricks/sdk/service/iam.py +19 -298
- databricks/sdk/service/jobs.py +77 -1263
- databricks/sdk/service/marketplace.py +3 -575
- databricks/sdk/service/ml.py +816 -2734
- databricks/sdk/service/oauth2.py +122 -238
- databricks/sdk/service/pipelines.py +133 -724
- databricks/sdk/service/provisioning.py +36 -757
- databricks/sdk/service/qualitymonitorv2.py +0 -18
- databricks/sdk/service/serving.py +37 -583
- databricks/sdk/service/settings.py +282 -1768
- databricks/sdk/service/sharing.py +6 -478
- databricks/sdk/service/sql.py +129 -1696
- databricks/sdk/service/vectorsearch.py +0 -410
- databricks/sdk/service/workspace.py +252 -727
- databricks/sdk/version.py +1 -1
- {databricks_sdk-0.57.0.dist-info → databricks_sdk-0.59.0.dist-info}/METADATA +1 -1
- {databricks_sdk-0.57.0.dist-info → databricks_sdk-0.59.0.dist-info}/RECORD +31 -31
- {databricks_sdk-0.57.0.dist-info → databricks_sdk-0.59.0.dist-info}/WHEEL +0 -0
- {databricks_sdk-0.57.0.dist-info → databricks_sdk-0.59.0.dist-info}/licenses/LICENSE +0 -0
- {databricks_sdk-0.57.0.dist-info → databricks_sdk-0.59.0.dist-info}/licenses/NOTICE +0 -0
- {databricks_sdk-0.57.0.dist-info → databricks_sdk-0.59.0.dist-info}/top_level.txt +0 -0
databricks/sdk/service/oauth2.py
CHANGED
|
@@ -14,75 +14,6 @@ _LOG = logging.getLogger("databricks.sdk")
|
|
|
14
14
|
# all definitions in this file are in alphabetical order
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
@dataclass
|
|
18
|
-
class CreateCustomAppIntegration:
|
|
19
|
-
confidential: Optional[bool] = None
|
|
20
|
-
"""This field indicates whether an OAuth client secret is required to authenticate this client."""
|
|
21
|
-
|
|
22
|
-
name: Optional[str] = None
|
|
23
|
-
"""Name of the custom OAuth app"""
|
|
24
|
-
|
|
25
|
-
redirect_urls: Optional[List[str]] = None
|
|
26
|
-
"""List of OAuth redirect urls"""
|
|
27
|
-
|
|
28
|
-
scopes: Optional[List[str]] = None
|
|
29
|
-
"""OAuth scopes granted to the application. Supported scopes: all-apis, sql, offline_access,
|
|
30
|
-
openid, profile, email."""
|
|
31
|
-
|
|
32
|
-
token_access_policy: Optional[TokenAccessPolicy] = None
|
|
33
|
-
"""Token access policy"""
|
|
34
|
-
|
|
35
|
-
user_authorized_scopes: Optional[List[str]] = None
|
|
36
|
-
"""Scopes that will need to be consented by end user to mint the access token. If the user does not
|
|
37
|
-
authorize the access token will not be minted. Must be a subset of scopes."""
|
|
38
|
-
|
|
39
|
-
def as_dict(self) -> dict:
|
|
40
|
-
"""Serializes the CreateCustomAppIntegration into a dictionary suitable for use as a JSON request body."""
|
|
41
|
-
body = {}
|
|
42
|
-
if self.confidential is not None:
|
|
43
|
-
body["confidential"] = self.confidential
|
|
44
|
-
if self.name is not None:
|
|
45
|
-
body["name"] = self.name
|
|
46
|
-
if self.redirect_urls:
|
|
47
|
-
body["redirect_urls"] = [v for v in self.redirect_urls]
|
|
48
|
-
if self.scopes:
|
|
49
|
-
body["scopes"] = [v for v in self.scopes]
|
|
50
|
-
if self.token_access_policy:
|
|
51
|
-
body["token_access_policy"] = self.token_access_policy.as_dict()
|
|
52
|
-
if self.user_authorized_scopes:
|
|
53
|
-
body["user_authorized_scopes"] = [v for v in self.user_authorized_scopes]
|
|
54
|
-
return body
|
|
55
|
-
|
|
56
|
-
def as_shallow_dict(self) -> dict:
|
|
57
|
-
"""Serializes the CreateCustomAppIntegration into a shallow dictionary of its immediate attributes."""
|
|
58
|
-
body = {}
|
|
59
|
-
if self.confidential is not None:
|
|
60
|
-
body["confidential"] = self.confidential
|
|
61
|
-
if self.name is not None:
|
|
62
|
-
body["name"] = self.name
|
|
63
|
-
if self.redirect_urls:
|
|
64
|
-
body["redirect_urls"] = self.redirect_urls
|
|
65
|
-
if self.scopes:
|
|
66
|
-
body["scopes"] = self.scopes
|
|
67
|
-
if self.token_access_policy:
|
|
68
|
-
body["token_access_policy"] = self.token_access_policy
|
|
69
|
-
if self.user_authorized_scopes:
|
|
70
|
-
body["user_authorized_scopes"] = self.user_authorized_scopes
|
|
71
|
-
return body
|
|
72
|
-
|
|
73
|
-
@classmethod
|
|
74
|
-
def from_dict(cls, d: Dict[str, Any]) -> CreateCustomAppIntegration:
|
|
75
|
-
"""Deserializes the CreateCustomAppIntegration from a dictionary."""
|
|
76
|
-
return cls(
|
|
77
|
-
confidential=d.get("confidential", None),
|
|
78
|
-
name=d.get("name", None),
|
|
79
|
-
redirect_urls=d.get("redirect_urls", None),
|
|
80
|
-
scopes=d.get("scopes", None),
|
|
81
|
-
token_access_policy=_from_dict(d, "token_access_policy", TokenAccessPolicy),
|
|
82
|
-
user_authorized_scopes=d.get("user_authorized_scopes", None),
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
|
|
86
17
|
@dataclass
|
|
87
18
|
class CreateCustomAppIntegrationOutput:
|
|
88
19
|
client_id: Optional[str] = None
|
|
@@ -127,40 +58,6 @@ class CreateCustomAppIntegrationOutput:
|
|
|
127
58
|
)
|
|
128
59
|
|
|
129
60
|
|
|
130
|
-
@dataclass
|
|
131
|
-
class CreatePublishedAppIntegration:
|
|
132
|
-
app_id: Optional[str] = None
|
|
133
|
-
"""App id of the OAuth published app integration. For example power-bi, tableau-deskop"""
|
|
134
|
-
|
|
135
|
-
token_access_policy: Optional[TokenAccessPolicy] = None
|
|
136
|
-
"""Token access policy"""
|
|
137
|
-
|
|
138
|
-
def as_dict(self) -> dict:
|
|
139
|
-
"""Serializes the CreatePublishedAppIntegration into a dictionary suitable for use as a JSON request body."""
|
|
140
|
-
body = {}
|
|
141
|
-
if self.app_id is not None:
|
|
142
|
-
body["app_id"] = self.app_id
|
|
143
|
-
if self.token_access_policy:
|
|
144
|
-
body["token_access_policy"] = self.token_access_policy.as_dict()
|
|
145
|
-
return body
|
|
146
|
-
|
|
147
|
-
def as_shallow_dict(self) -> dict:
|
|
148
|
-
"""Serializes the CreatePublishedAppIntegration into a shallow dictionary of its immediate attributes."""
|
|
149
|
-
body = {}
|
|
150
|
-
if self.app_id is not None:
|
|
151
|
-
body["app_id"] = self.app_id
|
|
152
|
-
if self.token_access_policy:
|
|
153
|
-
body["token_access_policy"] = self.token_access_policy
|
|
154
|
-
return body
|
|
155
|
-
|
|
156
|
-
@classmethod
|
|
157
|
-
def from_dict(cls, d: Dict[str, Any]) -> CreatePublishedAppIntegration:
|
|
158
|
-
"""Deserializes the CreatePublishedAppIntegration from a dictionary."""
|
|
159
|
-
return cls(
|
|
160
|
-
app_id=d.get("app_id", None), token_access_policy=_from_dict(d, "token_access_policy", TokenAccessPolicy)
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
|
|
164
61
|
@dataclass
|
|
165
62
|
class CreatePublishedAppIntegrationOutput:
|
|
166
63
|
integration_id: Optional[str] = None
|
|
@@ -186,39 +83,6 @@ class CreatePublishedAppIntegrationOutput:
|
|
|
186
83
|
return cls(integration_id=d.get("integration_id", None))
|
|
187
84
|
|
|
188
85
|
|
|
189
|
-
@dataclass
|
|
190
|
-
class CreateServicePrincipalSecretRequest:
|
|
191
|
-
lifetime: Optional[str] = None
|
|
192
|
-
"""The lifetime of the secret in seconds. If this parameter is not provided, the secret will have a
|
|
193
|
-
default lifetime of 730 days (63072000s)."""
|
|
194
|
-
|
|
195
|
-
service_principal_id: Optional[int] = None
|
|
196
|
-
"""The service principal ID."""
|
|
197
|
-
|
|
198
|
-
def as_dict(self) -> dict:
|
|
199
|
-
"""Serializes the CreateServicePrincipalSecretRequest into a dictionary suitable for use as a JSON request body."""
|
|
200
|
-
body = {}
|
|
201
|
-
if self.lifetime is not None:
|
|
202
|
-
body["lifetime"] = self.lifetime
|
|
203
|
-
if self.service_principal_id is not None:
|
|
204
|
-
body["service_principal_id"] = self.service_principal_id
|
|
205
|
-
return body
|
|
206
|
-
|
|
207
|
-
def as_shallow_dict(self) -> dict:
|
|
208
|
-
"""Serializes the CreateServicePrincipalSecretRequest into a shallow dictionary of its immediate attributes."""
|
|
209
|
-
body = {}
|
|
210
|
-
if self.lifetime is not None:
|
|
211
|
-
body["lifetime"] = self.lifetime
|
|
212
|
-
if self.service_principal_id is not None:
|
|
213
|
-
body["service_principal_id"] = self.service_principal_id
|
|
214
|
-
return body
|
|
215
|
-
|
|
216
|
-
@classmethod
|
|
217
|
-
def from_dict(cls, d: Dict[str, Any]) -> CreateServicePrincipalSecretRequest:
|
|
218
|
-
"""Deserializes the CreateServicePrincipalSecretRequest from a dictionary."""
|
|
219
|
-
return cls(lifetime=d.get("lifetime", None), service_principal_id=d.get("service_principal_id", None))
|
|
220
|
-
|
|
221
|
-
|
|
222
86
|
@dataclass
|
|
223
87
|
class CreateServicePrincipalSecretResponse:
|
|
224
88
|
create_time: Optional[str] = None
|
|
@@ -366,7 +230,6 @@ class FederationPolicy:
|
|
|
366
230
|
the request URL."""
|
|
367
231
|
|
|
368
232
|
oidc_policy: Optional[OidcFederationPolicy] = None
|
|
369
|
-
"""Specifies the policy to use for validating OIDC claims in your federated tokens."""
|
|
370
233
|
|
|
371
234
|
policy_id: Optional[str] = None
|
|
372
235
|
"""The ID of the federation policy."""
|
|
@@ -1033,66 +896,6 @@ class TokenAccessPolicy:
|
|
|
1033
896
|
)
|
|
1034
897
|
|
|
1035
898
|
|
|
1036
|
-
@dataclass
|
|
1037
|
-
class UpdateCustomAppIntegration:
|
|
1038
|
-
integration_id: Optional[str] = None
|
|
1039
|
-
|
|
1040
|
-
redirect_urls: Optional[List[str]] = None
|
|
1041
|
-
"""List of OAuth redirect urls to be updated in the custom OAuth app integration"""
|
|
1042
|
-
|
|
1043
|
-
scopes: Optional[List[str]] = None
|
|
1044
|
-
"""List of OAuth scopes to be updated in the custom OAuth app integration, similar to redirect URIs
|
|
1045
|
-
this will fully replace the existing values instead of appending"""
|
|
1046
|
-
|
|
1047
|
-
token_access_policy: Optional[TokenAccessPolicy] = None
|
|
1048
|
-
"""Token access policy to be updated in the custom OAuth app integration"""
|
|
1049
|
-
|
|
1050
|
-
user_authorized_scopes: Optional[List[str]] = None
|
|
1051
|
-
"""Scopes that will need to be consented by end user to mint the access token. If the user does not
|
|
1052
|
-
authorize the access token will not be minted. Must be a subset of scopes."""
|
|
1053
|
-
|
|
1054
|
-
def as_dict(self) -> dict:
|
|
1055
|
-
"""Serializes the UpdateCustomAppIntegration into a dictionary suitable for use as a JSON request body."""
|
|
1056
|
-
body = {}
|
|
1057
|
-
if self.integration_id is not None:
|
|
1058
|
-
body["integration_id"] = self.integration_id
|
|
1059
|
-
if self.redirect_urls:
|
|
1060
|
-
body["redirect_urls"] = [v for v in self.redirect_urls]
|
|
1061
|
-
if self.scopes:
|
|
1062
|
-
body["scopes"] = [v for v in self.scopes]
|
|
1063
|
-
if self.token_access_policy:
|
|
1064
|
-
body["token_access_policy"] = self.token_access_policy.as_dict()
|
|
1065
|
-
if self.user_authorized_scopes:
|
|
1066
|
-
body["user_authorized_scopes"] = [v for v in self.user_authorized_scopes]
|
|
1067
|
-
return body
|
|
1068
|
-
|
|
1069
|
-
def as_shallow_dict(self) -> dict:
|
|
1070
|
-
"""Serializes the UpdateCustomAppIntegration into a shallow dictionary of its immediate attributes."""
|
|
1071
|
-
body = {}
|
|
1072
|
-
if self.integration_id is not None:
|
|
1073
|
-
body["integration_id"] = self.integration_id
|
|
1074
|
-
if self.redirect_urls:
|
|
1075
|
-
body["redirect_urls"] = self.redirect_urls
|
|
1076
|
-
if self.scopes:
|
|
1077
|
-
body["scopes"] = self.scopes
|
|
1078
|
-
if self.token_access_policy:
|
|
1079
|
-
body["token_access_policy"] = self.token_access_policy
|
|
1080
|
-
if self.user_authorized_scopes:
|
|
1081
|
-
body["user_authorized_scopes"] = self.user_authorized_scopes
|
|
1082
|
-
return body
|
|
1083
|
-
|
|
1084
|
-
@classmethod
|
|
1085
|
-
def from_dict(cls, d: Dict[str, Any]) -> UpdateCustomAppIntegration:
|
|
1086
|
-
"""Deserializes the UpdateCustomAppIntegration from a dictionary."""
|
|
1087
|
-
return cls(
|
|
1088
|
-
integration_id=d.get("integration_id", None),
|
|
1089
|
-
redirect_urls=d.get("redirect_urls", None),
|
|
1090
|
-
scopes=d.get("scopes", None),
|
|
1091
|
-
token_access_policy=_from_dict(d, "token_access_policy", TokenAccessPolicy),
|
|
1092
|
-
user_authorized_scopes=d.get("user_authorized_scopes", None),
|
|
1093
|
-
)
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
899
|
@dataclass
|
|
1097
900
|
class UpdateCustomAppIntegrationOutput:
|
|
1098
901
|
def as_dict(self) -> dict:
|
|
@@ -1111,40 +914,6 @@ class UpdateCustomAppIntegrationOutput:
|
|
|
1111
914
|
return cls()
|
|
1112
915
|
|
|
1113
916
|
|
|
1114
|
-
@dataclass
|
|
1115
|
-
class UpdatePublishedAppIntegration:
|
|
1116
|
-
integration_id: Optional[str] = None
|
|
1117
|
-
|
|
1118
|
-
token_access_policy: Optional[TokenAccessPolicy] = None
|
|
1119
|
-
"""Token access policy to be updated in the published OAuth app integration"""
|
|
1120
|
-
|
|
1121
|
-
def as_dict(self) -> dict:
|
|
1122
|
-
"""Serializes the UpdatePublishedAppIntegration into a dictionary suitable for use as a JSON request body."""
|
|
1123
|
-
body = {}
|
|
1124
|
-
if self.integration_id is not None:
|
|
1125
|
-
body["integration_id"] = self.integration_id
|
|
1126
|
-
if self.token_access_policy:
|
|
1127
|
-
body["token_access_policy"] = self.token_access_policy.as_dict()
|
|
1128
|
-
return body
|
|
1129
|
-
|
|
1130
|
-
def as_shallow_dict(self) -> dict:
|
|
1131
|
-
"""Serializes the UpdatePublishedAppIntegration into a shallow dictionary of its immediate attributes."""
|
|
1132
|
-
body = {}
|
|
1133
|
-
if self.integration_id is not None:
|
|
1134
|
-
body["integration_id"] = self.integration_id
|
|
1135
|
-
if self.token_access_policy:
|
|
1136
|
-
body["token_access_policy"] = self.token_access_policy
|
|
1137
|
-
return body
|
|
1138
|
-
|
|
1139
|
-
@classmethod
|
|
1140
|
-
def from_dict(cls, d: Dict[str, Any]) -> UpdatePublishedAppIntegration:
|
|
1141
|
-
"""Deserializes the UpdatePublishedAppIntegration from a dictionary."""
|
|
1142
|
-
return cls(
|
|
1143
|
-
integration_id=d.get("integration_id", None),
|
|
1144
|
-
token_access_policy=_from_dict(d, "token_access_policy", TokenAccessPolicy),
|
|
1145
|
-
)
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
917
|
@dataclass
|
|
1149
918
|
class UpdatePublishedAppIntegrationOutput:
|
|
1150
919
|
def as_dict(self) -> dict:
|
|
@@ -1906,7 +1675,7 @@ class ServicePrincipalSecretsAPI:
|
|
|
1906
1675
|
|
|
1907
1676
|
You can use the generated secrets to obtain OAuth access tokens for a service principal, which can then be
|
|
1908
1677
|
used to access Databricks Accounts and Workspace APIs. For more information, see [Authentication using
|
|
1909
|
-
OAuth tokens for service principals]
|
|
1678
|
+
OAuth tokens for service principals].
|
|
1910
1679
|
|
|
1911
1680
|
In addition, the generated secrets can be used to configure the Databricks Terraform Provider to
|
|
1912
1681
|
authenticate with the service principal. For more information, see [Databricks Terraform Provider].
|
|
@@ -1919,11 +1688,11 @@ class ServicePrincipalSecretsAPI:
|
|
|
1919
1688
|
self._api = api_client
|
|
1920
1689
|
|
|
1921
1690
|
def create(
|
|
1922
|
-
self, service_principal_id:
|
|
1691
|
+
self, service_principal_id: str, *, lifetime: Optional[str] = None
|
|
1923
1692
|
) -> CreateServicePrincipalSecretResponse:
|
|
1924
1693
|
"""Create a secret for the given service principal.
|
|
1925
1694
|
|
|
1926
|
-
:param service_principal_id:
|
|
1695
|
+
:param service_principal_id: str
|
|
1927
1696
|
The service principal ID.
|
|
1928
1697
|
:param lifetime: str (optional)
|
|
1929
1698
|
The lifetime of the secret in seconds. If this parameter is not provided, the secret will have a
|
|
@@ -1947,10 +1716,10 @@ class ServicePrincipalSecretsAPI:
|
|
|
1947
1716
|
)
|
|
1948
1717
|
return CreateServicePrincipalSecretResponse.from_dict(res)
|
|
1949
1718
|
|
|
1950
|
-
def delete(self, service_principal_id:
|
|
1719
|
+
def delete(self, service_principal_id: str, secret_id: str):
|
|
1951
1720
|
"""Delete a secret from the given service principal.
|
|
1952
1721
|
|
|
1953
|
-
:param service_principal_id:
|
|
1722
|
+
:param service_principal_id: str
|
|
1954
1723
|
The service principal ID.
|
|
1955
1724
|
:param secret_id: str
|
|
1956
1725
|
The secret ID.
|
|
@@ -1966,12 +1735,15 @@ class ServicePrincipalSecretsAPI:
|
|
|
1966
1735
|
headers=headers,
|
|
1967
1736
|
)
|
|
1968
1737
|
|
|
1969
|
-
def list(
|
|
1738
|
+
def list(
|
|
1739
|
+
self, service_principal_id: str, *, page_size: Optional[int] = None, page_token: Optional[str] = None
|
|
1740
|
+
) -> Iterator[SecretInfo]:
|
|
1970
1741
|
"""List all secrets associated with the given service principal. This operation only returns information
|
|
1971
1742
|
about the secrets themselves and does not include the secret values.
|
|
1972
1743
|
|
|
1973
|
-
:param service_principal_id:
|
|
1744
|
+
:param service_principal_id: str
|
|
1974
1745
|
The service principal ID.
|
|
1746
|
+
:param page_size: int (optional)
|
|
1975
1747
|
:param page_token: str (optional)
|
|
1976
1748
|
An opaque page token which was the `next_page_token` in the response of the previous request to list
|
|
1977
1749
|
the secrets for this service principal. Provide this token to retrieve the next page of secret
|
|
@@ -1984,6 +1756,8 @@ class ServicePrincipalSecretsAPI:
|
|
|
1984
1756
|
"""
|
|
1985
1757
|
|
|
1986
1758
|
query = {}
|
|
1759
|
+
if page_size is not None:
|
|
1760
|
+
query["page_size"] = page_size
|
|
1987
1761
|
if page_token is not None:
|
|
1988
1762
|
query["page_token"] = page_token
|
|
1989
1763
|
headers = {
|
|
@@ -2003,3 +1777,113 @@ class ServicePrincipalSecretsAPI:
|
|
|
2003
1777
|
if "next_page_token" not in json or not json["next_page_token"]:
|
|
2004
1778
|
return
|
|
2005
1779
|
query["page_token"] = json["next_page_token"]
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
class ServicePrincipalSecretsProxyAPI:
|
|
1783
|
+
"""These APIs enable administrators to manage service principal secrets at the workspace level. To use these
|
|
1784
|
+
APIs, the service principal must be first added to the current workspace.
|
|
1785
|
+
|
|
1786
|
+
You can use the generated secrets to obtain OAuth access tokens for a service principal, which can then be
|
|
1787
|
+
used to access Databricks Accounts and Workspace APIs. For more information, see [Authentication using
|
|
1788
|
+
OAuth tokens for service principals].
|
|
1789
|
+
|
|
1790
|
+
In addition, the generated secrets can be used to configure the Databricks Terraform Providerto
|
|
1791
|
+
authenticate with the service principal. For more information, see [Databricks Terraform Provider].
|
|
1792
|
+
|
|
1793
|
+
[Authentication using OAuth tokens for service principals]: https://docs.databricks.com/dev-tools/authentication-oauth.html
|
|
1794
|
+
[Databricks Terraform Provider]: https://github.com/databricks/terraform-provider-databricks/blob/master/docs/index.md#authenticating-with-service-principal
|
|
1795
|
+
"""
|
|
1796
|
+
|
|
1797
|
+
def __init__(self, api_client):
|
|
1798
|
+
self._api = api_client
|
|
1799
|
+
|
|
1800
|
+
def create(
|
|
1801
|
+
self, service_principal_id: str, *, lifetime: Optional[str] = None
|
|
1802
|
+
) -> CreateServicePrincipalSecretResponse:
|
|
1803
|
+
"""Create a secret for the given service principal.
|
|
1804
|
+
|
|
1805
|
+
:param service_principal_id: str
|
|
1806
|
+
The service principal ID.
|
|
1807
|
+
:param lifetime: str (optional)
|
|
1808
|
+
The lifetime of the secret in seconds. If this parameter is not provided, the secret will have a
|
|
1809
|
+
default lifetime of 730 days (63072000s).
|
|
1810
|
+
|
|
1811
|
+
:returns: :class:`CreateServicePrincipalSecretResponse`
|
|
1812
|
+
"""
|
|
1813
|
+
body = {}
|
|
1814
|
+
if lifetime is not None:
|
|
1815
|
+
body["lifetime"] = lifetime
|
|
1816
|
+
headers = {
|
|
1817
|
+
"Accept": "application/json",
|
|
1818
|
+
"Content-Type": "application/json",
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
res = self._api.do(
|
|
1822
|
+
"POST",
|
|
1823
|
+
f"/api/2.0/accounts/servicePrincipals/{service_principal_id}/credentials/secrets",
|
|
1824
|
+
body=body,
|
|
1825
|
+
headers=headers,
|
|
1826
|
+
)
|
|
1827
|
+
return CreateServicePrincipalSecretResponse.from_dict(res)
|
|
1828
|
+
|
|
1829
|
+
def delete(self, service_principal_id: str, secret_id: str):
|
|
1830
|
+
"""Delete a secret from the given service principal.
|
|
1831
|
+
|
|
1832
|
+
:param service_principal_id: str
|
|
1833
|
+
The service principal ID.
|
|
1834
|
+
:param secret_id: str
|
|
1835
|
+
The secret ID.
|
|
1836
|
+
|
|
1837
|
+
|
|
1838
|
+
"""
|
|
1839
|
+
|
|
1840
|
+
headers = {}
|
|
1841
|
+
|
|
1842
|
+
self._api.do(
|
|
1843
|
+
"DELETE",
|
|
1844
|
+
f"/api/2.0/accounts/servicePrincipals/{service_principal_id}/credentials/secrets/{secret_id}",
|
|
1845
|
+
headers=headers,
|
|
1846
|
+
)
|
|
1847
|
+
|
|
1848
|
+
def list(
|
|
1849
|
+
self, service_principal_id: str, *, page_size: Optional[int] = None, page_token: Optional[str] = None
|
|
1850
|
+
) -> Iterator[SecretInfo]:
|
|
1851
|
+
"""List all secrets associated with the given service principal. This operation only returns information
|
|
1852
|
+
about the secrets themselves and does not include the secret values.
|
|
1853
|
+
|
|
1854
|
+
:param service_principal_id: str
|
|
1855
|
+
The service principal ID.
|
|
1856
|
+
:param page_size: int (optional)
|
|
1857
|
+
:param page_token: str (optional)
|
|
1858
|
+
An opaque page token which was the `next_page_token` in the response of the previous request to list
|
|
1859
|
+
the secrets for this service principal. Provide this token to retrieve the next page of secret
|
|
1860
|
+
entries. When providing a `page_token`, all other parameters provided to the request must match the
|
|
1861
|
+
previous request. To list all of the secrets for a service principal, it is necessary to continue
|
|
1862
|
+
requesting pages of entries until the response contains no `next_page_token`. Note that the number
|
|
1863
|
+
of entries returned must not be used to determine when the listing is complete.
|
|
1864
|
+
|
|
1865
|
+
:returns: Iterator over :class:`SecretInfo`
|
|
1866
|
+
"""
|
|
1867
|
+
|
|
1868
|
+
query = {}
|
|
1869
|
+
if page_size is not None:
|
|
1870
|
+
query["page_size"] = page_size
|
|
1871
|
+
if page_token is not None:
|
|
1872
|
+
query["page_token"] = page_token
|
|
1873
|
+
headers = {
|
|
1874
|
+
"Accept": "application/json",
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
while True:
|
|
1878
|
+
json = self._api.do(
|
|
1879
|
+
"GET",
|
|
1880
|
+
f"/api/2.0/accounts/servicePrincipals/{service_principal_id}/credentials/secrets",
|
|
1881
|
+
query=query,
|
|
1882
|
+
headers=headers,
|
|
1883
|
+
)
|
|
1884
|
+
if "secrets" in json:
|
|
1885
|
+
for v in json["secrets"]:
|
|
1886
|
+
yield SecretInfo.from_dict(v)
|
|
1887
|
+
if "next_page_token" not in json or not json["next_page_token"]:
|
|
1888
|
+
return
|
|
1889
|
+
query["page_token"] = json["next_page_token"]
|