Skip to content

Commit 2d5820a

Browse files
committed
Generalize how credentials are represented
1 parent 0313c12 commit 2d5820a

2 files changed

Lines changed: 36 additions & 160 deletions

File tree

open-api/rest-catalog-open-api.py

Lines changed: 16 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ class AssertViewUUID(BaseModel):
467467
uuid: str
468468

469469

470+
class StorageCredential(BaseModel):
471+
prefix: str = Field(
472+
...,
473+
description='Indicates a storage location prefix where the credential is relevant. Clients should choose the most specific prefix (by selecting the longest prefix) if several credentials of the same type are available.',
474+
)
475+
config: Dict[str, str]
476+
477+
470478
class PlanStatus(BaseModel):
471479
__root__: Literal['completed', 'submitted', 'cancelled', 'failed'] = Field(
472480
..., description='Status of a server-side planning operation'
@@ -1168,12 +1176,6 @@ class ViewUpdate(BaseModel):
11681176
]
11691177

11701178

1171-
class Credential(BaseModel):
1172-
__root__: Union[ADLSCredential, GCSCredential, S3Credential] = Field(
1173-
..., discriminator='type'
1174-
)
1175-
1176-
11771179
class LoadTableResult(BaseModel):
11781180
"""
11791181
Result used when a table is successfully loaded.
@@ -1203,9 +1205,8 @@ class LoadTableResult(BaseModel):
12031205
12041206
## Storage Credentials
12051207
1206-
Credentials for ADLS / GCS / S3 are provided through the `storage-credentials` field.
1207-
In order to avoid leaking non-expiring credentials, all credentials are required to have an expiration.
1208-
Clients should first check whether the respective credentials exist in the `storage-credentials` field before checking the `config` for credentials.
1208+
Credentials for ADLS / GCS / S3 / ... are provided through the `storage-credentials` field.
1209+
Clients must first check whether the respective credentials exist in the `storage-credentials` field before checking the `config` for credentials.
12091210
12101211
"""
12111212

