Skip to content

Latest commit

 

History

History
83 lines (59 loc) · 5.24 KB

File metadata and controls

83 lines (59 loc) · 5.24 KB

Keys

Overview

Usage & Quotas

Available Operations

getUsage

Get Usage Stats

Example Usage

import { WaveShield } from "waveshield";

const waveShield = new WaveShield({
  security: {
    apiKeyAuth: process.env["WAVESHIELD_API_KEY_AUTH"] ?? "",
    apiSecretAuth: process.env["WAVESHIELD_API_SECRET_AUTH"] ?? "",
  },
});

async function run() {
  const result = await waveShield.keys.getUsage();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { WaveShieldCore } from "waveshield/core.js";
import { keysGetUsage } from "waveshield/funcs/keysGetUsage.js";

// Use `WaveShieldCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const waveShield = new WaveShieldCore({
  security: {
    apiKeyAuth: process.env["WAVESHIELD_API_KEY_AUTH"] ?? "",
    apiSecretAuth: process.env["WAVESHIELD_API_SECRET_AUTH"] ?? "",
  },
});

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

run();

Parameters

Parameter Type Required Description
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.GetV1KeysUsageResponse>

Errors

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