Create reference table upload

POST https://api.ap1.datadoghq.com/api/v2/reference-tables/uploadshttps://api.ap2.datadoghq.com/api/v2/reference-tables/uploadshttps://api.datadoghq.eu/api/v2/reference-tables/uploadshttps://api.ddog-gov.com/api/v2/reference-tables/uploadshttps://api.us2.ddog-gov.com/api/v2/reference-tables/uploadshttps://api.uk1.datadoghq.com/api/v2/reference-tables/uploadshttps://api.datadoghq.com/api/v2/reference-tables/uploadshttps://api.us3.datadoghq.com/api/v2/reference-tables/uploadshttps://api.us5.datadoghq.com/api/v2/reference-tables/uploads

Présentation

Créer une importation de table de référence pour l’ingestion de données en masse

Requête

Body Data (required)

Expand All

Champ

Type

Description

data

object

Request data for creating an upload for a file to be ingested into a reference table.

attributes

object

Upload configuration specifying how data is uploaded by the user, and properties of the table to associate the upload with.

headers [required]

[string]

The CSV file headers that define the schema fields, provided in the same order as the columns in the uploaded file.

part_count [required]

int32

Number of parts to split the file into for multipart upload.

part_size [required]

int64

The size of each part in the upload in bytes. All parts except the last one must be at least 5,000,000 bytes.

table_name [required]

string

Name of the table to associate with this upload.

type [required]

enum

Upload resource type. Allowed enum values: upload

default: upload

{
  "data": {
    "attributes": {
      "headers": [
        "field_1",
        "field_2"
      ],
      "part_count": 3,
      "part_size": 10000000,
      "table_name": ""
    },
    "type": "upload"
  }
}

Réponse

Created

Information about the upload created containing the upload ID and pre-signed URLs to PUT chunks of the CSV file to.

Expand All

Champ

Type

Description

data

object

Upload ID and attributes of the created upload.

attributes

object

Pre-signed URLs for uploading parts of the file.

part_urls

[string]

The pre-signed URLs for uploading parts. These URLs expire after 5 minutes.

id

string

Unique identifier for this upload. Use this ID when creating the reference table.

type [required]

enum

Upload resource type. Allowed enum values: upload

default: upload

{
  "data": {
    "attributes": {
      "part_urls": []
    },
    "id": "string",
    "type": "upload"
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code

                  ## default
# 

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/reference-tables/uploads" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "headers": [ "product_id", "product_name", "price" ], "part_count": 3, "part_size": 10000000, "table_name": "my_products_table" }, "type": "upload" } } EOF
"""
Create reference table upload returns "Created" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.reference_tables_api import ReferenceTablesApi
from datadog_api_client.v2.model.create_upload_request import CreateUploadRequest
from datadog_api_client.v2.model.create_upload_request_data import CreateUploadRequestData
from datadog_api_client.v2.model.create_upload_request_data_attributes import CreateUploadRequestDataAttributes
from datadog_api_client.v2.model.create_upload_request_data_type import CreateUploadRequestDataType

body = CreateUploadRequest(
    data=CreateUploadRequestData(
        attributes=CreateUploadRequestDataAttributes(
            headers=[
                "id",
                "name",
                "value",
            ],
            table_name="test_upload_table_Example-Reference-Table",
            part_count=1,
            part_size=1024,
        ),
        type=CreateUploadRequestDataType.UPLOAD,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = ReferenceTablesApi(api_client)
    response = api_instance.create_reference_table_upload(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Create reference table upload returns "Created" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::ReferenceTablesAPI.new

body = DatadogAPIClient::V2::CreateUploadRequest.new({
  data: DatadogAPIClient::V2::CreateUploadRequestData.new({
    attributes: DatadogAPIClient::V2::CreateUploadRequestDataAttributes.new({
      headers: [
        "id",
        "name",
        "value",
      ],
      table_name: "test_upload_table_Example-Reference-Table",
      part_count: 1,
      part_size: 1024,
    }),
    type: DatadogAPIClient::V2::CreateUploadRequestDataType::UPLOAD,
  }),
})
p api_instance.create_reference_table_upload(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Create reference table upload returns "Created" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.CreateUploadRequest{
		Data: &datadogV2.CreateUploadRequestData{
			Attributes: &datadogV2.CreateUploadRequestDataAttributes{
				Headers: []string{
					"id",
					"name",
					"value",
				},
				TableName: "test_upload_table_Example-Reference-Table",
				PartCount: 1,
				PartSize:  1024,
			},
			Type: datadogV2.CREATEUPLOADREQUESTDATATYPE_UPLOAD,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewReferenceTablesApi(apiClient)
	resp, r, err := api.CreateReferenceTableUpload(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ReferenceTablesApi.CreateReferenceTableUpload`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ReferenceTablesApi.CreateReferenceTableUpload`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create reference table upload returns "Created" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ReferenceTablesApi;
import com.datadog.api.client.v2.model.CreateUploadRequest;
import com.datadog.api.client.v2.model.CreateUploadRequestData;
import com.datadog.api.client.v2.model.CreateUploadRequestDataAttributes;
import com.datadog.api.client.v2.model.CreateUploadRequestDataType;
import com.datadog.api.client.v2.model.CreateUploadResponse;
import java.util.Arrays;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    ReferenceTablesApi apiInstance = new ReferenceTablesApi(defaultClient);

    CreateUploadRequest body =
        new CreateUploadRequest()
            .data(
                new CreateUploadRequestData()
                    .attributes(
                        new CreateUploadRequestDataAttributes()
                            .headers(Arrays.asList("id", "name", "value"))
                            .tableName("test_upload_table_Example-Reference-Table")
                            .partCount(1)
                            .partSize(1024L))
                    .type(CreateUploadRequestDataType.UPLOAD));

    try {
      CreateUploadResponse result = apiInstance.createReferenceTableUpload(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ReferenceTablesApi#createReferenceTableUpload");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// 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());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Create reference table upload returns "Created" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.ReferenceTablesApi(configuration);

const params: v2.ReferenceTablesApiCreateReferenceTableUploadRequest = {
  body: {
    data: {
      attributes: {
        headers: ["id", "name", "value"],
        tableName: "test_upload_table_Example-Reference-Table",
        partCount: 1,
        partSize: 1024,
      },
      type: "upload",
    },
  },
};

apiInstance
  .createReferenceTableUpload(params)
  .then((data: v2.CreateUploadResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"