Skip to content

Latest commit

 

History

History
116 lines (92 loc) · 7.75 KB

File metadata and controls

116 lines (92 loc) · 7.75 KB

Proxy

Overview

Routing API requests through StackOne directly to the underlying provider.

Available Operations

proxyRequest

Proxy Request

Example Usage

import { StackOne } from "@stackone/stackone-client-ts";

const stackOne = new StackOne({
  security: {
    password: "",
    username: "",
  },
});

async function run() {
  const result = await stackOne.proxy.proxyRequest({
    prefer: "heartbeat",
    proxyRequestBody: {
      headers: {
        "Content-Type": "application/json",
      },
      path: "/employees/directory",
      url: "https://api.sample-integration.com/v1",
    },
    xAccountId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { StackOneCore } from "@stackone/stackone-client-ts/core.js";
import { proxyProxyRequest } from "@stackone/stackone-client-ts/funcs/proxyProxyRequest.js";

// Use `StackOneCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const stackOne = new StackOneCore({
  security: {
    password: "",
    username: "",
  },
});

async function run() {
  const res = await proxyProxyRequest(stackOne, {
    prefer: "heartbeat",
    proxyRequestBody: {
      headers: {
        "Content-Type": "application/json",
      },
      path: "/employees/directory",
      url: "https://api.sample-integration.com/v1",
    },
    xAccountId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("proxyProxyRequest failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.StackoneProxyRequestRequest ✔️ 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.

Response

Promise<operations.StackoneProxyRequestResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponse 400 application/json
errors.UnauthorizedResponse 401 application/json
errors.ForbiddenResponse 403 application/json
errors.NotFoundResponse 404 application/json
errors.RequestTimedOutResponse 408 application/json
errors.ConflictResponse 409 application/json
errors.PreconditionFailedResponse 412 application/json
errors.UnprocessableEntityResponse 422 application/json
errors.TooManyRequestsResponse 429 application/json
errors.InternalServerErrorResponse 500 application/json
errors.NotImplementedResponse 501 application/json
errors.BadGatewayResponse 502 application/json
errors.SDKError 4XX, 5XX */*