databricks-sdk 0.58.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 +13 -5
- databricks/sdk/service/aibuilder.py +0 -127
- databricks/sdk/service/apps.py +52 -46
- databricks/sdk/service/billing.py +9 -200
- databricks/sdk/service/catalog.py +5500 -7697
- databricks/sdk/service/cleanrooms.py +2 -32
- databricks/sdk/service/compute.py +456 -2515
- databricks/sdk/service/dashboards.py +1 -177
- databricks/sdk/service/database.py +18 -52
- databricks/sdk/service/files.py +2 -218
- databricks/sdk/service/iam.py +16 -295
- databricks/sdk/service/jobs.py +108 -1171
- databricks/sdk/service/marketplace.py +0 -573
- databricks/sdk/service/ml.py +76 -2445
- databricks/sdk/service/oauth2.py +122 -237
- databricks/sdk/service/pipelines.py +178 -752
- databricks/sdk/service/provisioning.py +0 -603
- databricks/sdk/service/serving.py +5 -577
- databricks/sdk/service/settings.py +191 -1560
- databricks/sdk/service/sharing.py +3 -469
- databricks/sdk/service/sql.py +117 -1704
- databricks/sdk/service/vectorsearch.py +0 -391
- databricks/sdk/service/workspace.py +250 -721
- databricks/sdk/version.py +1 -1
- {databricks_sdk-0.58.0.dist-info → databricks_sdk-0.59.0.dist-info}/METADATA +1 -1
- {databricks_sdk-0.58.0.dist-info → databricks_sdk-0.59.0.dist-info}/RECORD +30 -30
- {databricks_sdk-0.58.0.dist-info → databricks_sdk-0.59.0.dist-info}/WHEEL +0 -0
- {databricks_sdk-0.58.0.dist-info → databricks_sdk-0.59.0.dist-info}/licenses/LICENSE +0 -0
- {databricks_sdk-0.58.0.dist-info → databricks_sdk-0.59.0.dist-info}/licenses/NOTICE +0 -0
- {databricks_sdk-0.58.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
|
|
@@ -1032,66 +896,6 @@ class TokenAccessPolicy:
|
|
|
1032
896
|
)
|
|
1033
897
|
|
|
1034
898
|
|
|
1035
|
-
@dataclass
|
|
1036
|
-
class UpdateCustomAppIntegration:
|
|
1037
|
-
integration_id: Optional[str] = None
|
|
1038
|
-
|
|
1039
|
-
redirect_urls: Optional[List[str]] = None
|
|
1040
|
-
"""List of OAuth redirect urls to be updated in the custom OAuth app integration"""
|
|
1041
|
-
|
|
1042
|
-
scopes: Optional[List[str]] = None
|
|
1043
|
-
"""List of OAuth scopes to be updated in the custom OAuth app integration, similar to redirect URIs
|
|
1044
|
-
this will fully replace the existing values instead of appending"""
|
|
1045
|
-
|
|
1046
|
-
token_access_policy: Optional[TokenAccessPolicy] = None
|
|
1047
|
-
"""Token access policy to be updated in the custom OAuth app integration"""
|
|
1048
|
-
|
|
1049
|
-
user_authorized_scopes: Optional[List[str]] = None
|
|
1050
|
-
"""Scopes that will need to be consented by end user to mint the access token. If the user does not
|
|
1051
|
-
authorize the access token will not be minted. Must be a subset of scopes."""
|
|
1052
|
-
|
|
1053
|
-
def as_dict(self) -> dict:
|
|
1054
|
-
"""Serializes the UpdateCustomAppIntegration into a dictionary suitable for use as a JSON request body."""
|
|
1055
|
-
body = {}
|
|
1056
|
-
if self.integration_id is not None:
|
|
1057
|
-
body["integration_id"] = self.integration_id
|
|
1058
|
-
if self.redirect_urls:
|
|
1059
|
-
body["redirect_urls"] = [v for v in self.redirect_urls]
|
|
1060
|
-
if self.scopes:
|
|
1061
|
-
body["scopes"] = [v for v in self.scopes]
|
|
1062
|
-
if self.token_access_policy:
|
|
1063
|
-
body["token_access_policy"] = self.token_access_policy.as_dict()
|
|
1064
|
-
if self.user_authorized_scopes:
|
|
1065
|
-
body["user_authorized_scopes"] = [v for v in self.user_authorized_scopes]
|
|
1066
|
-
return body
|
|
1067
|
-
|
|
1068
|
-
def as_shallow_dict(self) -> dict:
|
|
1069
|
-
"""Serializes the UpdateCustomAppIntegration into a shallow dictionary of its immediate attributes."""
|
|
1070
|
-
body = {}
|
|
1071
|
-
if self.integration_id is not None:
|
|
1072
|
-
body["integration_id"] = self.integration_id
|
|
1073
|
-
if self.redirect_urls:
|
|
1074
|
-
body["redirect_urls"] = self.redirect_urls
|
|
1075
|
-
if self.scopes:
|
|
1076
|
-
body["scopes"] = self.scopes
|
|
1077
|
-
if self.token_access_policy:
|
|
1078
|
-
body["token_access_policy"] = self.token_access_policy
|
|
1079
|
-
if self.user_authorized_scopes:
|
|
1080
|
-
body["user_authorized_scopes"] = self.user_authorized_scopes
|
|
1081
|
-
return body
|
|
1082
|
-
|
|
1083
|
-
@classmethod
|
|
1084
|
-
def from_dict(cls, d: Dict[str, Any]) -> UpdateCustomAppIntegration:
|
|
1085
|
-
"""Deserializes the UpdateCustomAppIntegration from a dictionary."""
|
|
1086
|
-
return cls(
|
|
1087
|
-
integration_id=d.get("integration_id", None),
|
|
1088
|
-
redirect_urls=d.get("redirect_urls", None),
|
|
1089
|
-
scopes=d.get("scopes", None),
|
|
1090
|
-
token_access_policy=_from_dict(d, "token_access_policy", TokenAccessPolicy),
|
|
1091
|
-
user_authorized_scopes=d.get("user_authorized_scopes", None),
|
|
1092
|
-
)
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
899
|
@dataclass
|
|
1096
900
|
class UpdateCustomAppIntegrationOutput:
|
|
1097
901
|
def as_dict(self) -> dict:
|
|
@@ -1110,40 +914,6 @@ class UpdateCustomAppIntegrationOutput:
|
|
|
1110
914
|
return cls()
|
|
1111
915
|
|
|
1112
916
|
|
|
1113
|
-
@dataclass
|
|
1114
|
-
class UpdatePublishedAppIntegration:
|
|
1115
|
-
integration_id: Optional[str] = None
|
|
1116
|
-
|
|
1117
|
-
token_access_policy: Optional[TokenAccessPolicy] = None
|
|
1118
|
-
"""Token access policy to be updated in the published OAuth app integration"""
|
|
1119
|
-
|
|
1120
|
-
def as_dict(self) -> dict:
|
|
1121
|
-
"""Serializes the UpdatePublishedAppIntegration into a dictionary suitable for use as a JSON request body."""
|
|
1122
|
-
body = {}
|
|
1123
|
-
if self.integration_id is not None:
|
|
1124
|
-
body["integration_id"] = self.integration_id
|
|
1125
|
-
if self.token_access_policy:
|
|
1126
|
-
body["token_access_policy"] = self.token_access_policy.as_dict()
|
|
1127
|
-
return body
|
|
1128
|
-
|
|
1129
|
-
def as_shallow_dict(self) -> dict:
|
|
1130
|
-
"""Serializes the UpdatePublishedAppIntegration into a shallow dictionary of its immediate attributes."""
|
|
1131
|
-
body = {}
|
|
1132
|
-
if self.integration_id is not None:
|
|
1133
|
-
body["integration_id"] = self.integration_id
|
|
1134
|
-
if self.token_access_policy:
|
|
1135
|
-
body["token_access_policy"] = self.token_access_policy
|
|
1136
|
-
return body
|
|
1137
|
-
|
|
1138
|
-
@classmethod
|
|
1139
|
-
def from_dict(cls, d: Dict[str, Any]) -> UpdatePublishedAppIntegration:
|
|
1140
|
-
"""Deserializes the UpdatePublishedAppIntegration from a dictionary."""
|
|
1141
|
-
return cls(
|
|
1142
|
-
integration_id=d.get("integration_id", None),
|
|
1143
|
-
token_access_policy=_from_dict(d, "token_access_policy", TokenAccessPolicy),
|
|
1144
|
-
)
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
917
|
@dataclass
|
|
1148
918
|
class UpdatePublishedAppIntegrationOutput:
|
|
1149
919
|
def as_dict(self) -> dict:
|
|
@@ -1905,7 +1675,7 @@ class ServicePrincipalSecretsAPI:
|
|
|
1905
1675
|
|
|
1906
1676
|
You can use the generated secrets to obtain OAuth access tokens for a service principal, which can then be
|
|
1907
1677
|
used to access Databricks Accounts and Workspace APIs. For more information, see [Authentication using
|
|
1908
|
-
OAuth tokens for service principals]
|
|
1678
|
+
OAuth tokens for service principals].
|
|
1909
1679
|
|
|
1910
1680
|
In addition, the generated secrets can be used to configure the Databricks Terraform Provider to
|
|
1911
1681
|
authenticate with the service principal. For more information, see [Databricks Terraform Provider].
|
|
@@ -1918,11 +1688,11 @@ class ServicePrincipalSecretsAPI:
|
|
|
1918
1688
|
self._api = api_client
|
|
1919
1689
|
|
|
1920
1690
|
def create(
|
|
1921
|
-
self, service_principal_id:
|
|
1691
|
+
self, service_principal_id: str, *, lifetime: Optional[str] = None
|
|
1922
1692
|
) -> CreateServicePrincipalSecretResponse:
|
|
1923
1693
|
"""Create a secret for the given service principal.
|
|
1924
1694
|
|
|
1925
|
-
:param service_principal_id:
|
|
1695
|
+
:param service_principal_id: str
|
|
1926
1696
|
The service principal ID.
|
|
1927
1697
|
:param lifetime: str (optional)
|
|
1928
1698
|
The lifetime of the secret in seconds. If this parameter is not provided, the secret will have a
|
|
@@ -1946,10 +1716,10 @@ class ServicePrincipalSecretsAPI:
|
|
|
1946
1716
|
)
|
|
1947
1717
|
return CreateServicePrincipalSecretResponse.from_dict(res)
|
|
1948
1718
|
|
|
1949
|
-
def delete(self, service_principal_id:
|
|
1719
|
+
def delete(self, service_principal_id: str, secret_id: str):
|
|
1950
1720
|
"""Delete a secret from the given service principal.
|
|
1951
1721
|
|
|
1952
|
-
:param service_principal_id:
|
|
1722
|
+
:param service_principal_id: str
|
|
1953
1723
|
The service principal ID.
|
|
1954
1724
|
:param secret_id: str
|
|
1955
1725
|
The secret ID.
|
|
@@ -1965,12 +1735,15 @@ class ServicePrincipalSecretsAPI:
|
|
|
1965
1735
|
headers=headers,
|
|
1966
1736
|
)
|
|
1967
1737
|
|
|
1968
|
-
def list(
|
|
1738
|
+
def list(
|
|
1739
|
+
self, service_principal_id: str, *, page_size: Optional[int] = None, page_token: Optional[str] = None
|
|
1740
|
+
) -> Iterator[SecretInfo]:
|
|
1969
1741
|
"""List all secrets associated with the given service principal. This operation only returns information
|
|
1970
1742
|
about the secrets themselves and does not include the secret values.
|
|
1971
1743
|
|
|
1972
|
-
:param service_principal_id:
|
|
1744
|
+
:param service_principal_id: str
|
|
1973
1745
|
The service principal ID.
|
|
1746
|
+
:param page_size: int (optional)
|
|
1974
1747
|
:param page_token: str (optional)
|
|
1975
1748
|
An opaque page token which was the `next_page_token` in the response of the previous request to list
|
|
1976
1749
|
the secrets for this service principal. Provide this token to retrieve the next page of secret
|
|
@@ -1983,6 +1756,8 @@ class ServicePrincipalSecretsAPI:
|
|
|
1983
1756
|
"""
|
|
1984
1757
|
|
|
1985
1758
|
query = {}
|
|
1759
|
+
if page_size is not None:
|
|
1760
|
+
query["page_size"] = page_size
|
|
1986
1761
|
if page_token is not None:
|
|
1987
1762
|
query["page_token"] = page_token
|
|
1988
1763
|
headers = {
|
|
@@ -2002,3 +1777,113 @@ class ServicePrincipalSecretsAPI:
|
|
|
2002
1777
|
if "next_page_token" not in json or not json["next_page_token"]:
|
|
2003
1778
|
return
|
|
2004
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"]
|