Files
log10ts/src/lib/config.ts
Niklas Nielsen 31eac63741 Update
2024-05-24 17:33:34 -07:00

61 lines
1.6 KiB
TypeScript

/*
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
*/
import { HTTPClient } from "./http";
import { RetryConfig } from "./retries";
import { Params, pathToFunc } from "./url";
/**
* Contains the list of servers available to the SDK
*/
export const ServerList = ["https://log10.io"] as const;
export type SDKOptions = {
log10Token?: string | (() => Promise<string>);
/**
* Allows setting the xLog10Organization parameter for all supported operations
*/
xLog10Organization?: string;
httpClient?: HTTPClient;
/**
* Allows overriding the default server used by the SDK
*/
serverIdx?: number;
/**
* Allows overriding the default server URL used by the SDK
*/
serverURL?: string;
/**
* Allows overriding the default retry config used by the SDK
*/
retryConfig?: RetryConfig;
};
export function serverURLFromOptions(options: SDKOptions): URL | null {
let serverURL = options.serverURL;
const params: Params = {};
if (!serverURL) {
const serverIdx = options.serverIdx ?? 0;
if (serverIdx < 0 || serverIdx >= ServerList.length) {
throw new Error(`Invalid server index ${serverIdx}`);
}
serverURL = ServerList[serverIdx] || "";
}
const u = pathToFunc(serverURL)(params);
return new URL(u);
}
export const SDK_METADATA = {
language: "typescript",
openapiDocVersion: "1.0.0",
sdkVersion: "0.0.3",
genVersion: "2.338.1",
userAgent: "speakeasy-sdk/typescript 0.0.3 2.338.1 1.0.0 log10ts",
} as const;