@@ -1215,10 +1216,10 @@ class LoadTableResult(BaseModel):
12151216
description='May be null if the table is staged as part of a transaction',
12161217
)
12171218
metadata: TableMetadata
1218-
storage_credentials: Optional[List[Credential]] = Field(
1219+
config: Optional[Dict[str, str]] = None
1220+
storage_credentials: Optional[List[StorageCredential]] = Field(
12191221
None, alias='storage-credentials'
12201222
)
1221-
config: Optional[Dict[str, str]] = None
12221223

12231224

12241225
class ScanTasks(BaseModel):
@@ -1328,18 +1329,17 @@ class LoadViewResult(BaseModel):
13281329
13291330
## Storage Credentials
13301331
1331-
Credentials for ADLS / GCS / S3 are provided through the `storage-credentials` field.
1332-
In order to avoid leaking non-expiring credentials, all credentials are required to have an expiration.
1333-
Clients should first check whether the respective credentials exist in the `storage-credentials` field before checking the `config` for credentials.
1332+
Credentials for ADLS / GCS / S3 / ... are provided through the `storage-credentials` field.
1333+
Clients must first check whether the respective credentials exist in the `storage-credentials` field before checking the `config` for credentials.
13341334
13351335
"""
13361336

13371337
metadata_location: str = Field(..., alias='metadata-location')
13381338
metadata: ViewMetadata
1339-
storage_credentials: Optional[List[Credential]] = Field(
1339+
config: Optional[Dict[str, str]] = None
1340+
storage_credentials: Optional[List[StorageCredential]] = Field(
13401341
None, alias='storage-credentials'
13411342
)
1342-
config: Optional[Dict[str, str]] = None
13431343

13441344

13451345
class ReportMetricsRequest(BaseModel):
@@ -1422,50 +1422,6 @@ class Schema(StructType):
14221422
)
14231423

14241424

1425-
class ADLSCredential(BaseModel):
1426-
type: Literal['adls']
1427-
prefix: Optional[str] = Field(
1428-
None,
1429-
description='Indicates a storage location prefix where the credential is relevant. Clients should choose the most specific prefix if several credentials of the same type are available.',
1430-
)
1431-
sas_token: str = Field(..., alias='sas-token')
1432-
expires_at_ms: int = Field(
1433-
...,
1434-
alias='expires-at-ms',
1435-
description='The epoch millis since 1970-01-01T00:00:00Z at which the given token expires',
1436-
)
1437-
1438-
1439-
class GCSCredential(BaseModel):
1440-
type: Literal['gcs']
1441-
prefix: Optional[str] = Field(
1442-
None,
1443-
description='Indicates a storage location prefix where the credential is relevant. Clients should choose the most specific prefix if several credentials of the same type are available.',
1444-
)
1445-
token: str
1446-
expires_at_ms: int = Field(
1447-
...,
1448-
alias='expires-at-ms',
1449-
description='The epoch millis since 1970-01-01T00:00:00Z at which the given token expires',
1450-
)
1451-
1452-
1453-
class S3Credential(BaseModel):
1454-
type: Literal['s3']
1455-
prefix: Optional[str] = Field(
1456-
None,
1457-
description='Indicates a storage location prefix where the credential is relevant. Clients should choose the most specific prefix if several credentials of the same type are available.',
1458-
)
1459-
access_key_id: str = Field(..., alias='access-key-id')
1460-
secret_access_key: str = Field(..., alias='secret-access-key')
1461-
session_token: str = Field(..., alias='session-token')
1462-
expires_at_ms: int = Field(
1463-
...,
1464-
alias='expires-at-ms',
1465-
description='The epoch millis since 1970-01-01T00:00:00Z at which the given token expires',
1466-
)
1467-
1468-
14691425
class CompletedPlanningResult(ScanTasks):
14701426
"""
14711427
Completed server-side planning result
@@ -1498,16 +1454,12 @@ class CompletedPlanningWithIDResult(CompletedPlanningResult):
14981454
TableMetadata.update_forward_refs()
14991455
ViewMetadata.update_forward_refs()
15001456
AddSchemaUpdate.update_forward_refs()
1501-
Credential.update_forward_refs()
15021457
ScanTasks.update_forward_refs()
15031458
FetchPlanningResult.update_forward_refs()
15041459
PlanTableScanResult.update_forward_refs()
15051460
CreateTableRequest.update_forward_refs()
15061461
CreateViewRequest.update_forward_refs()
15071462
ReportMetricsRequest.update_forward_refs()
1508-
ADLSCredential.update_forward_refs()
1509-
GCSCredential.update_forward_refs()
1510-
S3Credential.update_forward_refs()
15111463
CompletedPlanningResult.update_forward_refs()
15121464
FetchScanTasksResult.update_forward_refs()
15131465
CompletedPlanningWithIDResult.update_forward_refs()

open-api/rest-catalog-open-api.yaml

Lines changed: 20 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,94 +3103,20 @@ components:
31033103
uuid:
31043104
type: string
31053105

3106-
ADLSCredential:
3106+
StorageCredential:
31073107
type: object
3108-
allOf:
3109-
- $ref: '#/components/schemas/Credential'
3110-
required:
3111-
- type
3112-
- sas-token
3113-
- expires-at-ms
3114-
properties:
3115-
type:
3116-
type: string
3117-
enum: [ "adls" ]
3118-
prefix:
3119-
type: string
3120-
description: Indicates a storage location prefix where the credential is relevant. Clients should choose the most
3121-
specific prefix if several credentials of the same type are available.
3122-
sas-token:
3123-
type: string
3124-
expires-at-ms:
3125-
type: integer
3126-
format: int64
3127-
description: The epoch millis since 1970-01-01T00:00:00Z at which the given token expires
3128-
3129-
3130-
GCSCredential:
3131-
type: object
3132-
allOf:
3133-
- $ref: '#/components/schemas/Credential'
3134-
required:
3135-
- type
3136-
- token
3137-
- expires-at-ms
3138-
properties:
3139-
type:
3140-
type: string
3141-
enum: [ "gcs" ]
3142-
prefix:
3143-
type: string
3144-
description: Indicates a storage location prefix where the credential is relevant. Clients should choose the most
3145-
specific prefix if several credentials of the same type are available.
3146-
token:
3147-
type: string
3148-
expires-at-ms:
3149-
type: integer
3150-
format: int64
3151-
description: The epoch millis since 1970-01-01T00:00:00Z at which the given token expires
3152-
3153-
S3Credential:
3154-
type: object
3155-
allOf:
3156-
- $ref: '#/components/schemas/Credential'
31573108
required:
3158-
- type
3159-
- access-key-id
3160-
- secret-access-key
3161-
- session-token
3162-
- expires-at-ms
3109+
- prefix
3110+
- config
31633111
properties:
3164-
type:
3165-
type: string
3166-
enum: [ "s3" ]
31673112
prefix:
31683113
type: string
31693114
description: Indicates a storage location prefix where the credential is relevant. Clients should choose the most
3170-
specific prefix if several credentials of the same type are available.
3171-
access-key-id:
3172-
type: string
3173-
secret-access-key:
3174-
type: string
3175-
session-token:
3176-
type: string
3177-
expires-at-ms:
3178-
type: integer
3179-
format: int64
3180-
description: The epoch millis since 1970-01-01T00:00:00Z at which the given token expires
3181-
3182-
Credential:
3183-
type: object
3184-
discriminator:
3185-
propertyName: type
3186-
mapping:
3187-
adls: '#/components/schemas/ADLSCredential'
3188-
gcs: '#/components/schemas/GCSCredential'
3189-
s3: '#/components/schemas/S3Credential'
3190-
oneOf:
3191-
- $ref: '#/components/schemas/ADLSCredential'
3192-
- $ref: '#/components/schemas/GCSCredential'
3193-
- $ref: '#/components/schemas/S3Credential'
3115+
specific prefix (by selecting the longest prefix) if several credentials of the same type are available.
3116+
config:
3117+
type: object
3118+
additionalProperties:
3119+
type: string
31943120

31953121
LoadTableResult:
31963122
description: |
@@ -3221,9 +3147,8 @@ components:
32213147
32223148
## Storage Credentials
32233149
3224-
Credentials for ADLS / GCS / S3 are provided through the `storage-credentials` field.
3225-
In order to avoid leaking non-expiring credentials, all credentials are required to have an expiration.
3226-
Clients should first check whether the respective credentials exist in the `storage-credentials` field before checking the `config` for credentials.
3150+
Credentials for ADLS / GCS / S3 / ... are provided through the `storage-credentials` field.
3151+
Clients must first check whether the respective credentials exist in the `storage-credentials` field before checking the `config` for credentials.
32273152
type: object
32283153
required:
32293154
- metadata
@@ -3233,14 +3158,14 @@ components:
32333158
description: May be null if the table is staged as part of a transaction
32343159
metadata:
32353160
$ref: '#/components/schemas/TableMetadata'
3236-
storage-credentials:
3237-
type: array
3238-
items:
3239-
$ref: '#/components/schemas/Credential'
32403161
config:
32413162
type: object
32423163
additionalProperties:
32433164
type: string
3165+
storage-credentials:
3166+
type: array
3167+
items:
3168+
$ref: '#/components/schemas/StorageCredential'
32443169

32453170
ScanTasks:
32463171
type: object
@@ -3496,9 +3421,8 @@ components:
34963421
34973422
## Storage Credentials
34983423
3499-
Credentials for ADLS / GCS / S3 are provided through the `storage-credentials` field.
3500-
In order to avoid leaking non-expiring credentials, all credentials are required to have an expiration.
3501-
Clients should first check whether the respective credentials exist in the `storage-credentials` field before checking the `config` for credentials.
3424+
Credentials for ADLS / GCS / S3 / ... are provided through the `storage-credentials` field.
3425+
Clients must first check whether the respective credentials exist in the `storage-credentials` field before checking the `config` for credentials.
35023426
type: object
35033427
required:
35043428
- metadata-location
@@ -3508,14 +3432,14 @@ components:
35083432
type: string
35093433
metadata:
35103434
$ref: '#/components/schemas/ViewMetadata'
3511-
storage-credentials:
3512-
type: array
3513-
items:
3514-
$ref: '#/components/schemas/Credential'
35153435
config:
35163436
type: object
35173437
additionalProperties:
35183438
type: string
3439+
storage-credentials:
3440+
type: array
3441+
items:
3442+
$ref: '#/components/schemas/StorageCredential'
35193443

35203444
TokenType:
35213445
type: string

0 commit comments

Comments
 (0)