Hierarchy

  • ReactQueryNetworkClient
    • CloudServicesClient

Constructors

Properties

alerts: InfiniteQueryObject<
    {
        env: string;
        page?: number;
        pageSize?: number;
        pillar?: "SECURITY"
        | "COST_OPTIMIZATION"
        | "RELIABILITY";
        search?: string;
        severity?: "LOW" | "MEDIUM" | "HIGH" | "MANDATORY";
        sort?: (
            | "STATUS_ASC"
            | "STATUS_DESC"
            | "POLICIES_ASC"
            | "POLICIES_DESC"
            | "PILLAR_ASC"
            | "PILLAR_DESC"
            | "SEVERITY_ASC"
            | "SEVERITY_DESC"
        )[];
        status?: "PENDING"
        | "NOT_APPLICABLE"
        | "COMPLETED";
        workspace: string;
    },
    PaginatedResponseAlert,
    "data",
> = ...

Gets the alerts in a workspace and environment (paginated).

allInstancesOfResource: QueryObject<
    {
        pageToken?: string;
        resourceId: string;
        search?: string;
        workspaceId: string;
    },
    ManagedResourceList,
> = ...

Lists instances of a particular service resource running in a workspace.

allServices: QueryObject<void, FixedManagedService[]> = ...

Lists all managed services.

allTags: QueryObject<{ stackspotAccountId: string }, string[]> = ...

Lists all tags.

billingAccounts: QueryObject<
    { showDeleted?: boolean; stackSpotAccountId: string },
    BillingAccountSummaryResponse[],
> = ...

Retrieves a summary for each billing account of the account with the id passed as parameter.

costAllocation: QueryObject<CostAllocationVariables, CostAllocationResult> = ...

Retrieves cost and usage metrics for the current account.

costAllocationFilters: QueryObject<
    { $type: "SUB_ACCOUNT_ID"
    | "REGION" },
    string[],
> = ...

Lists the filters related to the given type.

costOverview: QueryObject<
    Omit<{ sortBy?: string; sortOrder?: string }, "sortOrder"> & {
        sortOrder?: "asc" | "desc";
    },
    CostOverview,
> = ...

Gets overview of costs over the current month, last month and last 3 months.

downloadCostAllocationCSV: QueryObject<
    {
        endDate: string;
        masterAccount: string;
        stackspotAccountId: string;
        startDate: string;
    },
    AttachmentBase64,
> = ...

Gets a CSV file with the data of costAllocation.

downloadCostOverviewCSV: MutationObject<
    { month: number; year: number },
    AttachmentBase64,
> = ...

Gets a CSV file with the data of costOverview.

enableGuardRail: MutationObject<
    {
        account: string;
        enable: boolean;
        env?: string;
        guardrailId: string;
        workspace?: string;
    },
    unknown,
> = ...

Enables a Guard Rail in any level

guardRails: QueryObject<
    { account: string; env?: string; workspace?: string },
    GroupedGuardrailResponse[],
> = ...

Gets all Guard Rails.

instance: QueryObject<
    { cloudAccountId: string; instanceId: string; resourceId: string },
    string,
> = ...

Gets the description of an instance.

