From 6938055c895571330df91a7c12dabf20f1aa5784 Mon Sep 17 00:00:00 2001 From: Abhi Agarwal Date: Tue, 18 Jun 2024 19:53:44 -0400 Subject: [PATCH] feat: create models package --- Cargo.toml | 17 +- models/Cargo.toml | 17 + models/README.md | 12 + models/openapi.json | 2011 +++++++++++++++++ models/src/lib.rs | 7 + models/src/models/aws_credentials.rs | 12 + models/src/models/catalog_info.rs | 25 + models/src/models/column_info.rs | 35 + models/src/models/column_type_name.rs | 32 + models/src/models/create_catalog.rs | 35 + models/src/models/create_function.rs | 86 + models/src/models/create_function_request.rs | 7 + models/src/models/create_schema.rs | 17 + models/src/models/create_table.rs | 26 + .../models/create_volume_request_content.rs | 18 + models/src/models/data_source_format.rs | 18 + models/src/models/dependency.rs | 10 + models/src/models/dependency_list.rs | 9 + models/src/models/function_dependency.rs | 9 + models/src/models/function_info.rs | 124 + models/src/models/function_parameter_info.rs | 34 + models/src/models/function_parameter_infos.rs | 8 + models/src/models/function_parameter_mode.rs | 24 + models/src/models/function_parameter_type.rs | 27 + .../generate_temporary_table_credential.rs | 10 + ...ate_temporary_table_credential_response.rs | 11 + .../generate_temporary_volume_credential.rs | 10 + ...te_temporary_volume_credential_response.rs | 11 + models/src/models/list_catalogs_response.rs | 11 + models/src/models/list_functions_response.rs | 11 + models/src/models/list_schemas_response.rs | 11 + models/src/models/list_tables_response.rs | 11 + .../models/list_volumes_response_content.rs | 10 + models/src/models/mod.rs | 78 + models/src/models/schema_info.rs | 29 + models/src/models/table_dependency.rs | 9 + models/src/models/table_info.rs | 36 + models/src/models/table_operation.rs | 29 + models/src/models/table_type.rs | 26 + models/src/models/update_catalog.rs | 16 + models/src/models/update_schema.rs | 16 + .../models/update_volume_request_content.rs | 21 + models/src/models/volume_info.rs | 30 + models/src/models/volume_operation.rs | 29 + models/src/models/volume_type.rs | 27 + server/Cargo.toml | 3 +- 46 files changed, 3062 insertions(+), 3 deletions(-) create mode 100644 models/Cargo.toml create mode 100644 models/README.md create mode 100644 models/openapi.json create mode 100644 models/src/lib.rs create mode 100644 models/src/models/aws_credentials.rs create mode 100644 models/src/models/catalog_info.rs create mode 100644 models/src/models/column_info.rs create mode 100644 models/src/models/column_type_name.rs create mode 100644 models/src/models/create_catalog.rs create mode 100644 models/src/models/create_function.rs create mode 100644 models/src/models/create_function_request.rs create mode 100644 models/src/models/create_schema.rs create mode 100644 models/src/models/create_table.rs create mode 100644 models/src/models/create_volume_request_content.rs create mode 100644 models/src/models/data_source_format.rs create mode 100644 models/src/models/dependency.rs create mode 100644 models/src/models/dependency_list.rs create mode 100644 models/src/models/function_dependency.rs create mode 100644 models/src/models/function_info.rs create mode 100644 models/src/models/function_parameter_info.rs create mode 100644 models/src/models/function_parameter_infos.rs create mode 100644 models/src/models/function_parameter_mode.rs create mode 100644 models/src/models/function_parameter_type.rs create mode 100644 models/src/models/generate_temporary_table_credential.rs create mode 100644 models/src/models/generate_temporary_table_credential_response.rs create mode 100644 models/src/models/generate_temporary_volume_credential.rs create mode 100644 models/src/models/generate_temporary_volume_credential_response.rs create mode 100644 models/src/models/list_catalogs_response.rs create mode 100644 models/src/models/list_functions_response.rs create mode 100644 models/src/models/list_schemas_response.rs create mode 100644 models/src/models/list_tables_response.rs create mode 100644 models/src/models/list_volumes_response_content.rs create mode 100644 models/src/models/mod.rs create mode 100644 models/src/models/schema_info.rs create mode 100644 models/src/models/table_dependency.rs create mode 100644 models/src/models/table_info.rs create mode 100644 models/src/models/table_operation.rs create mode 100644 models/src/models/table_type.rs create mode 100644 models/src/models/update_catalog.rs create mode 100644 models/src/models/update_schema.rs create mode 100644 models/src/models/update_volume_request_content.rs create mode 100644 models/src/models/volume_info.rs create mode 100644 models/src/models/volume_operation.rs create mode 100644 models/src/models/volume_type.rs diff --git a/Cargo.toml b/Cargo.toml index 1660f7b..1c656a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,21 @@ [workspace] -members = ["server"] +members = [ + "server", + "models", +] resolver = "2" [workspace.package] edition = "2021" license = "Apache-2.0" -version = "0.0.1" \ No newline at end of file +version = "0.0.1" + +[workspace.dependencies] +chrono = { version = "0.4.38", features = ["serde"] } +reqwest = { version = "0.12.4", default-features = false, features = ["rustls-tls"] } +tokio = { version = "1.38.0", features = ["full"] } +serde = { version = "^1.0", features = ["derive"] } +serde_json = "^1.0" +tracing = { version = "^0.1.40" } +tracing-subscriber = { version = "^0.3.18", features = ["env-filter"] } +uuid = { version = "^1.8", features = ["serde", "v4"] } \ No newline at end of file diff --git a/models/Cargo.toml b/models/Cargo.toml new file mode 100644 index 0000000..72f8f0b --- /dev/null +++ b/models/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "unitycatalog-models" +version = "0.1.0" +description = "Generated structs for Unity Catalog models" + +edition.workspace = true +license.workspace = true + +publish = false + +[dependencies] +strum = { version = "0.26", features = ["derive"] } + +serde = { workspace = true } +serde_json = { workspace = true } +uuid = { workspace = true } +chrono = { workspace = true } diff --git a/models/README.md b/models/README.md new file mode 100644 index 0000000..3478274 --- /dev/null +++ b/models/README.md @@ -0,0 +1,12 @@ +# Rust=generated structs for Unity Catalog + +## Overview + +These models were generated by the [OpenAPI Generator](https://openapi-generator.tech) project. + +- API version: 0.1 +- Package version: 0.1 +- Generator version: 7.6.0 +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +From there, they have been manually tuned and fixed. \ No newline at end of file diff --git a/models/openapi.json b/models/openapi.json new file mode 100644 index 0000000..8986ef1 --- /dev/null +++ b/models/openapi.json @@ -0,0 +1,2011 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "google.com", + "description": "Localhost reference server" + } + ], + "tags": [ + { + "name": "Catalogs", + "description": "A catalog is the first layer of Unity Catalog’s three-level namespace. It’s used to organize your data assets.\n" + }, + { + "name": "Schemas", + "description": "A schema (also called a database) is the second layer of Unity Catalog’s three-level namespace. A schema organizes tables, volumes and functions.\n" + }, + { + "name": "Tables", + "description": "A table resides in the third layer of Unity Catalog’s three-level namespace. It contains rows of data. \nA table can be managed or external.\n" + }, + { + "name": "Volumes", + "description": "Volumes are a Unity Catalog capability for accessing, storing, governing, organizing and processing files. Use cases include running machine learning on unstructured data such as image, audio, video, or PDF files, organizing data sets during the data exploration stages in data science, working with libraries that require access to the local file system on cluster machines, storing library and config files of arbitrary formats such as .whl or .txt centrally and providing secure access across workspaces to it, or transforming and querying non-tabular data files in ETL.\n" + }, + { + "name": "Functions", + "description": "Functions implement User-Defined Functions (UDFs) in Unity Catalog.\nThe function implementation can be a SQL expression/query or a python function, and it can be invoked wherever a table reference is allowed in a query.\nIn Unity Catalog, a function resides at the same level as a table, so it can be referenced with the form __catalog_name__.__schema_name__.__function_name__.\n" + } + ], + "paths": { + "/catalogs": { + "post": { + "tags": [ + "Catalogs" + ], + "operationId": "createCatalog", + "summary": "Create a catalog", + "description": "Creates a new catalog instance.\n", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCatalog" + } + } + } + }, + "responses": { + "200": { + "description": "The new catalog was successfully created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CatalogInfo" + } + } + } + } + } + }, + "get": { + "tags": [ + "Catalogs" + ], + "parameters": [ + { + "name": "page_token", + "in": "query", + "description": "Opaque pagination token to go to next page based on previous query.\n", + "schema": { + "type": "string" + }, + "required": false + }, + { + "name": "max_results", + "in": "query", + "description": "Maximum number of catalogs to return.\n- when set to a value greater than 0, the page length is the minimum of this value and a server configured value;\n- when set to 0, the page length is set to a server configured value;\n- when set to a value less than 0, an invalid parameter error is returned;\n", + "schema": { + "type": "integer", + "format": "int32", + "maximum": 1000 + }, + "required": false + } + ], + "operationId": "listCatalogs", + "summary": "List catalogs", + "description": "Lists the available catalogs. There is no guarantee of a specific ordering of the elements in the list.\n", + "responses": { + "200": { + "description": "The catalog list was successfully retrieved.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListCatalogsResponse" + } + } + } + } + } + } + }, + "/catalogs/{name}": { + "parameters": [ + { + "name": "name", + "in": "path", + "description": "The name of the catalog.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "get": { + "tags": [ + "Catalogs" + ], + "operationId": "getCatalog", + "summary": "Get a catalog", + "description": "Gets the specified catalog.\n", + "responses": { + "200": { + "description": "The catalog was successfully retrieved.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CatalogInfo" + } + } + } + } + } + }, + "patch": { + "tags": [ + "Catalogs" + ], + "operationId": "updateCatalog", + "summary": "Update a catalog", + "description": "Updates the catalog that matches the supplied name.\n", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateCatalog" + } + } + } + }, + "responses": { + "200": { + "description": "The catalog was successfully updated.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CatalogInfo" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Catalogs" + ], + "operationId": "deleteCatalog", + "summary": "Delete a catalog", + "description": "Deletes the catalog that matches the supplied name.\n", + "parameters": [ + { + "name": "force", + "in": "query", + "description": "Force deletion even if the catalog is not empty.", + "required": false, + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "The catalog was successfully deleted.", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + }, + "/schemas": { + "post": { + "tags": [ + "Schemas" + ], + "operationId": "createSchema", + "summary": "Create a schema", + "description": "Creates a new schema in the specified catalog.\n", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateSchema" + } + } + } + }, + "responses": { + "200": { + "description": "The new schema was successfully created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SchemaInfo" + } + } + } + } + } + }, + "get": { + "tags": [ + "Schemas" + ], + "parameters": [ + { + "name": "catalog_name", + "in": "query", + "description": "Parent catalog for schemas of interest.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "max_results", + "in": "query", + "description": "Maximum number of schemas to return.\n- when set to a value greater than 0, the page length is the minimum of this value and a server configured value;\n- when set to 0, the page length is set to a server configured value;\n- when set to a value less than 0, an invalid parameter error is returned;\n", + "schema": { + "type": "integer", + "format": "int32", + "maximum": 1000 + }, + "required": false + }, + { + "name": "page_token", + "in": "query", + "description": "Opaque pagination token to go to next page based on previous query.\n", + "schema": { + "type": "string" + }, + "required": false + } + ], + "operationId": "listSchemas", + "summary": "List schemas", + "description": "Gets an array of schemas for a catalog.\nThere is no guarantee of a specific ordering of the elements in the array.\n", + "responses": { + "200": { + "description": "The schemas list was successfully retrieved.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListSchemasResponse" + } + } + } + } + } + } + }, + "/schemas/{full_name}": { + "parameters": [ + { + "name": "full_name", + "in": "path", + "description": "Full name of the schema.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "get": { + "tags": [ + "Schemas" + ], + "operationId": "getSchema", + "summary": "Get a schema", + "description": "Gets the specified schema for a catalog.\n", + "responses": { + "200": { + "description": "The schema was successfully retrieved.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SchemaInfo" + } + } + } + } + } + }, + "patch": { + "tags": [ + "Schemas" + ], + "operationId": "updateSchema", + "summary": "Update a schema", + "description": "Updates the specified schema.\n", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateSchema" + } + } + } + }, + "responses": { + "200": { + "description": "The schema was successfully updated.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SchemaInfo" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Schemas" + ], + "operationId": "deleteSchema", + "summary": "Delete a schema", + "description": "Deletes the specified schema from the parent catalog.\n", + "responses": { + "200": { + "description": "The schema was successfully deleted.", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + }, + "/tables": { + "post": { + "operationId": "createTable", + "summary": "Create a table.\nWARNING: This API is experimental and will change in future versions.\n", + "tags": [ + "Tables" + ], + "description": "Creates a new table instance.\nWARNING: This API is experimental and will change in future versions.\n", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTable" + } + } + } + }, + "responses": { + "200": { + "description": "The new table was successfully created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TableInfo" + } + } + } + } + } + }, + "get": { + "tags": [ + "Tables" + ], + "parameters": [ + { + "name": "catalog_name", + "in": "query", + "description": "Name of parent catalog for tables of interest.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "schema_name", + "in": "query", + "description": "Parent schema of tables.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "max_results", + "in": "query", + "description": "Maximum number of tables to return.\n- when set to a value greater than 0, the page length is the minimum of this value and a server configured value;\n- when set to 0, the page length is set to a server configured value;\n- when set to a value less than 0, an invalid parameter error is returned;\n", + "required": false, + "schema": { + "type": "integer", + "format": "int32", + "maximum": 50 + } + }, + { + "name": "page_token", + "in": "query", + "description": "Opaque token to send for the next page of results (pagination).", + "required": false, + "schema": { + "type": "string" + } + } + ], + "operationId": "listTables", + "summary": "List tables", + "description": "Gets the list of all available tables under the parent catalog and schema.\nThere is no guarantee of a specific ordering of the elements in the array.\n", + "responses": { + "200": { + "description": "The tables list was successfully retrieved.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListTablesResponse" + } + } + } + } + } + } + }, + "/tables/{full_name}": { + "parameters": [ + { + "name": "full_name", + "in": "path", + "description": "Full name of the table.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "get": { + "tags": [ + "Tables" + ], + "operationId": "getTable", + "summary": "Get a table", + "description": "Gets a table for a specific catalog and schema.\n", + "responses": { + "200": { + "description": "The table was successfully retrieved.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TableInfo" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Tables" + ], + "operationId": "deleteTable", + "summary": "Delete a table", + "description": "Deletes a table from the specified parent catalog and schema.\n", + "responses": { + "200": { + "description": "The table was successfully deleted.", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + }, + "/volumes": { + "post": { + "tags": [ + "Volumes" + ], + "operationId": "createVolume", + "summary": "Create a Volume", + "description": "Creates a new volume.\n", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateVolumeRequestContent" + }, + "examples": { + "CreateExternalVolumeExample": { + "summary": "Create an External Volume", + "description": "Create an External Volume and point the volume to a folder in the S3 bucket", + "value": { + "catalog_name": "main", + "schema_name": "default", + "name": "my_volume", + "volume_type": "EXTERNAL", + "comment": "This is my first volume", + "storage_location": "storage_location" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successfully created the volume", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VolumeInfo" + }, + "examples": { + "CreateVolumeExample": { + "summary": "Response of successful creation", + "description": "The properties of the volume will be returned if the operation succeeds", + "value": { + "catalog_name": "main", + "schema_name": "default", + "name": "my_volume", + "volume_type": "EXTERNAL", + "created_at": 1666369196203, + "updated_at": 1666369196203, + "comment": "This is my first volume" + } + } + } + } + } + } + } + }, + "get": { + "tags": [ + "Volumes" + ], + "operationId": "listVolumes", + "summary": "List Volumes", + "description": "Gets an array of available volumes under the parent catalog and schema.\nThere is no guarantee of a specific ordering of the elements in the array.\n", + "parameters": [ + { + "name": "catalog_name", + "in": "query", + "description": "The identifier of the catalog", + "schema": { + "type": "string" + }, + "required": true, + "examples": { + "CatalogNameExample": { + "summary": "Specify the target catalog to be `main`", + "description": "Execute the operation against the `main` catalog", + "value": "main" + } + } + }, + { + "name": "schema_name", + "in": "query", + "description": "The identifier of the schema", + "schema": { + "type": "string" + }, + "required": true, + "examples": { + "SchemaNameExample": { + "summary": "Specify the target schema to be `default`", + "description": "Execute the operation against the `default` schema", + "value": "default" + } + } + }, + { + "name": "max_results", + "in": "query", + "description": "Maximum number of volumes to return (page length).\n\nIf not set, the page length is set to a server configured value.\n- when set to a value greater than 0, the page length is the minimum of this value and a server configured value;\n- when set to 0, the page length is set to a server configured value;\n- when set to a value less than 0, an invalid parameter error is returned;\n\nNote: this parameter controls only the maximum number of volumes to return. The actual number of volumes returned in a page may be smaller than this value, including 0, even if there are more pages.\n\n", + "required": false, + "schema": { + "type": "integer", + "format": "int32", + "maximum": 10000 + } + }, + { + "name": "page_token", + "in": "query", + "description": "Opaque token returned by a previous request. It must be included in the request to retrieve the next page of results (pagination).", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The volume list was successfully retrieved", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListVolumesResponseContent" + }, + "examples": { + "ListVolumesExample": { + "summary": "Response of success retrieval of the volumes", + "description": "A list of volume properties will be returned if the operation succeeds", + "value": { + "volumes": [ + { + "catalog_name": "main", + "schema_name": "default", + "name": "my_volume", + "volume_type": "EXTERNAL", + "created_at": 1666369196203, + "updated_at": 1666369196203, + "comment": "This is my first volume" + }, + { + "catalog_name": "main", + "schema_name": "default", + "name": "my_another_volume", + "volume_type": "EXTERNAL", + "created_at": 1666369196203, + "updated_at": 1666369196203, + "comment": "This is my other volume" + } + ] + } + } + } + } + } + } + } + } + }, + "/volumes/{name}": { + "parameters": [ + { + "name": "name", + "in": "path", + "description": "The three-level (fully qualified) name of the volume", + "schema": { + "type": "string" + }, + "required": true, + "examples": { + "FullNameArgExample": { + "summary": "Execute the operation against the volume named `my_volume` under `main` catalog and `default` schema", + "value": "main.default.my_volume" + } + } + } + ], + "get": { + "tags": [ + "Volumes" + ], + "operationId": "getVolume", + "summary": "Get a Volume", + "description": "Gets a volume for a specific catalog and schema.\n", + "responses": { + "200": { + "description": "Successfully retrieved the properties of the volume", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VolumeInfo" + }, + "examples": { + "GetVolumeExample": { + "summary": "Response of successful retrieval of an existing volume", + "description": "The properties of the volume will be returned if the operation succeeds", + "value": { + "catalog_name": "main", + "schema_name": "default", + "name": "my_volume", + "volume_type": "EXTERNAL", + "created_at": 1666369196203, + "updated_at": 1666369196203, + "comment": "This is my first volume" + } + } + } + } + } + } + } + }, + "patch": { + "tags": [ + "Volumes" + ], + "operationId": "updateVolume", + "summary": "Update a Volume", + "description": "Updates the specified volume under the specified parent catalog and schema.\n\nCurrently only the name or the comment of the volume could be updated.\n", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateVolumeRequestContent" + }, + "examples": { + "UpdateVolumeName": { + "summary": "Update the name of the volume", + "description": "Update the name of the volume", + "value": { + "new_name": "my_new_volume" + } + }, + "UpdateVolumeComment": { + "summary": "Update the comment of the volume", + "description": "Update the comment of the volume", + "value": { + "comment": "This is my new volume" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successfully updated the properties of the volume", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VolumeInfo" + }, + "examples": { + "UpdateVolumeName": { + "summary": "Update the name of the volume", + "description": "The new properties of the volume will be returned if the operation succeeds", + "value": { + "catalog_name": "main", + "schema_name": "default", + "name": "my_new_volume", + "volume_type": "EXTERNAL", + "created_at": 1666369196203, + "updated_at": 1666369207415, + "comment": "This is my new volume" + } + } + } + } + } + } + } + }, + "delete": { + "tags": [ + "Volumes" + ], + "operationId": "deleteVolume", + "summary": "Delete a Volume", + "description": "Deletes a volume from the specified parent catalog and schema.\n", + "responses": { + "200": { + "description": "Successfully deleted the volume", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + }, + "/temporary-table-credentials": { + "post": { + "operationId": "generateTemporaryTableCredentials", + "tags": [ + "TemporaryTableCredentials" + ], + "summary": "Generate temporary table credentials.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GenerateTemporaryTableCredential" + } + } + } + }, + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GenerateTemporaryTableCredentialResponse" + } + } + } + } + } + } + }, + "/temporary-volume-credentials": { + "post": { + "operationId": "generateTemporaryVolumeCredentials", + "tags": [ + "TemporaryVolumeCredentials" + ], + "summary": "Generate temporary volume credentials.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GenerateTemporaryVolumeCredential" + } + } + } + }, + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GenerateTemporaryVolumeCredentialResponse" + } + } + } + } + } + } + }, + "/functions": { + "post": { + "tags": [ + "Functions" + ], + "operationId": "createFunction", + "summary": "Create a function.\nWARNING: This API is experimental and will change in future versions.\n", + "description": "Creates a new function instance.\nWARNING: This API is experimental and will change in future versions.\n", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateFunctionRequest" + } + } + } + }, + "responses": { + "200": { + "description": "The new function was successfully created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FunctionInfo" + } + } + } + } + } + }, + "get": { + "tags": [ + "Functions" + ], + "parameters": [ + { + "name": "catalog_name", + "in": "query", + "description": "Name of parent catalog for functions of interest.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "schema_name", + "in": "query", + "description": "Parent schema of functions.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "max_results", + "in": "query", + "description": "Maximum number of functions to return.\n- when set to a value greater than 0, the page length is the minimum of this value and a server configured value;\n- when set to 0, the page length is set to a server configured value;\n- when set to a value less than 0, an invalid parameter error is returned;\n", + "schema": { + "type": "integer", + "format": "int32", + "maximum": 1000 + }, + "required": false + }, + { + "name": "page_token", + "in": "query", + "description": "Opaque pagination token to go to next page based on previous query.", + "schema": { + "type": "string" + }, + "required": false + } + ], + "operationId": "listFunctions", + "summary": "List functions", + "description": "List functions within the specified parent catalog and schema.\nThere is no guarantee of a specific ordering of the elements in the array.\n", + "responses": { + "200": { + "description": "The function list was successfully retrieved.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListFunctionsResponse" + } + } + } + } + } + } + }, + "/functions/{name}": { + "parameters": [ + { + "name": "name", + "in": "path", + "description": "The fully-qualified name of the function (of the form __catalog_name__.__schema_name__.__function__name__).", + "required": true, + "schema": { + "type": "string" + } + } + ], + "get": { + "tags": [ + "Functions" + ], + "parameters": [], + "operationId": "getFunction", + "summary": "Get a function", + "description": "Gets a function from within a parent catalog and schema.", + "responses": { + "200": { + "description": "The function was successfully retrieved.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FunctionInfo" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Functions" + ], + "operationId": "deleteFunction", + "summary": "Delete a function", + "description": "Deletes the function that matches the supplied name.", + "responses": { + "200": { + "description": "The function was successfully deleted.", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SecurablePropertiesMap": { + "description": "A map of key-value properties attached to the securable.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "VolumeType": { + "type": "string", + "enum": [ + "MANAGED", + "EXTERNAL" + ], + "description": "The type of the volume" + }, + "CreateVolumeRequestContent": { + "type": "object", + "properties": { + "catalog_name": { + "type": "string", + "description": "The name of the catalog where the schema and the volume are" + }, + "schema_name": { + "type": "string", + "description": "The name of the schema where the volume is" + }, + "name": { + "type": "string", + "description": "The name of the volume" + }, + "volume_type": { + "$ref": "#/components/schemas/VolumeType" + }, + "comment": { + "type": "string", + "maxLength": 65536, + "minLength": 1, + "description": "The comment attached to the volume" + }, + "storage_location": { + "type": "string", + "description": "The storage location of the volume" + } + }, + "required": [ + "catalog_name", + "schema_name", + "name", + "volume_type", + "storage_location" + ] + }, + "ListVolumesResponseContent": { + "type": "object", + "properties": { + "volumes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/VolumeInfo" + } + }, + "next_page_token": { + "description": "Opaque token to retrieve the next page of results. Absent if there are no more pages.\n__page_token__ should be set to this value for the next request to retrieve the next page of results.\n", + "type": "string" + } + } + }, + "UpdateVolumeRequestContent": { + "type": "object", + "properties": { + "comment": { + "type": "string", + "maxLength": 65536, + "minLength": 1, + "description": "The comment attached to the volume" + }, + "new_name": { + "description": "New name for the volume.", + "type": "string" + } + } + }, + "VolumeInfo": { + "type": "object", + "properties": { + "catalog_name": { + "type": "string", + "description": "The name of the catalog where the schema and the volume are" + }, + "schema_name": { + "type": "string", + "description": "The name of the schema where the volume is" + }, + "name": { + "type": "string", + "description": "The name of the volume" + }, + "comment": { + "type": "string", + "maxLength": 65536, + "minLength": 1, + "description": "The comment attached to the volume" + }, + "created_at": { + "type": "integer", + "format": "int64", + "description": "Time at which this volume was created, in epoch milliseconds." + }, + "updated_at": { + "type": "integer", + "format": "int64", + "description": "Time at which this volume was last modified, in epoch milliseconds." + }, + "volume_id": { + "type": "string", + "description": "Unique identifier for the volume" + }, + "volume_type": { + "$ref": "#/components/schemas/VolumeType" + }, + "storage_location": { + "type": "string", + "description": "The storage location of the volume" + }, + "full_name": { + "type": "string", + "description": "Full name of volume, in form of __catalog_name__.__schema_name__.__volume_name__." + } + } + }, + "ColumnTypeName": { + "description": "Name of type (INT, STRUCT, MAP, etc.).", + "type": "string", + "enum": [ + "BOOLEAN", + "BYTE", + "SHORT", + "INT", + "LONG", + "FLOAT", + "DOUBLE", + "DATE", + "TIMESTAMP", + "TIMESTAMP_NTZ", + "STRING", + "BINARY", + "DECIMAL", + "INTERVAL", + "ARRAY", + "STRUCT", + "MAP", + "CHAR", + "NULL", + "USER_DEFINED_TYPE", + "TABLE_TYPE" + ] + }, + "ColumnInfo": { + "type": "object", + "properties": { + "name": { + "description": "Name of Column.", + "type": "string" + }, + "type_text": { + "description": "Full data type specification as SQL/catalogString text.", + "type": "string" + }, + "type_json": { + "description": "Full data type specification, JSON-serialized.", + "type": "string" + }, + "type_name": { + "$ref": "#/components/schemas/ColumnTypeName" + }, + "type_precision": { + "description": "Digits of precision; required for DecimalTypes.", + "type": "integer", + "format": "int32" + }, + "type_scale": { + "description": "Digits to right of decimal; Required for DecimalTypes.", + "type": "integer", + "format": "int32" + }, + "type_interval_type": { + "description": "Format of IntervalType.", + "type": "string" + }, + "position": { + "description": "Ordinal position of column (starting at position 0).", + "type": "integer", + "format": "int32" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "nullable": { + "description": "Whether field may be Null.", + "type": "boolean", + "default": "true" + }, + "partition_index": { + "description": "Partition index for column.", + "type": "integer", + "format": "int32" + } + } + }, + "TableType": { + "type": "string", + "enum": [ + "MANAGED", + "EXTERNAL" + ] + }, + "DataSourceFormat": { + "description": "Data source format", + "type": "string", + "enum": [ + "DELTA", + "CSV", + "JSON", + "AVRO", + "PARQUET", + "ORC", + "TEXT" + ] + }, + "TableInfo": { + "type": "object", + "properties": { + "name": { + "description": "Name of table, relative to parent schema.", + "type": "string" + }, + "catalog_name": { + "description": "Name of parent catalog.", + "type": "string" + }, + "schema_name": { + "description": "Name of parent schema relative to its parent catalog.", + "type": "string" + }, + "table_type": { + "$ref": "#/components/schemas/TableType" + }, + "data_source_format": { + "$ref": "#/components/schemas/DataSourceFormat" + }, + "columns": { + "description": "The array of __ColumnInfo__ definitions of the table's columns.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ColumnInfo" + } + }, + "storage_location": { + "description": "Storage root URL for table (for **MANAGED**, **EXTERNAL** tables)", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/SecurablePropertiesMap" + }, + "created_at": { + "description": "Time at which this table was created, in epoch milliseconds.", + "type": "integer", + "format": "int64" + }, + "updated_at": { + "description": "Time at which this table was last modified, in epoch milliseconds.", + "type": "integer", + "format": "int64" + }, + "table_id": { + "description": "Unique identifier for the table.", + "type": "string" + } + } + }, + "CreateTable": { + "type": "object", + "properties": { + "name": { + "description": "Name of table, relative to parent schema.", + "type": "string" + }, + "catalog_name": { + "description": "Name of parent catalog.", + "type": "string" + }, + "schema_name": { + "description": "Name of parent schema relative to its parent catalog.", + "type": "string" + }, + "table_type": { + "$ref": "#/components/schemas/TableType" + }, + "data_source_format": { + "$ref": "#/components/schemas/DataSourceFormat" + }, + "columns": { + "description": "The array of __ColumnInfo__ definitions of the table's columns.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ColumnInfo" + } + }, + "storage_location": { + "description": "Storage root URL for table (for **MANAGED**, **EXTERNAL** tables)", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/SecurablePropertiesMap" + } + }, + "required": [ + "name", + "catalog_name", + "schema_name", + "table_type", + "data_source_format", + "columns" + ] + }, + "ListTablesResponse": { + "type": "object", + "properties": { + "tables": { + "description": "An array of table information objects.", + "type": "array", + "items": { + "$ref": "#/components/schemas/TableInfo" + } + }, + "next_page_token": { + "description": "Opaque token to retrieve the next page of results. Absent if there are no more pages.\n__page_token__ should be set to this value for the next request (for the next page of results).\n", + "type": "string" + } + } + }, + "SchemaInfo": { + "type": "object", + "properties": { + "name": { + "description": "Name of schema, relative to parent catalog.", + "type": "string" + }, + "catalog_name": { + "description": "Name of parent catalog.", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/SecurablePropertiesMap" + }, + "full_name": { + "description": "Full name of schema, in form of __catalog_name__.__schema_name__.", + "type": "string" + }, + "created_at": { + "description": "Time at which this schema was created, in epoch milliseconds.", + "type": "integer", + "format": "int64" + }, + "updated_at": { + "description": "Time at which this schema was last modified, in epoch milliseconds.", + "type": "integer", + "format": "int64" + }, + "schema_id": { + "description": "Unique identifier for the schema.", + "type": "string" + } + } + }, + "CreateSchema": { + "type": "object", + "properties": { + "name": { + "description": "Name of schema, relative to parent catalog.", + "type": "string" + }, + "catalog_name": { + "description": "Name of parent catalog.", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/SecurablePropertiesMap" + } + }, + "required": [ + "name", + "catalog_name" + ] + }, + "UpdateSchema": { + "type": "object", + "properties": { + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/SecurablePropertiesMap" + }, + "new_name": { + "description": "New name for the schema.", + "type": "string" + } + } + }, + "ListSchemasResponse": { + "type": "object", + "properties": { + "schemas": { + "description": "An array of schema information objects.", + "type": "array", + "items": { + "$ref": "#/components/schemas/SchemaInfo" + } + }, + "next_page_token": { + "type": "string", + "description": "Opaque token to retrieve the next page of results. Absent if there are no more pages.\n__page_token__ should be set to this value for the next request (for the next page of results).\n" + } + } + }, + "CatalogInfo": { + "type": "object", + "properties": { + "name": { + "description": "Name of catalog.", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/SecurablePropertiesMap" + }, + "created_at": { + "description": "Time at which this catalog was created, in epoch milliseconds.", + "type": "integer", + "format": "int64" + }, + "updated_at": { + "description": "Time at which this catalog was last modified, in epoch milliseconds.", + "type": "integer", + "format": "int64" + }, + "id": { + "description": "Unique identifier for the catalog.", + "type": "string" + } + } + }, + "CreateCatalog": { + "type": "object", + "properties": { + "name": { + "description": "Name of catalog.", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/SecurablePropertiesMap" + } + }, + "required": [ + "name" + ] + }, + "UpdateCatalog": { + "type": "object", + "properties": { + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/SecurablePropertiesMap" + }, + "new_name": { + "description": "New name for the catalog.", + "type": "string" + } + } + }, + "ListCatalogsResponse": { + "type": "object", + "properties": { + "catalogs": { + "description": "An array of catalog information objects.", + "type": "array", + "items": { + "$ref": "#/components/schemas/CatalogInfo" + } + }, + "next_page_token": { + "type": "string", + "description": "Opaque token to retrieve the next page of results. Absent if there are no more pages.\n__page_token__ should be set to this value for the next request (for the next page of results).\n" + } + } + }, + "FunctionParameterType": { + "description": "The type of function parameter.", + "type": "string", + "enum": [ + "PARAM", + "COLUMN" + ] + }, + "FunctionParameterMode": { + "description": "The mode of the function parameter.", + "type": "string", + "enum": [ + "IN" + ] + }, + "FunctionParameterInfo": { + "type": "object", + "required": [ + "name", + "type_text", + "type_name", + "type_json", + "position" + ], + "properties": { + "name": { + "description": "Name of parameter.", + "type": "string" + }, + "type_text": { + "description": "Full data type spec, SQL/catalogString text.", + "type": "string" + }, + "type_json": { + "description": "Full data type spec, JSON-serialized.", + "type": "string" + }, + "type_name": { + "$ref": "#/components/schemas/ColumnTypeName" + }, + "type_precision": { + "description": "Digits of precision; required on Create for DecimalTypes.", + "type": "integer", + "format": "int32" + }, + "type_scale": { + "description": "Digits to right of decimal; Required on Create for DecimalTypes.", + "type": "integer", + "format": "int32" + }, + "type_interval_type": { + "description": "Format of IntervalType.", + "type": "string" + }, + "position": { + "description": "Ordinal position of column (starting at position 0).", + "type": "integer", + "format": "int32" + }, + "parameter_mode": { + "$ref": "#/components/schemas/FunctionParameterMode" + }, + "parameter_type": { + "$ref": "#/components/schemas/FunctionParameterType" + }, + "parameter_default": { + "description": "Default value of the parameter.", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + } + } + }, + "FunctionParameterInfos": { + "type": "object", + "properties": { + "parameters": { + "description": "The array of __FunctionParameterInfo__ definitions of the function's parameters.", + "type": "array", + "items": { + "$ref": "#/components/schemas/FunctionParameterInfo" + } + } + } + }, + "CreateFunctionRequest": { + "type": "object", + "properties": { + "function_info": { + "$ref": "#/components/schemas/CreateFunction" + } + }, + "required": [ + "function_info" + ] + }, + "FunctionDependency": { + "description": "A function that is dependent on a SQL object.", + "type": "object", + "required": [ + "function_full_name" + ], + "properties": { + "function_full_name": { + "description": "Full name of the dependent function, in the form of __catalog_name__.__schema_name__.__function_name__.", + "type": "string" + } + } + }, + "TableDependency": { + "description": "A table that is dependent on a SQL object.", + "type": "object", + "required": [ + "table_full_name" + ], + "properties": { + "table_full_name": { + "description": "Full name of the dependent table, in the form of __catalog_name__.__schema_name__.__table_name__.", + "type": "string" + } + } + }, + "Dependency": { + "description": "A dependency of a SQL object. Either the __table__ field or the __function__ field must be defined.", + "type": "object", + "properties": { + "table": { + "$ref": "#/components/schemas/TableDependency" + }, + "function": { + "$ref": "#/components/schemas/FunctionDependency" + } + } + }, + "DependencyList": { + "description": "A list of dependencies.", + "type": "object", + "properties": { + "dependencies": { + "description": "Array of dependencies.", + "type": "array", + "items": { + "$ref": "#/components/schemas/Dependency" + } + } + } + }, + "CreateFunction": { + "type": "object", + "required": [ + "name", + "catalog_name", + "schema_name", + "input_params", + "data_type", + "full_data_type", + "routine_body", + "routine_definition", + "parameter_style", + "is_deterministic", + "sql_data_access", + "is_null_call", + "security_type", + "specific_name", + "properties" + ], + "properties": { + "name": { + "description": "Name of function, relative to parent schema.", + "type": "string" + }, + "catalog_name": { + "description": "Name of parent catalog.", + "type": "string" + }, + "schema_name": { + "description": "Name of parent schema relative to its parent catalog.", + "type": "string" + }, + "input_params": { + "$ref": "#/components/schemas/FunctionParameterInfos" + }, + "data_type": { + "$ref": "#/components/schemas/ColumnTypeName" + }, + "full_data_type": { + "description": "Pretty printed function data type.", + "type": "string" + }, + "return_params": { + "$ref": "#/components/schemas/FunctionParameterInfos" + }, + "routine_body": { + "description": "Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the __external_language__ field, \nand the __return_params__ of the function cannot be used (as **TABLE** return type is not supported),\nand the __sql_data_access__ field must be **NO_SQL**.\n", + "type": "string", + "enum": [ + "SQL", + "EXTERNAL" + ] + }, + "routine_definition": { + "description": "Function body.", + "type": "string" + }, + "routine_dependencies": { + "$ref": "#/components/schemas/DependencyList" + }, + "parameter_style": { + "description": "Function parameter style. **S** is the value for SQL.", + "type": "string", + "enum": [ + "S" + ] + }, + "is_deterministic": { + "description": "Whether the function is deterministic.", + "type": "boolean" + }, + "sql_data_access": { + "description": "Function SQL data access.", + "type": "string", + "enum": [ + "CONTAINS_SQL", + "READS_SQL_DATA", + "NO_SQL" + ] + }, + "is_null_call": { + "description": "Function null call.", + "type": "boolean" + }, + "security_type": { + "description": "Function security type.", + "type": "string", + "enum": [ + "DEFINER" + ] + }, + "specific_name": { + "description": "Specific name of the function; Reserved for future use.", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "description": "JSON-serialized key-value pair map, encoded (escaped) as a string.", + "type": "string" + }, + "external_language": { + "description": "External language of the function.", + "type": "string" + } + } + }, + "FunctionInfo": { + "type": "object", + "properties": { + "name": { + "description": "Name of function, relative to parent schema.", + "type": "string" + }, + "catalog_name": { + "description": "Name of parent catalog.", + "type": "string" + }, + "schema_name": { + "description": "Name of parent schema relative to its parent catalog.", + "type": "string" + }, + "input_params": { + "$ref": "#/components/schemas/FunctionParameterInfos" + }, + "data_type": { + "$ref": "#/components/schemas/ColumnTypeName" + }, + "full_data_type": { + "description": "Pretty printed function data type.", + "type": "string" + }, + "return_params": { + "$ref": "#/components/schemas/FunctionParameterInfos" + }, + "routine_body": { + "description": "Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the __external_language__ field, \nand the __return_params__ of the function cannot be used (as **TABLE** return type is not supported),\nand the __sql_data_access__ field must be **NO_SQL**.\n", + "type": "string", + "enum": [ + "SQL", + "EXTERNAL" + ] + }, + "routine_definition": { + "description": "Function body.", + "type": "string" + }, + "routine_dependencies": { + "$ref": "#/components/schemas/DependencyList" + }, + "parameter_style": { + "description": "Function parameter style. **S** is the value for SQL.", + "type": "string", + "enum": [ + "S" + ] + }, + "is_deterministic": { + "description": "Whether the function is deterministic.", + "type": "boolean" + }, + "sql_data_access": { + "description": "Function SQL data access.", + "type": "string", + "enum": [ + "CONTAINS_SQL", + "READS_SQL_DATA", + "NO_SQL" + ] + }, + "is_null_call": { + "description": "Function null call.", + "type": "boolean" + }, + "security_type": { + "description": "Function security type.", + "type": "string", + "enum": [ + "DEFINER" + ] + }, + "specific_name": { + "description": "Specific name of the function; Reserved for future use.", + "type": "string" + }, + "comment": { + "description": "User-provided free-form text description.", + "type": "string" + }, + "properties": { + "description": "JSON-serialized key-value pair map, encoded (escaped) as a string.", + "type": "string" + }, + "full_name": { + "description": "Full name of function, in form of __catalog_name__.__schema_name__.__function__name__", + "type": "string" + }, + "created_at": { + "description": "Time at which this function was created, in epoch milliseconds.", + "type": "integer", + "format": "int64" + }, + "updated_at": { + "description": "Time at which this function was last updated, in epoch milliseconds.", + "type": "integer", + "format": "int64" + }, + "function_id": { + "description": "Id of Function, relative to parent schema.", + "type": "string" + }, + "external_language": { + "description": "External language of the function.", + "type": "string" + } + } + }, + "ListFunctionsResponse": { + "type": "object", + "properties": { + "functions": { + "description": "An array of function information objects.", + "type": "array", + "items": { + "$ref": "#/components/schemas/FunctionInfo" + } + }, + "next_page_token": { + "type": "string", + "description": "Opaque token to retrieve the next page of results. Absent if there are no more pages.\n__page_token__ should be set to this value for the next request (for the next page of results).\n" + } + } + }, + "GenerateTemporaryTableCredential": { + "example": { + "table_id": "table_id", + "operation": null + }, + "properties": { + "table_id": { + "description": "Table id for which temporary credentials are generated. \nCan be obtained from tables/{full_name} (get table info) API.\n", + "type": "string" + }, + "operation": { + "$ref": "#/components/schemas/TableOperation" + } + }, + "type": "object", + "required": [ + "table_id", + "operation" + ] + }, + "GenerateTemporaryTableCredentialResponse": { + "properties": { + "aws_temp_credentials": { + "$ref": "#/components/schemas/AwsCredentials" + }, + "expiration_time": { + "description": "Server time when the credential will expire, in epoch milliseconds.\nThe API client is advised to cache the credential given this expiration time.\n", + "type": "integer", + "format": "int64" + } + }, + "type": "object" + }, + "TableOperation": { + "enum": [ + "UNKNOWN_TABLE_OPERATION", + "READ", + "READ_WRITE" + ], + "type": "string" + }, + "AwsCredentials": { + "properties": { + "access_key_id": { + "description": "The access key ID that identifies the temporary credentials.", + "type": "string" + }, + "secret_access_key": { + "description": "The secret access key that can be used to sign AWS API requests.", + "type": "string" + }, + "session_token": { + "description": "The token that users must pass to AWS API to use the temporary credentials.", + "type": "string" + } + }, + "type": "object" + }, + "GenerateTemporaryVolumeCredential": { + "properties": { + "volume_id": { + "description": "Volume id for which temporary credentials are generated. \nCan be obtained from volumes/{full_name} (get volume info) API.\n", + "type": "string" + }, + "operation": { + "$ref": "#/components/schemas/VolumeOperation" + } + }, + "type": "object", + "required": [ + "volume_id", + "operation" + ] + }, + "GenerateTemporaryVolumeCredentialResponse": { + "properties": { + "aws_temp_credentials": { + "$ref": "#/components/schemas/AwsCredentials" + }, + "expiration_time": { + "description": "Server time when the credential will expire, in epoch milliseconds.\nThe API client is advised to cache the credential given this expiration time.\n", + "type": "integer", + "format": "int64" + } + }, + "type": "object" + }, + "VolumeOperation": { + "enum": [ + "UNKNOWN_VOLUME_OPERATION", + "READ_VOLUME", + "WRITE_VOLUME" + ], + "type": "string" + } + } + }, + "info": { + "title": "Unity Catalog API", + "version": "0.1" + } +} \ No newline at end of file diff --git a/models/src/lib.rs b/models/src/lib.rs new file mode 100644 index 0000000..2312d5e --- /dev/null +++ b/models/src/lib.rs @@ -0,0 +1,7 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde; +extern crate serde_json; + +pub mod models; diff --git a/models/src/models/aws_credentials.rs b/models/src/models/aws_credentials.rs new file mode 100644 index 0000000..71746bd --- /dev/null +++ b/models/src/models/aws_credentials.rs @@ -0,0 +1,12 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AwsCredentials { + /// The access key ID that identifies the temporary credentials. + pub access_key_id: String, + /// The secret access key that can be used to sign AWS API requests. + pub secret_access_key: String, + /// The token that users must pass to AWS API to use the temporary credentials. + pub session_token: String, +} diff --git a/models/src/models/catalog_info.rs b/models/src/models/catalog_info.rs new file mode 100644 index 0000000..7ed6a17 --- /dev/null +++ b/models/src/models/catalog_info.rs @@ -0,0 +1,25 @@ +use crate::models; +use chrono::{serde::ts_milliseconds, DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; +use std::collections::HashMap; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CatalogInfo { + /// Name of catalog. + pub name: String, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// A map of key-value properties attached to the securable. + #[serde(skip_serializing_if = "HashMap::is_empty")] + pub properties: HashMap, + /// Time at which this catalog was created, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub created_at: DateTime, + /// Time at which this catalog was last modified, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub updated_at: DateTime, + /// Unique identifier for the catalog. + pub id: Uuid, +} diff --git a/models/src/models/column_info.rs b/models/src/models/column_info.rs new file mode 100644 index 0000000..af851be --- /dev/null +++ b/models/src/models/column_info.rs @@ -0,0 +1,35 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ColumnInfo { + /// Name of Column. + pub name: String, + /// Full data type specification as SQL/catalogString text. + #[serde(skip_serializing_if = "Option::is_none")] + pub type_text: Option, + /// Full data type specification, JSON-serialized. + #[serde(skip_serializing_if = "Option::is_none")] + pub type_json: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub type_name: Option, + /// Digits of precision; required for DecimalTypes. + #[serde(skip_serializing_if = "Option::is_none")] + pub type_precision: Option, + /// Digits to right of decimal; Required for DecimalTypes. + #[serde(skip_serializing_if = "Option::is_none")] + pub type_scale: Option, + /// Format of IntervalType. + #[serde(skip_serializing_if = "Option::is_none")] + pub type_interval_type: Option, + /// Ordinal position of column (starting at position 0). + pub position: u32, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// Whether field may be Null. + pub nullable: bool, + /// Partition index for column. + #[serde(rename = "partition_index", skip_serializing_if = "Option::is_none")] + pub partition_index: Option, +} diff --git a/models/src/models/column_type_name.rs b/models/src/models/column_type_name.rs new file mode 100644 index 0000000..2a60bd2 --- /dev/null +++ b/models/src/models/column_type_name.rs @@ -0,0 +1,32 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use strum::{Display, IntoStaticStr}; + +/// ColumnTypeName : Name of type (INT, STRUCT, MAP, etc.). +/// Name of type (INT, STRUCT, MAP, etc.). +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Display, IntoStaticStr)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +#[strum(serialize_all = "SCREAMING_SNAKE_CASE")] +pub enum ColumnTypeName { + Boolean, + Byte, + Short, + Int, + Long, + Float, + Double, + Date, + Timestamp, + TimestampNtz, + String, + Binary, + Decimal, + Interval, + Array, + Struct, + Map, + Char, + Null, + UserDefinedType, + TableType, +} diff --git a/models/src/models/create_catalog.rs b/models/src/models/create_catalog.rs new file mode 100644 index 0000000..bb0cc2c --- /dev/null +++ b/models/src/models/create_catalog.rs @@ -0,0 +1,35 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateCatalog { + /// Name of catalog. + pub name: String, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// A map of key-value properties attached to the securable. + #[serde(skip_serializing_if = "HashMap::is_empty")] + pub properties: HashMap, +} + +impl CreateCatalog { + pub fn build(self) -> models::CatalogInfo { + let current_time = chrono::Utc::now(); + models::CatalogInfo { + name: self.name, + comment: self.comment, + created_at: current_time, + updated_at: current_time, + id: uuid::Uuid::new_v4(), + properties: self.properties, + } + } +} + +impl From for models::CatalogInfo { + fn from(catalog: models::CreateCatalog) -> Self { + catalog.build() + } +} \ No newline at end of file diff --git a/models/src/models/create_function.rs b/models/src/models/create_function.rs new file mode 100644 index 0000000..9aab462 --- /dev/null +++ b/models/src/models/create_function.rs @@ -0,0 +1,86 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use strum::{Display, IntoStaticStr}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateFunction { + /// Name of function, relative to parent schema. + pub name: String, + /// Name of parent catalog. + pub catalog_name: String, + /// Name of parent schema relative to its parent catalog. + pub schema_name: String, + pub input_params: models::FunctionParameterInfos, + pub data_type: models::ColumnTypeName, + /// Pretty printed function data type. + pub full_data_type: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub return_params: Option, + /// Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the __external_language__ field, and the __return_params__ of the function cannot be used (as **TABLE** return type is not supported), and the __sql_data_access__ field must be **NO_SQL**. + pub routine_body: RoutineBody, + /// Function body. + pub routine_definition: String, + #[serde( + skip_serializing_if = "Option::is_none" + )] + pub routine_dependencies: Option, + /// Function parameter style. **S** is the value for SQL. + pub parameter_style: ParameterStyle, + /// Whether the function is deterministic. + pub is_deterministic: bool, + /// Function SQL data access. + pub sql_data_access: SqlDataAccess, + /// Function null call. + pub is_null_call: bool, + /// Function security type. + pub security_type: SecurityType, + /// Specific name of the function; Reserved for future use. + pub specific_name: String, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// JSON-serialized key-value pair map, encoded (escaped) as a string. + #[serde(skip_serializing_if = "Option::is_none")] + pub properties: Option, + /// External language of the function. + #[serde(skip_serializing_if = "Option::is_none")] + pub external_language: Option, +} + +/// Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the __external_language__ field, and the __return_params__ of the function cannot be used (as **TABLE** return type is not supported), and the __sql_data_access__ field must be **NO_SQL**. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Display, IntoStaticStr)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +#[strum(serialize_all = "SCREAMING_SNAKE_CASE")] +pub enum RoutineBody { + Sql, + External, +} + +/// Function parameter style. **S** is the value for SQL. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Display, IntoStaticStr)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +#[strum(serialize_all = "SCREAMING_SNAKE_CASE")] +pub enum ParameterStyle { + S, +} + +impl Default for ParameterStyle { + fn default() -> ParameterStyle { + Self::S + } +} +/// Function SQL data access. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Display, IntoStaticStr)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum SqlDataAccess { + ContainsSql, + ReadsSqlData, + NoSql, +} + +/// Function security type. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Display, IntoStaticStr)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum SecurityType { + Definer, +} diff --git a/models/src/models/create_function_request.rs b/models/src/models/create_function_request.rs new file mode 100644 index 0000000..5c18548 --- /dev/null +++ b/models/src/models/create_function_request.rs @@ -0,0 +1,7 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateFunctionRequest { + pub function_info: models::CreateFunction, +} diff --git a/models/src/models/create_schema.rs b/models/src/models/create_schema.rs new file mode 100644 index 0000000..499ee1c --- /dev/null +++ b/models/src/models/create_schema.rs @@ -0,0 +1,17 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateSchema { + /// Name of schema, relative to parent catalog. + pub name: String, + /// Name of parent catalog. + pub catalog_name: String, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// A map of key-value properties attached to the securable. + #[serde(skip_serializing_if = "HashMap::is_empty")] + pub properties: HashMap, +} \ No newline at end of file diff --git a/models/src/models/create_table.rs b/models/src/models/create_table.rs new file mode 100644 index 0000000..eddedc4 --- /dev/null +++ b/models/src/models/create_table.rs @@ -0,0 +1,26 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateTable { + /// Name of table, relative to parent schema. + pub name: String, + /// Name of parent catalog. + pub catalog_name: String, + /// Name of parent schema relative to its parent catalog. + pub schema_name: String, + pub table_type: models::TableType, + pub data_source_format: models::DataSourceFormat, + /// The array of __ColumnInfo__ definitions of the table's columns. + pub columns: Vec, + /// Storage root URL for table (for **MANAGED**, **EXTERNAL** tables) + #[serde(skip_serializing_if = "Option::is_none")] + pub storage_location: Option, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// A map of key-value properties attached to the securable. + #[serde(skip_serializing_if = "HashMap::is_empty")] + pub properties: HashMap, +} diff --git a/models/src/models/create_volume_request_content.rs b/models/src/models/create_volume_request_content.rs new file mode 100644 index 0000000..50ea082 --- /dev/null +++ b/models/src/models/create_volume_request_content.rs @@ -0,0 +1,18 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateVolumeRequestContent { + /// The name of the catalog where the schema and the volume are + pub catalog_name: String, + /// The name of the schema where the volume is + pub schema_name: String, + /// The name of the volume + pub name: String, + pub volume_type: models::VolumeType, + /// The comment attached to the volume + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// The storage location of the volume + pub storage_location: String, +} diff --git a/models/src/models/data_source_format.rs b/models/src/models/data_source_format.rs new file mode 100644 index 0000000..ca74fba --- /dev/null +++ b/models/src/models/data_source_format.rs @@ -0,0 +1,18 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use strum::{Display, IntoStaticStr}; + +/// DataSourceFormat : Data source format +/// Data source format +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Display, IntoStaticStr)] +#[strum(serialize_all = "SCREAMING_SNAKE_CASE")] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum DataSourceFormat { + Delta, + Csv, + Json, + Avro, + Parquet, + Orc, + Text, +} diff --git a/models/src/models/dependency.rs b/models/src/models/dependency.rs new file mode 100644 index 0000000..072108a --- /dev/null +++ b/models/src/models/dependency.rs @@ -0,0 +1,10 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Dependency : A dependency of a SQL object. Either the __table__ field or the __function__ field must be defined. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum Dependency { + Table(models::TableDependency), + Function(models::FunctionDependency), +} diff --git a/models/src/models/dependency_list.rs b/models/src/models/dependency_list.rs new file mode 100644 index 0000000..099f84f --- /dev/null +++ b/models/src/models/dependency_list.rs @@ -0,0 +1,9 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// DependencyList : A list of dependencies. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DependencyList { + /// Array of dependencies. + pub dependencies: Vec, +} diff --git a/models/src/models/function_dependency.rs b/models/src/models/function_dependency.rs new file mode 100644 index 0000000..049b0c4 --- /dev/null +++ b/models/src/models/function_dependency.rs @@ -0,0 +1,9 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// FunctionDependency : A function that is dependent on a SQL object. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FunctionDependency { + /// Full name of the dependent function, in the form of __catalog_name__.__schema_name__.__function_name__. + pub function_full_name: String, +} \ No newline at end of file diff --git a/models/src/models/function_info.rs b/models/src/models/function_info.rs new file mode 100644 index 0000000..7dbccce --- /dev/null +++ b/models/src/models/function_info.rs @@ -0,0 +1,124 @@ +use crate::models; +use chrono::{serde::ts_milliseconds, DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FunctionInfo { + /// Name of function, relative to parent schema. + pub name: String, + /// Name of parent catalog. + pub catalog_name: String, + /// Name of parent schema relative to its parent catalog. + pub schema_name: String, + #[serde(rename = "input_params", skip_serializing_if = "Option::is_none")] + pub input_params: Option>, + #[serde(rename = "data_type", skip_serializing_if = "Option::is_none")] + pub data_type: Option, + /// Pretty printed function data type. + #[serde(rename = "full_data_type", skip_serializing_if = "Option::is_none")] + pub full_data_type: Option, + #[serde(rename = "return_params", skip_serializing_if = "Option::is_none")] + pub return_params: Option>, + /// Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the __external_language__ field, and the __return_params__ of the function cannot be used (as **TABLE** return type is not supported), and the __sql_data_access__ field must be **NO_SQL**. + #[serde(rename = "routine_body", skip_serializing_if = "Option::is_none")] + pub routine_body: Option, + /// Function body. + #[serde(rename = "routine_definition", skip_serializing_if = "Option::is_none")] + pub routine_definition: Option, + #[serde( + rename = "routine_dependencies", + skip_serializing_if = "Option::is_none" + )] + pub routine_dependencies: Option>, + /// Function parameter style. **S** is the value for SQL. + #[serde(rename = "parameter_style", skip_serializing_if = "Option::is_none")] + pub parameter_style: Option, + /// Whether the function is deterministic. + pub is_deterministic: bool, + /// Function SQL data access. + #[serde(skip_serializing_if = "Option::is_none")] + pub sql_data_access: Option, + /// Function null call. + #[serde(skip_serializing_if = "Option::is_none")] + pub is_null_call: Option, + /// Function security type. + #[serde(skip_serializing_if = "Option::is_none")] + pub security_type: Option, + /// Specific name of the function; Reserved for future use. + #[serde(skip_serializing_if = "Option::is_none")] + pub specific_name: Option, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// JSON-serialized key-value pair map, encoded (escaped) as a string. + #[serde(skip_serializing_if = "Option::is_none")] + pub properties: Option, + /// Full name of function, in form of __catalog_name__.__schema_name__.__function__name__ + pub full_name: String, + /// Time at which this function was created, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub created_at: DateTime, + /// Time at which this function was last updated, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub updated_at: DateTime, + /// Id of Function, relative to parent schema. + pub function_id: String, + /// External language of the function. + #[serde(skip_serializing_if = "Option::is_none")] + pub external_language: Option, +} + +/// Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the __external_language__ field, and the __return_params__ of the function cannot be used (as **TABLE** return type is not supported), and the __sql_data_access__ field must be **NO_SQL**. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum RoutineBody { + #[serde(rename = "SQL")] + Sql, + #[serde(rename = "EXTERNAL")] + External, +} + +impl Default for RoutineBody { + fn default() -> RoutineBody { + Self::Sql + } +} +/// Function parameter style. **S** is the value for SQL. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum ParameterStyle { + #[serde(rename = "S")] + S, +} + +impl Default for ParameterStyle { + fn default() -> ParameterStyle { + Self::S + } +} +/// Function SQL data access. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum SqlDataAccess { + #[serde(rename = "CONTAINS_SQL")] + ContainsSql, + #[serde(rename = "READS_SQL_DATA")] + ReadsSqlData, + #[serde(rename = "NO_SQL")] + NoSql, +} + +impl Default for SqlDataAccess { + fn default() -> SqlDataAccess { + Self::ContainsSql + } +} +/// Function security type. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum SecurityType { + #[serde(rename = "DEFINER")] + Definer, +} + +impl Default for SecurityType { + fn default() -> SecurityType { + Self::Definer + } +} diff --git a/models/src/models/function_parameter_info.rs b/models/src/models/function_parameter_info.rs new file mode 100644 index 0000000..5d7fdc2 --- /dev/null +++ b/models/src/models/function_parameter_info.rs @@ -0,0 +1,34 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct FunctionParameterInfo { + /// Name of parameter. + pub name: String, + /// Full data type spec, SQL/catalogString text. + pub type_text: String, + /// Full data type spec, JSON-serialized. + pub type_json: String, + pub type_name: models::ColumnTypeName, + /// Digits of precision; required on Create for DecimalTypes. + #[serde(skip_serializing_if = "Option::is_none")] + pub type_precision: Option, + /// Digits to right of decimal; Required on Create for DecimalTypes. + #[serde(skip_serializing_if = "Option::is_none")] + pub type_scale: Option, + /// Format of IntervalType. + #[serde(skip_serializing_if = "Option::is_none")] + pub type_interval_type: Option, + /// Ordinal position of column (starting at position 0). + pub position: i32, + #[serde(skip_serializing_if = "Option::is_none")] + pub parameter_mode: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub parameter_type: Option, + /// Default value of the parameter. + #[serde(skip_serializing_if = "Option::is_none")] + pub parameter_default: Option, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, +} diff --git a/models/src/models/function_parameter_infos.rs b/models/src/models/function_parameter_infos.rs new file mode 100644 index 0000000..55ff59a --- /dev/null +++ b/models/src/models/function_parameter_infos.rs @@ -0,0 +1,8 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FunctionParameterInfos { + /// The array of __FunctionParameterInfo__ definitions of the function's parameters. + pub parameters: Vec, +} diff --git a/models/src/models/function_parameter_mode.rs b/models/src/models/function_parameter_mode.rs new file mode 100644 index 0000000..4d625cd --- /dev/null +++ b/models/src/models/function_parameter_mode.rs @@ -0,0 +1,24 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// FunctionParameterMode : The mode of the function parameter. +/// The mode of the function parameter. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum FunctionParameterMode { + #[serde(rename = "IN")] + In, +} + +impl std::fmt::Display for FunctionParameterMode { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::In => write!(f, "IN"), + } + } +} + +impl Default for FunctionParameterMode { + fn default() -> FunctionParameterMode { + Self::In + } +} diff --git a/models/src/models/function_parameter_type.rs b/models/src/models/function_parameter_type.rs new file mode 100644 index 0000000..e844a1c --- /dev/null +++ b/models/src/models/function_parameter_type.rs @@ -0,0 +1,27 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// FunctionParameterType : The type of function parameter. +/// The type of function parameter. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum FunctionParameterType { + #[serde(rename = "PARAM")] + Param, + #[serde(rename = "COLUMN")] + Column, +} + +impl std::fmt::Display for FunctionParameterType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::Param => write!(f, "PARAM"), + Self::Column => write!(f, "COLUMN"), + } + } +} + +impl Default for FunctionParameterType { + fn default() -> FunctionParameterType { + Self::Param + } +} diff --git a/models/src/models/generate_temporary_table_credential.rs b/models/src/models/generate_temporary_table_credential.rs new file mode 100644 index 0000000..00dd4c0 --- /dev/null +++ b/models/src/models/generate_temporary_table_credential.rs @@ -0,0 +1,10 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GenerateTemporaryTableCredential { + /// Table id for which temporary credentials are generated. Can be obtained from tables/{full_name} (get table info) API. + pub table_id: Uuid, + pub operation: models::TableOperation, +} diff --git a/models/src/models/generate_temporary_table_credential_response.rs b/models/src/models/generate_temporary_table_credential_response.rs new file mode 100644 index 0000000..f343123 --- /dev/null +++ b/models/src/models/generate_temporary_table_credential_response.rs @@ -0,0 +1,11 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use chrono::{DateTime, Utc, serde::ts_milliseconds}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GenerateTemporaryTableCredentialResponse { + pub aws_temp_credentials: models::AwsCredentials, + /// Server time when the credential will expire, in epoch milliseconds. The API client is advised to cache the credential given this expiration time. + #[serde(with = "ts_milliseconds")] + pub expiration_time: DateTime, +} diff --git a/models/src/models/generate_temporary_volume_credential.rs b/models/src/models/generate_temporary_volume_credential.rs new file mode 100644 index 0000000..bdc7faf --- /dev/null +++ b/models/src/models/generate_temporary_volume_credential.rs @@ -0,0 +1,10 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GenerateTemporaryVolumeCredential { + /// Volume id for which temporary credentials are generated. Can be obtained from volumes/{full_name} (get volume info) API. + pub volume_id: Uuid, + pub operation: models::VolumeOperation, +} diff --git a/models/src/models/generate_temporary_volume_credential_response.rs b/models/src/models/generate_temporary_volume_credential_response.rs new file mode 100644 index 0000000..0bcfb06 --- /dev/null +++ b/models/src/models/generate_temporary_volume_credential_response.rs @@ -0,0 +1,11 @@ +use crate::models; +use chrono::{DateTime, Utc, serde::ts_milliseconds}; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GenerateTemporaryVolumeCredentialResponse { + pub aws_temp_credentials: models::AwsCredentials, + /// Server time when the credential will expire, in epoch milliseconds. The API client is advised to cache the credential given this expiration time. + #[serde(with = "ts_milliseconds")] + pub expiration_time: DateTime, +} diff --git a/models/src/models/list_catalogs_response.rs b/models/src/models/list_catalogs_response.rs new file mode 100644 index 0000000..27f1e19 --- /dev/null +++ b/models/src/models/list_catalogs_response.rs @@ -0,0 +1,11 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ListCatalogsResponse { + /// An array of catalog information objects. + pub catalogs: Vec, + /// Opaque token to retrieve the next page of results. Absent if there are no more pages. __page_token__ should be set to this value for the next request (for the next page of results). + #[serde(skip_serializing_if = "Option::is_none")] + pub next_page_token: Option, +} diff --git a/models/src/models/list_functions_response.rs b/models/src/models/list_functions_response.rs new file mode 100644 index 0000000..a811278 --- /dev/null +++ b/models/src/models/list_functions_response.rs @@ -0,0 +1,11 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ListFunctionsResponse { + /// An array of function information objects. + pub functions: Vec, + /// Opaque token to retrieve the next page of results. Absent if there are no more pages. __page_token__ should be set to this value for the next request (for the next page of results). + #[serde(skip_serializing_if = "Option::is_none")] + pub next_page_token: Option, +} diff --git a/models/src/models/list_schemas_response.rs b/models/src/models/list_schemas_response.rs new file mode 100644 index 0000000..5963659 --- /dev/null +++ b/models/src/models/list_schemas_response.rs @@ -0,0 +1,11 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ListSchemasResponse { + /// An array of schema information objects. + pub schemas: Vec, + /// Opaque token to retrieve the next page of results. Absent if there are no more pages. __page_token__ should be set to this value for the next request (for the next page of results). + #[serde(skip_serializing_if = "Option::is_none")] + pub next_page_token: Option, +} diff --git a/models/src/models/list_tables_response.rs b/models/src/models/list_tables_response.rs new file mode 100644 index 0000000..4c22074 --- /dev/null +++ b/models/src/models/list_tables_response.rs @@ -0,0 +1,11 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ListTablesResponse { + /// An array of table information objects. + pub tables: Vec, + /// Opaque token to retrieve the next page of results. Absent if there are no more pages. __page_token__ should be set to this value for the next request (for the next page of results). + #[serde(skip_serializing_if = "Option::is_none")] + pub next_page_token: Option, +} diff --git a/models/src/models/list_volumes_response_content.rs b/models/src/models/list_volumes_response_content.rs new file mode 100644 index 0000000..f10befe --- /dev/null +++ b/models/src/models/list_volumes_response_content.rs @@ -0,0 +1,10 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ListVolumesResponseContent { + pub volumes: Vec, + /// Opaque token to retrieve the next page of results. Absent if there are no more pages. __page_token__ should be set to this value for the next request to retrieve the next page of results. + #[serde(skip_serializing_if = "Option::is_none")] + pub next_page_token: Option, +} diff --git a/models/src/models/mod.rs b/models/src/models/mod.rs new file mode 100644 index 0000000..b8aa727 --- /dev/null +++ b/models/src/models/mod.rs @@ -0,0 +1,78 @@ +pub mod aws_credentials; +pub use self::aws_credentials::AwsCredentials; +pub mod catalog_info; +pub use self::catalog_info::CatalogInfo; +pub mod column_info; +pub use self::column_info::ColumnInfo; +pub mod column_type_name; +pub use self::column_type_name::ColumnTypeName; +pub mod create_catalog; +pub use self::create_catalog::CreateCatalog; +pub mod create_function; +pub use self::create_function::CreateFunction; +pub mod create_function_request; +pub use self::create_function_request::CreateFunctionRequest; +pub mod create_schema; +pub use self::create_schema::CreateSchema; +pub mod create_table; +pub use self::create_table::CreateTable; +pub mod create_volume_request_content; +pub use self::create_volume_request_content::CreateVolumeRequestContent; +pub mod data_source_format; +pub use self::data_source_format::DataSourceFormat; +pub mod dependency; +pub use self::dependency::Dependency; +pub mod dependency_list; +pub use self::dependency_list::DependencyList; +pub mod function_dependency; +pub use self::function_dependency::FunctionDependency; +pub mod function_info; +pub use self::function_info::FunctionInfo; +pub mod function_parameter_info; +pub use self::function_parameter_info::FunctionParameterInfo; +pub mod function_parameter_infos; +pub use self::function_parameter_infos::FunctionParameterInfos; +pub mod function_parameter_mode; +pub use self::function_parameter_mode::FunctionParameterMode; +pub mod function_parameter_type; +pub use self::function_parameter_type::FunctionParameterType; +pub mod generate_temporary_table_credential; +pub use self::generate_temporary_table_credential::GenerateTemporaryTableCredential; +pub mod generate_temporary_table_credential_response; +pub use self::generate_temporary_table_credential_response::GenerateTemporaryTableCredentialResponse; +pub mod generate_temporary_volume_credential; +pub use self::generate_temporary_volume_credential::GenerateTemporaryVolumeCredential; +pub mod generate_temporary_volume_credential_response; +pub use self::generate_temporary_volume_credential_response::GenerateTemporaryVolumeCredentialResponse; +pub mod list_catalogs_response; +pub use self::list_catalogs_response::ListCatalogsResponse; +pub mod list_functions_response; +pub use self::list_functions_response::ListFunctionsResponse; +pub mod list_schemas_response; +pub use self::list_schemas_response::ListSchemasResponse; +pub mod list_tables_response; +pub use self::list_tables_response::ListTablesResponse; +pub mod list_volumes_response_content; +pub use self::list_volumes_response_content::ListVolumesResponseContent; +pub mod schema_info; +pub use self::schema_info::SchemaInfo; +pub mod table_dependency; +pub use self::table_dependency::TableDependency; +pub mod table_info; +pub use self::table_info::TableInfo; +pub mod table_operation; +pub use self::table_operation::TableOperation; +pub mod table_type; +pub use self::table_type::TableType; +pub mod update_catalog; +pub use self::update_catalog::UpdateCatalog; +pub mod update_schema; +pub use self::update_schema::UpdateSchema; +pub mod update_volume_request_content; +pub use self::update_volume_request_content::UpdateVolumeRequestContent; +pub mod volume_info; +pub use self::volume_info::VolumeInfo; +pub mod volume_operation; +pub use self::volume_operation::VolumeOperation; +pub mod volume_type; +pub use self::volume_type::VolumeType; diff --git a/models/src/models/schema_info.rs b/models/src/models/schema_info.rs new file mode 100644 index 0000000..a8a2bec --- /dev/null +++ b/models/src/models/schema_info.rs @@ -0,0 +1,29 @@ +use crate::models; +use chrono::{serde::ts_milliseconds, DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; +use std::collections::HashMap; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SchemaInfo { + /// Name of schema, relative to parent catalog. + pub name: String, + /// Name of parent catalog. + pub catalog_name: String, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// A map of key-value properties attached to the securable. + #[serde(skip_serializing_if = "HashMap::is_empty")] + pub properties: HashMap, + /// Full name of schema, in form of __catalog_name__.__schema_name__. + pub full_name: String, + /// Time at which this schema was created, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub created_at: DateTime, + /// Time at which this schema was last modified, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub updated_at: DateTime, + /// Unique identifier for the schema. + pub schema_id: Uuid, +} diff --git a/models/src/models/table_dependency.rs b/models/src/models/table_dependency.rs new file mode 100644 index 0000000..4135171 --- /dev/null +++ b/models/src/models/table_dependency.rs @@ -0,0 +1,9 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// TableDependency : A table that is dependent on a SQL object. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TableDependency { + /// Full name of the dependent table, in the form of __catalog_name__.__schema_name__.__table_name__. + pub table_full_name: String, +} diff --git a/models/src/models/table_info.rs b/models/src/models/table_info.rs new file mode 100644 index 0000000..e0b032a --- /dev/null +++ b/models/src/models/table_info.rs @@ -0,0 +1,36 @@ +use std::collections::HashMap; + +use crate::models; +use chrono::{serde::ts_milliseconds, DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct TableInfo { + /// Name of table, relative to parent schema. + pub name: String, + /// Name of parent catalog. + pub catalog_name: String, + /// Name of parent schema relative to its parent catalog. + pub schema_name: String, + pub table_type: models::TableType, + pub data_source_format: models::DataSourceFormat, + /// The array of __ColumnInfo__ definitions of the table's columns. + pub columns: Vec, + /// Storage root URL for table (for **MANAGED**, **EXTERNAL** tables) + pub storage_location: String, + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// A map of key-value properties attached to the securable. + #[serde(skip_serializing_if = "HashMap::is_empty")] + pub properties: HashMap, + /// Time at which this table was created, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub created_at: DateTime, + /// Time at which this table was last modified, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub updated_at: DateTime, + /// Unique identifier for the table. + pub table_id: Uuid, +} diff --git a/models/src/models/table_operation.rs b/models/src/models/table_operation.rs new file mode 100644 index 0000000..b1a1e70 --- /dev/null +++ b/models/src/models/table_operation.rs @@ -0,0 +1,29 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TableOperation { + #[serde(rename = "UNKNOWN_TABLE_OPERATION")] + UnknownTableOperation, + #[serde(rename = "READ")] + Read, + #[serde(rename = "READ_WRITE")] + ReadWrite, +} + +impl std::fmt::Display for TableOperation { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UnknownTableOperation => write!(f, "UNKNOWN_TABLE_OPERATION"), + Self::Read => write!(f, "READ"), + Self::ReadWrite => write!(f, "READ_WRITE"), + } + } +} + +impl Default for TableOperation { + fn default() -> TableOperation { + Self::UnknownTableOperation + } +} diff --git a/models/src/models/table_type.rs b/models/src/models/table_type.rs new file mode 100644 index 0000000..21cef8b --- /dev/null +++ b/models/src/models/table_type.rs @@ -0,0 +1,26 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TableType { + #[serde(rename = "MANAGED")] + Managed, + #[serde(rename = "EXTERNAL")] + External, +} + +impl std::fmt::Display for TableType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::Managed => write!(f, "MANAGED"), + Self::External => write!(f, "EXTERNAL"), + } + } +} + +impl Default for TableType { + fn default() -> TableType { + Self::Managed + } +} diff --git a/models/src/models/update_catalog.rs b/models/src/models/update_catalog.rs new file mode 100644 index 0000000..8b10209 --- /dev/null +++ b/models/src/models/update_catalog.rs @@ -0,0 +1,16 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateCatalog { + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// A map of key-value properties attached to the securable. + #[serde(skip_serializing_if = "HashMap::is_empty")] + pub properties: HashMap, + /// New name for the catalog. + #[serde(skip_serializing_if = "Option::is_none")] + pub new_name: Option, +} diff --git a/models/src/models/update_schema.rs b/models/src/models/update_schema.rs new file mode 100644 index 0000000..c861623 --- /dev/null +++ b/models/src/models/update_schema.rs @@ -0,0 +1,16 @@ +use crate::models; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateSchema { + /// User-provided free-form text description. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// A map of key-value properties attached to the securable. + #[serde(skip_serializing_if = "HashMap::is_empty")] + pub properties: HashMap, + /// New name for the schema. + #[serde(skip_serializing_if = "Option::is_none")] + pub new_name: Option, +} diff --git a/models/src/models/update_volume_request_content.rs b/models/src/models/update_volume_request_content.rs new file mode 100644 index 0000000..0ebf915 --- /dev/null +++ b/models/src/models/update_volume_request_content.rs @@ -0,0 +1,21 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateVolumeRequestContent { + /// The comment attached to the volume + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// New name for the volume. + #[serde(skip_serializing_if = "Option::is_none")] + pub new_name: Option, +} + +impl UpdateVolumeRequestContent { + pub fn new() -> UpdateVolumeRequestContent { + UpdateVolumeRequestContent { + comment: None, + new_name: None, + } + } +} diff --git a/models/src/models/volume_info.rs b/models/src/models/volume_info.rs new file mode 100644 index 0000000..7602275 --- /dev/null +++ b/models/src/models/volume_info.rs @@ -0,0 +1,30 @@ +use crate::models; +use chrono::{serde::ts_milliseconds, DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct VolumeInfo { + /// The name of the catalog where the schema and the volume are + pub catalog_name: String, + /// The name of the schema where the volume is + pub schema_name: String, + /// The name of the volume + pub name: String, + /// The comment attached to the volume + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + /// Time at which this volume was created, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub created_at: DateTime, + /// Time at which this volume was last modified, in epoch milliseconds. + #[serde(with = "ts_milliseconds")] + pub updated_at: DateTime, + /// Unique identifier for the volume + pub volume_id: Uuid, + pub volume_type: models::VolumeType, + /// The storage location of the volume + pub storage_location: String, + /// Full name of volume, in form of __catalog_name__.__schema_name__.__volume_name__. + pub full_name: String, +} diff --git a/models/src/models/volume_operation.rs b/models/src/models/volume_operation.rs new file mode 100644 index 0000000..cb15f7a --- /dev/null +++ b/models/src/models/volume_operation.rs @@ -0,0 +1,29 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum VolumeOperation { + #[serde(rename = "UNKNOWN_VOLUME_OPERATION")] + UnknownVolumeOperation, + #[serde(rename = "READ_VOLUME")] + ReadVolume, + #[serde(rename = "WRITE_VOLUME")] + WriteVolume, +} + +impl std::fmt::Display for VolumeOperation { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UnknownVolumeOperation => write!(f, "UNKNOWN_VOLUME_OPERATION"), + Self::ReadVolume => write!(f, "READ_VOLUME"), + Self::WriteVolume => write!(f, "WRITE_VOLUME"), + } + } +} + +impl Default for VolumeOperation { + fn default() -> VolumeOperation { + Self::UnknownVolumeOperation + } +} diff --git a/models/src/models/volume_type.rs b/models/src/models/volume_type.rs new file mode 100644 index 0000000..2a068a0 --- /dev/null +++ b/models/src/models/volume_type.rs @@ -0,0 +1,27 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// VolumeType : The type of the volume +/// The type of the volume +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum VolumeType { + #[serde(rename = "MANAGED")] + Managed, + #[serde(rename = "EXTERNAL")] + External, +} + +impl std::fmt::Display for VolumeType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::Managed => write!(f, "MANAGED"), + Self::External => write!(f, "EXTERNAL"), + } + } +} + +impl Default for VolumeType { + fn default() -> VolumeType { + Self::Managed + } +} diff --git a/server/Cargo.toml b/server/Cargo.toml index 6b752ac..11de01a 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,7 +1,8 @@ [package] -name = "server" +name = "unitycatalog-server" edition.workspace = true license.workspace = true version.workspace = true +publish = false [dependencies]