|
30 | 30 | |
31 | 31 | w = WorkspaceClient() |
32 | 32 | |
33 | | - credential = w.storage_credentials.create( |
| 33 | + storage_credential = w.storage_credentials.create( |
34 | 34 | name=f"sdk-{time.time_ns()}", |
35 | 35 | aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]), |
| 36 | + comment="created via SDK", |
36 | 37 | ) |
37 | 38 | |
38 | | - created = w.external_locations.create( |
| 39 | + external_location = w.external_locations.create( |
39 | 40 | name=f"sdk-{time.time_ns()}", |
40 | | - credential_name=credential.name, |
41 | | - url="s3://%s/%s" % (os.environ["TEST_BUCKET"], 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()}", |
42 | 44 | ) |
43 | 45 | |
44 | 46 | # cleanup |
45 | | - w.storage_credentials.delete(name=credential.name) |
46 | | - w.external_locations.delete(name=created.name) |
| 47 | + w.storage_credentials.delete(name=storage_credential.name) |
| 48 | + w.external_locations.delete(name=external_location.name) |
47 | 49 |
|
48 | 50 | Creates a new external location entry in the metastore. The caller must be a metastore admin or have |
49 | 51 | the **CREATE_EXTERNAL_LOCATION** privilege on both the metastore and the associated storage |
|
105 | 107 | |
106 | 108 | credential = w.storage_credentials.create( |
107 | 109 | name=f"sdk-{time.time_ns()}", |
108 | | - aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]), |
| 110 | + aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]), |
109 | 111 | ) |
110 | 112 | |
111 | 113 | created = w.external_locations.create( |
112 | 114 | name=f"sdk-{time.time_ns()}", |
113 | 115 | credential_name=credential.name, |
114 | | - url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"), |
| 116 | + url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}', |
115 | 117 | ) |
116 | 118 | |
117 | | - _ = w.external_locations.get(name=created.name) |
| 119 | + _ = w.external_locations.get(get=created.name) |
118 | 120 | |
119 | 121 | # cleanup |
120 | | - w.storage_credentials.delete(name=credential.name) |
121 | | - w.external_locations.delete(name=created.name) |
| 122 | + w.storage_credentials.delete(delete=credential.name) |
| 123 | + w.external_locations.delete(delete=created.name) |
122 | 124 |
|
123 | 125 | Gets an external location from the metastore. The caller must be either a metastore admin, the owner |
124 | 126 | of the external location, or a user that has some privilege on the external location. |
|
140 | 142 | .. code-block:: |
141 | 143 |
|
142 | 144 | from databricks.sdk import WorkspaceClient |
| 145 | + from databricks.sdk.service import catalog |
143 | 146 | |
144 | 147 | w = WorkspaceClient() |
145 | 148 | |
146 | | - all = w.external_locations.list() |
| 149 | + all = w.external_locations.list(catalog.ListExternalLocationsRequest()) |
147 | 150 |
|
148 | 151 | Gets an array of external locations (__ExternalLocationInfo__ objects) from the metastore. The caller |
149 | 152 | must be a metastore admin, the owner of the external location, or a user that has some privilege on |
|
0 commit comments