Methods

  • Receives an HttpError and returns a StackspotAPIError.

    Parameters

    • error: HttpError

      the original HttpError created by oazapfts.

    Returns StackspotAPIError

  • Creates a function that checks the permission for a request generated by an oazapfts function.

    This is intended to help creating a manual operation.

    Type Parameters

    • Args extends [variables: Record<string, any>, opts?: RequestOpts] | [opts?: RequestOpts]

    Parameters

    • fn: (...args: Args) => Promise<any>

      the function generated by oazapfts.

    Returns (
        ...args: Args extends [opts?: RequestOpts]
            ? []
            : [variables?: Partial<Args[0]>],
    ) => Promise<boolean>

    a function that receives the variables of fn (if any) and returns a promise that resolves to true if the request is allowed and false otherwise.

    myOperation = this.mutation({
    // ...
    permission: this.createPermissionFunctionFor(oazapftsFnForMyOperation)
    })
  • Creates a function that runs a oazapfts function with an abort signal.

    This is intended to help creating a manual operation.

    Type Parameters

    • Args extends [variables: Record<string, any>, opts?: RequestOpts] | [opts?: RequestOpts]
    • Result

    Parameters

    • fn: (...args: Args) => Promise<Result>

      the function generated by oazapfts.

    Returns (
        ...args: Args extends [opts?: RequestOpts]
            ? [signal: AbortSignal]
            : [signal: AbortSignal, variables: Args[0]],
    ) => Promise<Result>

    a function that receives a signal and the variables of fn (if any) and returns the same as fn.

    myOperation = this.mutation({
    // ...
    request: this.createRequestFunctionFor(oazapftsFnForMyOperation)
    })
  • Makes a request (same signature as globalThis.fetch). This request will prepend the base url to the url and, if there's an active session, include authentication headers.

    Parameters

    • input: string | URL | Request

      the url or request object.

    • Optionalinit: RequestInit

      the fetch options.

    Returns Promise<Response>

    a promise with the Response.

  • Checks whether or not the current account is freemium.

    Returns boolean

    true if it's a freemium account, false otherwise.

  • Builds a mutation manually by using a configuration object.

    Type Parameters

    • Args extends [AbortSignal, Record<string, any>] | [AbortSignal]
    • Result

    Parameters

    • config: OperationConfig<Args, Result>

      the configuration object containing the name, a request function and a permission function.

    Returns MutationObject<Args extends [AbortSignal] ? void : Args[1], Result>

  • Builds a mutation manually by using a configuration object.

    Type Parameters

    • Args extends [AbortSignal, Record<string, any>] | [AbortSignal]
    • Result

    Parameters

    • config: Omit<OperationConfig<Args, Result>, "permission">

      the configuration object containing the name and a request function.

    Returns Omit<
        MutationObject<Args extends [AbortSignal] ? void : Args[1], Result>,
        keyof OperationObject<any>,
    >

  • Builds a mutation automatically by using a function generated by oazapfts.

    Type Parameters

    • Args extends [opts?: RequestOpts] | [variables: Record<string, any>, opts?: RequestOpts]
    • Result

    Parameters

    • fn: (...args: Args) => Promise<Result>

      the oazapfts function.

    Returns Args extends [variables: Variables, opts?: RequestOpts]
        ? MutationObject<Variables, Result>
        : MutationObject<void, Result>

  • Builds a query manually by using a configuration object.

    Type Parameters

    • Args extends [AbortSignal, Record<string, any>] | [AbortSignal]
    • Result

    Parameters

    • config: OperationConfig<Args, Result>

      the configuration object containing the name, a request function and a permission function.

    Returns QueryObject<Args extends [AbortSignal] ? void : Args[1], Result>

  • Builds a query manually by using a configuration object.

    Type Parameters

    • Args extends [AbortSignal, Record<string, any>] | [AbortSignal]
    • Result

    Parameters

    • config: Omit<OperationConfig<Args, Result>, "permission">

      the configuration object containing the name and a request function.

    Returns Omit<
        QueryObject<Args extends [AbortSignal] ? void : Args[1], Result>,
        "isAllowed" | "useAllowed" | "getPermissionKey",
    >

  • Builds a query automatically by using a function generated by oazapfts.

    Type Parameters

    • Args extends [opts?: RequestOpts] | [variables: Record<string, any>, opts?: RequestOpts]
    • Result

    Parameters

    • fn: (...args: Args) => Promise<Result>

      the oazapfts function.

    Returns Args extends [variables: Variables, opts?: RequestOpts]
        ? QueryObject<Variables, Result>
        : QueryObject<void, Result>

  • Verifies if the current user is allowed to send the given request.

    Parameters

    • method: HTTPMethod

      the request's method.

    • path: string

      the path to the resource.

    • Optionalbody: string | object

      the request's body.

    Returns Promise<boolean>

    a promise that resolves to true if it's allowed or false otherwise.

  • Builds a URL with the baseUrl of this network client and the path passed as parameter.

    Parameters

    • path: string

      the path to the resource.

    Returns URL

    a full URL.

  • Reads an EventSource from the endpoint. Differently than the original specification, this allows common HTTP requests with method and body to be made.

    Parameters

    • input: string | URL | Request

      the url or request object.

    • Optionalinit: RequestInit

      the fetch options.

    Returns Promise<FetchEventStream>

    a promise with a FetchEventStream, which is an AsyncGenerator.

    let events = this.stream('url', options)
    for await (let event of events) {
    console.log('<<', event.data)
    }
  • Sets up all network clients. Must be called before attempting to make any request.

    Parameters

    • sessionManager: SessionManager

      An object with functions capable of checking, retrieving and ending the current session.

    • env: Env

      The environment to send the requests to.

    Returns void