Skip to content

Commit 46887ce

Browse files
committed
OpenAPI: Standardize credentials in loadTable/loadView responses
1 parent e5d9a15 commit 46887ce

2 files changed

Lines changed: 143 additions & 0 deletions

File tree

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,12 @@ class ViewUpdate(BaseModel):
11681168
]
11691169

11701170

1171+
class Credentials(BaseModel):
1172+
__root__: Union[ADLSCredentials, GCSCredentials, S3Credentials] = Field(
1173+
..., discriminator='type'
1174+
)
1175+
1176+
11711177
class LoadTableResult(BaseModel):
11721178
"""
11731179
Result used when a table is successfully loaded.
@@ -1195,6 +1201,11 @@ class LoadTableResult(BaseModel):
11951201
- `s3.session-token`: if present, this value should be used for as the session token
11961202
- `s3.remote-signing-enabled`: if `true` remote signing should be performed as described in the `s3-signer-open-api.yaml` specification
11971203
1204+
## Credentials
1205+
1206+
Credentials for ADLS / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
1207+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
1208+
11981209
"""
11991210

12001211
metadata_location: Optional[str] = Field(
@@ -1203,6 +1214,7 @@ class LoadTableResult(BaseModel):
12031214
description='May be null if the table is staged as part of a transaction',
12041215
)
12051216
metadata: TableMetadata
1217+
credentials: Optional[Credentials] = None
12061218
config: Optional[Dict[str, str]] = None
12071219

12081220

@@ -1311,10 +1323,16 @@ class LoadViewResult(BaseModel):
13111323
13121324
- `token`: Authorization bearer token to use for view requests if OAuth2 security is enabled
13131325
1326+
## Credentials
1327+
1328+
Credentials for ADLS / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
1329+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
1330+
13141331
"""
13151332

13161333
metadata_location: str = Field(..., alias='metadata-location')
13171334
metadata: ViewMetadata
1335+
credentials: Optional[Credentials] = None
13181336
config: Optional[Dict[str, str]] = None
13191337

13201338

@@ -1398,6 +1416,38 @@ class Schema(StructType):
13981416
)
13991417

14001418

1419+
class ADLSCredentials(BaseModel):
1420+
type: Literal['adls']
1421+
sas_token: str = Field(..., alias='sas-token')
1422+
expires_at_ms: int = Field(
1423+
...,
1424+
alias='expires-at-ms',
1425+
description='The epoch millis at which the given token expires',
1426+
)
1427+
1428+
1429+
class GCSCredentials(BaseModel):
1430+
type: Literal['gcs']
1431+
token: str
1432+
expires_at_ms: int = Field(
1433+
...,
1434+
alias='expires-at-ms',
1435+
description='The epoch millis at which the given token expires',
1436+
)
1437+
1438+
1439+
class S3Credentials(BaseModel):
1440+
type: Literal['s3']
1441+
access_key_id: str = Field(..., alias='access-key-id')
1442+
secret_access_key: str = Field(..., alias='secret-access-key')
1443+
session_token: str = Field(..., alias='session-token')
1444+
expires_at_ms: int = Field(
1445+
...,
1446+
alias='expires-at-ms',
1447+
description='The epoch millis at which the given token expires',
1448+
)
1449+
1450+
14011451
class CompletedPlanningResult(ScanTasks):
14021452
"""
14031453
Completed server-side planning result
@@ -1430,12 +1480,16 @@ class CompletedPlanningWithIDResult(CompletedPlanningResult):
14301480
TableMetadata.update_forward_refs()
14311481
ViewMetadata.update_forward_refs()
14321482
AddSchemaUpdate.update_forward_refs()
1483+
Credentials.update_forward_refs()
14331484
ScanTasks.update_forward_refs()
14341485
FetchPlanningResult.update_forward_refs()
14351486
PlanTableScanResult.update_forward_refs()
14361487
CreateTableRequest.update_forward_refs()
14371488
CreateViewRequest.update_forward_refs()
14381489
ReportMetricsRequest.update_forward_refs()
1490+
ADLSCredentials.update_forward_refs()
1491+
GCSCredentials.update_forward_refs()
1492+
S3Credentials.update_forward_refs()
14391493
CompletedPlanningResult.update_forward_refs()
14401494
FetchScanTasksResult.update_forward_refs()
14411495
CompletedPlanningWithIDResult.update_forward_refs()

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

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,6 +3103,82 @@ components:
31033103
uuid:
31043104
type: string
31053105

