|
30 | 30 | |
31 | 31 | w = WorkspaceClient() |
32 | 32 | |
33 | | - storage_credential = w.storage_credentials.create( |
| 33 | + credential = w.storage_credentials.create( |
34 | 34 | name=f"sdk-{time.time_ns()}", |
35 | | - aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]), |
36 | | - comment="created via SDK", |
| 35 | + aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]), |
37 | 36 | ) |
38 | 37 | |
39 | | - external_location = w.external_locations.create( |
| 38 | + created = w.external_locations.create( |
40 | 39 | name=f"sdk-{time.time_ns()}", |
41 | | - credential_name=storage_credential.name, |
42 | | - comment="created via SDK", |
43 | | - url="s3://" + os.environ["TEST_BUCKET"] + "/" + f"sdk-{time.time_ns()}", |
| 40 | + credential_name=credential.name, |
| 41 | + url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}', |
44 | 42 | ) |
45 | 43 | |
46 | 44 | # cleanup |
47 | | - w.storage_credentials.delete(name=storage_credential.name) |
48 | | - w.external_locations.delete(name=external_location.name) |
| 45 | + w.storage_credentials.delete(delete=credential.name) |
| 46 | + w.external_locations.delete(delete=created.name) |
49 | 47 |
|
50 | 48 | Creates a new external location entry in the metastore. The caller must be a metastore admin or have |
51 | 49 | the **CREATE_EXTERNAL_LOCATION** privilege on both the metastore and the associated storage |
|
142 | 140 | .. code-block:: |
143 | 141 |
|
144 | 142 | from databricks.sdk import WorkspaceClient |
| 143 | + from databricks.sdk.service import catalog |
145 | 144 | |
146 | 145 | w = WorkspaceClient() |
147 | 146 | |
148 | | - all = w.external_locations.list() |
| 147 | + all = w.external_locations.list(catalog.ListExternalLocationsRequest()) |
149 | 148 |
|
150 | 149 | Gets an array of external locations (__ExternalLocationInfo__ objects) from the metastore. The caller |
151 | 150 | must be a metastore admin, the owner of the external location, or a user that has some privilege on |
|
192 | 191 | |
193 | 192 | credential = w.storage_credentials.create( |
194 | 193 | name=f"sdk-{time.time_ns()}", |
195 | | - aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]), |
| 194 | + aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]), |
196 | 195 | ) |
197 | 196 | |
198 | 197 | created = w.external_locations.create( |
199 | 198 | name=f"sdk-{time.time_ns()}", |
200 | 199 | credential_name=credential.name, |
201 | | - url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}', |
| 200 | + url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"), |
202 | 201 | ) |
203 | 202 | |
204 | 203 | _ = w.external_locations.update( |
205 | 204 | name=created.name, |
206 | 205 | credential_name=credential.name, |
207 | | - url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}', |
| 206 | + url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"), |
208 | 207 | ) |
209 | 208 | |
210 | 209 | # cleanup |
211 | | - w.storage_credentials.delete(delete=credential.name) |
212 | | - w.external_locations.delete(delete=created.name) |
| 210 | + w.storage_credentials.delete(name=credential.name) |
| 211 | + w.external_locations.delete(name=created.name) |
213 | 212 |
|
214 | 213 | Updates an external location in the metastore. The caller must be the owner of the external location, |
215 | 214 | or be a metastore admin. In the second case, the admin can only update the name of the external |
|
0 commit comments