generate_payload_for_resource¶
- MetadataGenerationApi.generate_payload_for_resource(resource_type, role_id, metadata_generator_input, content_type=None, action=None, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)¶
Generate schema or create-dataset payload from an uploaded file
Extracts schema and/or generates a create-dataset payload from a file previously uploaded via the GET pre-signed URL (or referenced by QueryId). Only resource_type=datasets is supported (else GE-1106). Body is MetadataGeneratorInput with required FileName and Action (get-schema|get-payload). Optional dataset fields (DatasetName, Domain, Keywords, TargetLocation, TableUpdate, Iceberg/Hudi options, QueryId, etc.) are accepted when present. get-schema returns {DatasetSchema}; get-payload returns {Payload: <create-dataset body>}.
- Parameters:
resource_type (str) – Resource kind to generate payload for. Only datasets is supported today (else GE-1106). (required)
role_id (str) – Amorphic role ID the request is authorized against. Must be a role the caller belongs to. (required)
metadata_generator_input (MetadataGeneratorInput) – (required)
content_type (str) – Optional Content-Type header (application/json).
action (str) – Optional query action. Handler uses Action from the request body (get-schema|get-payload), not this query param.
_request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.
_request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.
_content_type (str, Optional) – force content-type for the request.
_headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.
_host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.
- Return type:
- Returns:
Returns the result object.
Request and Response Examples¶
HTTP: POST /generate-payload/{resource_type}
Parameter examples¶
Name |
In |
Example |
|---|---|---|
|
path |
|
Request¶
Extract schema from uploaded CSV
{
"FileName": "generate_payload/alice@example.com/datasets/1723545600_monthly_orders.csv",
"Action": "get-schema",
"TargetLocation": "s3athena"
}
Generate create-dataset payload
{
"FileName": "generate_payload/alice@example.com/datasets/1723545600_monthly_orders.csv",
"Action": "get-payload",
"DatasetName": "monthly_orders",
"Domain": "sales",
"Keywords": [
"orders",
"sales"
],
"TargetLocation": "s3athena",
"TableUpdate": "append"
}
Success (HTTP 200)¶
For Action=get-schema, body is {DatasetSchema: […]}. For Action=get-payload, body is MetadataGeneratorOutput with Payload containing DatasetName, DatasetDescription, Domain, Keywords, DatasetSchema, TargetLocation, DatasourceType, FileType, TableUpdate, DatasetType, and related create-dataset fields.
Schema extraction result
{
"DatasetSchema": [
{
"name": "CustomerID",
"type": "string",
"description": "Customer identifier"
},
{
"name": "Amount",
"type": "double",
"description": "Order amount"
}
]
}
Create-dataset payload
{
"Payload": {
"DatasetName": "monthly_orders",
"DatasetDescription": "Order line items, refreshed monthly",
"Domain": "sales",
"Keywords": [
"orders",
"sales"
],
"DatasetSchema": [
{
"name": "CustomerID",
"type": "string"
},
{
"name": "Amount",
"type": "double"
}
],
"TargetLocation": "s3athena",
"DatasourceType": "api",
"FileType": "csv",
"TableUpdate": "append",
"DatasetType": "internal"
}
}
Errors¶
Documented error codes: IPV-1001, IPV-1041, GE-1034, GE-1106, RTE-1001.
HTTP 400
Validation failure. Body is {“Message”: “<CODE> - <text>”}. Codes: IPV-1001 (missing FileName/Action), IPV-1041 (Action not get-schema|get-payload), GE-1034 (missing file extension / extract failures), GE-1106 (resource_type not datasets).
FileName missing in body
{
"Message": "IPV-1001 - Missing required key(s) 'FileName' in the input"
}
Action not get-schema or get-payload
{
"Message": "IPV-1041 - Invalid value for parameter Action, Allowed values - ['get-schema','get-payload']"
}
resource_type is not datasets
{
"Message": "GE-1106 - Invalid resource type!, Resource Payload creation is/are not supported for jobs"
}
HTTP 500
Backend/generic failure. Body is {“Message”: “<CODE> - <text>”}.
Request / response example
{
"Message": "RTE-1001 - An error occurred."
}