Skip to content

Commit d8c748f

Browse files
committed
OpenAPI: Standardize credentials in loadTable/loadView responses
1 parent 0747b60 commit d8c748f

2 files changed

Lines changed: 132 additions & 0 deletions

File tree

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

Lines changed: 44 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,28 @@ class Schema(StructType):
13981416
)
13991417

14001418

1419+
class ADLSCredentials(BaseModel):
1420+
type: Literal['adls']
1421+
account_name: Optional[str] = Field(None, alias='account-name')
1422+
account_key: Optional[str] = Field(None, alias='account-key')
1423+
sas_token: Optional[str] = Field(None, alias='sas-token')
1424+
expires_at_ms: Optional[int] = Field(None, alias='expires-at-ms')
1425+
1426+
1427+
class GCSCredentials(BaseModel):
1428+
type: Literal['gcs']
1429+
token: str
1430+
expires_at_ms: int = Field(..., alias='expires-at-ms')
1431+
1432+
1433+
class S3Credentials(BaseModel):
1434+
type: Literal['s3']
1435+
access_key_id: str = Field(..., alias='access-key-id')
1436+
secret_access_key: str = Field(..., alias='secret-access-key')
1437+
session_token: str = Field(..., alias='session-token')
1438+
expires_at_ms: int = Field(..., alias='expires-at-ms')
1439+
1440+
14011441
class CompletedPlanningResult(ScanTasks):
14021442
"""
14031443
Completed server-side planning result
@@ -1430,12 +1470,16 @@ class CompletedPlanningWithIDResult(CompletedPlanningResult):
14301470
TableMetadata.update_forward_refs()
14311471
ViewMetadata.update_forward_refs()
14321472
AddSchemaUpdate.update_forward_refs()
1473+
Credentials.update_forward_refs()
14331474
ScanTasks.update_forward_refs()
14341475
FetchPlanningResult.update_forward_refs()
14351476
PlanTableScanResult.update_forward_refs()
14361477
CreateTableRequest.update_forward_refs()
14371478
CreateViewRequest.update_forward_refs()
14381479
ReportMetricsRequest.update_forward_refs()
1480+
ADLSCredentials.update_forward_refs()
1481+
GCSCredentials.update_forward_refs()
1482+
S3Credentials.update_forward_refs()
14391483
CompletedPlanningResult.update_forward_refs()
14401484
FetchScanTasksResult.update_forward_refs()
14411485
CompletedPlanningWithIDResult.update_forward_refs()

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

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

3106+
ADLSCredentials:
3107+
type: object
3108+
allOf:
3109+
- $ref: '#/components/schemas/Credentials'
3110+
required:
3111+
- type
3112+
properties:
3113+
type:
3114+
type: string
3115+
enum: [ "adls" ]
3116+
account-name:
3117+
type: string
3118+
account-key:
3119+
type: string
3120+
sas-token:
3121+
type: string
3122+
expires-at-ms:
3123+
type: integer
3124+
format: int64
3125+
3126+
GCSCredentials:
3127+
type: object
3128+
allOf:
3129+
- $ref: '#/components/schemas/Credentials'
3130+
required:
3131+
- type
3132+
- token
3133+
- expires-at-ms
3134+
properties:
3135+
type:
3136+
type: string
3137+
enum: [ "gcs" ]
3138+
token:
3139+
type: string
3140+
expires-at-ms:
3141+
type: integer
3142+
format: int64
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+
3168+
Credentials:
3169+
type: object
3170+
discriminator:
3171+
propertyName: type
3172+
mapping:
3173+
adls: '#/components/schemas/ADLSCredentials'
3174+
gcs: '#/components/schemas/GCSCredentials'
3175+
s3: '#/components/schemas/S3Credentials'
3176+
oneOf:
3177+
- $ref: '#/components/schemas/ADLSCredentials'
3178+
- $ref: '#/components/schemas/GCSCredentials'
3179+
- $ref: '#/components/schemas/S3Credentials'
3180+
31063181
LoadTableResult:
31073182
description: |
31083183
Result used when a table is successfully loaded.
@@ -3129,6 +3204,11 @@ components:
31293204
- `s3.secret-access-key`: secret for credentials that provide access to data in S3
31303205
- `s3.session-token`: if present, this value should be used for as the session token
31313206
- `s3.remote-signing-enabled`: if `true` remote signing should be performed as described in the `s3-signer-open-api.yaml` specification
3207+
3208+
## Credentials
3209+
3210+
Credentials for ADLS / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
3211+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
31323212
type: object
31333213
required:
31343214
- metadata
@@ -3138,6 +3218,8 @@ components:
31383218
description: May be null if the table is staged as part of a transaction
31393219
metadata:
31403220
$ref: '#/components/schemas/TableMetadata'
3221+
credentials:
3222+
$ref: '#/components/schemas/Credentials'
31413223
config:
31423224
type: object
31433225
additionalProperties:
@@ -3395,6 +3477,10 @@ components:
33953477
33963478
- `token`: Authorization bearer token to use for view requests if OAuth2 security is enabled
33973479
3480+
## Credentials
3481+
3482+
Credentials for ADLS / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
3483+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
33983484
type: object
33993485
required:
34003486
- metadata-location
@@ -3404,6 +3490,8 @@ components:
34043490
type: string
34053491
metadata:
34063492
$ref: '#/components/schemas/ViewMetadata'
3493+
credentials:
3494+
$ref: '#/components/schemas/Credentials'
34073495
config:
34083496
type: object
34093497
additionalProperties:

0 commit comments

Comments
 (0)