3106+
ADLSCredentials:
3107+
type: object
3108+
allOf:
3109+
- $ref: '#/components/schemas/Credentials'
3110+
required:
3111+
- type
3112+
- sas-token
3113+
- expires-at-ms
3114+
properties:
3115+
type:
3116+
type: string
3117+
enum: [ "adls" ]
3118+
sas-token:
3119+
type: string
3120+
expires-at-ms:
3121+
type: integer
3122+
format: int64
3123+
description: The epoch millis at which the given token expires
3124+
3125+
GCSCredentials:
3126+
type: object
3127+
allOf:
3128+
- $ref: '#/components/schemas/Credentials'
3129+
required:
3130+
- type
3131+
- token
3132+
- expires-at-ms
3133+
properties:
3134+
type:
3135+
type: string
3136+
enum: [ "gcs" ]
3137+
token:
3138+
type: string
3139+
expires-at-ms:
3140+
type: integer
3141+
format: int64
3142+
description: The epoch millis at which the given token expires
3143+
3144+
S3Credentials:
3145+
type: object
3146+
allOf:
3147+
- $ref: '#/components/schemas/Credentials'
3148+
required:
3149+
- type
3150+
- access-key-id
3151+
- secret-access-key
3152+
- session-token
3153+
- expires-at-ms
3154+
properties:
3155+
type:
3156+
type: string
3157+
enum: [ "s3" ]
3158+
access-key-id:
3159+
type: string
3160+
secret-access-key:
3161+
type: string
3162+
session-token:
3163+
type: string
3164+
expires-at-ms:
3165+
type: integer
3166+
format: int64
3167+
description: The epoch millis at which the given token expires
3168+
3169+
Credentials:
3170+
type: object
3171+
discriminator:
3172+
propertyName: type
3173+
mapping:
3174+
adls: '#/components/schemas/ADLSCredentials'
3175+
gcs: '#/components/schemas/GCSCredentials'
3176+
s3: '#/components/schemas/S3Credentials'
3177+
oneOf:
3178+
- $ref: '#/components/schemas/ADLSCredentials'
3179+
- $ref: '#/components/schemas/GCSCredentials'
3180+
- $ref: '#/components/schemas/S3Credentials'
3181+
31063182
LoadTableResult:
31073183
description: |
31083184
Result used when a table is successfully loaded.
@@ -3129,6 +3205,11 @@ components:
31293205
- `s3.secret-access-key`: secret for credentials that provide access to data in S3
31303206
- `s3.session-token`: if present, this value should be used for as the session token
31313207
- `s3.remote-signing-enabled`: if `true` remote signing should be performed as described in the `s3-signer-open-api.yaml` specification
3208+
3209+
## Credentials
3210+
3211+
Credentials for ADLS / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
3212+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
31323213
type: object
31333214
required:
31343215
- metadata
@@ -3138,6 +3219,8 @@ components:
31383219
description: May be null if the table is staged as part of a transaction
31393220
metadata:
31403221
$ref: '#/components/schemas/TableMetadata'
3222+
credentials:
3223+
$ref: '#/components/schemas/Credentials'
31413224
config:
31423225
type: object
31433226
additionalProperties:
@@ -3395,6 +3478,10 @@ components:
33953478
33963479
- `token`: Authorization bearer token to use for view requests if OAuth2 security is enabled
33973480
3481+
## Credentials
3482+
3483+
Credentials for ADLS / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
3484+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
33983485
type: object
33993486
required:
34003487
- metadata-location
@@ -3404,6 +3491,8 @@ components:
34043491
type: string
34053492
metadata:
34063493
$ref: '#/components/schemas/ViewMetadata'
3494+
credentials:
3495+
$ref: '#/components/schemas/Credentials'
34073496
config:
34083497
type: object
34093498
additionalProperties:

0 commit comments

Comments
 (0)