diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 79c3e338f..10a5a5875 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -12266,6 +12266,349 @@ components: type: string x-enum-varnames: - CREATE_RULESET + CreateTableRequest: + description: The definition of `CreateTableRequest` object. + example: + data: + attributes: + description: this is a cloud table generated via a cloud bucket sync + file_metadata: + access_details: + aws_detail: + aws_account_id: test-account-id + aws_bucket_name: test-bucket + file_path: test_rt.csv + sync_enabled: true + schema: + fields: + - name: name + type: STRING + - name: account_id + type: STRING + primary_keys: + - account_id + source: S3 + table_name: test_reference_table + tags: + - test_tag + type: reference_table + properties: + data: + $ref: '#/components/schemas/CreateTableRequestData' + type: object + CreateTableRequestData: + description: The definition of `CreateTableRequestData` object. + properties: + attributes: + $ref: '#/components/schemas/CreateTableRequestDataAttributes' + id: + description: The ID of the reference table. + type: string + type: + $ref: '#/components/schemas/CreateTableRequestDataType' + required: + - type + type: object + CreateTableRequestDataAttributes: + description: The definition of `CreateTableRequestDataAttributes` object. + properties: + description: + description: The description of the reference table. + type: string + file_metadata: + $ref: '#/components/schemas/CreateTableRequestDataAttributesFileMetadata' + schema: + $ref: '#/components/schemas/CreateTableRequestDataAttributesSchema' + source: + $ref: '#/components/schemas/ReferenceTableCreateSourceType' + table_name: + description: The name of the reference table. + example: '' + type: string + tags: + description: The tags of the reference table. + items: + type: string + type: array + required: + - table_name + - schema + - source + type: object + CreateTableRequestDataAttributesFileMetadata: + description: The definition of `CreateTableRequestDataAttributesFileMetadata` + object. + oneOf: + - $ref: '#/components/schemas/CreateTableRequestDataAttributesFileMetadataCloudStorage' + - $ref: '#/components/schemas/CreateTableRequestDataAttributesFileMetadataLocalFile' + CreateTableRequestDataAttributesFileMetadataCloudStorage: + additionalProperties: false + description: Cloud storage file metadata for create requests. Both access_details + and sync_enabled are required. + properties: + access_details: + $ref: '#/components/schemas/CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails' + sync_enabled: + description: Whether this table is synced automatically. + example: false + type: boolean + required: + - access_details + - sync_enabled + title: CloudFileMetadataV2 + type: object + CreateTableRequestDataAttributesFileMetadataLocalFile: + additionalProperties: false + description: Local file metadata for create requests using the upload ID. + properties: + upload_id: + description: The upload ID. + example: '' + type: string + required: + - upload_id + title: LocalFileMetadataV2 + type: object + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails: + description: The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails` + object. + properties: + aws_detail: + $ref: '#/components/schemas/CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail' + azure_detail: + $ref: '#/components/schemas/CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail' + gcp_detail: + $ref: '#/components/schemas/CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail' + type: object + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail: + description: The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail` + object. + properties: + aws_account_id: + description: The ID of the AWS account. + example: '123456789000' + type: string + aws_bucket_name: + description: The name of the Amazon S3 bucket. + example: example-data-bucket + type: string + file_path: + description: The relative file path from the S3 bucket root to the CSV file. + example: reference-tables/users.csv + type: string + required: + - aws_account_id + - aws_bucket_name + - file_path + type: object + x-oneOf-parent: + - AwsDetail + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail: + description: The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail` + object. + properties: + azure_client_id: + description: The Azure client ID. + example: aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb + type: string + azure_container_name: + description: The name of the Azure container. + example: reference-data + type: string + azure_storage_account_name: + description: The name of the Azure storage account. + example: examplestorageaccount + type: string + azure_tenant_id: + description: The ID of the Azure tenant. + example: cccccccc-4444-5555-6666-dddddddddddd + type: string + file_path: + description: The relative file path from the Azure container root to the + CSV file. + example: tables/users.csv + type: string + required: + - azure_client_id + - azure_container_name + - azure_storage_account_name + - azure_tenant_id + - file_path + type: object + x-oneOf-parent: + - AzureDetail + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail: + description: The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail` + object. + properties: + file_path: + description: The relative file path from the GCS bucket root to the CSV + file. + example: data/reference_tables/users.csv + type: string + gcp_bucket_name: + description: The name of the GCP bucket. + example: example-data-bucket + type: string + gcp_project_id: + description: The ID of the GCP project. + example: example-gcp-project-12345 + type: string + gcp_service_account_email: + description: The email of the GCP service account. + example: example-service@example-gcp-project-12345.iam.gserviceaccount.com + type: string + required: + - file_path + - gcp_bucket_name + - gcp_project_id + - gcp_service_account_email + type: object + x-oneOf-parent: + - GcpDetail + CreateTableRequestDataAttributesSchema: + description: The definition of `CreateTableRequestDataAttributesSchema` object. + properties: + fields: + description: The `schema` `fields`. + items: + $ref: '#/components/schemas/CreateTableRequestDataAttributesSchemaFieldsItems' + type: array + primary_keys: + description: List of field names that serve as primary keys for the table. + Only one primary key is supported, and it is used as an ID to retrieve + rows. + example: + - '' + items: + type: string + type: array + required: + - fields + - primary_keys + type: object + CreateTableRequestDataAttributesSchemaFieldsItems: + description: The definition of `CreateTableRequestDataAttributesSchemaFieldsItems` + object. + properties: + name: + description: The field name. + example: '' + type: string + type: + $ref: '#/components/schemas/ReferenceTableSchemaFieldType' + required: + - name + - type + type: object + CreateTableRequestDataType: + default: reference_table + description: Reference table resource type. + enum: + - reference_table + example: reference_table + type: string + x-enum-varnames: + - REFERENCE_TABLE + CreateUploadRequest: + description: The definition of `CreateUploadRequest` object. + properties: + data: + $ref: '#/components/schemas/CreateUploadRequestData' + type: object + CreateUploadRequestData: + description: The definition of `CreateUploadRequestData` object. + properties: + attributes: + $ref: '#/components/schemas/CreateUploadRequestDataAttributes' + id: + description: The ID of the upload. + type: string + type: + $ref: '#/components/schemas/CreateUploadRequestDataType' + required: + - type + type: object + CreateUploadRequestDataAttributes: + description: The definition of `CreateUploadRequestDataAttributes` object. + properties: + headers: + description: The headers of the file to upload. + example: + - '' + items: + type: string + type: array + part_count: + description: The number of parts in the upload. + example: 3 + format: int32 + maximum: 20 + type: integer + part_size: + description: The size of each part in the upload in bytes. For multipart + uploads (part_count > 1), all parts except the last one must be at least + 5,000,000 bytes. For single-part uploads (part_count = 1), any size is + allowed. + example: 10000000 + format: int64 + type: integer + table_name: + description: The name of the reference table. + example: '' + type: string + required: + - headers + - table_name + - part_count + - part_size + type: object + CreateUploadRequestDataType: + default: upload + description: Upload resource type. + enum: + - upload + example: upload + type: string + x-enum-varnames: + - UPLOAD + CreateUploadResponse: + description: The definition of `CreateUploadResponse` object. + properties: + data: + $ref: '#/components/schemas/CreateUploadResponseData' + type: object + CreateUploadResponseData: + description: The definition of `CreateUploadResponseData` object. + properties: + attributes: + $ref: '#/components/schemas/CreateUploadResponseDataAttributes' + id: + description: The ID of the upload. + type: string + type: + $ref: '#/components/schemas/CreateUploadResponseDataType' + required: + - type + type: object + CreateUploadResponseDataAttributes: + description: The definition of `CreateUploadResponseDataAttributes` object. + properties: + part_urls: + description: The URLs of the parts in the upload. + items: + type: string + type: array + type: object + CreateUploadResponseDataType: + default: upload + description: Upload resource type. + enum: + - upload + example: upload + type: string + x-enum-varnames: + - UPLOAD CreateWorkflowRequest: description: A request object for creating a new workflow. example: @@ -35482,6 +35825,225 @@ components: version: $ref: '#/components/schemas/Version' type: object + PatchTableRequest: + description: The definition of `PatchTableRequest` object. + example: + data: + attributes: + description: this is a cloud table generated via a cloud bucket sync + file_metadata: + access_details: + aws_detail: + aws_account_id: test-account-id + aws_bucket_name: test-bucket + file_path: test_rt.csv + sync_enabled: true + schema: + fields: + - name: id + type: INT32 + - name: name + type: STRING + primary_keys: + - id + sync_enabled: false + tags: + - test_tag + id: 00000000-0000-0000-0000-000000000000 + type: reference_table + properties: + data: + $ref: '#/components/schemas/PatchTableRequestData' + type: object + PatchTableRequestData: + description: The definition of `PatchTableRequestData` object. + properties: + attributes: + $ref: '#/components/schemas/PatchTableRequestDataAttributes' + id: + description: The ID of the reference table. + type: string + type: + $ref: '#/components/schemas/PatchTableRequestDataType' + required: + - type + type: object + PatchTableRequestDataAttributes: + description: The definition of `PatchTableRequestDataAttributes` object. + properties: + description: + description: The description of the reference table. + type: string + file_metadata: + $ref: '#/components/schemas/PatchTableRequestDataAttributesFileMetadata' + schema: + $ref: '#/components/schemas/PatchTableRequestDataAttributesSchema' + sync_enabled: + description: Whether this table is synced automatically. + type: boolean + tags: + description: The tags of the reference table. + items: + type: string + type: array + type: object + PatchTableRequestDataAttributesFileMetadata: + description: The definition of `PatchTableRequestDataAttributesFileMetadata` + object. + oneOf: + - $ref: '#/components/schemas/PatchTableRequestDataAttributesFileMetadataCloudStorage' + - $ref: '#/components/schemas/PatchTableRequestDataAttributesFileMetadataLocalFile' + PatchTableRequestDataAttributesFileMetadataCloudStorage: + additionalProperties: false + description: Cloud storage file metadata for patch requests. Allows partial + updates of access_details and sync_enabled. + properties: + access_details: + $ref: '#/components/schemas/PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails' + sync_enabled: + description: Whether this table is synced automatically. + example: false + type: boolean + title: CloudFileMetadataV2 + type: object + PatchTableRequestDataAttributesFileMetadataLocalFile: + additionalProperties: false + description: Local file metadata for patch requests using upload ID. + properties: + upload_id: + description: The upload ID. + example: '' + type: string + required: + - upload_id + title: LocalFileMetadataV2 + type: object + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails: + description: The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails` + object. + properties: + aws_detail: + $ref: '#/components/schemas/PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail' + azure_detail: + $ref: '#/components/schemas/PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail' + gcp_detail: + $ref: '#/components/schemas/PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail' + type: object + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail: + description: The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail` + object. + properties: + aws_account_id: + description: The ID of the AWS account. + example: '123456789000' + type: string + aws_bucket_name: + description: The name of the AWS bucket. + example: example-data-bucket + type: string + file_path: + description: The relative file path from the S3 bucket root to the CSV file. + example: reference-tables/users.csv + type: string + type: object + x-oneOf-parent: + - AwsDetail + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail: + description: The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail` + object. + properties: + azure_client_id: + description: The Azure client ID. + example: aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb + type: string + azure_container_name: + description: The name of the Azure container. + example: reference-data + type: string + azure_storage_account_name: + description: The name of the Azure storage account. + example: examplestorageaccount + type: string + azure_tenant_id: + description: The ID of the Azure tenant. + example: cccccccc-4444-5555-6666-dddddddddddd + type: string + file_path: + description: The relative file path from the Azure container root to the + CSV file. + example: tables/users.csv + type: string + type: object + x-oneOf-parent: + - AzureDetail + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail: + description: The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail` + object. + properties: + file_path: + description: The relative file path from the GCS bucket root to the CSV + file. + example: data/reference_tables/users.csv + type: string + gcp_bucket_name: + description: The name of the GCP bucket. + example: example-data-bucket + type: string + gcp_project_id: + description: The ID of the GCP project. + example: example-gcp-project-12345 + type: string + gcp_service_account_email: + description: The email of the GCP service account. + example: example-service@example-gcp-project-12345.iam.gserviceaccount.com + type: string + type: object + x-oneOf-parent: + - GcpDetail + PatchTableRequestDataAttributesSchema: + description: The definition of `PatchTableRequestDataAttributesSchema` object. + properties: + fields: + description: The `schema` `fields`. + items: + $ref: '#/components/schemas/PatchTableRequestDataAttributesSchemaFieldsItems' + type: array + primary_keys: + description: List of field names that serve as primary keys for the table. + Only one primary key is supported, and it is used as an ID to retrieve + rows. + example: + - '' + items: + type: string + type: array + required: + - fields + - primary_keys + type: object + PatchTableRequestDataAttributesSchemaFieldsItems: + description: The definition of `PatchTableRequestDataAttributesSchemaFieldsItems` + object. + properties: + name: + description: The field name. + example: '' + type: string + type: + $ref: '#/components/schemas/ReferenceTableSchemaFieldType' + required: + - name + - type + type: object + PatchTableRequestDataType: + default: reference_table + description: Reference table resource type. + enum: + - reference_table + example: reference_table + type: string + x-enum-varnames: + - REFERENCE_TABLE Permission: description: Permission object. properties: @@ -37099,6 +37661,73 @@ components: type: string x-enum-varnames: - RECOMMENDATION + ReferenceTableCreateSourceType: + description: The source type for creating reference table data. Only these source + types can be created through this API. + enum: + - LOCAL_FILE + - S3 + - GCS + - AZURE + example: LOCAL_FILE + type: string + x-enum-varnames: + - LOCAL_FILE + - S3 + - GCS + - AZURE + ReferenceTableSchemaFieldType: + description: The field type for reference table schema fields. + enum: + - STRING + - INT32 + example: STRING + type: string + x-enum-varnames: + - STRING + - INT32 + ReferenceTableSortType: + default: -updated_at + description: Sort field and direction for reference tables. Use field name for + ascending, prefix with "-" for descending. + enum: + - updated_at + - table_name + - status + - -updated_at + - -table_name + - -status + type: string + x-enum-varnames: + - UPDATED_AT + - TABLE_NAME + - STATUS + - MINUS_UPDATED_AT + - MINUS_TABLE_NAME + - MINUS_STATUS + ReferenceTableSourceType: + description: The source type for reference table data. Includes all possible + source types that can appear in responses. + enum: + - LOCAL_FILE + - S3 + - GCS + - AZURE + - SERVICENOW + - SALESFORCE + - DATABRICKS + - SNOWFLAKE + example: LOCAL_FILE + type: string + x-enum-varnames: + - LOCAL_FILE + - S3 + - GCS + - AZURE + - SERVICENOW + - SALESFORCE + - DATABRICKS + - SNOWFLAKE RegisterAppKeyResponse: description: The response object after creating an app key registration. properties: @@ -47003,6 +47632,394 @@ components: format: double type: number type: object + TableResultV2: + description: The definition of `TableResultV2` object. + example: + data: + attributes: + created_by: 00000000-0000-0000-0000-000000000000 + description: example description + file_metadata: + access_details: {} + upload_id: 00000000-0000-0000-0000-000000000000 + last_updated_by: '' + row_count: 5 + schema: + fields: + - name: id + type: INT32 + - name: name + type: STRING + primary_keys: + - id + source: LOCAL_FILE + status: DONE + table_name: test_reference_table + tags: + - tag1 + - tag2 + updated_at: '2000-01-01T01:00:00+00:00' + id: 00000000-0000-0000-0000-000000000000 + type: reference_table + properties: + data: + $ref: '#/components/schemas/TableResultV2Data' + type: object + TableResultV2Array: + description: The definition of `TableResultV2Array` object. + example: + data: + - attributes: + created_by: 00000000-0000-0000-0000-000000000000 + description: example description + file_metadata: + access_details: {} + error_message: '' + error_row_count: 0 + upload_id: 00000000-0000-0000-0000-000000000000 + last_updated_by: '' + row_count: 5 + schema: + fields: + - name: id + type: INT32 + - name: name + type: STRING + primary_keys: + - id + source: LOCAL_FILE + status: DONE + table_name: test_reference_table + tags: + - tag1 + - tag2 + updated_at: '2000-01-01T01:00:00+00:00' + id: 00000000-0000-0000-0000-000000000000 + type: reference_table + - attributes: + created_by: 00000000-0000-0000-0000-000000000000 + description: example description + file_metadata: + access_details: + aws_detail: + aws_account_id: test-account-id + aws_bucket_name: test-bucket + file_path: test_rt.csv + error_message: '' + error_row_count: 0 + sync_enabled: true + last_updated_by: 00000000-0000-0000-0000-000000000000 + row_count: 5 + schema: + fields: + - name: location + type: STRING + - name: file_name + type: STRING + primary_keys: + - location + source: S3 + status: DONE + table_name: test_reference_table_2 + tags: + - test_tag1 + - tag2 + - '3' + updated_at: '2000-01-01T01:00:00+00:00' + id: 00000000-0000-0000-0000-000000000000 + type: reference_table + properties: + data: + description: The reference tables. + items: + $ref: '#/components/schemas/TableResultV2Data' + type: array + required: + - data + type: object + TableResultV2Data: + description: The definition of `TableResultV2Data` object. + properties: + attributes: + $ref: '#/components/schemas/TableResultV2DataAttributes' + id: + description: The ID of the reference table. + type: string + type: + $ref: '#/components/schemas/TableResultV2DataType' + required: + - type + type: object + TableResultV2DataAttributes: + description: The definition of `TableResultV2DataAttributes` object. + properties: + created_by: + description: UUID of the user who created the reference table. + type: string + description: + description: The description of the reference table. + type: string + file_metadata: + $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadata' + last_updated_by: + description: UUID of the user who last updated the reference table. + type: string + row_count: + description: The number of successfully processed rows in the reference + table. + format: int64 + type: integer + schema: + $ref: '#/components/schemas/TableResultV2DataAttributesSchema' + source: + $ref: '#/components/schemas/ReferenceTableSourceType' + status: + description: The status of the reference table. + type: string + table_name: + description: The name of the reference table. + type: string + tags: + description: The tags of the reference table. + items: + type: string + type: array + updated_at: + description: The timestamp of the last update to the reference table in + ISO 8601 format. + type: string + type: object + TableResultV2DataAttributesFileMetadata: + description: The definition of `TableResultV2DataAttributesFileMetadata` object. + oneOf: + - $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataCloudStorage' + - $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataLocalFile' + TableResultV2DataAttributesFileMetadataCloudStorage: + description: File metadata for reference tables created by cloud storage. + properties: + access_details: + $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataOneOfAccessDetails' + error_message: + description: The error message returned from the sync. + type: string + error_row_count: + description: The number of rows that failed to sync. + format: int64 + type: integer + error_type: + $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataCloudStorageErrorType' + sync_enabled: + description: Whether this table is synced automatically. + type: boolean + title: CloudFileMetadataV2 + type: object + TableResultV2DataAttributesFileMetadataCloudStorageErrorType: + description: The type of error that occurred during file processing. This field + provides high-level error categories for easier troubleshooting and is only + present when there are errors. + enum: + - TABLE_SCHEMA_ERROR + - FILE_FORMAT_ERROR + - CONFIGURATION_ERROR + - QUOTA_EXCEEDED + - CONFLICT_ERROR + - VALIDATION_ERROR + - STATE_ERROR + - OPERATION_ERROR + - SYSTEM_ERROR + type: string + x-enum-varnames: + - TABLE_SCHEMA_ERROR + - FILE_FORMAT_ERROR + - CONFIGURATION_ERROR + - QUOTA_EXCEEDED + - CONFLICT_ERROR + - VALIDATION_ERROR + - STATE_ERROR + - OPERATION_ERROR + - SYSTEM_ERROR + TableResultV2DataAttributesFileMetadataLocalFile: + description: File metadata for reference tables created by upload. + properties: + error_message: + description: The error message returned from the creation/update. + type: string + error_row_count: + description: The number of rows that failed to create/update. + format: int64 + type: integer + upload_id: + description: The upload ID that was used to create/update the table. + type: string + title: LocalFileMetadataV2 + type: object + TableResultV2DataAttributesFileMetadataOneOfAccessDetails: + description: The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetails` + object. + properties: + aws_detail: + $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail' + azure_detail: + $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail' + gcp_detail: + $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail' + type: object + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail: + description: The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail` + object. + properties: + aws_account_id: + description: The ID of the AWS account. + example: '123456789000' + type: string + aws_bucket_name: + description: The name of the AWS bucket. + example: example-data-bucket + type: string + file_path: + description: The relative file path from the S3 bucket root to the CSV file. + example: reference-tables/users.csv + type: string + type: object + x-oneOf-parent: + - AwsDetail + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail: + description: The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail` + object. + properties: + azure_client_id: + description: The Azure client ID. + example: aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb + type: string + azure_container_name: + description: The name of the Azure container. + example: reference-data + type: string + azure_storage_account_name: + description: The name of the Azure storage account. + example: examplestorageaccount + type: string + azure_tenant_id: + description: The ID of the Azure tenant. + example: cccccccc-4444-5555-6666-dddddddddddd + type: string + file_path: + description: The relative file path from the Azure container root to the + CSV file. + example: tables/users.csv + type: string + type: object + x-oneOf-parent: + - AzureDetail + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail: + description: The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail` + object. + properties: + file_path: + description: The relative file path from the GCS bucket root to the CSV + file. + example: data/reference_tables/users.csv + type: string + gcp_bucket_name: + description: The name of the GCP bucket. + example: example-data-bucket + type: string + gcp_project_id: + description: The ID of the GCP project. + example: example-gcp-project-12345 + type: string + gcp_service_account_email: + description: The email of the GCP service account. + example: example-service@example-gcp-project-12345.iam.gserviceaccount.com + type: string + type: object + x-oneOf-parent: + - GcpDetail + TableResultV2DataAttributesSchema: + description: The definition of `TableResultV2DataAttributesSchema` object. + properties: + fields: + description: The `schema` `fields`. + items: + $ref: '#/components/schemas/TableResultV2DataAttributesSchemaFieldsItems' + type: array + primary_keys: + description: List of field names that serve as primary keys for the table. + Only one primary key is supported, and it is used as an ID to retrieve + rows. + example: + - '' + items: + type: string + type: array + required: + - fields + - primary_keys + type: object + TableResultV2DataAttributesSchemaFieldsItems: + description: The definition of `TableResultV2DataAttributesSchemaFieldsItems` + object. + properties: + name: + description: The field name. + example: '' + type: string + type: + $ref: '#/components/schemas/ReferenceTableSchemaFieldType' + required: + - name + - type + type: object + TableResultV2DataType: + default: reference_table + description: Reference table resource type. + enum: + - reference_table + example: reference_table + type: string + x-enum-varnames: + - REFERENCE_TABLE + TableRowResourceArray: + description: The definition of `TableRowResourceArray` object. + properties: + data: + description: The rows. + items: + $ref: '#/components/schemas/TableRowResourceData' + type: array + required: + - data + type: object + TableRowResourceData: + description: The definition of `TableRowResourceData` object. + properties: + attributes: + $ref: '#/components/schemas/TableRowResourceDataAttributes' + id: + description: The ID of the row. + type: string + type: + $ref: '#/components/schemas/TableRowResourceDataType' + required: + - type + type: object + TableRowResourceDataAttributes: + description: The definition of `TableRowResourceDataAttributes` object. + properties: + values: + additionalProperties: {} + description: The values of the row. + type: object + type: object + TableRowResourceDataType: + default: row + description: Row resource type. + enum: + - row + example: row + type: string + x-enum-varnames: + - ROW TagFilter: description: Tag filter for the budget's entries. properties: @@ -66728,6 +67745,284 @@ paths: operator: OR permissions: - timeseries_query + /api/v2/reference-tables/tables: + get: + description: List all reference tables in this organization. + operationId: ListTables + parameters: + - description: Number of tables to return. + example: 15 + in: query + name: limit + required: false + schema: + default: 15 + format: int64 + maximum: 100 + minimum: 1 + type: integer + - description: Number of tables to skip for pagination. + example: 0 + in: query + name: offset + required: false + schema: + default: 0 + format: int64 + minimum: 0 + type: integer + - description: Sort field and direction. Use field name for ascending, prefix + with "-" for descending. + example: -updated_at + in: query + name: sort + required: false + schema: + $ref: '#/components/schemas/ReferenceTableSortType' + - description: Filter by table status. + example: DONE + in: query + name: filter[status] + required: false + schema: + type: string + - description: Filter by exact table name match. + example: my_reference_table + in: query + name: filter[table_name][exact] + required: false + schema: + type: string + - description: Filter by table name containing substring. + example: user + in: query + name: filter[table_name][contains] + required: false + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TableResultV2Array' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: List tables + tags: + - Reference Tables + post: + description: 'Create a new reference table. You can provide data in two ways: + 1) Call POST api/v2/reference-tables/upload first to get an upload ID, then + PUT chunks of CSV data to each provided URL, and finally call this POST endpoint + with the upload_id in file_metadata, OR 2) Provide access_details in file_metadata + pointing to a CSV file in cloud storage (Amazon S3, Azure Blob Storage, or + GCP Cloud Storage).' + operationId: CreateReferenceTable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateTableRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/TableResultV2' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Create reference table + tags: + - Reference Tables + /api/v2/reference-tables/tables/{id}: + delete: + description: Delete a reference table by ID + operationId: DeleteTable + parameters: + - description: The ID of the reference table to delete + in: path + name: id + required: true + schema: + type: string + responses: + '200': + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Delete table + tags: + - Reference Tables + get: + description: Get a reference table by ID + operationId: GetTable + parameters: + - description: The ID of the reference table to retrieve + in: path + name: id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TableResultV2' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get table + tags: + - Reference Tables + patch: + description: 'Update a reference table by ID. You can update the table''s data, + description, and tags. Note: The source type cannot be changed after table + creation. For data updates: For existing tables of type `source:LOCAL_FILE`, + call POST api/v2/reference-tables/uploads first to get an upload ID, then + PUT chunks of CSV data to each provided URL, and finally call this PATCH endpoint + with the upload_id in file_metadata. For existing tables with `source:` types + of `S3`, `GCS`, or `AZURE`, provide updated access_details in file_metadata + pointing to a CSV file in the same type of cloud storage.' + operationId: UpdateReferenceTable + parameters: + - description: The ID of the reference table to update + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatchTableRequest' + required: true + responses: + '200': + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Update reference table + tags: + - Reference Tables + /api/v2/reference-tables/tables/{id}/rows: + get: + description: Get reference table rows by their primary key values. + operationId: GetRowsByID + parameters: + - description: The ID of the reference table + example: table-123 + in: path + name: id + required: true + schema: + type: string + - description: List of row IDs (primary key values) to retrieve from the reference + table. + example: + - row1 + - row2 + explode: true + in: query + name: row_id + required: true + schema: + items: + type: string + type: array + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TableRowResourceArray' + description: Some or all requested rows were found. + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get rows by id + tags: + - Reference Tables + /api/v2/reference-tables/uploads: + post: + description: Create a reference table upload for bulk data ingestion + operationId: CreateReferenceTableUpload + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateUploadRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/CreateUploadResponse' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Create reference table upload + tags: + - Reference Tables /api/v2/remote_config/products/asm/waf/custom_rules: get: description: Retrieve a list of WAF custom rule. @@ -76923,6 +78218,8 @@ tags: aggregate your RUM events over HTTP. See the [RUM & Session Replay page](https://docs.datadoghq.com/real_user_monitoring/) for more information name: RUM +- description: Auto-generated tag Reference Tables + name: Reference Tables - description: 'A restriction policy defines the access control rules for a resource, mapping a set of relations diff --git a/examples/v2_reference-tables_CreateReferenceTable.rs b/examples/v2_reference-tables_CreateReferenceTable.rs new file mode 100644 index 000000000..8a990a393 --- /dev/null +++ b/examples/v2_reference-tables_CreateReferenceTable.rs @@ -0,0 +1,72 @@ +// Create reference table returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI; +use datadog_api_client::datadogV2::model::CreateTableRequest; +use datadog_api_client::datadogV2::model::CreateTableRequestData; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributes; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadata; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataCloudStorage; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesSchema; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesSchemaFieldsItems; +use datadog_api_client::datadogV2::model::CreateTableRequestDataType; +use datadog_api_client::datadogV2::model::ReferenceTableCreateSourceType; +use datadog_api_client::datadogV2::model::ReferenceTableSchemaFieldType; + +#[tokio::main] +async fn main() { + let body = + CreateTableRequest + ::new().data( + CreateTableRequestData::new( + CreateTableRequestDataType::REFERENCE_TABLE, + ).attributes( + CreateTableRequestDataAttributes::new( + CreateTableRequestDataAttributesSchema::new( + vec![ + CreateTableRequestDataAttributesSchemaFieldsItems::new( + "name".to_string(), + ReferenceTableSchemaFieldType::STRING, + ), + CreateTableRequestDataAttributesSchemaFieldsItems::new( + "account_id".to_string(), + ReferenceTableSchemaFieldType::STRING, + ) + ], + vec!["account_id".to_string()], + ), + ReferenceTableCreateSourceType::S3, + "test_reference_table".to_string(), + ) + .description("this is a cloud table generated via a cloud bucket sync".to_string()) + .file_metadata( + CreateTableRequestDataAttributesFileMetadata + ::CreateTableRequestDataAttributesFileMetadataCloudStorage( + Box::new( + CreateTableRequestDataAttributesFileMetadataCloudStorage::new( + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails + ::new().aws_detail( + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail::new( + "test-account-id".to_string(), + "test-bucket".to_string(), + "test_rt.csv".to_string(), + ), + ), + true, + ), + ), + ), + ) + .tags(vec!["test_tag".to_string()]), + ), + ); + let configuration = datadog::Configuration::new(); + let api = ReferenceTablesAPI::with_config(configuration); + let resp = api.create_reference_table(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_reference-tables_CreateReferenceTableUpload.rs b/examples/v2_reference-tables_CreateReferenceTableUpload.rs new file mode 100644 index 000000000..62b490ff1 --- /dev/null +++ b/examples/v2_reference-tables_CreateReferenceTableUpload.rs @@ -0,0 +1,29 @@ +// Create reference table upload returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI; +use datadog_api_client::datadogV2::model::CreateUploadRequest; +use datadog_api_client::datadogV2::model::CreateUploadRequestData; +use datadog_api_client::datadogV2::model::CreateUploadRequestDataAttributes; +use datadog_api_client::datadogV2::model::CreateUploadRequestDataType; + +#[tokio::main] +async fn main() { + let body = CreateUploadRequest::new().data( + CreateUploadRequestData::new(CreateUploadRequestDataType::UPLOAD).attributes( + CreateUploadRequestDataAttributes::new( + vec!["id".to_string(), "name".to_string(), "value".to_string()], + 1, + 1024, + "test_upload_table_Example-Reference-Table".to_string(), + ), + ), + ); + let configuration = datadog::Configuration::new(); + let api = ReferenceTablesAPI::with_config(configuration); + let resp = api.create_reference_table_upload(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_reference-tables_CreateReferenceTable_3196130987.rs b/examples/v2_reference-tables_CreateReferenceTable_3196130987.rs new file mode 100644 index 000000000..8a6fc33c9 --- /dev/null +++ b/examples/v2_reference-tables_CreateReferenceTable_3196130987.rs @@ -0,0 +1,66 @@ +// Create reference table with upload returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI; +use datadog_api_client::datadogV2::model::CreateTableRequest; +use datadog_api_client::datadogV2::model::CreateTableRequestData; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributes; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadata; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataLocalFile; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesSchema; +use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesSchemaFieldsItems; +use datadog_api_client::datadogV2::model::CreateTableRequestDataType; +use datadog_api_client::datadogV2::model::ReferenceTableCreateSourceType; +use datadog_api_client::datadogV2::model::ReferenceTableSchemaFieldType; + +#[tokio::main] +async fn main() { + let body = + CreateTableRequest + ::new().data( + CreateTableRequestData::new( + CreateTableRequestDataType::REFERENCE_TABLE, + ).attributes( + CreateTableRequestDataAttributes::new( + CreateTableRequestDataAttributesSchema::new( + vec![ + CreateTableRequestDataAttributesSchemaFieldsItems::new( + "id".to_string(), + ReferenceTableSchemaFieldType::STRING, + ), + CreateTableRequestDataAttributesSchemaFieldsItems::new( + "name".to_string(), + ReferenceTableSchemaFieldType::STRING, + ), + CreateTableRequestDataAttributesSchemaFieldsItems::new( + "value".to_string(), + ReferenceTableSchemaFieldType::INT32, + ) + ], + vec!["id".to_string()], + ), + ReferenceTableCreateSourceType::LOCAL_FILE, + "test_reference_table_Example-Reference-Table".to_string(), + ) + .description("Test reference table created via BDD test Example-Reference-Table".to_string()) + .file_metadata( + CreateTableRequestDataAttributesFileMetadata + ::CreateTableRequestDataAttributesFileMetadataLocalFile( + Box::new( + CreateTableRequestDataAttributesFileMetadataLocalFile::new( + "test-upload-id-Example-Reference-Table".to_string(), + ), + ), + ), + ) + .tags(vec!["test_tag".to_string()]), + ), + ); + let configuration = datadog::Configuration::new(); + let api = ReferenceTablesAPI::with_config(configuration); + let resp = api.create_reference_table(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_reference-tables_DeleteTable.rs b/examples/v2_reference-tables_DeleteTable.rs new file mode 100644 index 000000000..5a6b29534 --- /dev/null +++ b/examples/v2_reference-tables_DeleteTable.rs @@ -0,0 +1,15 @@ +// Delete table returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ReferenceTablesAPI::with_config(configuration); + let resp = api.delete_table("id".to_string()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_reference-tables_GetRowsByID.rs b/examples/v2_reference-tables_GetRowsByID.rs new file mode 100644 index 000000000..6fd552197 --- /dev/null +++ b/examples/v2_reference-tables_GetRowsByID.rs @@ -0,0 +1,15 @@ +// Get rows by id returns "Some or all requested rows were found." response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ReferenceTablesAPI::with_config(configuration); + let resp = api.get_rows_by_id("id".to_string(), vec![]).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_reference-tables_GetTable.rs b/examples/v2_reference-tables_GetTable.rs new file mode 100644 index 000000000..518be48b8 --- /dev/null +++ b/examples/v2_reference-tables_GetTable.rs @@ -0,0 +1,15 @@ +// Get table returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ReferenceTablesAPI::with_config(configuration); + let resp = api.get_table("id".to_string()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_reference-tables_ListTables.rs b/examples/v2_reference-tables_ListTables.rs new file mode 100644 index 000000000..572a52381 --- /dev/null +++ b/examples/v2_reference-tables_ListTables.rs @@ -0,0 +1,16 @@ +// List tables returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_reference_tables::ListTablesOptionalParams; +use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ReferenceTablesAPI::with_config(configuration); + let resp = api.list_tables(ListTablesOptionalParams::default()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_reference-tables_UpdateReferenceTable.rs b/examples/v2_reference-tables_UpdateReferenceTable.rs new file mode 100644 index 000000000..87101d59c --- /dev/null +++ b/examples/v2_reference-tables_UpdateReferenceTable.rs @@ -0,0 +1,72 @@ +// Update reference table returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI; +use datadog_api_client::datadogV2::model::PatchTableRequest; +use datadog_api_client::datadogV2::model::PatchTableRequestData; +use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributes; +use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesFileMetadata; +use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesFileMetadataCloudStorage; +use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails; +use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail; +use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesSchema; +use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesSchemaFieldsItems; +use datadog_api_client::datadogV2::model::PatchTableRequestDataType; +use datadog_api_client::datadogV2::model::ReferenceTableSchemaFieldType; + +#[tokio::main] +async fn main() { + let body = + PatchTableRequest + ::new().data( + PatchTableRequestData::new(PatchTableRequestDataType::REFERENCE_TABLE) + .attributes( + PatchTableRequestDataAttributes::new() + .description("this is a cloud table generated via a cloud bucket sync".to_string()) + .file_metadata( + PatchTableRequestDataAttributesFileMetadata + ::PatchTableRequestDataAttributesFileMetadataCloudStorage( + Box::new( + PatchTableRequestDataAttributesFileMetadataCloudStorage::new() + .access_details( + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails + ::new().aws_detail( + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail + ::new() + .aws_account_id("test-account-id".to_string()) + .aws_bucket_name("test-bucket".to_string()) + .file_path("test_rt.csv".to_string()), + ), + ) + .sync_enabled(true), + ), + ), + ) + .schema( + PatchTableRequestDataAttributesSchema::new( + vec![ + PatchTableRequestDataAttributesSchemaFieldsItems::new( + "id".to_string(), + ReferenceTableSchemaFieldType::INT32, + ), + PatchTableRequestDataAttributesSchemaFieldsItems::new( + "name".to_string(), + ReferenceTableSchemaFieldType::STRING, + ) + ], + vec!["id".to_string()], + ), + ) + .sync_enabled(false) + .tags(vec!["test_tag".to_string()]), + ) + .id("00000000-0000-0000-0000-000000000000".to_string()), + ); + let configuration = datadog::Configuration::new(); + let api = ReferenceTablesAPI::with_config(configuration); + let resp = api.update_reference_table("id".to_string(), body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_reference_tables.rs b/src/datadogV2/api/api_reference_tables.rs new file mode 100644 index 000000000..4145546d4 --- /dev/null +++ b/src/datadogV2/api/api_reference_tables.rs @@ -0,0 +1,1071 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use crate::datadog; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// ListTablesOptionalParams is a struct for passing parameters to the method [`ReferenceTablesAPI::list_tables`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListTablesOptionalParams { + /// Number of tables to return. + pub limit: Option, + /// Number of tables to skip for pagination. + pub offset: Option, + /// Sort field and direction. Use field name for ascending, prefix with "-" for descending. + pub sort: Option, + /// Filter by table status. + pub filter_status: Option, + /// Filter by exact table name match. + pub filter_table_name_exact: Option, + /// Filter by table name containing substring. + pub filter_table_name_contains: Option, +} + +impl ListTablesOptionalParams { + /// Number of tables to return. + pub fn limit(mut self, value: i64) -> Self { + self.limit = Some(value); + self + } + /// Number of tables to skip for pagination. + pub fn offset(mut self, value: i64) -> Self { + self.offset = Some(value); + self + } + /// Sort field and direction. Use field name for ascending, prefix with "-" for descending. + pub fn sort(mut self, value: crate::datadogV2::model::ReferenceTableSortType) -> Self { + self.sort = Some(value); + self + } + /// Filter by table status. + pub fn filter_status(mut self, value: String) -> Self { + self.filter_status = Some(value); + self + } + /// Filter by exact table name match. + pub fn filter_table_name_exact(mut self, value: String) -> Self { + self.filter_table_name_exact = Some(value); + self + } + /// Filter by table name containing substring. + pub fn filter_table_name_contains(mut self, value: String) -> Self { + self.filter_table_name_contains = Some(value); + self + } +} + +/// CreateReferenceTableError is a struct for typed errors of method [`ReferenceTablesAPI::create_reference_table`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateReferenceTableError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// CreateReferenceTableUploadError is a struct for typed errors of method [`ReferenceTablesAPI::create_reference_table_upload`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateReferenceTableUploadError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteTableError is a struct for typed errors of method [`ReferenceTablesAPI::delete_table`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteTableError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetRowsByIDError is a struct for typed errors of method [`ReferenceTablesAPI::get_rows_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRowsByIDError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetTableError is a struct for typed errors of method [`ReferenceTablesAPI::get_table`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTableError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListTablesError is a struct for typed errors of method [`ReferenceTablesAPI::list_tables`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListTablesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpdateReferenceTableError is a struct for typed errors of method [`ReferenceTablesAPI::update_reference_table`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateReferenceTableError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Auto-generated tag Reference Tables +#[derive(Debug, Clone)] +pub struct ReferenceTablesAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for ReferenceTablesAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl ReferenceTablesAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let mut reqwest_client_builder = reqwest::Client::builder(); + + if let Some(proxy_url) = &config.proxy_url { + let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"); + reqwest_client_builder = reqwest_client_builder.proxy(proxy); + } + + let mut middleware_client_builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + + if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + middleware_client_builder = middleware_client_builder.with(retry_middleware); + } + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Create a new reference table. You can provide data in two ways: 1) Call POST api/v2/reference-tables/upload first to get an upload ID, then PUT chunks of CSV data to each provided URL, and finally call this POST endpoint with the upload_id in file_metadata, OR 2) Provide access_details in file_metadata pointing to a CSV file in cloud storage (Amazon S3, Azure Blob Storage, or GCP Cloud Storage). + pub async fn create_reference_table( + &self, + body: crate::datadogV2::model::CreateTableRequest, + ) -> Result> + { + match self.create_reference_table_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create a new reference table. You can provide data in two ways: 1) Call POST api/v2/reference-tables/upload first to get an upload ID, then PUT chunks of CSV data to each provided URL, and finally call this POST endpoint with the upload_id in file_metadata, OR 2) Provide access_details in file_metadata pointing to a CSV file in cloud storage (Amazon S3, Azure Blob Storage, or GCP Cloud Storage). + pub async fn create_reference_table_with_http_info( + &self, + body: crate::datadogV2::model::CreateTableRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_reference_table"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reference-tables/tables", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Create a reference table upload for bulk data ingestion + pub async fn create_reference_table_upload( + &self, + body: crate::datadogV2::model::CreateUploadRequest, + ) -> Result< + crate::datadogV2::model::CreateUploadResponse, + datadog::Error, + > { + match self + .create_reference_table_upload_with_http_info(body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create a reference table upload for bulk data ingestion + pub async fn create_reference_table_upload_with_http_info( + &self, + body: crate::datadogV2::model::CreateUploadRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_reference_table_upload"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reference-tables/uploads", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete a reference table by ID + pub async fn delete_table(&self, id: String) -> Result<(), datadog::Error> { + match self.delete_table_with_http_info(id).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete a reference table by ID + pub async fn delete_table_with_http_info( + &self, + id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_table"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reference-tables/tables/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get reference table rows by their primary key values. + pub async fn get_rows_by_id( + &self, + id: String, + row_id: Vec, + ) -> Result> + { + match self.get_rows_by_id_with_http_info(id, row_id).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get reference table rows by their primary key values. + pub async fn get_rows_by_id_with_http_info( + &self, + id: String, + row_id: Vec, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_rows_by_id"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reference-tables/tables/{id}/rows", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + local_req_builder = local_req_builder.query(&[( + "row_id", + &row_id + .iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get a reference table by ID + pub async fn get_table( + &self, + id: String, + ) -> Result> { + match self.get_table_with_http_info(id).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get a reference table by ID + pub async fn get_table_with_http_info( + &self, + id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_table"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reference-tables/tables/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// List all reference tables in this organization. + pub async fn list_tables( + &self, + params: ListTablesOptionalParams, + ) -> Result> { + match self.list_tables_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// List all reference tables in this organization. + pub async fn list_tables_with_http_info( + &self, + params: ListTablesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_tables"; + + // unbox and build optional parameters + let limit = params.limit; + let offset = params.offset; + let sort = params.sort; + let filter_status = params.filter_status; + let filter_table_name_exact = params.filter_table_name_exact; + let filter_table_name_contains = params.filter_table_name_contains; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reference-tables/tables", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = limit { + local_req_builder = + local_req_builder.query(&[("limit", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = offset { + local_req_builder = + local_req_builder.query(&[("offset", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = sort { + local_req_builder = + local_req_builder.query(&[("sort", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_status { + local_req_builder = + local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_table_name_exact { + local_req_builder = local_req_builder + .query(&[("filter[table_name][exact]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_table_name_contains { + local_req_builder = local_req_builder.query(&[( + "filter[table_name][contains]", + &local_query_param.to_string(), + )]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Update a reference table by ID. You can update the table's data, description, and tags. Note: The source type cannot be changed after table creation. For data updates: For existing tables of type `source:LOCAL_FILE`, call POST api/v2/reference-tables/uploads first to get an upload ID, then PUT chunks of CSV data to each provided URL, and finally call this PATCH endpoint with the upload_id in file_metadata. For existing tables with `source:` types of `S3`, `GCS`, or `AZURE`, provide updated access_details in file_metadata pointing to a CSV file in the same type of cloud storage. + pub async fn update_reference_table( + &self, + id: String, + body: crate::datadogV2::model::PatchTableRequest, + ) -> Result<(), datadog::Error> { + match self.update_reference_table_with_http_info(id, body).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Update a reference table by ID. You can update the table's data, description, and tags. Note: The source type cannot be changed after table creation. For data updates: For existing tables of type `source:LOCAL_FILE`, call POST api/v2/reference-tables/uploads first to get an upload ID, then PUT chunks of CSV data to each provided URL, and finally call this PATCH endpoint with the upload_id in file_metadata. For existing tables with `source:` types of `S3`, `GCS`, or `AZURE`, provide updated access_details in file_metadata pointing to a CSV file in the same type of cloud storage. + pub async fn update_reference_table_with_http_info( + &self, + id: String, + body: crate::datadogV2::model::PatchTableRequest, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.update_reference_table"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reference-tables/tables/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index f2b57dade..8a36be09b 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -57,6 +57,7 @@ pub mod api_org_connections; pub mod api_organizations; pub mod api_powerpack; pub mod api_processes; +pub mod api_reference_tables; pub mod api_restriction_policies; pub mod api_roles; pub mod api_rum; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index 647592c9d..a9caf8e62 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -58,6 +58,7 @@ pub use self::api::api_org_connections; pub use self::api::api_organizations; pub use self::api::api_powerpack; pub use self::api::api_processes; +pub use self::api::api_reference_tables; pub use self::api::api_restriction_policies; pub use self::api::api_roles; pub use self::api::api_rum; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 0a5ba6ecc..a266a5395 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -4126,6 +4126,120 @@ pub mod model_timeseries_response_series; pub use self::model_timeseries_response_series::TimeseriesResponseSeries; pub mod model_timeseries_formula_response_type; pub use self::model_timeseries_formula_response_type::TimeseriesFormulaResponseType; +pub mod model_reference_table_sort_type; +pub use self::model_reference_table_sort_type::ReferenceTableSortType; +pub mod model_table_result_v2_array; +pub use self::model_table_result_v2_array::TableResultV2Array; +pub mod model_table_result_v2_data; +pub use self::model_table_result_v2_data::TableResultV2Data; +pub mod model_table_result_v2_data_attributes; +pub use self::model_table_result_v2_data_attributes::TableResultV2DataAttributes; +pub mod model_table_result_v2_data_attributes_file_metadata_cloud_storage; +pub use self::model_table_result_v2_data_attributes_file_metadata_cloud_storage::TableResultV2DataAttributesFileMetadataCloudStorage; +pub mod model_table_result_v2_data_attributes_file_metadata_one_of_access_details; +pub use self::model_table_result_v2_data_attributes_file_metadata_one_of_access_details::TableResultV2DataAttributesFileMetadataOneOfAccessDetails; +pub mod model_table_result_v2_data_attributes_file_metadata_one_of_access_details_aws_detail; +pub use self::model_table_result_v2_data_attributes_file_metadata_one_of_access_details_aws_detail::TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail; +pub mod model_table_result_v2_data_attributes_file_metadata_one_of_access_details_azure_detail; +pub use self::model_table_result_v2_data_attributes_file_metadata_one_of_access_details_azure_detail::TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail; +pub mod model_table_result_v2_data_attributes_file_metadata_one_of_access_details_gcp_detail; +pub use self::model_table_result_v2_data_attributes_file_metadata_one_of_access_details_gcp_detail::TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail; +pub mod model_table_result_v2_data_attributes_file_metadata_cloud_storage_error_type; +pub use self::model_table_result_v2_data_attributes_file_metadata_cloud_storage_error_type::TableResultV2DataAttributesFileMetadataCloudStorageErrorType; +pub mod model_table_result_v2_data_attributes_file_metadata_local_file; +pub use self::model_table_result_v2_data_attributes_file_metadata_local_file::TableResultV2DataAttributesFileMetadataLocalFile; +pub mod model_table_result_v2_data_attributes_file_metadata; +pub use self::model_table_result_v2_data_attributes_file_metadata::TableResultV2DataAttributesFileMetadata; +pub mod model_table_result_v2_data_attributes_schema; +pub use self::model_table_result_v2_data_attributes_schema::TableResultV2DataAttributesSchema; +pub mod model_table_result_v2_data_attributes_schema_fields_items; +pub use self::model_table_result_v2_data_attributes_schema_fields_items::TableResultV2DataAttributesSchemaFieldsItems; +pub mod model_reference_table_schema_field_type; +pub use self::model_reference_table_schema_field_type::ReferenceTableSchemaFieldType; +pub mod model_reference_table_source_type; +pub use self::model_reference_table_source_type::ReferenceTableSourceType; +pub mod model_table_result_v2_data_type; +pub use self::model_table_result_v2_data_type::TableResultV2DataType; +pub mod model_create_table_request; +pub use self::model_create_table_request::CreateTableRequest; +pub mod model_create_table_request_data; +pub use self::model_create_table_request_data::CreateTableRequestData; +pub mod model_create_table_request_data_attributes; +pub use self::model_create_table_request_data_attributes::CreateTableRequestDataAttributes; +pub mod model_create_table_request_data_attributes_file_metadata_cloud_storage; +pub use self::model_create_table_request_data_attributes_file_metadata_cloud_storage::CreateTableRequestDataAttributesFileMetadataCloudStorage; +pub mod model_create_table_request_data_attributes_file_metadata_one_of_access_details; +pub use self::model_create_table_request_data_attributes_file_metadata_one_of_access_details::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails; +pub mod model_create_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail; +pub use self::model_create_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail; +pub mod model_create_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail; +pub use self::model_create_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail; +pub mod model_create_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail; +pub use self::model_create_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail; +pub mod model_create_table_request_data_attributes_file_metadata_local_file; +pub use self::model_create_table_request_data_attributes_file_metadata_local_file::CreateTableRequestDataAttributesFileMetadataLocalFile; +pub mod model_create_table_request_data_attributes_file_metadata; +pub use self::model_create_table_request_data_attributes_file_metadata::CreateTableRequestDataAttributesFileMetadata; +pub mod model_create_table_request_data_attributes_schema; +pub use self::model_create_table_request_data_attributes_schema::CreateTableRequestDataAttributesSchema; +pub mod model_create_table_request_data_attributes_schema_fields_items; +pub use self::model_create_table_request_data_attributes_schema_fields_items::CreateTableRequestDataAttributesSchemaFieldsItems; +pub mod model_reference_table_create_source_type; +pub use self::model_reference_table_create_source_type::ReferenceTableCreateSourceType; +pub mod model_create_table_request_data_type; +pub use self::model_create_table_request_data_type::CreateTableRequestDataType; +pub mod model_table_result_v2; +pub use self::model_table_result_v2::TableResultV2; +pub mod model_patch_table_request; +pub use self::model_patch_table_request::PatchTableRequest; +pub mod model_patch_table_request_data; +pub use self::model_patch_table_request_data::PatchTableRequestData; +pub mod model_patch_table_request_data_attributes; +pub use self::model_patch_table_request_data_attributes::PatchTableRequestDataAttributes; +pub mod model_patch_table_request_data_attributes_file_metadata_cloud_storage; +pub use self::model_patch_table_request_data_attributes_file_metadata_cloud_storage::PatchTableRequestDataAttributesFileMetadataCloudStorage; +pub mod model_patch_table_request_data_attributes_file_metadata_one_of_access_details; +pub use self::model_patch_table_request_data_attributes_file_metadata_one_of_access_details::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails; +pub mod model_patch_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail; +pub use self::model_patch_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail; +pub mod model_patch_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail; +pub use self::model_patch_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail; +pub mod model_patch_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail; +pub use self::model_patch_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail; +pub mod model_patch_table_request_data_attributes_file_metadata_local_file; +pub use self::model_patch_table_request_data_attributes_file_metadata_local_file::PatchTableRequestDataAttributesFileMetadataLocalFile; +pub mod model_patch_table_request_data_attributes_file_metadata; +pub use self::model_patch_table_request_data_attributes_file_metadata::PatchTableRequestDataAttributesFileMetadata; +pub mod model_patch_table_request_data_attributes_schema; +pub use self::model_patch_table_request_data_attributes_schema::PatchTableRequestDataAttributesSchema; +pub mod model_patch_table_request_data_attributes_schema_fields_items; +pub use self::model_patch_table_request_data_attributes_schema_fields_items::PatchTableRequestDataAttributesSchemaFieldsItems; +pub mod model_patch_table_request_data_type; +pub use self::model_patch_table_request_data_type::PatchTableRequestDataType; +pub mod model_table_row_resource_array; +pub use self::model_table_row_resource_array::TableRowResourceArray; +pub mod model_table_row_resource_data; +pub use self::model_table_row_resource_data::TableRowResourceData; +pub mod model_table_row_resource_data_attributes; +pub use self::model_table_row_resource_data_attributes::TableRowResourceDataAttributes; +pub mod model_table_row_resource_data_type; +pub use self::model_table_row_resource_data_type::TableRowResourceDataType; +pub mod model_create_upload_request; +pub use self::model_create_upload_request::CreateUploadRequest; +pub mod model_create_upload_request_data; +pub use self::model_create_upload_request_data::CreateUploadRequestData; +pub mod model_create_upload_request_data_attributes; +pub use self::model_create_upload_request_data_attributes::CreateUploadRequestDataAttributes; +pub mod model_create_upload_request_data_type; +pub use self::model_create_upload_request_data_type::CreateUploadRequestDataType; +pub mod model_create_upload_response; +pub use self::model_create_upload_response::CreateUploadResponse; +pub mod model_create_upload_response_data; +pub use self::model_create_upload_response_data::CreateUploadResponseData; +pub mod model_create_upload_response_data_attributes; +pub use self::model_create_upload_response_data_attributes::CreateUploadResponseDataAttributes; +pub mod model_create_upload_response_data_type; +pub use self::model_create_upload_response_data_type::CreateUploadResponseDataType; pub mod model_application_security_waf_custom_rule_list_response; pub use self::model_application_security_waf_custom_rule_list_response::ApplicationSecurityWafCustomRuleListResponse; pub mod model_application_security_waf_custom_rule_data; diff --git a/src/datadogV2/model/model_create_table_request.rs b/src/datadogV2/model/model_create_table_request.rs new file mode 100644 index 000000000..01abe9ffc --- /dev/null +++ b/src/datadogV2/model/model_create_table_request.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequest` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequest { + /// The definition of `CreateTableRequestData` object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequest { + pub fn new() -> CreateTableRequest { + CreateTableRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::CreateTableRequestData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateTableRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateTableRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestVisitor; + impl<'a> Visitor<'a> for CreateTableRequestVisitor { + type Value = CreateTableRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateTableRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTableRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data.rs b/src/datadogV2/model/model_create_table_request_data.rs new file mode 100644 index 000000000..12637227d --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data.rs @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequestData` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestData { + /// The definition of `CreateTableRequestDataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the reference table. + #[serde(rename = "id")] + pub id: Option, + /// Reference table resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::CreateTableRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestData { + pub fn new( + type_: crate::datadogV2::model::CreateTableRequestDataType, + ) -> CreateTableRequestData { + CreateTableRequestData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CreateTableRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateTableRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataVisitor; + impl<'a> Visitor<'a> for CreateTableRequestDataVisitor { + type Value = CreateTableRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateTableRequestDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::CreateTableRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateTableRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTableRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes.rs b/src/datadogV2/model/model_create_table_request_data_attributes.rs new file mode 100644 index 000000000..6ccfe9402 --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes.rs @@ -0,0 +1,194 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequestDataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributes { + /// The description of the reference table. + #[serde(rename = "description")] + pub description: Option, + /// The definition of `CreateTableRequestDataAttributesFileMetadata` object. + #[serde(rename = "file_metadata")] + pub file_metadata: + Option, + /// The definition of `CreateTableRequestDataAttributesSchema` object. + #[serde(rename = "schema")] + pub schema: crate::datadogV2::model::CreateTableRequestDataAttributesSchema, + /// The source type for creating reference table data. Only these source types can be created through this API. + #[serde(rename = "source")] + pub source: crate::datadogV2::model::ReferenceTableCreateSourceType, + /// The name of the reference table. + #[serde(rename = "table_name")] + pub table_name: String, + /// The tags of the reference table. + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestDataAttributes { + pub fn new( + schema: crate::datadogV2::model::CreateTableRequestDataAttributesSchema, + source: crate::datadogV2::model::ReferenceTableCreateSourceType, + table_name: String, + ) -> CreateTableRequestDataAttributes { + CreateTableRequestDataAttributes { + description: None, + file_metadata: None, + schema, + source, + table_name, + tags: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn file_metadata( + mut self, + value: crate::datadogV2::model::CreateTableRequestDataAttributesFileMetadata, + ) -> Self { + self.file_metadata = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateTableRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateTableRequestDataAttributesVisitor { + type Value = CreateTableRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut description: Option = None; + let mut file_metadata: Option< + crate::datadogV2::model::CreateTableRequestDataAttributesFileMetadata, + > = None; + let mut schema: Option< + crate::datadogV2::model::CreateTableRequestDataAttributesSchema, + > = None; + let mut source: Option = + None; + let mut table_name: Option = None; + let mut tags: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_metadata" => { + if v.is_null() { + continue; + } + file_metadata = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _file_metadata) = file_metadata { + match _file_metadata { + crate::datadogV2::model::CreateTableRequestDataAttributesFileMetadata::UnparsedObject(_file_metadata) => { + _unparsed = true; + }, + _ => {} + } + } + } + "schema" => { + schema = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "source" => { + source = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _source) = source { + match _source { + crate::datadogV2::model::ReferenceTableCreateSourceType::UnparsedObject(_source) => { + _unparsed = true; + }, + _ => {} + } + } + } + "table_name" => { + table_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let schema = schema.ok_or_else(|| M::Error::missing_field("schema"))?; + let source = source.ok_or_else(|| M::Error::missing_field("source"))?; + let table_name = table_name.ok_or_else(|| M::Error::missing_field("table_name"))?; + + let content = CreateTableRequestDataAttributes { + description, + file_metadata, + schema, + source, + table_name, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTableRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata.rs b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata.rs new file mode 100644 index 000000000..997156c6e --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata.rs @@ -0,0 +1,49 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::{Deserialize, Deserializer, Serialize}; + +/// The definition of `CreateTableRequestDataAttributesFileMetadata` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum CreateTableRequestDataAttributesFileMetadata { + CreateTableRequestDataAttributesFileMetadataCloudStorage( + Box, + ), + CreateTableRequestDataAttributesFileMetadataLocalFile( + Box, + ), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for CreateTableRequestDataAttributesFileMetadata { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(CreateTableRequestDataAttributesFileMetadata::CreateTableRequestDataAttributesFileMetadataCloudStorage(_v)); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(CreateTableRequestDataAttributesFileMetadata::CreateTableRequestDataAttributesFileMetadataLocalFile(_v)); + } + } + + return Ok( + CreateTableRequestDataAttributesFileMetadata::UnparsedObject( + crate::datadog::UnparsedObject { value }, + ), + ); + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_cloud_storage.rs b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_cloud_storage.rs new file mode 100644 index 000000000..6338ac840 --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_cloud_storage.rs @@ -0,0 +1,95 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Cloud storage file metadata for create requests. Both access_details and sync_enabled are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributesFileMetadataCloudStorage { + /// The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails` object. + #[serde(rename = "access_details")] + pub access_details: + crate::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails, + /// Whether this table is synced automatically. + #[serde(rename = "sync_enabled")] + pub sync_enabled: bool, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestDataAttributesFileMetadataCloudStorage { + pub fn new( + access_details: crate::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails, + sync_enabled: bool, + ) -> CreateTableRequestDataAttributesFileMetadataCloudStorage { + CreateTableRequestDataAttributesFileMetadataCloudStorage { + access_details, + sync_enabled, + _unparsed: false, + } + } +} + +impl<'de> Deserialize<'de> for CreateTableRequestDataAttributesFileMetadataCloudStorage { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesFileMetadataCloudStorageVisitor; + impl<'a> Visitor<'a> for CreateTableRequestDataAttributesFileMetadataCloudStorageVisitor { + type Value = CreateTableRequestDataAttributesFileMetadataCloudStorage; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut access_details: Option = None; + let mut sync_enabled: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "access_details" => { + access_details = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sync_enabled" => { + sync_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + let access_details = + access_details.ok_or_else(|| M::Error::missing_field("access_details"))?; + let sync_enabled = + sync_enabled.ok_or_else(|| M::Error::missing_field("sync_enabled"))?; + + let content = CreateTableRequestDataAttributesFileMetadataCloudStorage { + access_details, + sync_enabled, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(CreateTableRequestDataAttributesFileMetadataCloudStorageVisitor) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_local_file.rs b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_local_file.rs new file mode 100644 index 000000000..72ce654bd --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_local_file.rs @@ -0,0 +1,76 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Local file metadata for create requests using the upload ID. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributesFileMetadataLocalFile { + /// The upload ID. + #[serde(rename = "upload_id")] + pub upload_id: String, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestDataAttributesFileMetadataLocalFile { + pub fn new(upload_id: String) -> CreateTableRequestDataAttributesFileMetadataLocalFile { + CreateTableRequestDataAttributesFileMetadataLocalFile { + upload_id, + _unparsed: false, + } + } +} + +impl<'de> Deserialize<'de> for CreateTableRequestDataAttributesFileMetadataLocalFile { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesFileMetadataLocalFileVisitor; + impl<'a> Visitor<'a> for CreateTableRequestDataAttributesFileMetadataLocalFileVisitor { + type Value = CreateTableRequestDataAttributesFileMetadataLocalFile; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut upload_id: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "upload_id" => { + upload_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + let upload_id = upload_id.ok_or_else(|| M::Error::missing_field("upload_id"))?; + + let content = CreateTableRequestDataAttributesFileMetadataLocalFile { + upload_id, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTableRequestDataAttributesFileMetadataLocalFileVisitor) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details.rs b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details.rs new file mode 100644 index 000000000..22007923e --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details.rs @@ -0,0 +1,150 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails { + /// The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail` object. + #[serde(rename = "aws_detail")] + pub aws_detail: Option, + /// The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail` object. + #[serde(rename = "azure_detail")] + pub azure_detail: Option, + /// The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail` object. + #[serde(rename = "gcp_detail")] + pub gcp_detail: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails { + pub fn new() -> CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails { + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails { + aws_detail: None, + azure_detail: None, + gcp_detail: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aws_detail( + mut self, + value: crate::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail, + ) -> Self { + self.aws_detail = Some(value); + self + } + + pub fn azure_detail( + mut self, + value: crate::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail, + ) -> Self { + self.azure_detail = Some(value); + self + } + + pub fn gcp_detail( + mut self, + value: crate::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail, + ) -> Self { + self.gcp_detail = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsVisitor; + impl<'a> Visitor<'a> for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsVisitor { + type Value = CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut aws_detail: Option = None; + let mut azure_detail: Option = None; + let mut gcp_detail: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "aws_detail" => { + if v.is_null() { + continue; + } + aws_detail = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_detail" => { + if v.is_null() { + continue; + } + azure_detail = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_detail" => { + if v.is_null() { + continue; + } + gcp_detail = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails { + aws_detail, + azure_detail, + gcp_detail, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail.rs b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail.rs new file mode 100644 index 000000000..3d6cdaa1f --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail.rs @@ -0,0 +1,127 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + /// The ID of the AWS account. + #[serde(rename = "aws_account_id")] + pub aws_account_id: String, + /// The name of the Amazon S3 bucket. + #[serde(rename = "aws_bucket_name")] + pub aws_bucket_name: String, + /// The relative file path from the S3 bucket root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + pub fn new( + aws_account_id: String, + aws_bucket_name: String, + file_path: String, + ) -> CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + aws_account_id, + aws_bucket_name, + file_path, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> + for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor; + impl<'a> Visitor<'a> + for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor + { + type Value = CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut aws_account_id: Option = None; + let mut aws_bucket_name: Option = None; + let mut file_path: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "aws_account_id" => { + aws_account_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "aws_bucket_name" => { + aws_bucket_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_path" => { + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let aws_account_id = + aws_account_id.ok_or_else(|| M::Error::missing_field("aws_account_id"))?; + let aws_bucket_name = + aws_bucket_name.ok_or_else(|| M::Error::missing_field("aws_bucket_name"))?; + let file_path = file_path.ok_or_else(|| M::Error::missing_field("file_path"))?; + + let content = + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + aws_account_id, + aws_bucket_name, + file_path, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail.rs b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail.rs new file mode 100644 index 000000000..bcf344cbc --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail.rs @@ -0,0 +1,153 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + /// The Azure client ID. + #[serde(rename = "azure_client_id")] + pub azure_client_id: String, + /// The name of the Azure container. + #[serde(rename = "azure_container_name")] + pub azure_container_name: String, + /// The name of the Azure storage account. + #[serde(rename = "azure_storage_account_name")] + pub azure_storage_account_name: String, + /// The ID of the Azure tenant. + #[serde(rename = "azure_tenant_id")] + pub azure_tenant_id: String, + /// The relative file path from the Azure container root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + pub fn new( + azure_client_id: String, + azure_container_name: String, + azure_storage_account_name: String, + azure_tenant_id: String, + file_path: String, + ) -> CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + azure_client_id, + azure_container_name, + azure_storage_account_name, + azure_tenant_id, + file_path, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> + for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor; + impl<'a> Visitor<'a> + for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor + { + type Value = CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut azure_client_id: Option = None; + let mut azure_container_name: Option = None; + let mut azure_storage_account_name: Option = None; + let mut azure_tenant_id: Option = None; + let mut file_path: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "azure_client_id" => { + azure_client_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_container_name" => { + azure_container_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_storage_account_name" => { + azure_storage_account_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_tenant_id" => { + azure_tenant_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_path" => { + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let azure_client_id = + azure_client_id.ok_or_else(|| M::Error::missing_field("azure_client_id"))?; + let azure_container_name = azure_container_name + .ok_or_else(|| M::Error::missing_field("azure_container_name"))?; + let azure_storage_account_name = azure_storage_account_name + .ok_or_else(|| M::Error::missing_field("azure_storage_account_name"))?; + let azure_tenant_id = + azure_tenant_id.ok_or_else(|| M::Error::missing_field("azure_tenant_id"))?; + let file_path = file_path.ok_or_else(|| M::Error::missing_field("file_path"))?; + + let content = + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + azure_client_id, + azure_container_name, + azure_storage_account_name, + azure_tenant_id, + file_path, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs new file mode 100644 index 000000000..4317f4308 --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs @@ -0,0 +1,140 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + /// The relative file path from the GCS bucket root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: String, + /// The name of the GCP bucket. + #[serde(rename = "gcp_bucket_name")] + pub gcp_bucket_name: String, + /// The ID of the GCP project. + #[serde(rename = "gcp_project_id")] + pub gcp_project_id: String, + /// The email of the GCP service account. + #[serde(rename = "gcp_service_account_email")] + pub gcp_service_account_email: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + pub fn new( + file_path: String, + gcp_bucket_name: String, + gcp_project_id: String, + gcp_service_account_email: String, + ) -> CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + file_path, + gcp_bucket_name, + gcp_project_id, + gcp_service_account_email, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> + for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor; + impl<'a> Visitor<'a> + for CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor + { + type Value = CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut file_path: Option = None; + let mut gcp_bucket_name: Option = None; + let mut gcp_project_id: Option = None; + let mut gcp_service_account_email: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "file_path" => { + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_bucket_name" => { + gcp_bucket_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_project_id" => { + gcp_project_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_service_account_email" => { + gcp_service_account_email = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let file_path = file_path.ok_or_else(|| M::Error::missing_field("file_path"))?; + let gcp_bucket_name = + gcp_bucket_name.ok_or_else(|| M::Error::missing_field("gcp_bucket_name"))?; + let gcp_project_id = + gcp_project_id.ok_or_else(|| M::Error::missing_field("gcp_project_id"))?; + let gcp_service_account_email = gcp_service_account_email + .ok_or_else(|| M::Error::missing_field("gcp_service_account_email"))?; + + let content = + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + file_path, + gcp_bucket_name, + gcp_project_id, + gcp_service_account_email, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_schema.rs b/src/datadogV2/model/model_create_table_request_data_attributes_schema.rs new file mode 100644 index 000000000..5f084a4a3 --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_schema.rs @@ -0,0 +1,109 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequestDataAttributesSchema` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributesSchema { + /// The `schema` `fields`. + #[serde(rename = "fields")] + pub fields: Vec, + /// List of field names that serve as primary keys for the table. Only one primary key is supported, and it is used as an ID to retrieve rows. + #[serde(rename = "primary_keys")] + pub primary_keys: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestDataAttributesSchema { + pub fn new( + fields: Vec, + primary_keys: Vec, + ) -> CreateTableRequestDataAttributesSchema { + CreateTableRequestDataAttributesSchema { + fields, + primary_keys, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateTableRequestDataAttributesSchema { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesSchemaVisitor; + impl<'a> Visitor<'a> for CreateTableRequestDataAttributesSchemaVisitor { + type Value = CreateTableRequestDataAttributesSchema; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut fields: Option< + Vec, + > = None; + let mut primary_keys: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "fields" => { + fields = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_keys" => { + primary_keys = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let fields = fields.ok_or_else(|| M::Error::missing_field("fields"))?; + let primary_keys = + primary_keys.ok_or_else(|| M::Error::missing_field("primary_keys"))?; + + let content = CreateTableRequestDataAttributesSchema { + fields, + primary_keys, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTableRequestDataAttributesSchemaVisitor) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_attributes_schema_fields_items.rs b/src/datadogV2/model/model_create_table_request_data_attributes_schema_fields_items.rs new file mode 100644 index 000000000..fbb7aab00 --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_attributes_schema_fields_items.rs @@ -0,0 +1,114 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateTableRequestDataAttributesSchemaFieldsItems` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTableRequestDataAttributesSchemaFieldsItems { + /// The field name. + #[serde(rename = "name")] + pub name: String, + /// The field type for reference table schema fields. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ReferenceTableSchemaFieldType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTableRequestDataAttributesSchemaFieldsItems { + pub fn new( + name: String, + type_: crate::datadogV2::model::ReferenceTableSchemaFieldType, + ) -> CreateTableRequestDataAttributesSchemaFieldsItems { + CreateTableRequestDataAttributesSchemaFieldsItems { + name, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateTableRequestDataAttributesSchemaFieldsItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTableRequestDataAttributesSchemaFieldsItemsVisitor; + impl<'a> Visitor<'a> for CreateTableRequestDataAttributesSchemaFieldsItemsVisitor { + type Value = CreateTableRequestDataAttributesSchemaFieldsItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut type_: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ReferenceTableSchemaFieldType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateTableRequestDataAttributesSchemaFieldsItems { + name, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTableRequestDataAttributesSchemaFieldsItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_table_request_data_type.rs b/src/datadogV2/model/model_create_table_request_data_type.rs new file mode 100644 index 000000000..4a32a0a1b --- /dev/null +++ b/src/datadogV2/model/model_create_table_request_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum CreateTableRequestDataType { + REFERENCE_TABLE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for CreateTableRequestDataType { + fn to_string(&self) -> String { + match self { + Self::REFERENCE_TABLE => String::from("reference_table"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for CreateTableRequestDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for CreateTableRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "reference_table" => Self::REFERENCE_TABLE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_create_upload_request.rs b/src/datadogV2/model/model_create_upload_request.rs new file mode 100644 index 000000000..e9c1d4278 --- /dev/null +++ b/src/datadogV2/model/model_create_upload_request.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateUploadRequest` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateUploadRequest { + /// The definition of `CreateUploadRequestData` object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateUploadRequest { + pub fn new() -> CreateUploadRequest { + CreateUploadRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::CreateUploadRequestData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateUploadRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateUploadRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateUploadRequestVisitor; + impl<'a> Visitor<'a> for CreateUploadRequestVisitor { + type Value = CreateUploadRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateUploadRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateUploadRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_create_upload_request_data.rs b/src/datadogV2/model/model_create_upload_request_data.rs new file mode 100644 index 000000000..6818d9e4d --- /dev/null +++ b/src/datadogV2/model/model_create_upload_request_data.rs @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateUploadRequestData` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateUploadRequestData { + /// The definition of `CreateUploadRequestDataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the upload. + #[serde(rename = "id")] + pub id: Option, + /// Upload resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::CreateUploadRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateUploadRequestData { + pub fn new( + type_: crate::datadogV2::model::CreateUploadRequestDataType, + ) -> CreateUploadRequestData { + CreateUploadRequestData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CreateUploadRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateUploadRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateUploadRequestDataVisitor; + impl<'a> Visitor<'a> for CreateUploadRequestDataVisitor { + type Value = CreateUploadRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateUploadRequestDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::CreateUploadRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateUploadRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateUploadRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_upload_request_data_attributes.rs b/src/datadogV2/model/model_create_upload_request_data_attributes.rs new file mode 100644 index 000000000..e6be5d37d --- /dev/null +++ b/src/datadogV2/model/model_create_upload_request_data_attributes.rs @@ -0,0 +1,127 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateUploadRequestDataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateUploadRequestDataAttributes { + /// The headers of the file to upload. + #[serde(rename = "headers")] + pub headers: Vec, + /// The number of parts in the upload. + #[serde(rename = "part_count")] + pub part_count: i32, + /// The size of each part in the upload in bytes. For multipart uploads (part_count > 1), all parts except the last one must be at least 5,000,000 bytes. For single-part uploads (part_count = 1), any size is allowed. + #[serde(rename = "part_size")] + pub part_size: i64, + /// The name of the reference table. + #[serde(rename = "table_name")] + pub table_name: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateUploadRequestDataAttributes { + pub fn new( + headers: Vec, + part_count: i32, + part_size: i64, + table_name: String, + ) -> CreateUploadRequestDataAttributes { + CreateUploadRequestDataAttributes { + headers, + part_count, + part_size, + table_name, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateUploadRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateUploadRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateUploadRequestDataAttributesVisitor { + type Value = CreateUploadRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut headers: Option> = None; + let mut part_count: Option = None; + let mut part_size: Option = None; + let mut table_name: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "headers" => { + headers = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "part_count" => { + part_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "part_size" => { + part_size = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "table_name" => { + table_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let headers = headers.ok_or_else(|| M::Error::missing_field("headers"))?; + let part_count = part_count.ok_or_else(|| M::Error::missing_field("part_count"))?; + let part_size = part_size.ok_or_else(|| M::Error::missing_field("part_size"))?; + let table_name = table_name.ok_or_else(|| M::Error::missing_field("table_name"))?; + + let content = CreateUploadRequestDataAttributes { + headers, + part_count, + part_size, + table_name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateUploadRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_upload_request_data_type.rs b/src/datadogV2/model/model_create_upload_request_data_type.rs new file mode 100644 index 000000000..ea99e9734 --- /dev/null +++ b/src/datadogV2/model/model_create_upload_request_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum CreateUploadRequestDataType { + UPLOAD, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for CreateUploadRequestDataType { + fn to_string(&self) -> String { + match self { + Self::UPLOAD => String::from("upload"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for CreateUploadRequestDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for CreateUploadRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "upload" => Self::UPLOAD, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_create_upload_response.rs b/src/datadogV2/model/model_create_upload_response.rs new file mode 100644 index 000000000..8016beafe --- /dev/null +++ b/src/datadogV2/model/model_create_upload_response.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateUploadResponse` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateUploadResponse { + /// The definition of `CreateUploadResponseData` object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateUploadResponse { + pub fn new() -> CreateUploadResponse { + CreateUploadResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::CreateUploadResponseData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateUploadResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateUploadResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateUploadResponseVisitor; + impl<'a> Visitor<'a> for CreateUploadResponseVisitor { + type Value = CreateUploadResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateUploadResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateUploadResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_create_upload_response_data.rs b/src/datadogV2/model/model_create_upload_response_data.rs new file mode 100644 index 000000000..9b3eeca23 --- /dev/null +++ b/src/datadogV2/model/model_create_upload_response_data.rs @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateUploadResponseData` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateUploadResponseData { + /// The definition of `CreateUploadResponseDataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the upload. + #[serde(rename = "id")] + pub id: Option, + /// Upload resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::CreateUploadResponseDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateUploadResponseData { + pub fn new( + type_: crate::datadogV2::model::CreateUploadResponseDataType, + ) -> CreateUploadResponseData { + CreateUploadResponseData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CreateUploadResponseDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateUploadResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateUploadResponseDataVisitor; + impl<'a> Visitor<'a> for CreateUploadResponseDataVisitor { + type Value = CreateUploadResponseData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateUploadResponseDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::CreateUploadResponseDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateUploadResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateUploadResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_upload_response_data_attributes.rs b/src/datadogV2/model/model_create_upload_response_data_attributes.rs new file mode 100644 index 000000000..eeff5f59e --- /dev/null +++ b/src/datadogV2/model/model_create_upload_response_data_attributes.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `CreateUploadResponseDataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateUploadResponseDataAttributes { + /// The URLs of the parts in the upload. + #[serde(rename = "part_urls")] + pub part_urls: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateUploadResponseDataAttributes { + pub fn new() -> CreateUploadResponseDataAttributes { + CreateUploadResponseDataAttributes { + part_urls: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn part_urls(mut self, value: Vec) -> Self { + self.part_urls = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateUploadResponseDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateUploadResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateUploadResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateUploadResponseDataAttributesVisitor { + type Value = CreateUploadResponseDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut part_urls: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "part_urls" => { + if v.is_null() { + continue; + } + part_urls = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateUploadResponseDataAttributes { + part_urls, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateUploadResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_upload_response_data_type.rs b/src/datadogV2/model/model_create_upload_response_data_type.rs new file mode 100644 index 000000000..5b8caf2bf --- /dev/null +++ b/src/datadogV2/model/model_create_upload_response_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum CreateUploadResponseDataType { + UPLOAD, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for CreateUploadResponseDataType { + fn to_string(&self) -> String { + match self { + Self::UPLOAD => String::from("upload"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for CreateUploadResponseDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for CreateUploadResponseDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "upload" => Self::UPLOAD, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_patch_table_request.rs b/src/datadogV2/model/model_patch_table_request.rs new file mode 100644 index 000000000..9e9790838 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequest` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequest { + /// The definition of `PatchTableRequestData` object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequest { + pub fn new() -> PatchTableRequest { + PatchTableRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::PatchTableRequestData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchTableRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchTableRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestVisitor; + impl<'a> Visitor<'a> for PatchTableRequestVisitor { + type Value = PatchTableRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchTableRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchTableRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data.rs b/src/datadogV2/model/model_patch_table_request_data.rs new file mode 100644 index 000000000..a64d8a5c7 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data.rs @@ -0,0 +1,139 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequestData` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestData { + /// The definition of `PatchTableRequestDataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the reference table. + #[serde(rename = "id")] + pub id: Option, + /// Reference table resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchTableRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestData { + pub fn new(type_: crate::datadogV2::model::PatchTableRequestDataType) -> PatchTableRequestData { + PatchTableRequestData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::PatchTableRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchTableRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataVisitor; + impl<'a> Visitor<'a> for PatchTableRequestDataVisitor { + type Value = PatchTableRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::PatchTableRequestDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchTableRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchTableRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchTableRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes.rs b/src/datadogV2/model/model_patch_table_request_data_attributes.rs new file mode 100644 index 000000000..2790ae24f --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes.rs @@ -0,0 +1,194 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequestDataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributes { + /// The description of the reference table. + #[serde(rename = "description")] + pub description: Option, + /// The definition of `PatchTableRequestDataAttributesFileMetadata` object. + #[serde(rename = "file_metadata")] + pub file_metadata: Option, + /// The definition of `PatchTableRequestDataAttributesSchema` object. + #[serde(rename = "schema")] + pub schema: Option, + /// Whether this table is synced automatically. + #[serde(rename = "sync_enabled")] + pub sync_enabled: Option, + /// The tags of the reference table. + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestDataAttributes { + pub fn new() -> PatchTableRequestDataAttributes { + PatchTableRequestDataAttributes { + description: None, + file_metadata: None, + schema: None, + sync_enabled: None, + tags: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn file_metadata( + mut self, + value: crate::datadogV2::model::PatchTableRequestDataAttributesFileMetadata, + ) -> Self { + self.file_metadata = Some(value); + self + } + + pub fn schema( + mut self, + value: crate::datadogV2::model::PatchTableRequestDataAttributesSchema, + ) -> Self { + self.schema = Some(value); + self + } + + pub fn sync_enabled(mut self, value: bool) -> Self { + self.sync_enabled = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchTableRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchTableRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for PatchTableRequestDataAttributesVisitor { + type Value = PatchTableRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut description: Option = None; + let mut file_metadata: Option< + crate::datadogV2::model::PatchTableRequestDataAttributesFileMetadata, + > = None; + let mut schema: Option< + crate::datadogV2::model::PatchTableRequestDataAttributesSchema, + > = None; + let mut sync_enabled: Option = None; + let mut tags: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_metadata" => { + if v.is_null() { + continue; + } + file_metadata = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _file_metadata) = file_metadata { + match _file_metadata { + crate::datadogV2::model::PatchTableRequestDataAttributesFileMetadata::UnparsedObject(_file_metadata) => { + _unparsed = true; + }, + _ => {} + } + } + } + "schema" => { + if v.is_null() { + continue; + } + schema = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sync_enabled" => { + if v.is_null() { + continue; + } + sync_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchTableRequestDataAttributes { + description, + file_metadata, + schema, + sync_enabled, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchTableRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata.rs new file mode 100644 index 000000000..cc2be240c --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata.rs @@ -0,0 +1,47 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::{Deserialize, Deserializer, Serialize}; + +/// The definition of `PatchTableRequestDataAttributesFileMetadata` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum PatchTableRequestDataAttributesFileMetadata { + PatchTableRequestDataAttributesFileMetadataCloudStorage( + Box, + ), + PatchTableRequestDataAttributesFileMetadataLocalFile( + Box, + ), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for PatchTableRequestDataAttributesFileMetadata { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(PatchTableRequestDataAttributesFileMetadata::PatchTableRequestDataAttributesFileMetadataCloudStorage(_v)); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(PatchTableRequestDataAttributesFileMetadata::PatchTableRequestDataAttributesFileMetadataLocalFile(_v)); + } + } + + return Ok(PatchTableRequestDataAttributesFileMetadata::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_cloud_storage.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_cloud_storage.rs new file mode 100644 index 000000000..5bec977a9 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_cloud_storage.rs @@ -0,0 +1,113 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Cloud storage file metadata for patch requests. Allows partial updates of access_details and sync_enabled. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributesFileMetadataCloudStorage { + /// The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails` object. + #[serde(rename = "access_details")] + pub access_details: Option< + crate::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails, + >, + /// Whether this table is synced automatically. + #[serde(rename = "sync_enabled")] + pub sync_enabled: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestDataAttributesFileMetadataCloudStorage { + pub fn new() -> PatchTableRequestDataAttributesFileMetadataCloudStorage { + PatchTableRequestDataAttributesFileMetadataCloudStorage { + access_details: None, + sync_enabled: None, + _unparsed: false, + } + } + + pub fn access_details( + mut self, + value: crate::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails, + ) -> Self { + self.access_details = Some(value); + self + } + + pub fn sync_enabled(mut self, value: bool) -> Self { + self.sync_enabled = Some(value); + self + } +} + +impl Default for PatchTableRequestDataAttributesFileMetadataCloudStorage { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchTableRequestDataAttributesFileMetadataCloudStorage { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesFileMetadataCloudStorageVisitor; + impl<'a> Visitor<'a> for PatchTableRequestDataAttributesFileMetadataCloudStorageVisitor { + type Value = PatchTableRequestDataAttributesFileMetadataCloudStorage; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut access_details: Option = None; + let mut sync_enabled: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "access_details" => { + if v.is_null() { + continue; + } + access_details = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sync_enabled" => { + if v.is_null() { + continue; + } + sync_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + + let content = PatchTableRequestDataAttributesFileMetadataCloudStorage { + access_details, + sync_enabled, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchTableRequestDataAttributesFileMetadataCloudStorageVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_local_file.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_local_file.rs new file mode 100644 index 000000000..5dd90d63a --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_local_file.rs @@ -0,0 +1,76 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Local file metadata for patch requests using upload ID. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributesFileMetadataLocalFile { + /// The upload ID. + #[serde(rename = "upload_id")] + pub upload_id: String, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestDataAttributesFileMetadataLocalFile { + pub fn new(upload_id: String) -> PatchTableRequestDataAttributesFileMetadataLocalFile { + PatchTableRequestDataAttributesFileMetadataLocalFile { + upload_id, + _unparsed: false, + } + } +} + +impl<'de> Deserialize<'de> for PatchTableRequestDataAttributesFileMetadataLocalFile { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesFileMetadataLocalFileVisitor; + impl<'a> Visitor<'a> for PatchTableRequestDataAttributesFileMetadataLocalFileVisitor { + type Value = PatchTableRequestDataAttributesFileMetadataLocalFile; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut upload_id: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "upload_id" => { + upload_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + let upload_id = upload_id.ok_or_else(|| M::Error::missing_field("upload_id"))?; + + let content = PatchTableRequestDataAttributesFileMetadataLocalFile { + upload_id, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchTableRequestDataAttributesFileMetadataLocalFileVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details.rs new file mode 100644 index 000000000..f7ca169f2 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details.rs @@ -0,0 +1,150 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails { + /// The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail` object. + #[serde(rename = "aws_detail")] + pub aws_detail: Option, + /// The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail` object. + #[serde(rename = "azure_detail")] + pub azure_detail: Option, + /// The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail` object. + #[serde(rename = "gcp_detail")] + pub gcp_detail: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails { + pub fn new() -> PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails { + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails { + aws_detail: None, + azure_detail: None, + gcp_detail: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aws_detail( + mut self, + value: crate::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail, + ) -> Self { + self.aws_detail = Some(value); + self + } + + pub fn azure_detail( + mut self, + value: crate::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail, + ) -> Self { + self.azure_detail = Some(value); + self + } + + pub fn gcp_detail( + mut self, + value: crate::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail, + ) -> Self { + self.gcp_detail = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsVisitor; + impl<'a> Visitor<'a> for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsVisitor { + type Value = PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut aws_detail: Option = None; + let mut azure_detail: Option = None; + let mut gcp_detail: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "aws_detail" => { + if v.is_null() { + continue; + } + aws_detail = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_detail" => { + if v.is_null() { + continue; + } + azure_detail = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_detail" => { + if v.is_null() { + continue; + } + gcp_detail = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails { + aws_detail, + azure_detail, + gcp_detail, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail.rs new file mode 100644 index 000000000..cf7a6c4da --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail.rs @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + /// The ID of the AWS account. + #[serde(rename = "aws_account_id")] + pub aws_account_id: Option, + /// The name of the AWS bucket. + #[serde(rename = "aws_bucket_name")] + pub aws_bucket_name: Option, + /// The relative file path from the S3 bucket root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + pub fn new() -> PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + aws_account_id: None, + aws_bucket_name: None, + file_path: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aws_account_id(mut self, value: String) -> Self { + self.aws_account_id = Some(value); + self + } + + pub fn aws_bucket_name(mut self, value: String) -> Self { + self.aws_bucket_name = Some(value); + self + } + + pub fn file_path(mut self, value: String) -> Self { + self.file_path = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> + for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor; + impl<'a> Visitor<'a> + for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor + { + type Value = PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut aws_account_id: Option = None; + let mut aws_bucket_name: Option = None; + let mut file_path: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "aws_account_id" => { + if v.is_null() { + continue; + } + aws_account_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "aws_bucket_name" => { + if v.is_null() { + continue; + } + aws_bucket_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_path" => { + if v.is_null() { + continue; + } + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + aws_account_id, + aws_bucket_name, + file_path, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail.rs new file mode 100644 index 000000000..2c49304a7 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail.rs @@ -0,0 +1,184 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + /// The Azure client ID. + #[serde(rename = "azure_client_id")] + pub azure_client_id: Option, + /// The name of the Azure container. + #[serde(rename = "azure_container_name")] + pub azure_container_name: Option, + /// The name of the Azure storage account. + #[serde(rename = "azure_storage_account_name")] + pub azure_storage_account_name: Option, + /// The ID of the Azure tenant. + #[serde(rename = "azure_tenant_id")] + pub azure_tenant_id: Option, + /// The relative file path from the Azure container root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + pub fn new() -> PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + azure_client_id: None, + azure_container_name: None, + azure_storage_account_name: None, + azure_tenant_id: None, + file_path: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn azure_client_id(mut self, value: String) -> Self { + self.azure_client_id = Some(value); + self + } + + pub fn azure_container_name(mut self, value: String) -> Self { + self.azure_container_name = Some(value); + self + } + + pub fn azure_storage_account_name(mut self, value: String) -> Self { + self.azure_storage_account_name = Some(value); + self + } + + pub fn azure_tenant_id(mut self, value: String) -> Self { + self.azure_tenant_id = Some(value); + self + } + + pub fn file_path(mut self, value: String) -> Self { + self.file_path = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> + for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor; + impl<'a> Visitor<'a> + for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor + { + type Value = PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut azure_client_id: Option = None; + let mut azure_container_name: Option = None; + let mut azure_storage_account_name: Option = None; + let mut azure_tenant_id: Option = None; + let mut file_path: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "azure_client_id" => { + if v.is_null() { + continue; + } + azure_client_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_container_name" => { + if v.is_null() { + continue; + } + azure_container_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_storage_account_name" => { + if v.is_null() { + continue; + } + azure_storage_account_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_tenant_id" => { + if v.is_null() { + continue; + } + azure_tenant_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_path" => { + if v.is_null() { + continue; + } + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + azure_client_id, + azure_container_name, + azure_storage_account_name, + azure_tenant_id, + file_path, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs new file mode 100644 index 000000000..303846912 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs @@ -0,0 +1,166 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + /// The relative file path from the GCS bucket root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: Option, + /// The name of the GCP bucket. + #[serde(rename = "gcp_bucket_name")] + pub gcp_bucket_name: Option, + /// The ID of the GCP project. + #[serde(rename = "gcp_project_id")] + pub gcp_project_id: Option, + /// The email of the GCP service account. + #[serde(rename = "gcp_service_account_email")] + pub gcp_service_account_email: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + pub fn new() -> PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + file_path: None, + gcp_bucket_name: None, + gcp_project_id: None, + gcp_service_account_email: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn file_path(mut self, value: String) -> Self { + self.file_path = Some(value); + self + } + + pub fn gcp_bucket_name(mut self, value: String) -> Self { + self.gcp_bucket_name = Some(value); + self + } + + pub fn gcp_project_id(mut self, value: String) -> Self { + self.gcp_project_id = Some(value); + self + } + + pub fn gcp_service_account_email(mut self, value: String) -> Self { + self.gcp_service_account_email = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> + for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor; + impl<'a> Visitor<'a> + for PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor + { + type Value = PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut file_path: Option = None; + let mut gcp_bucket_name: Option = None; + let mut gcp_project_id: Option = None; + let mut gcp_service_account_email: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "file_path" => { + if v.is_null() { + continue; + } + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_bucket_name" => { + if v.is_null() { + continue; + } + gcp_bucket_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_project_id" => { + if v.is_null() { + continue; + } + gcp_project_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_service_account_email" => { + if v.is_null() { + continue; + } + gcp_service_account_email = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + file_path, + gcp_bucket_name, + gcp_project_id, + gcp_service_account_email, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_schema.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_schema.rs new file mode 100644 index 000000000..baa161720 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_schema.rs @@ -0,0 +1,109 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequestDataAttributesSchema` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributesSchema { + /// The `schema` `fields`. + #[serde(rename = "fields")] + pub fields: Vec, + /// List of field names that serve as primary keys for the table. Only one primary key is supported, and it is used as an ID to retrieve rows. + #[serde(rename = "primary_keys")] + pub primary_keys: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestDataAttributesSchema { + pub fn new( + fields: Vec, + primary_keys: Vec, + ) -> PatchTableRequestDataAttributesSchema { + PatchTableRequestDataAttributesSchema { + fields, + primary_keys, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchTableRequestDataAttributesSchema { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesSchemaVisitor; + impl<'a> Visitor<'a> for PatchTableRequestDataAttributesSchemaVisitor { + type Value = PatchTableRequestDataAttributesSchema; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut fields: Option< + Vec, + > = None; + let mut primary_keys: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "fields" => { + fields = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_keys" => { + primary_keys = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let fields = fields.ok_or_else(|| M::Error::missing_field("fields"))?; + let primary_keys = + primary_keys.ok_or_else(|| M::Error::missing_field("primary_keys"))?; + + let content = PatchTableRequestDataAttributesSchema { + fields, + primary_keys, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchTableRequestDataAttributesSchemaVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_attributes_schema_fields_items.rs b/src/datadogV2/model/model_patch_table_request_data_attributes_schema_fields_items.rs new file mode 100644 index 000000000..620d999b7 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_attributes_schema_fields_items.rs @@ -0,0 +1,114 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `PatchTableRequestDataAttributesSchemaFieldsItems` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchTableRequestDataAttributesSchemaFieldsItems { + /// The field name. + #[serde(rename = "name")] + pub name: String, + /// The field type for reference table schema fields. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ReferenceTableSchemaFieldType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchTableRequestDataAttributesSchemaFieldsItems { + pub fn new( + name: String, + type_: crate::datadogV2::model::ReferenceTableSchemaFieldType, + ) -> PatchTableRequestDataAttributesSchemaFieldsItems { + PatchTableRequestDataAttributesSchemaFieldsItems { + name, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchTableRequestDataAttributesSchemaFieldsItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchTableRequestDataAttributesSchemaFieldsItemsVisitor; + impl<'a> Visitor<'a> for PatchTableRequestDataAttributesSchemaFieldsItemsVisitor { + type Value = PatchTableRequestDataAttributesSchemaFieldsItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut type_: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ReferenceTableSchemaFieldType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchTableRequestDataAttributesSchemaFieldsItems { + name, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchTableRequestDataAttributesSchemaFieldsItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_table_request_data_type.rs b/src/datadogV2/model/model_patch_table_request_data_type.rs new file mode 100644 index 000000000..8fb6879d4 --- /dev/null +++ b/src/datadogV2/model/model_patch_table_request_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum PatchTableRequestDataType { + REFERENCE_TABLE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for PatchTableRequestDataType { + fn to_string(&self) -> String { + match self { + Self::REFERENCE_TABLE => String::from("reference_table"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for PatchTableRequestDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for PatchTableRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "reference_table" => Self::REFERENCE_TABLE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_reference_table_create_source_type.rs b/src/datadogV2/model/model_reference_table_create_source_type.rs new file mode 100644 index 000000000..6792f6180 --- /dev/null +++ b/src/datadogV2/model/model_reference_table_create_source_type.rs @@ -0,0 +1,57 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ReferenceTableCreateSourceType { + LOCAL_FILE, + S3, + GCS, + AZURE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ReferenceTableCreateSourceType { + fn to_string(&self) -> String { + match self { + Self::LOCAL_FILE => String::from("LOCAL_FILE"), + Self::S3 => String::from("S3"), + Self::GCS => String::from("GCS"), + Self::AZURE => String::from("AZURE"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ReferenceTableCreateSourceType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ReferenceTableCreateSourceType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "LOCAL_FILE" => Self::LOCAL_FILE, + "S3" => Self::S3, + "GCS" => Self::GCS, + "AZURE" => Self::AZURE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_reference_table_schema_field_type.rs b/src/datadogV2/model/model_reference_table_schema_field_type.rs new file mode 100644 index 000000000..856120bf4 --- /dev/null +++ b/src/datadogV2/model/model_reference_table_schema_field_type.rs @@ -0,0 +1,51 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ReferenceTableSchemaFieldType { + STRING, + INT32, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ReferenceTableSchemaFieldType { + fn to_string(&self) -> String { + match self { + Self::STRING => String::from("STRING"), + Self::INT32 => String::from("INT32"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ReferenceTableSchemaFieldType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ReferenceTableSchemaFieldType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "STRING" => Self::STRING, + "INT32" => Self::INT32, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_reference_table_sort_type.rs b/src/datadogV2/model/model_reference_table_sort_type.rs new file mode 100644 index 000000000..667ee64c0 --- /dev/null +++ b/src/datadogV2/model/model_reference_table_sort_type.rs @@ -0,0 +1,63 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ReferenceTableSortType { + UPDATED_AT, + TABLE_NAME, + STATUS, + MINUS_UPDATED_AT, + MINUS_TABLE_NAME, + MINUS_STATUS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ReferenceTableSortType { + fn to_string(&self) -> String { + match self { + Self::UPDATED_AT => String::from("updated_at"), + Self::TABLE_NAME => String::from("table_name"), + Self::STATUS => String::from("status"), + Self::MINUS_UPDATED_AT => String::from("-updated_at"), + Self::MINUS_TABLE_NAME => String::from("-table_name"), + Self::MINUS_STATUS => String::from("-status"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ReferenceTableSortType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ReferenceTableSortType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "updated_at" => Self::UPDATED_AT, + "table_name" => Self::TABLE_NAME, + "status" => Self::STATUS, + "-updated_at" => Self::MINUS_UPDATED_AT, + "-table_name" => Self::MINUS_TABLE_NAME, + "-status" => Self::MINUS_STATUS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_reference_table_source_type.rs b/src/datadogV2/model/model_reference_table_source_type.rs new file mode 100644 index 000000000..8c547e774 --- /dev/null +++ b/src/datadogV2/model/model_reference_table_source_type.rs @@ -0,0 +1,69 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ReferenceTableSourceType { + LOCAL_FILE, + S3, + GCS, + AZURE, + SERVICENOW, + SALESFORCE, + DATABRICKS, + SNOWFLAKE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ReferenceTableSourceType { + fn to_string(&self) -> String { + match self { + Self::LOCAL_FILE => String::from("LOCAL_FILE"), + Self::S3 => String::from("S3"), + Self::GCS => String::from("GCS"), + Self::AZURE => String::from("AZURE"), + Self::SERVICENOW => String::from("SERVICENOW"), + Self::SALESFORCE => String::from("SALESFORCE"), + Self::DATABRICKS => String::from("DATABRICKS"), + Self::SNOWFLAKE => String::from("SNOWFLAKE"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ReferenceTableSourceType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ReferenceTableSourceType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "LOCAL_FILE" => Self::LOCAL_FILE, + "S3" => Self::S3, + "GCS" => Self::GCS, + "AZURE" => Self::AZURE, + "SERVICENOW" => Self::SERVICENOW, + "SALESFORCE" => Self::SALESFORCE, + "DATABRICKS" => Self::DATABRICKS, + "SNOWFLAKE" => Self::SNOWFLAKE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_table_result_v2.rs b/src/datadogV2/model/model_table_result_v2.rs new file mode 100644 index 000000000..a8b1d50fd --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2 { + /// The definition of `TableResultV2Data` object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2 { + pub fn new() -> TableResultV2 { + TableResultV2 { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::TableResultV2Data) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableResultV2 { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TableResultV2 { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2Visitor; + impl<'a> Visitor<'a> for TableResultV2Visitor { + type Value = TableResultV2; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TableResultV2 { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableResultV2Visitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_array.rs b/src/datadogV2/model/model_table_result_v2_array.rs new file mode 100644 index 000000000..5f2c015ca --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_array.rs @@ -0,0 +1,92 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2Array` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2Array { + /// The reference tables. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2Array { + pub fn new(data: Vec) -> TableResultV2Array { + TableResultV2Array { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TableResultV2Array { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2ArrayVisitor; + impl<'a> Visitor<'a> for TableResultV2ArrayVisitor { + type Value = TableResultV2Array; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = TableResultV2Array { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableResultV2ArrayVisitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data.rs b/src/datadogV2/model/model_table_result_v2_data.rs new file mode 100644 index 000000000..37b671141 --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data.rs @@ -0,0 +1,138 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2Data` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2Data { + /// The definition of `TableResultV2DataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the reference table. + #[serde(rename = "id")] + pub id: Option, + /// Reference table resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TableResultV2DataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2Data { + pub fn new(type_: crate::datadogV2::model::TableResultV2DataType) -> TableResultV2Data { + TableResultV2Data { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::TableResultV2DataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TableResultV2Data { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataVisitor; + impl<'a> Visitor<'a> for TableResultV2DataVisitor { + type Value = TableResultV2Data; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TableResultV2DataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TableResultV2Data { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableResultV2DataVisitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes.rs b/src/datadogV2/model/model_table_result_v2_data_attributes.rs new file mode 100644 index 000000000..b53d53db9 --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes.rs @@ -0,0 +1,303 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2DataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributes { + /// UUID of the user who created the reference table. + #[serde(rename = "created_by")] + pub created_by: Option, + /// The description of the reference table. + #[serde(rename = "description")] + pub description: Option, + /// The definition of `TableResultV2DataAttributesFileMetadata` object. + #[serde(rename = "file_metadata")] + pub file_metadata: Option, + /// UUID of the user who last updated the reference table. + #[serde(rename = "last_updated_by")] + pub last_updated_by: Option, + /// The number of successfully processed rows in the reference table. + #[serde(rename = "row_count")] + pub row_count: Option, + /// The definition of `TableResultV2DataAttributesSchema` object. + #[serde(rename = "schema")] + pub schema: Option, + /// The source type for reference table data. Includes all possible source types that can appear in responses. + #[serde(rename = "source")] + pub source: Option, + /// The status of the reference table. + #[serde(rename = "status")] + pub status: Option, + /// The name of the reference table. + #[serde(rename = "table_name")] + pub table_name: Option, + /// The tags of the reference table. + #[serde(rename = "tags")] + pub tags: Option>, + /// The timestamp of the last update to the reference table in ISO 8601 format. + #[serde(rename = "updated_at")] + pub updated_at: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2DataAttributes { + pub fn new() -> TableResultV2DataAttributes { + TableResultV2DataAttributes { + created_by: None, + description: None, + file_metadata: None, + last_updated_by: None, + row_count: None, + schema: None, + source: None, + status: None, + table_name: None, + tags: None, + updated_at: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn created_by(mut self, value: String) -> Self { + self.created_by = Some(value); + self + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn file_metadata( + mut self, + value: crate::datadogV2::model::TableResultV2DataAttributesFileMetadata, + ) -> Self { + self.file_metadata = Some(value); + self + } + + pub fn last_updated_by(mut self, value: String) -> Self { + self.last_updated_by = Some(value); + self + } + + pub fn row_count(mut self, value: i64) -> Self { + self.row_count = Some(value); + self + } + + pub fn schema( + mut self, + value: crate::datadogV2::model::TableResultV2DataAttributesSchema, + ) -> Self { + self.schema = Some(value); + self + } + + pub fn source(mut self, value: crate::datadogV2::model::ReferenceTableSourceType) -> Self { + self.source = Some(value); + self + } + + pub fn status(mut self, value: String) -> Self { + self.status = Some(value); + self + } + + pub fn table_name(mut self, value: String) -> Self { + self.table_name = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn updated_at(mut self, value: String) -> Self { + self.updated_at = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableResultV2DataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesVisitor; + impl<'a> Visitor<'a> for TableResultV2DataAttributesVisitor { + type Value = TableResultV2DataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_by: Option = None; + let mut description: Option = None; + let mut file_metadata: Option< + crate::datadogV2::model::TableResultV2DataAttributesFileMetadata, + > = None; + let mut last_updated_by: Option = None; + let mut row_count: Option = None; + let mut schema: Option = + None; + let mut source: Option = None; + let mut status: Option = None; + let mut table_name: Option = None; + let mut tags: Option> = None; + let mut updated_at: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_by" => { + if v.is_null() { + continue; + } + created_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_metadata" => { + if v.is_null() { + continue; + } + file_metadata = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _file_metadata) = file_metadata { + match _file_metadata { + crate::datadogV2::model::TableResultV2DataAttributesFileMetadata::UnparsedObject(_file_metadata) => { + _unparsed = true; + }, + _ => {} + } + } + } + "last_updated_by" => { + if v.is_null() { + continue; + } + last_updated_by = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "row_count" => { + if v.is_null() { + continue; + } + row_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "schema" => { + if v.is_null() { + continue; + } + schema = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "source" => { + if v.is_null() { + continue; + } + source = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _source) = source { + match _source { + crate::datadogV2::model::ReferenceTableSourceType::UnparsedObject(_source) => { + _unparsed = true; + }, + _ => {} + } + } + } + "status" => { + if v.is_null() { + continue; + } + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "table_name" => { + if v.is_null() { + continue; + } + table_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "updated_at" => { + if v.is_null() { + continue; + } + updated_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TableResultV2DataAttributes { + created_by, + description, + file_metadata, + last_updated_by, + row_count, + schema, + source, + status, + table_name, + tags, + updated_at, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableResultV2DataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata.rs new file mode 100644 index 000000000..2e34f3028 --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata.rs @@ -0,0 +1,47 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::{Deserialize, Deserializer, Serialize}; + +/// The definition of `TableResultV2DataAttributesFileMetadata` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum TableResultV2DataAttributesFileMetadata { + TableResultV2DataAttributesFileMetadataCloudStorage( + Box, + ), + TableResultV2DataAttributesFileMetadataLocalFile( + Box, + ), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesFileMetadata { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(TableResultV2DataAttributesFileMetadata::TableResultV2DataAttributesFileMetadataCloudStorage(_v)); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(TableResultV2DataAttributesFileMetadata::TableResultV2DataAttributesFileMetadataLocalFile(_v)); + } + } + + return Ok(TableResultV2DataAttributesFileMetadata::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_cloud_storage.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_cloud_storage.rs new file mode 100644 index 000000000..c64dc9a44 --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_cloud_storage.rs @@ -0,0 +1,194 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// File metadata for reference tables created by cloud storage. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributesFileMetadataCloudStorage { + /// The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetails` object. + #[serde(rename = "access_details")] + pub access_details: + Option, + /// The error message returned from the sync. + #[serde(rename = "error_message")] + pub error_message: Option, + /// The number of rows that failed to sync. + #[serde(rename = "error_row_count")] + pub error_row_count: Option, + /// The type of error that occurred during file processing. This field provides high-level error categories for easier troubleshooting and is only present when there are errors. + #[serde(rename = "error_type")] + pub error_type: Option< + crate::datadogV2::model::TableResultV2DataAttributesFileMetadataCloudStorageErrorType, + >, + /// Whether this table is synced automatically. + #[serde(rename = "sync_enabled")] + pub sync_enabled: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2DataAttributesFileMetadataCloudStorage { + pub fn new() -> TableResultV2DataAttributesFileMetadataCloudStorage { + TableResultV2DataAttributesFileMetadataCloudStorage { + access_details: None, + error_message: None, + error_row_count: None, + error_type: None, + sync_enabled: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn access_details( + mut self, + value: crate::datadogV2::model::TableResultV2DataAttributesFileMetadataOneOfAccessDetails, + ) -> Self { + self.access_details = Some(value); + self + } + + pub fn error_message(mut self, value: String) -> Self { + self.error_message = Some(value); + self + } + + pub fn error_row_count(mut self, value: i64) -> Self { + self.error_row_count = Some(value); + self + } + + pub fn error_type( + mut self, + value: crate::datadogV2::model::TableResultV2DataAttributesFileMetadataCloudStorageErrorType, + ) -> Self { + self.error_type = Some(value); + self + } + + pub fn sync_enabled(mut self, value: bool) -> Self { + self.sync_enabled = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableResultV2DataAttributesFileMetadataCloudStorage { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesFileMetadataCloudStorage { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesFileMetadataCloudStorageVisitor; + impl<'a> Visitor<'a> for TableResultV2DataAttributesFileMetadataCloudStorageVisitor { + type Value = TableResultV2DataAttributesFileMetadataCloudStorage; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut access_details: Option = None; + let mut error_message: Option = None; + let mut error_row_count: Option = None; + let mut error_type: Option = None; + let mut sync_enabled: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "access_details" => { + if v.is_null() { + continue; + } + access_details = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "error_message" => { + if v.is_null() { + continue; + } + error_message = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "error_row_count" => { + if v.is_null() { + continue; + } + error_row_count = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "error_type" => { + if v.is_null() { + continue; + } + error_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _error_type) = error_type { + match _error_type { + crate::datadogV2::model::TableResultV2DataAttributesFileMetadataCloudStorageErrorType::UnparsedObject(_error_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "sync_enabled" => { + if v.is_null() { + continue; + } + sync_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TableResultV2DataAttributesFileMetadataCloudStorage { + access_details, + error_message, + error_row_count, + error_type, + sync_enabled, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableResultV2DataAttributesFileMetadataCloudStorageVisitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_cloud_storage_error_type.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_cloud_storage_error_type.rs new file mode 100644 index 000000000..23edca10b --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_cloud_storage_error_type.rs @@ -0,0 +1,72 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TableResultV2DataAttributesFileMetadataCloudStorageErrorType { + TABLE_SCHEMA_ERROR, + FILE_FORMAT_ERROR, + CONFIGURATION_ERROR, + QUOTA_EXCEEDED, + CONFLICT_ERROR, + VALIDATION_ERROR, + STATE_ERROR, + OPERATION_ERROR, + SYSTEM_ERROR, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TableResultV2DataAttributesFileMetadataCloudStorageErrorType { + fn to_string(&self) -> String { + match self { + Self::TABLE_SCHEMA_ERROR => String::from("TABLE_SCHEMA_ERROR"), + Self::FILE_FORMAT_ERROR => String::from("FILE_FORMAT_ERROR"), + Self::CONFIGURATION_ERROR => String::from("CONFIGURATION_ERROR"), + Self::QUOTA_EXCEEDED => String::from("QUOTA_EXCEEDED"), + Self::CONFLICT_ERROR => String::from("CONFLICT_ERROR"), + Self::VALIDATION_ERROR => String::from("VALIDATION_ERROR"), + Self::STATE_ERROR => String::from("STATE_ERROR"), + Self::OPERATION_ERROR => String::from("OPERATION_ERROR"), + Self::SYSTEM_ERROR => String::from("SYSTEM_ERROR"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TableResultV2DataAttributesFileMetadataCloudStorageErrorType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesFileMetadataCloudStorageErrorType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "TABLE_SCHEMA_ERROR" => Self::TABLE_SCHEMA_ERROR, + "FILE_FORMAT_ERROR" => Self::FILE_FORMAT_ERROR, + "CONFIGURATION_ERROR" => Self::CONFIGURATION_ERROR, + "QUOTA_EXCEEDED" => Self::QUOTA_EXCEEDED, + "CONFLICT_ERROR" => Self::CONFLICT_ERROR, + "VALIDATION_ERROR" => Self::VALIDATION_ERROR, + "STATE_ERROR" => Self::STATE_ERROR, + "OPERATION_ERROR" => Self::OPERATION_ERROR, + "SYSTEM_ERROR" => Self::SYSTEM_ERROR, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_local_file.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_local_file.rs new file mode 100644 index 000000000..a226e77a1 --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_local_file.rs @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// File metadata for reference tables created by upload. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributesFileMetadataLocalFile { + /// The error message returned from the creation/update. + #[serde(rename = "error_message")] + pub error_message: Option, + /// The number of rows that failed to create/update. + #[serde(rename = "error_row_count")] + pub error_row_count: Option, + /// The upload ID that was used to create/update the table. + #[serde(rename = "upload_id")] + pub upload_id: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2DataAttributesFileMetadataLocalFile { + pub fn new() -> TableResultV2DataAttributesFileMetadataLocalFile { + TableResultV2DataAttributesFileMetadataLocalFile { + error_message: None, + error_row_count: None, + upload_id: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn error_message(mut self, value: String) -> Self { + self.error_message = Some(value); + self + } + + pub fn error_row_count(mut self, value: i64) -> Self { + self.error_row_count = Some(value); + self + } + + pub fn upload_id(mut self, value: String) -> Self { + self.upload_id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableResultV2DataAttributesFileMetadataLocalFile { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesFileMetadataLocalFile { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesFileMetadataLocalFileVisitor; + impl<'a> Visitor<'a> for TableResultV2DataAttributesFileMetadataLocalFileVisitor { + type Value = TableResultV2DataAttributesFileMetadataLocalFile; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut error_message: Option = None; + let mut error_row_count: Option = None; + let mut upload_id: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "error_message" => { + if v.is_null() { + continue; + } + error_message = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "error_row_count" => { + if v.is_null() { + continue; + } + error_row_count = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "upload_id" => { + if v.is_null() { + continue; + } + upload_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TableResultV2DataAttributesFileMetadataLocalFile { + error_message, + error_row_count, + upload_id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableResultV2DataAttributesFileMetadataLocalFileVisitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details.rs new file mode 100644 index 000000000..66b153403 --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details.rs @@ -0,0 +1,150 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetails` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributesFileMetadataOneOfAccessDetails { + /// The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail` object. + #[serde(rename = "aws_detail")] + pub aws_detail: Option, + /// The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail` object. + #[serde(rename = "azure_detail")] + pub azure_detail: Option, + /// The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail` object. + #[serde(rename = "gcp_detail")] + pub gcp_detail: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl TableResultV2DataAttributesFileMetadataOneOfAccessDetails { + pub fn new() -> TableResultV2DataAttributesFileMetadataOneOfAccessDetails { + TableResultV2DataAttributesFileMetadataOneOfAccessDetails { + aws_detail: None, + azure_detail: None, + gcp_detail: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aws_detail( + mut self, + value: crate::datadogV2::model::TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail, + ) -> Self { + self.aws_detail = Some(value); + self + } + + pub fn azure_detail( + mut self, + value: crate::datadogV2::model::TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail, + ) -> Self { + self.azure_detail = Some(value); + self + } + + pub fn gcp_detail( + mut self, + value: crate::datadogV2::model::TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail, + ) -> Self { + self.gcp_detail = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableResultV2DataAttributesFileMetadataOneOfAccessDetails { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesFileMetadataOneOfAccessDetails { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesFileMetadataOneOfAccessDetailsVisitor; + impl<'a> Visitor<'a> for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsVisitor { + type Value = TableResultV2DataAttributesFileMetadataOneOfAccessDetails; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut aws_detail: Option = None; + let mut azure_detail: Option = None; + let mut gcp_detail: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "aws_detail" => { + if v.is_null() { + continue; + } + aws_detail = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_detail" => { + if v.is_null() { + continue; + } + azure_detail = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_detail" => { + if v.is_null() { + continue; + } + gcp_detail = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TableResultV2DataAttributesFileMetadataOneOfAccessDetails { + aws_detail, + azure_detail, + gcp_detail, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(TableResultV2DataAttributesFileMetadataOneOfAccessDetailsVisitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_aws_detail.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_aws_detail.rs new file mode 100644 index 000000000..3eaaf258f --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_aws_detail.rs @@ -0,0 +1,143 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + /// The ID of the AWS account. + #[serde(rename = "aws_account_id")] + pub aws_account_id: Option, + /// The name of the AWS bucket. + #[serde(rename = "aws_bucket_name")] + pub aws_bucket_name: Option, + /// The relative file path from the S3 bucket root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + pub fn new() -> TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + aws_account_id: None, + aws_bucket_name: None, + file_path: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aws_account_id(mut self, value: String) -> Self { + self.aws_account_id = Some(value); + self + } + + pub fn aws_bucket_name(mut self, value: String) -> Self { + self.aws_bucket_name = Some(value); + self + } + + pub fn file_path(mut self, value: String) -> Self { + self.file_path = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor; + impl<'a> Visitor<'a> for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor { + type Value = TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut aws_account_id: Option = None; + let mut aws_bucket_name: Option = None; + let mut file_path: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "aws_account_id" => { + if v.is_null() { + continue; + } + aws_account_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "aws_bucket_name" => { + if v.is_null() { + continue; + } + aws_bucket_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_path" => { + if v.is_null() { + continue; + } + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail { + aws_account_id, + aws_bucket_name, + file_path, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_azure_detail.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_azure_detail.rs new file mode 100644 index 000000000..83b841c6d --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_azure_detail.rs @@ -0,0 +1,184 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + /// The Azure client ID. + #[serde(rename = "azure_client_id")] + pub azure_client_id: Option, + /// The name of the Azure container. + #[serde(rename = "azure_container_name")] + pub azure_container_name: Option, + /// The name of the Azure storage account. + #[serde(rename = "azure_storage_account_name")] + pub azure_storage_account_name: Option, + /// The ID of the Azure tenant. + #[serde(rename = "azure_tenant_id")] + pub azure_tenant_id: Option, + /// The relative file path from the Azure container root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + pub fn new() -> TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + azure_client_id: None, + azure_container_name: None, + azure_storage_account_name: None, + azure_tenant_id: None, + file_path: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn azure_client_id(mut self, value: String) -> Self { + self.azure_client_id = Some(value); + self + } + + pub fn azure_container_name(mut self, value: String) -> Self { + self.azure_container_name = Some(value); + self + } + + pub fn azure_storage_account_name(mut self, value: String) -> Self { + self.azure_storage_account_name = Some(value); + self + } + + pub fn azure_tenant_id(mut self, value: String) -> Self { + self.azure_tenant_id = Some(value); + self + } + + pub fn file_path(mut self, value: String) -> Self { + self.file_path = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> + for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor; + impl<'a> Visitor<'a> + for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor + { + type Value = TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut azure_client_id: Option = None; + let mut azure_container_name: Option = None; + let mut azure_storage_account_name: Option = None; + let mut azure_tenant_id: Option = None; + let mut file_path: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "azure_client_id" => { + if v.is_null() { + continue; + } + azure_client_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_container_name" => { + if v.is_null() { + continue; + } + azure_container_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_storage_account_name" => { + if v.is_null() { + continue; + } + azure_storage_account_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_tenant_id" => { + if v.is_null() { + continue; + } + azure_tenant_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_path" => { + if v.is_null() { + continue; + } + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail { + azure_client_id, + azure_container_name, + azure_storage_account_name, + azure_tenant_id, + file_path, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs new file mode 100644 index 000000000..b5a6681fc --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_file_metadata_one_of_access_details_gcp_detail.rs @@ -0,0 +1,161 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + /// The relative file path from the GCS bucket root to the CSV file. + #[serde(rename = "file_path")] + pub file_path: Option, + /// The name of the GCP bucket. + #[serde(rename = "gcp_bucket_name")] + pub gcp_bucket_name: Option, + /// The ID of the GCP project. + #[serde(rename = "gcp_project_id")] + pub gcp_project_id: Option, + /// The email of the GCP service account. + #[serde(rename = "gcp_service_account_email")] + pub gcp_service_account_email: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + pub fn new() -> TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + file_path: None, + gcp_bucket_name: None, + gcp_project_id: None, + gcp_service_account_email: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn file_path(mut self, value: String) -> Self { + self.file_path = Some(value); + self + } + + pub fn gcp_bucket_name(mut self, value: String) -> Self { + self.gcp_bucket_name = Some(value); + self + } + + pub fn gcp_project_id(mut self, value: String) -> Self { + self.gcp_project_id = Some(value); + self + } + + pub fn gcp_service_account_email(mut self, value: String) -> Self { + self.gcp_service_account_email = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor; + impl<'a> Visitor<'a> for TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor { + type Value = TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut file_path: Option = None; + let mut gcp_bucket_name: Option = None; + let mut gcp_project_id: Option = None; + let mut gcp_service_account_email: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "file_path" => { + if v.is_null() { + continue; + } + file_path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_bucket_name" => { + if v.is_null() { + continue; + } + gcp_bucket_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_project_id" => { + if v.is_null() { + continue; + } + gcp_project_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_service_account_email" => { + if v.is_null() { + continue; + } + gcp_service_account_email = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetail { + file_path, + gcp_bucket_name, + gcp_project_id, + gcp_service_account_email, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + TableResultV2DataAttributesFileMetadataOneOfAccessDetailsGcpDetailVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_schema.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_schema.rs new file mode 100644 index 000000000..9f31ffea6 --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_schema.rs @@ -0,0 +1,109 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2DataAttributesSchema` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributesSchema { + /// The `schema` `fields`. + #[serde(rename = "fields")] + pub fields: Vec, + /// List of field names that serve as primary keys for the table. Only one primary key is supported, and it is used as an ID to retrieve rows. + #[serde(rename = "primary_keys")] + pub primary_keys: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2DataAttributesSchema { + pub fn new( + fields: Vec, + primary_keys: Vec, + ) -> TableResultV2DataAttributesSchema { + TableResultV2DataAttributesSchema { + fields, + primary_keys, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesSchema { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesSchemaVisitor; + impl<'a> Visitor<'a> for TableResultV2DataAttributesSchemaVisitor { + type Value = TableResultV2DataAttributesSchema; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut fields: Option< + Vec, + > = None; + let mut primary_keys: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "fields" => { + fields = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_keys" => { + primary_keys = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let fields = fields.ok_or_else(|| M::Error::missing_field("fields"))?; + let primary_keys = + primary_keys.ok_or_else(|| M::Error::missing_field("primary_keys"))?; + + let content = TableResultV2DataAttributesSchema { + fields, + primary_keys, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableResultV2DataAttributesSchemaVisitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_attributes_schema_fields_items.rs b/src/datadogV2/model/model_table_result_v2_data_attributes_schema_fields_items.rs new file mode 100644 index 000000000..f37a2898e --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_attributes_schema_fields_items.rs @@ -0,0 +1,114 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableResultV2DataAttributesSchemaFieldsItems` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableResultV2DataAttributesSchemaFieldsItems { + /// The field name. + #[serde(rename = "name")] + pub name: String, + /// The field type for reference table schema fields. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ReferenceTableSchemaFieldType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableResultV2DataAttributesSchemaFieldsItems { + pub fn new( + name: String, + type_: crate::datadogV2::model::ReferenceTableSchemaFieldType, + ) -> TableResultV2DataAttributesSchemaFieldsItems { + TableResultV2DataAttributesSchemaFieldsItems { + name, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataAttributesSchemaFieldsItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableResultV2DataAttributesSchemaFieldsItemsVisitor; + impl<'a> Visitor<'a> for TableResultV2DataAttributesSchemaFieldsItemsVisitor { + type Value = TableResultV2DataAttributesSchemaFieldsItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut type_: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ReferenceTableSchemaFieldType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TableResultV2DataAttributesSchemaFieldsItems { + name, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableResultV2DataAttributesSchemaFieldsItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_table_result_v2_data_type.rs b/src/datadogV2/model/model_table_result_v2_data_type.rs new file mode 100644 index 000000000..de69b5c6e --- /dev/null +++ b/src/datadogV2/model/model_table_result_v2_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TableResultV2DataType { + REFERENCE_TABLE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TableResultV2DataType { + fn to_string(&self) -> String { + match self { + Self::REFERENCE_TABLE => String::from("reference_table"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TableResultV2DataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TableResultV2DataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "reference_table" => Self::REFERENCE_TABLE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_table_row_resource_array.rs b/src/datadogV2/model/model_table_row_resource_array.rs new file mode 100644 index 000000000..84d3e2443 --- /dev/null +++ b/src/datadogV2/model/model_table_row_resource_array.rs @@ -0,0 +1,92 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableRowResourceArray` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableRowResourceArray { + /// The rows. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableRowResourceArray { + pub fn new(data: Vec) -> TableRowResourceArray { + TableRowResourceArray { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TableRowResourceArray { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableRowResourceArrayVisitor; + impl<'a> Visitor<'a> for TableRowResourceArrayVisitor { + type Value = TableRowResourceArray; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = TableRowResourceArray { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableRowResourceArrayVisitor) + } +} diff --git a/src/datadogV2/model/model_table_row_resource_data.rs b/src/datadogV2/model/model_table_row_resource_data.rs new file mode 100644 index 000000000..8e6c62b97 --- /dev/null +++ b/src/datadogV2/model/model_table_row_resource_data.rs @@ -0,0 +1,139 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableRowResourceData` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableRowResourceData { + /// The definition of `TableRowResourceDataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the row. + #[serde(rename = "id")] + pub id: Option, + /// Row resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TableRowResourceDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableRowResourceData { + pub fn new(type_: crate::datadogV2::model::TableRowResourceDataType) -> TableRowResourceData { + TableRowResourceData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::TableRowResourceDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TableRowResourceData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableRowResourceDataVisitor; + impl<'a> Visitor<'a> for TableRowResourceDataVisitor { + type Value = TableRowResourceData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::TableRowResourceDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TableRowResourceDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TableRowResourceData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableRowResourceDataVisitor) + } +} diff --git a/src/datadogV2/model/model_table_row_resource_data_attributes.rs b/src/datadogV2/model/model_table_row_resource_data_attributes.rs new file mode 100644 index 000000000..a0905be5d --- /dev/null +++ b/src/datadogV2/model/model_table_row_resource_data_attributes.rs @@ -0,0 +1,106 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TableRowResourceDataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TableRowResourceDataAttributes { + /// The values of the row. + #[serde(rename = "values")] + pub values: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TableRowResourceDataAttributes { + pub fn new() -> TableRowResourceDataAttributes { + TableRowResourceDataAttributes { + values: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn values(mut self, value: std::collections::BTreeMap) -> Self { + self.values = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TableRowResourceDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TableRowResourceDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TableRowResourceDataAttributesVisitor; + impl<'a> Visitor<'a> for TableRowResourceDataAttributesVisitor { + type Value = TableRowResourceDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut values: Option> = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "values" => { + if v.is_null() { + continue; + } + values = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TableRowResourceDataAttributes { + values, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TableRowResourceDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_table_row_resource_data_type.rs b/src/datadogV2/model/model_table_row_resource_data_type.rs new file mode 100644 index 000000000..741641136 --- /dev/null +++ b/src/datadogV2/model/model_table_row_resource_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TableRowResourceDataType { + ROW, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TableRowResourceDataType { + fn to_string(&self) -> String { + match self { + Self::ROW => String::from("row"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TableRowResourceDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TableRowResourceDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "row" => Self::ROW, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/cassettes/v2/reference_tables/Create-reference-table-without-upload-or-access-details-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/reference_tables/Create-reference-table-without-upload-or-access-details-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..2e6c5cff6 --- /dev/null +++ b/tests/scenarios/cassettes/v2/reference_tables/Create-reference-table-without-upload-or-access-details-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-01T20:51:23.877Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/reference_tables/Create-reference-table-without-upload-or-access-details-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/reference_tables/Create-reference-table-without-upload-or-access-details-returns-Bad-Request-response.json new file mode 100644 index 000000000..f8b3a2b2a --- /dev/null +++ b/tests/scenarios/cassettes/v2/reference_tables/Create-reference-table-without-upload-or-access-details-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"description\":\"Test reference table without upload or access details\",\"schema\":{\"fields\":[{\"name\":\"id\",\"type\":\"STRING\"}],\"primary_keys\":[\"id\"]},\"source\":\"LOCAL_FILE\",\"table_name\":\"test_invalid_table_Test-Create_reference_table_without_upload_or_access_details_returns_Bad_Request_response-1759351883\",\"tags\":[\"test_tag\"]},\"type\":\"reference_table\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/reference-tables/tables" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"upload_id is required for tables with 'LOCAL_FILE' source\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Wed, 01 Oct 2025 20:51:23 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/reference_tables.feature b/tests/scenarios/features/v2/reference_tables.feature new file mode 100644 index 000000000..17e66019c --- /dev/null +++ b/tests/scenarios/features/v2/reference_tables.feature @@ -0,0 +1,121 @@ +@endpoint(reference-tables) @endpoint(reference-tables-v2) +Feature: Reference Tables + Auto-generated tag Reference Tables + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ReferenceTables" API + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Create reference table returns "Bad Request" response + Given new "CreateReferenceTable" request + And body with value {"data": {"attributes": {"description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv"}}, "sync_enabled": true}, "schema": {"fields": [{"name": "name", "type": "STRING"}, {"name": "account_id", "type": "STRING"}], "primary_keys": ["account_id"]}, "source": "S3", "table_name": "test_reference_table", "tags": ["test_tag"]}, "type": "reference_table"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Create reference table returns "Created" response + Given new "CreateReferenceTable" request + And body with value {"data": {"attributes": {"description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv"}}, "sync_enabled": true}, "schema": {"fields": [{"name": "name", "type": "STRING"}, {"name": "account_id", "type": "STRING"}], "primary_keys": ["account_id"]}, "source": "S3", "table_name": "test_reference_table", "tags": ["test_tag"]}, "type": "reference_table"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Create reference table upload returns "Bad Request" response + Given new "CreateReferenceTableUpload" request + And body with value {"data": {"attributes": {"headers": [""], "part_count": 3, "part_size": 10000000, "table_name": ""}, "type": "upload"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/redapl-experiences + Scenario: Create reference table upload returns "Created" response + Given new "CreateReferenceTableUpload" request + And body with value {"data": {"attributes": {"headers": ["id", "name", "value"], "table_name": "test_upload_table_{{ unique }}", "part_count": 1, "part_size": 1024}, "type": "upload"}} + When the request is sent + Then the response status is 201 Created + And the response "data.type" is equal to "upload" + And the response "data.attributes.table_name" is equal to "test_upload_table_{{ unique }}" + + @skip @team:DataDog/redapl-experiences + Scenario: Create reference table with upload returns "Created" response + Given new "CreateReferenceTable" request + And body with value {"data": {"attributes": {"description": "Test reference table created via BDD test {{ unique }}", "source": "LOCAL_FILE", "file_metadata": {"upload_id": "test-upload-id-{{ unique }}"}, "schema": {"fields": [{"name": "id", "type": "STRING"}, {"name": "name", "type": "STRING"}, {"name": "value", "type": "INT32"}], "primary_keys": ["id"]}, "table_name": "test_reference_table_{{ unique }}", "tags": ["test_tag"]}, "type": "reference_table"}} + When the request is sent + Then the response status is 201 Created + And the response "data.type" is equal to "reference_table" + And the response "data.attributes.table_name" is equal to "test_reference_table_{{ unique }}" + + @team:DataDog/redapl-experiences + Scenario: Create reference table without upload or access details returns "Bad Request" response + Given new "CreateReferenceTable" request + And body with value {"data": {"attributes": {"description": "Test reference table without upload or access details", "source": "LOCAL_FILE", "schema": {"fields": [{"name": "id", "type": "STRING"}], "primary_keys": ["id"]}, "table_name": "test_invalid_table_{{ unique }}", "tags": ["test_tag"]}, "type": "reference_table"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Delete table returns "Not Found" response + Given new "DeleteTable" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Delete table returns "OK" response + Given new "DeleteTable" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Get rows by id returns "Not Found" response + Given new "GetRowsByID" request + And request contains "id" parameter from "REPLACE.ME" + And request contains "row_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Get rows by id returns "Some or all requested rows were found." response + Given new "GetRowsByID" request + And request contains "id" parameter from "REPLACE.ME" + And request contains "row_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 Some or all requested rows were found. + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Get table returns "Not Found" response + Given new "GetTable" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Get table returns "OK" response + Given new "GetTable" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @skip @team:DataDog/redapl-experiences + Scenario: List tables returns "OK" response + Given new "ListTables" request + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Update reference table returns "Bad Request" response + Given new "UpdateReferenceTable" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv"}}, "sync_enabled": true}, "schema": {"fields": [{"name": "id", "type": "INT32"}, {"name": "name", "type": "STRING"}], "primary_keys": ["id"]}, "sync_enabled": false, "tags": ["test_tag"]}, "id": "00000000-0000-0000-0000-000000000000", "type": "reference_table"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Update reference table returns "OK" response + Given new "UpdateReferenceTable" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv"}}, "sync_enabled": true}, "schema": {"fields": [{"name": "id", "type": "INT32"}, {"name": "name", "type": "STRING"}], "primary_keys": ["id"]}, "sync_enabled": false, "tags": ["test_tag"]}, "id": "00000000-0000-0000-0000-000000000000", "type": "reference_table"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index c4c269d3c..f57ef9065 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2641,6 +2641,55 @@ "type": "idempotent" } }, + "ListTables": { + "tag": "Reference Tables", + "undo": { + "type": "safe" + } + }, + "CreateReferenceTable": { + "tag": "Reference Tables", + "undo": { + "operationId": "DeleteTable", + "parameters": [ + { + "name": "id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteTable": { + "tag": "Reference Tables", + "undo": { + "type": "idempotent" + } + }, + "GetTable": { + "tag": "Reference Tables", + "undo": { + "type": "safe" + } + }, + "UpdateReferenceTable": { + "tag": "Reference Tables", + "undo": { + "type": "idempotent" + } + }, + "GetRowsByID": { + "tag": "Reference Tables", + "undo": { + "type": "safe" + } + }, + "CreateReferenceTableUpload": { + "tag": "Reference Tables", + "undo": { + "type": "idempotent" + } + }, "ListApplicationSecurityWAFCustomRules": { "tag": "Application Security", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index fa1b7b0b8..057f8b266 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -117,6 +117,7 @@ pub struct ApiInstances { pub v2_api_roles: Option, pub v2_api_powerpack: Option, pub v2_api_processes: Option, + pub v2_api_reference_tables: Option, pub v2_api_application_security: Option, pub v2_api_csm_threats: Option, @@ -790,6 +791,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "ReferenceTables" => { + world.api_instances.v2_api_reference_tables = Some( + datadogV2::api_reference_tables::ReferenceTablesAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "ApplicationSecurity" => { world.api_instances.v2_api_application_security = Some( datadogV2::api_application_security::ApplicationSecurityAPI::with_client_and_config( @@ -3544,6 +3553,30 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ListProcessesWithPagination".into(), test_v2_list_processes_with_pagination, ); + world + .function_mappings + .insert("v2.ListTables".into(), test_v2_list_tables); + world.function_mappings.insert( + "v2.CreateReferenceTable".into(), + test_v2_create_reference_table, + ); + world + .function_mappings + .insert("v2.DeleteTable".into(), test_v2_delete_table); + world + .function_mappings + .insert("v2.GetTable".into(), test_v2_get_table); + world.function_mappings.insert( + "v2.UpdateReferenceTable".into(), + test_v2_update_reference_table, + ); + world + .function_mappings + .insert("v2.GetRowsByID".into(), test_v2_get_rows_by_id); + world.function_mappings.insert( + "v2.CreateReferenceTableUpload".into(), + test_v2_create_reference_table_upload, + ); world.function_mappings.insert( "v2.ListApplicationSecurityWAFCustomRules".into(), test_v2_list_application_security_waf_custom_rules, @@ -27184,6 +27217,210 @@ fn test_v2_list_processes_with_pagination( world.response.code = 200; } +fn test_v2_list_tables(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_reference_tables + .as_ref() + .expect("api instance not found"); + let limit = _parameters + .get("limit") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let offset = _parameters + .get("offset") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let sort = _parameters + .get("sort") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_status = _parameters + .get("filter[status]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_table_name_exact = _parameters + .get("filter[table_name][exact]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_table_name_contains = _parameters + .get("filter[table_name][contains]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_reference_tables::ListTablesOptionalParams::default(); + params.limit = limit; + params.offset = offset; + params.sort = sort; + params.filter_status = filter_status; + params.filter_table_name_exact = filter_table_name_exact; + params.filter_table_name_contains = filter_table_name_contains; + let response = match block_on(api.list_tables_with_http_info(params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_reference_table(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_reference_tables + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_reference_table_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_table(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_reference_tables + .as_ref() + .expect("api instance not found"); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_table_with_http_info(id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_table(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_reference_tables + .as_ref() + .expect("api instance not found"); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_table_with_http_info(id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_reference_table(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_reference_tables + .as_ref() + .expect("api instance not found"); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_reference_table_with_http_info(id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_rows_by_id(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_reference_tables + .as_ref() + .expect("api instance not found"); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let row_id = serde_json::from_value(_parameters.get("row_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_rows_by_id_with_http_info(id, row_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_reference_table_upload( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_reference_tables + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_reference_table_upload_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_application_security_waf_custom_rules( world: &mut DatadogWorld, _parameters: &HashMap,