Skip to content

Latest commit

 

History

History
570 lines (416 loc) · 33.4 KB

File metadata and controls

570 lines (416 loc) · 33.4 KB

Events

(events)

Overview

REST APIs for managing events captured by a speakeasy binary (CLI, GitHub Action etc)

Available Operations

  • getEventsByTarget - Load recent events for a particular workspace
  • getTargets - Load targets for a particular workspace
  • getTargetsDeprecated - Load targets for a particular workspace
  • post - Post events for a specific workspace
  • search - Search events for a particular workspace by any field

getEventsByTarget

Load recent events for a particular workspace

Example Usage

import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";

const speakeasy = new Speakeasy({
  security: {
    apiKey: "<YOUR_API_KEY_HERE>",
  },
});

async function run() {
  const result = await speakeasy.events.getEventsByTarget({
    workspaceId: "<id>",
    targetId: "<id>",
  });

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

run();

Standalone function

The standalone function version of this method:

import { SpeakeasyCore } from "@speakeasy-api/speakeasy-client-sdk-typescript/core.js";
import { eventsGetEventsByTarget } from "@speakeasy-api/speakeasy-client-sdk-typescript/funcs/eventsGetEventsByTarget.js";

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

async function run() {
  const res = await eventsGetEventsByTarget(speakeasy, {
    workspaceId: "<id>",
    targetId: "<id>",
  });

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

  const { value: result } = res;

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

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.
  useEventsGetEventsByTarget,
  useEventsGetEventsByTargetSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchEventsGetEventsByTarget,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateEventsGetEventsByTarget,
  invalidateAllEventsGetEventsByTarget,
} from "@speakeasy-api/speakeasy-client-sdk-typescript/react-query/eventsGetEventsByTarget.js";

Parameters

Parameter Type Required Description
request operations.GetWorkspaceEventsByTargetRequest ✔️ 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<shared.CliEvent[]>

Errors

Error Type Status Code Content Type
errors.ErrorT 5XX application/json
errors.SDKError 4XX */*

getTargets

Load targets for a particular workspace

Example Usage

import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";

const speakeasy = new Speakeasy({
  security: {
    apiKey: "<YOUR_API_KEY_HERE>",
  },
});

async function run() {
  const result = await speakeasy.events.getTargets({});

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

run();

Standalone function

The standalone function version of this method:

import { SpeakeasyCore } from "@speakeasy-api/speakeasy-client-sdk-typescript/core.js";
import { eventsGetTargets } from "@speakeasy-api/speakeasy-client-sdk-typescript/funcs/eventsGetTargets.js";

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

async function run() {
  const res = await eventsGetTargets(speakeasy, {});

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

  const { value: result } = res;

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

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.
  useEventsGetTargets,
  useEventsGetTargetsSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchEventsGetTargets,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateEventsGetTargets,
  invalidateAllEventsGetTargets,
} from "@speakeasy-api/speakeasy-client-sdk-typescript/react-query/eventsGetTargets.js";

Parameters

Parameter Type Required Description
request operations.GetWorkspaceTargetsRequest ✔️ 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<shared.TargetSDK[]>

Errors

Error Type Status Code Content Type
errors.ErrorT 5XX application/json
errors.SDKError 4XX */*

getTargetsDeprecated

Load targets for a particular workspace

Example Usage

import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";

const speakeasy = new Speakeasy({
  security: {
    apiKey: "<YOUR_API_KEY_HERE>",
  },
});

async function run() {
  const result = await speakeasy.events.getTargetsDeprecated({
    workspaceId: "<id>",
  });

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

run();

Standalone function

The standalone function version of this method:

import { SpeakeasyCore } from "@speakeasy-api/speakeasy-client-sdk-typescript/core.js";
import { eventsGetTargetsDeprecated } from "@speakeasy-api/speakeasy-client-sdk-typescript/funcs/eventsGetTargetsDeprecated.js";

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

async function run() {
  const res = await eventsGetTargetsDeprecated(speakeasy, {
    workspaceId: "<id>",
  });

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

  const { value: result } = res;

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

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.
  useEventsGetTargetsDeprecated,
  useEventsGetTargetsDeprecatedSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchEventsGetTargetsDeprecated,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateEventsGetTargetsDeprecated,
  invalidateAllEventsGetTargetsDeprecated,
} from "@speakeasy-api/speakeasy-client-sdk-typescript/react-query/eventsGetTargetsDeprecated.js";

Parameters

Parameter Type Required Description
request operations.GetWorkspaceTargetsDeprecatedRequest ✔️ 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<shared.TargetSDK[]>

Errors

Error Type Status Code Content Type
errors.ErrorT 5XX application/json
errors.SDKError 4XX */*

post

Sends an array of events to be stored for a particular workspace.

Example Usage

import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";

const speakeasy = new Speakeasy({
  security: {
    apiKey: "<YOUR_API_KEY_HERE>",
  },
});

async function run() {
  await speakeasy.events.post({
    workspaceId: "<id>",
    requestBody: [
      {
        createdAt: new Date("2025-03-02T10:07:28.113Z"),
        executionId: "<id>",
        id: "<id>",
        interactionType: "AUTHENTICATE",
        localStartedAt: new Date("2025-08-12T17:54:17.538Z"),
        speakeasyApiKeyName: "<value>",
        speakeasyVersion: "<value>",
        success: true,
        workspaceId: "<id>",
      },
    ],
  });


}

run();

Standalone function

The standalone function version of this method:

import { SpeakeasyCore } from "@speakeasy-api/speakeasy-client-sdk-typescript/core.js";
import { eventsPost } from "@speakeasy-api/speakeasy-client-sdk-typescript/funcs/eventsPost.js";

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

async function run() {
  const res = await eventsPost(speakeasy, {
    workspaceId: "<id>",
    requestBody: [
      {
        createdAt: new Date("2025-03-02T10:07:28.113Z"),
        executionId: "<id>",
        id: "<id>",
        interactionType: "AUTHENTICATE",
        localStartedAt: new Date("2025-08-12T17:54:17.538Z"),
        speakeasyApiKeyName: "<value>",
        speakeasyVersion: "<value>",
        success: true,
        workspaceId: "<id>",
      },
    ],
  });

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

  const { value: result } = res;

  
}

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.
  useEventsPostMutation
} from "@speakeasy-api/speakeasy-client-sdk-typescript/react-query/eventsPost.js";

Parameters

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

Errors

Error Type Status Code Content Type
errors.ErrorT 5XX application/json
errors.SDKError 4XX */*

search

Search events for a particular workspace by any field

Example Usage

import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";

const speakeasy = new Speakeasy({
  security: {
    apiKey: "<YOUR_API_KEY_HERE>",
  },
});

async function run() {
  const result = await speakeasy.events.search({
    workspaceId: "<id>",
  });

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

run();

Standalone function

The standalone function version of this method:

import { SpeakeasyCore } from "@speakeasy-api/speakeasy-client-sdk-typescript/core.js";
import { eventsSearch } from "@speakeasy-api/speakeasy-client-sdk-typescript/funcs/eventsSearch.js";

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

async function run() {
  const res = await eventsSearch(speakeasy, {
    workspaceId: "<id>",
  });

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

  const { value: result } = res;

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

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.
  useEventsSearch,
  useEventsSearchSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchEventsSearch,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateEventsSearch,
  invalidateAllEventsSearch,
} from "@speakeasy-api/speakeasy-client-sdk-typescript/react-query/eventsSearch.js";

Parameters

Parameter Type Required Description
request operations.SearchWorkspaceEventsRequest ✔️ 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<shared.CliEvent[]>

Errors

Error Type Status Code Content Type
errors.ErrorT 5XX application/json
errors.SDKError 4XX */*