Skip to content

Latest commit

 

History

History
337 lines (242 loc) · 26.9 KB

README.md

File metadata and controls

337 lines (242 loc) · 26.9 KB

Connections

(connections)

Overview

Available Operations

  • list - List connections
  • generate - Generate a new connection
  • get - Get a connection
  • delete - Delete a connection

list

List connections

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.connections.list({
    projectIdOrName: "<value>",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { connectionsList } from "@amp-labs/sdk-node/funcs/connectionsList.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await connectionsList(sdk, {
    projectIdOrName: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.ListConnectionsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.ListConnectionsResponse>

Errors

Error Type Status Code Content Type
errors.ListConnectionsInputValidationProblem 404 application/problem+json
errors.APIError 4XX, 5XX */*

generate

For providers which support OAuth2 Authorization Code, it is recommended that you use the /oauth-connect endpoint instead, unless you already have the refresh token and are importing it into Ampersand.

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.connections.generate({
    projectIdOrName: "<value>",
    requestBody: {
      groupRef: "<value>",
      consumerRef: "<value>",
      provider: "<value>",
    },
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { connectionsGenerate } from "@amp-labs/sdk-node/funcs/connectionsGenerate.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await connectionsGenerate(sdk, {
    projectIdOrName: "<value>",
    requestBody: {
      groupRef: "<value>",
      consumerRef: "<value>",
      provider: "<value>",
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.GenerateConnectionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.GenerateConnectionResponse>

Errors

Error Type Status Code Content Type
errors.GenerateConnectionInputValidationProblem 400 application/problem+json
errors.GenerateConnectionConnectionsInputValidationProblem 422 application/problem+json
errors.APIError 4XX, 5XX */*

get

Get a connection

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.connections.get({
    projectIdOrName: "<value>",
    connectionId: "<id>",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { connectionsGet } from "@amp-labs/sdk-node/funcs/connectionsGet.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await connectionsGet(sdk, {
    projectIdOrName: "<value>",
    connectionId: "<id>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.GetConnectionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.GetConnectionResponse>

Errors

Error Type Status Code Content Type
errors.GetConnectionInputValidationProblem 404 application/problem+json
errors.APIError 4XX, 5XX */*

delete

Delete a connection

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.connections.delete({
    projectIdOrName: "<value>",
    connectionId: "<id>",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { connectionsDelete } from "@amp-labs/sdk-node/funcs/connectionsDelete.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await connectionsDelete(sdk, {
    projectIdOrName: "<value>",
    connectionId: "<id>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteConnectionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.DeleteConnectionAPIProblem>

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*