Skip to content

Latest commit

 

History

History
413 lines (300 loc) · 36 KB

File metadata and controls

413 lines (300 loc) · 36 KB

Client.Datasources

Overview

Available Operations

retrieveConfiguration

Gets the greenlisted configuration values for a datasource instance. Returns only configuration keys that are exposed via the public API greenlist.

Example Usage

import { Glean } from "@gleanwork/api-client";

const glean = new Glean({
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
});

async function run() {
  const result = await glean.client.datasources.retrieveConfiguration("o365sharepoint", "o365sharepoint_abc123");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { GleanCore } from "@gleanwork/api-client/core.js";
import { clientDatasourcesRetrieveConfiguration } from "@gleanwork/api-client/funcs/clientDatasourcesRetrieveConfiguration.js";

// Use `GleanCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const glean = new GleanCore({
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
});

async function run() {
  const res = await clientDatasourcesRetrieveConfiguration(glean, "o365sharepoint", "o365sharepoint_abc123");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("clientDatasourcesRetrieveConfiguration failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

import {
  // Query hooks for fetching data.
  useClientDatasourcesRetrieveConfiguration,
  useClientDatasourcesRetrieveConfigurationSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchClientDatasourcesRetrieveConfiguration,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateClientDatasourcesRetrieveConfiguration,
  invalidateAllClientDatasourcesRetrieveConfiguration,
} from "@gleanwork/api-client/react-query/clientDatasourcesRetrieveConfiguration.js";

Parameters

Parameter Type Required Description Example
datasourceId string ✔️ The datasource type identifier (e.g. o365sharepoint) o365sharepoint
instanceId string ✔️ The datasource instance identifier o365sharepoint_abc123
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<components.DatasourceConfigurationResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400, 403, 404 application/json
errors.GleanError 4XX, 5XX */*

updateConfiguration

Updates the greenlisted configuration values for a datasource instance. Only configuration keys that are exposed via the public API greenlist may be set. Returns the full greenlisted configuration after the update is applied.

Example Usage

import { Glean } from "@gleanwork/api-client";

const glean = new Glean({
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
});

async function run() {
  const result = await glean.client.datasources.updateConfiguration({
    configuration: {
      values: {

      },
    },
  }, "o365sharepoint", "o365sharepoint_abc123");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { GleanCore } from "@gleanwork/api-client/core.js";
import { clientDatasourcesUpdateConfiguration } from "@gleanwork/api-client/funcs/clientDatasourcesUpdateConfiguration.js";

// Use `GleanCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const glean = new GleanCore({
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
});

async function run() {
  const res = await clientDatasourcesUpdateConfiguration(glean, {
    configuration: {
      values: {
  
      },
    },
  }, "o365sharepoint", "o365sharepoint_abc123");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("clientDatasourcesUpdateConfiguration failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

import {
  // Mutation hook for triggering the API call.
  useClientDatasourcesUpdateConfigurationMutation
} from "@gleanwork/api-client/react-query/clientDatasourcesUpdateConfiguration.js";

Parameters

Parameter Type Required Description Example
datasourceId string ✔️ The datasource type identifier (e.g. o365sharepoint) o365sharepoint
instanceId string ✔️ The datasource instance identifier o365sharepoint_abc123
updateDatasourceConfigurationRequest components.UpdateDatasourceConfigurationRequest ✔️ N/A
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<components.DatasourceConfigurationResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400, 403, 404 application/json
errors.GleanError 4XX, 5XX */*

retrieveCredentialStatus

Returns the current credential status for a datasource instance. Access is limited to callers with the ADMIN scope; the handler enforces this check.

Example Usage

import { Glean } from "@gleanwork/api-client";

const glean = new Glean({
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
});

async function run() {
  const result = await glean.client.datasources.retrieveCredentialStatus("o365sharepoint_abc123");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { GleanCore } from "@gleanwork/api-client/core.js";
import { clientDatasourcesRetrieveCredentialStatus } from "@gleanwork/api-client/funcs/clientDatasourcesRetrieveCredentialStatus.js";

// Use `GleanCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const glean = new GleanCore({
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
});

async function run() {
  const res = await clientDatasourcesRetrieveCredentialStatus(glean, "o365sharepoint_abc123");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("clientDatasourcesRetrieveCredentialStatus failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

import {
  // Query hooks for fetching data.
  useClientDatasourcesRetrieveCredentialStatus,
  useClientDatasourcesRetrieveCredentialStatusSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchClientDatasourcesRetrieveCredentialStatus,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateClientDatasourcesRetrieveCredentialStatus,
  invalidateAllClientDatasourcesRetrieveCredentialStatus,
} from "@gleanwork/api-client/react-query/clientDatasourcesRetrieveCredentialStatus.js";

Parameters

Parameter Type Required Description Example
datasourceInstanceId string ✔️ The full datasource instance identifier (e.g. o365sharepoint_abc123) o365sharepoint_abc123
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<components.DatasourceCredentialStatusResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400, 403, 404 application/json
errors.GleanError 4XX, 5XX */*

rotateCredentials

Rotates the credentials that a datasource instance uses to connect to its upstream system. Replaces the active credential material with the supplied values and returns the credential status after rotation. Access is limited to callers with the ADMIN scope; the handler enforces this check. Only keys recognized as credential material for the datasource type may be set in credentials.values (e.g. clientSecret, apiToken, privateKey, depending on the configured auth method). Unrecognized keys, or keys that correspond to non-credential configuration, cause a 400; other instance configuration must be updated via PATCH /configure/datasources/{datasourceId}/instances/{instanceId}.

Example Usage

import { Glean } from "@gleanwork/api-client";

const glean = new Glean({
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
});

async function run() {
  const result = await glean.client.datasources.rotateCredentials({
    credentials: {
      values: {
        "key": {},
      },
    },
  }, "o365sharepoint_abc123");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { GleanCore } from "@gleanwork/api-client/core.js";
import { clientDatasourcesRotateCredentials } from "@gleanwork/api-client/funcs/clientDatasourcesRotateCredentials.js";

// Use `GleanCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const glean = new GleanCore({
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
});

async function run() {
  const res = await clientDatasourcesRotateCredentials(glean, {
    credentials: {
      values: {
        "key": {},
      },
    },
  }, "o365sharepoint_abc123");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("clientDatasourcesRotateCredentials failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

import {
  // Mutation hook for triggering the API call.
  useClientDatasourcesRotateCredentialsMutation
} from "@gleanwork/api-client/react-query/clientDatasourcesRotateCredentials.js";

Parameters

Parameter Type Required Description Example
datasourceInstanceId string ✔️ The full datasource instance identifier (e.g. o365sharepoint_abc123) o365sharepoint_abc123
rotateDatasourceCredentialsRequest components.RotateDatasourceCredentialsRequest ✔️ N/A
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<components.DatasourceCredentialStatusResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400, 403, 404 application/json
errors.GleanError 4XX, 5XX */*