Skip to content

Commit 34d0b02

Browse files
committed
OpenAPI: Standardize credentials in loadTable/loadView responses
1 parent cb6540c commit 34d0b02

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
@@ -1086,6 +1086,12 @@ class ViewUpdate(BaseModel):
10861086
]
10871087

10881088

1089+
class Credentials(BaseModel):
1090+
__root__: Union[ADLSCredentials, GCSCredentials, S3Credentials] = Field(
1091+
..., discriminator='type'
1092+
)
1093+
1094+
10891095
class LoadTableResult(BaseModel):
10901096
"""
10911097
Result used when a table is successfully loaded.
@@ -1113,6 +1119,11 @@ class LoadTableResult(BaseModel):
11131119
- `s3.session-token`: if present, this value should be used for as the session token
11141120
- `s3.remote-signing-enabled`: if `true` remote signing should be performed as described in the `s3-signer-open-api.yaml` specification
11151121
1122+
## Credentials
1123+
1124+
Credentials for ADLS / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
1125+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
1126+
11161127
"""
11171128

11181129
metadata_location: Optional[str] = Field(
@@ -1121,6 +1132,7 @@ class LoadTableResult(BaseModel):
11211132
description='May be null if the table is staged as part of a transaction',
11221133
)
11231134
metadata: TableMetadata
1135+
credentials: Optional[Credentials] = None
11241136
config: Optional[Dict[str, str]] = None
11251137

11261138

@@ -1183,10 +1195,16 @@ class LoadViewResult(BaseModel):
11831195
11841196
- `token`: Authorization bearer token to use for view requests if OAuth2 security is enabled
11851197
1198+
## Credentials
1199+
1200+
Credentials for Azure / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
1201+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
1202+
11861203
"""
11871204

11881205
metadata_location: str = Field(..., alias='metadata-location')
11891206
metadata: ViewMetadata
1207+
credentials: Optional[Credentials] = None
11901208
config: Optional[Dict[str, str]] = None
11911209

11921210

@@ -1217,6 +1235,28 @@ class Schema(StructType):
12171235
)
12181236

12191237

1238+
class ADLSCredentials(BaseModel):
1239+
type: Literal['adls']
1240+
account_name: Optional[str] = Field(None, alias='account-name')
1241+
account_key: Optional[str] = Field(None, alias='account-key')
1242+
sas_token: Optional[str] = Field(None, alias='sas-token')
1243+
expires_at_ms: Optional[int] = Field(None, alias='expires-at-ms')
1244+
1245+
1246+
class GCSCredentials(BaseModel):
1247+
type: Literal['gcs']
1248+
token: str
1249+
expires_at_ms: int = Field(..., alias='expires-at-ms')
1250+
1251+
1252+
class S3Credentials(BaseModel):
1253+
type: Literal['s3']
1254+
access_key_id: str = Field(..., alias='access-key-id')
1255+
secret_access_key: str = Field(..., alias='secret-access-key')
1256+
session_token: str = Field(..., alias='session-token')
1257+
expires_at_ms: int = Field(..., alias='expires-at-ms')
1258+
1259+
12201260
class ReportMetricsRequest1(ScanReport):
12211261
report_type: str = Field(..., alias='report-type')
12221262

@@ -1228,6 +1268,10 @@ class ReportMetricsRequest1(ScanReport):
12281268
TableMetadata.update_forward_refs()
12291269
ViewMetadata.update_forward_refs()
12301270
AddSchemaUpdate.update_forward_refs()
1271+
Credentials.update_forward_refs()
12311272
CreateTableRequest.update_forward_refs()
12321273
CreateViewRequest.update_forward_refs()
12331274
ReportMetricsRequest.update_forward_refs()
1275+
ADLSCredentials.update_forward_refs()
1276+
GCSCredentials.update_forward_refs()
1277+
S3Credentials.update_forward_refs()

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

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,81 @@ components:
27472747
uuid:
27482748
type: string
27492749

2750+
ADLSCredentials:
2751+
type: object
2752+
allOf:
2753+
- $ref: '#/components/schemas/Credentials'
2754+
required:
2755+
- type
2756+
properties:
2757+
type:
2758+
type: string
2759+
enum: [ "adls" ]
2760+
account-name:
2761+
type: string
2762+
account-key:
2763+
type: string
2764+
sas-token:
2765+
type: string
2766+
expires-at-ms:
2767+
type: integer
2768+
format: int64
2769+
2770+
GCSCredentials:
2771+
type: object
2772+
allOf:
2773+
- $ref: '#/components/schemas/Credentials'
2774+
required:
2775+
- type
2776+
- token
2777+
- expires-at-ms
2778+
properties:
2779+
type:
2780+
type: string
2781+
enum: [ "gcs" ]
2782+
token:
2783+
type: string
2784+
expires-at-ms:
2785+
type: integer
2786+
format: int64
2787+
2788+
S3Credentials:
2789+
type: object
2790+
allOf:
2791+
- $ref: '#/components/schemas/Credentials'
2792+
required:
2793+
- type
2794+
- access-key-id
2795+
- secret-access-key
2796+
- session-token
2797+
- expires-at-ms
2798+
properties:
2799+
type:
2800+
type: string
2801+
enum: [ "s3" ]
2802+
access-key-id:
2803+
type: string
2804+
secret-access-key:
2805+
type: string
2806+
session-token:
2807+
type: string
2808+
expires-at-ms:
2809+
type: integer
2810+
format: int64
2811+
2812+
Credentials:
2813+
type: object
2814+
discriminator:
2815+
propertyName: type
2816+
mapping:
2817+
adls: '#/components/schemas/ADLSCredentials'
2818+
gcs: '#/components/schemas/GCSCredentials'
2819+
s3: '#/components/schemas/S3Credentials'
2820+
oneOf:
2821+
- $ref: '#/components/schemas/ADLSCredentials'
2822+
- $ref: '#/components/schemas/GCSCredentials'
2823+
- $ref: '#/components/schemas/S3Credentials'
2824+
27502825
LoadTableResult:
27512826
description: |
27522827
Result used when a table is successfully loaded.
@@ -2773,6 +2848,11 @@ components:
27732848
- `s3.secret-access-key`: secret for credentials that provide access to data in S3
27742849
- `s3.session-token`: if present, this value should be used for as the session token
27752850
- `s3.remote-signing-enabled`: if `true` remote signing should be performed as described in the `s3-signer-open-api.yaml` specification
2851+
2852+
## Credentials
2853+
2854+
Credentials for ADLS / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
2855+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
27762856
type: object
27772857
required:
27782858
- metadata
@@ -2782,6 +2862,8 @@ components:
27822862
description: May be null if the table is staged as part of a transaction
27832863
metadata:
27842864
$ref: '#/components/schemas/TableMetadata'
2865+
credentials:
2866+
$ref: '#/components/schemas/Credentials'
27852867
config:
27862868
type: object
27872869
additionalProperties:
@@ -2905,6 +2987,10 @@ components:
29052987
29062988
- `token`: Authorization bearer token to use for view requests if OAuth2 security is enabled
29072989
2990+
## Credentials
2991+
2992+
Credentials for Azure / GCS / S3 are provided through the `credentials` field. Clients should first check whether the
2993+
respective credentials exist in the `credentials` field before checking the `config` for credentials.
29082994
type: object
29092995
required:
29102996
- metadata-location
@@ -2914,6 +3000,8 @@ components:
29143000
type: string
29153001
metadata:
29163002
$ref: '#/components/schemas/ViewMetadata'
3003+
credentials:
3004+
$ref: '#/components/schemas/Credentials'
29173005
config:
29183006
type: object
29193007
additionalProperties:

0 commit comments

Comments
 (0)