levelfour 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.fernignore +9 -0
- package/BaseClient.ts +56 -0
- package/Client.ts +90 -0
- package/LevelFourClient.ts +50 -0
- package/api/errors/UnprocessableEntityError.ts +22 -0
- package/api/errors/index.ts +1 -0
- package/api/index.ts +3 -0
- package/api/resources/apiKeys/client/Client.ts +298 -0
- package/api/resources/apiKeys/client/index.ts +1 -0
- package/api/resources/apiKeys/client/requests/CreateApiKeyRequest.ts +23 -0
- package/api/resources/apiKeys/client/requests/ListApiKeysApiV1ApiKeysGetRequest.ts +11 -0
- package/api/resources/apiKeys/client/requests/RevokeApiKeyApiV1ApiKeysKeyIdDeleteRequest.ts +14 -0
- package/api/resources/apiKeys/client/requests/RotateApiKeyApiV1ApiKeysKeyIdRotatePostRequest.ts +14 -0
- package/api/resources/apiKeys/client/requests/index.ts +4 -0
- package/api/resources/apiKeys/exports.ts +4 -0
- package/api/resources/apiKeys/index.ts +1 -0
- package/api/resources/evaluation/client/Client.ts +71 -0
- package/api/resources/evaluation/client/index.ts +1 -0
- package/api/resources/evaluation/exports.ts +4 -0
- package/api/resources/evaluation/index.ts +1 -0
- package/api/resources/health/client/Client.ts +108 -0
- package/api/resources/health/client/index.ts +1 -0
- package/api/resources/health/exports.ts +4 -0
- package/api/resources/health/index.ts +1 -0
- package/api/resources/index.ts +24 -0
- package/api/resources/prAnalysis/client/Client.ts +100 -0
- package/api/resources/prAnalysis/client/index.ts +1 -0
- package/api/resources/prAnalysis/client/requests/AnalyzePrRequest.ts +30 -0
- package/api/resources/prAnalysis/client/requests/index.ts +1 -0
- package/api/resources/prAnalysis/exports.ts +4 -0
- package/api/resources/prAnalysis/index.ts +1 -0
- package/api/resources/prAnalysisActions/client/Client.ts +418 -0
- package/api/resources/prAnalysisActions/client/index.ts +1 -0
- package/api/resources/prAnalysisActions/client/requests/DismissSuggestionsApiV1PrAnalysisActionsDismissPostRequest.ts +21 -0
- package/api/resources/prAnalysisActions/client/requests/GetIgnoredResourcesApiV1PrAnalysisActionsIgnoreGetRequest.ts +15 -0
- package/api/resources/prAnalysisActions/client/requests/GetPrStatusApiV1PrAnalysisActionsStatusGetRequest.ts +15 -0
- package/api/resources/prAnalysisActions/client/requests/IgnoreRequest.ts +21 -0
- package/api/resources/prAnalysisActions/client/requests/SnoozeSuggestionsApiV1PrAnalysisActionsSnoozePostRequest.ts +21 -0
- package/api/resources/prAnalysisActions/client/requests/index.ts +5 -0
- package/api/resources/prAnalysisActions/exports.ts +4 -0
- package/api/resources/prAnalysisActions/index.ts +1 -0
- package/api/resources/prAnalysisInstallations/client/Client.ts +410 -0
- package/api/resources/prAnalysisInstallations/client/index.ts +1 -0
- package/api/resources/prAnalysisInstallations/client/requests/AddReposRequest.ts +17 -0
- package/api/resources/prAnalysisInstallations/client/requests/DeleteInstallationApiV1PrAnalysisInstallationsInstallationIdDeleteRequest.ts +15 -0
- package/api/resources/prAnalysisInstallations/client/requests/ListInstallationsApiV1PrAnalysisInstallationsGetRequest.ts +13 -0
- package/api/resources/prAnalysisInstallations/client/requests/RegisterInstallationRequest.ts +16 -0
- package/api/resources/prAnalysisInstallations/client/requests/RemoveReposRequest.ts +17 -0
- package/api/resources/prAnalysisInstallations/client/requests/index.ts +5 -0
- package/api/resources/prAnalysisInstallations/exports.ts +4 -0
- package/api/resources/prAnalysisInstallations/index.ts +1 -0
- package/api/resources/prAnalysisQuery/client/Client.ts +169 -0
- package/api/resources/prAnalysisQuery/client/index.ts +1 -0
- package/api/resources/prAnalysisQuery/client/requests/ExplainRequest.ts +17 -0
- package/api/resources/prAnalysisQuery/client/requests/WhatifRequest.ts +21 -0
- package/api/resources/prAnalysisQuery/client/requests/index.ts +2 -0
- package/api/resources/prAnalysisQuery/exports.ts +4 -0
- package/api/resources/prAnalysisQuery/index.ts +1 -0
- package/api/resources/providers/client/Client.ts +991 -0
- package/api/resources/providers/client/index.ts +1 -0
- package/api/resources/providers/client/requests/GetProviderFilterOptionsApiV1ProvidersProviderIdSpendingFilterOptionsGetRequest.ts +17 -0
- package/api/resources/providers/client/requests/GetProviderPotentialSavingsBreakdownApiV1ProvidersProviderIdPotentialSavingsBreakdownGetRequest.ts +19 -0
- package/api/resources/providers/client/requests/GetProviderPotentialSavingsSummaryApiV1ProvidersProviderIdPotentialSavingsSummaryGetRequest.ts +11 -0
- package/api/resources/providers/client/requests/GetProviderRecommendationFilterOptionsApiV1ProvidersProviderIdRecommendationsFilterOptionsGetRequest.ts +11 -0
- package/api/resources/providers/client/requests/GetProviderRecommendationsBreakdownApiV1ProvidersProviderIdRecommendationsGetRequest.ts +33 -0
- package/api/resources/providers/client/requests/GetProviderRecommendationsOverviewApiV1ProvidersProviderIdRecommendationsOverviewGetRequest.ts +11 -0
- package/api/resources/providers/client/requests/GetProviderRecommendationsSummaryApiV1ProvidersProviderIdRecommendationsSummaryGetRequest.ts +11 -0
- package/api/resources/providers/client/requests/GetProviderSavedSummaryApiV1ProvidersProviderIdSavingsSummaryGetRequest.ts +11 -0
- package/api/resources/providers/client/requests/GetProviderServiceBreakdownApiV1ProvidersProviderIdSpendingBreakdownGetRequest.ts +45 -0
- package/api/resources/providers/client/requests/GetProviderSpendingSummaryApiV1ProvidersProviderIdSpendingSummaryGetRequest.ts +11 -0
- package/api/resources/providers/client/requests/GetProviderSpendingTimelineApiV1ProvidersProviderIdSpendingTimelineGetRequest.ts +17 -0
- package/api/resources/providers/client/requests/GetSavedByProviderBreakdownApiV1ProvidersProviderIdSavingsBreakdownGetRequest.ts +31 -0
- package/api/resources/providers/client/requests/index.ts +12 -0
- package/api/resources/providers/exports.ts +4 -0
- package/api/resources/providers/index.ts +2 -0
- package/api/resources/providers/types/GetProviderServiceBreakdownApiV1ProvidersProviderIdSpendingBreakdownGetResponse.ts +8 -0
- package/api/resources/providers/types/index.ts +1 -0
- package/api/resources/recommendations/client/Client.ts +815 -0
- package/api/resources/recommendations/client/index.ts +1 -0
- package/api/resources/recommendations/client/requests/AcceptTermsApiV1RecommendationsRecommendationIdAcceptTermsPostRequest.ts +11 -0
- package/api/resources/recommendations/client/requests/CompleteWizardApiV1RecommendationsRecommendationIdCompletePostRequest.ts +11 -0
- package/api/resources/recommendations/client/requests/GetRecommendationDetailsApiV1RecommendationsRecommendationIdDetailsGetRequest.ts +11 -0
- package/api/resources/recommendations/client/requests/GetRecommendationForWizardApiV1RecommendationsRecommendationIdGetRequest.ts +11 -0
- package/api/resources/recommendations/client/requests/GetRecommendationsApiV1RecommendationsGetRequest.ts +16 -0
- package/api/resources/recommendations/client/requests/ImplementationMethodRequest.ts +14 -0
- package/api/resources/recommendations/client/requests/SavingsDecisionRequest.ts +18 -0
- package/api/resources/recommendations/client/requests/UpdateTagRequest.ts +13 -0
- package/api/resources/recommendations/client/requests/index.ts +8 -0
- package/api/resources/recommendations/exports.ts +4 -0
- package/api/resources/recommendations/index.ts +1 -0
- package/api/resources/savings/client/Client.ts +231 -0
- package/api/resources/savings/client/index.ts +1 -0
- package/api/resources/savings/client/requests/ExecutionRequestBody.ts +15 -0
- package/api/resources/savings/client/requests/GetSavedBreakdownApiV1SavingsBreakdownGetRequest.ts +30 -0
- package/api/resources/savings/client/requests/index.ts +2 -0
- package/api/resources/savings/exports.ts +4 -0
- package/api/resources/savings/index.ts +1 -0
- package/api/resources/spending/client/Client.ts +288 -0
- package/api/resources/spending/client/index.ts +1 -0
- package/api/resources/spending/client/requests/GetCostBreakdownApiV1SpendingBreakdownGetRequest.ts +30 -0
- package/api/resources/spending/client/requests/GetDailySpendingBreakdownApiV1SpendingDailyBreakdownGetRequest.ts +12 -0
- package/api/resources/spending/client/requests/index.ts +2 -0
- package/api/resources/spending/exports.ts +4 -0
- package/api/resources/spending/index.ts +2 -0
- package/api/resources/spending/types/GetCostBreakdownApiV1SpendingBreakdownGetResponse.ts +9 -0
- package/api/resources/spending/types/index.ts +1 -0
- package/api/resources/webhooks/client/Client.ts +232 -0
- package/api/resources/webhooks/client/index.ts +1 -0
- package/api/resources/webhooks/client/requests/DeleteEndpointApiV1WebhooksEndpointsEndpointIdDeleteRequest.ts +14 -0
- package/api/resources/webhooks/client/requests/ListEndpointsApiV1WebhooksEndpointsGetRequest.ts +11 -0
- package/api/resources/webhooks/client/requests/RegisterEndpointRequest.ts +18 -0
- package/api/resources/webhooks/client/requests/index.ts +3 -0
- package/api/resources/webhooks/exports.ts +4 -0
- package/api/resources/webhooks/index.ts +1 -0
- package/api/types/AcceptTermsData.ts +10 -0
- package/api/types/AcceptTermsResponse.ts +12 -0
- package/api/types/ActionRequest.ts +14 -0
- package/api/types/ApiKeyCreatedData.ts +13 -0
- package/api/types/ApiKeyData.ts +12 -0
- package/api/types/ComparisonItem.ts +10 -0
- package/api/types/CompleteWizardData.ts +12 -0
- package/api/types/CompleteWizardResponse.ts +12 -0
- package/api/types/CostBreakdownData.ts +14 -0
- package/api/types/CostBreakdownItem.ts +27 -0
- package/api/types/CostBreakdownRawData.ts +15 -0
- package/api/types/CostBreakdownRawResponse.ts +12 -0
- package/api/types/CostBreakdownResponse.ts +12 -0
- package/api/types/CostsBreakdownChartData.ts +19 -0
- package/api/types/CostsBreakdownChartResponse.ts +12 -0
- package/api/types/CostsBreakdownDataPoint.ts +17 -0
- package/api/types/CostsBreakdownGroupedChartData.ts +21 -0
- package/api/types/CostsBreakdownGroupedChartResponse.ts +12 -0
- package/api/types/CostsBreakdownGroupedDataPoint.ts +13 -0
- package/api/types/CostsBreakdownTotals.ts +15 -0
- package/api/types/CreateApiKeyResponse.ts +9 -0
- package/api/types/DailySpendingBreakdownData.ts +17 -0
- package/api/types/DailySpendingBreakdownResponse.ts +12 -0
- package/api/types/DailySpendingDataPoint.ts +11 -0
- package/api/types/DashboardSummaryData.ts +29 -0
- package/api/types/DashboardSummaryResponse.ts +12 -0
- package/api/types/DeleteEndpointData.ts +6 -0
- package/api/types/DeleteEndpointResponse.ts +9 -0
- package/api/types/EndpointData.ts +9 -0
- package/api/types/EvaluationStatusData.ts +27 -0
- package/api/types/EvaluationStatusResponse.ts +12 -0
- package/api/types/ExecutionLogCommand.ts +7 -0
- package/api/types/ExecutionLogEntry.ts +10 -0
- package/api/types/ExecutionStepSchema.ts +9 -0
- package/api/types/HttpValidationError.ts +7 -0
- package/api/types/ImplementationMethodData.ts +10 -0
- package/api/types/ImplementationMethodResponse.ts +12 -0
- package/api/types/ImplementationStep.ts +8 -0
- package/api/types/ListApiKeysData.ts +8 -0
- package/api/types/ListApiKeysResponse.ts +9 -0
- package/api/types/ListEndpointsResponse.ts +9 -0
- package/api/types/MetricDataPoint.ts +8 -0
- package/api/types/MetricSeries.ts +15 -0
- package/api/types/MetricSeriesEntry.ts +9 -0
- package/api/types/MonthlySpendingData.ts +11 -0
- package/api/types/MonthlySpendingDataPoint.ts +11 -0
- package/api/types/MonthlySpendingResponse.ts +12 -0
- package/api/types/PaginationMeta.ts +19 -0
- package/api/types/ProcessingRecommendationItem.ts +23 -0
- package/api/types/ProcessingRecommendationsData.ts +12 -0
- package/api/types/ProcessingRecommendationsResponse.ts +12 -0
- package/api/types/Provider.ts +17 -0
- package/api/types/ProviderBreakdownData.ts +13 -0
- package/api/types/ProviderBreakdownItem.ts +31 -0
- package/api/types/ProviderBreakdownResponse.ts +12 -0
- package/api/types/ProviderFilterOptionsData.ts +19 -0
- package/api/types/ProviderFilterOptionsResponse.ts +12 -0
- package/api/types/ProviderPotentialSavingsSummaryData.ts +17 -0
- package/api/types/ProviderPotentialSavingsSummaryResponse.ts +12 -0
- package/api/types/ProviderRecommendationsSummaryData.ts +15 -0
- package/api/types/ProviderRecommendationsSummaryResponse.ts +12 -0
- package/api/types/ProviderSavedSummaryData.ts +21 -0
- package/api/types/ProviderSavedSummaryResponse.ts +12 -0
- package/api/types/ProviderServiceBreakdownData.ts +26 -0
- package/api/types/ProviderServiceBreakdownItem.ts +29 -0
- package/api/types/ProviderServiceBreakdownRawData.ts +25 -0
- package/api/types/ProviderServiceBreakdownRawResponse.ts +12 -0
- package/api/types/ProviderServiceBreakdownResponse.ts +12 -0
- package/api/types/ProviderServiceCostsBreakdownData.ts +25 -0
- package/api/types/ProviderServiceCostsBreakdownResponse.ts +12 -0
- package/api/types/ProviderServiceCostsDataPoint.ts +13 -0
- package/api/types/ProviderSpending.ts +23 -0
- package/api/types/ProviderSpendingSummaryData.ts +27 -0
- package/api/types/ProviderSpendingSummaryResponse.ts +12 -0
- package/api/types/ProviderTimelineData.ts +23 -0
- package/api/types/ProviderTimelineResponse.ts +12 -0
- package/api/types/ProviderTopService.ts +13 -0
- package/api/types/ProvidersSummaryData.ts +10 -0
- package/api/types/ProvidersSummaryResponse.ts +12 -0
- package/api/types/RecommendationActions.ts +28 -0
- package/api/types/RecommendationDetail.ts +22 -0
- package/api/types/RecommendationDetailResponse.ts +12 -0
- package/api/types/RecommendationFilterOptionsData.ts +15 -0
- package/api/types/RecommendationFilterOptionsResponse.ts +12 -0
- package/api/types/RecommendationItem.ts +19 -0
- package/api/types/RecommendationWizardData.ts +83 -0
- package/api/types/RecommendationWizardResponse.ts +12 -0
- package/api/types/RecommendationsBreakdownData.ts +11 -0
- package/api/types/RecommendationsBreakdownResponse.ts +12 -0
- package/api/types/RecommendationsOverviewData.ts +19 -0
- package/api/types/RecommendationsOverviewResponse.ts +12 -0
- package/api/types/RegisterEndpointResponse.ts +9 -0
- package/api/types/ResourceChange.ts +14 -0
- package/api/types/ResourceSnapshot.ts +7 -0
- package/api/types/RevokeApiKeyData.ts +6 -0
- package/api/types/RevokeApiKeyResponse.ts +9 -0
- package/api/types/RiskAssessment.ts +11 -0
- package/api/types/RiskFactor.ts +8 -0
- package/api/types/SavedBreakdownData.ts +13 -0
- package/api/types/SavedBreakdownResponse.ts +12 -0
- package/api/types/SavedByProviderBreakdownData.ts +13 -0
- package/api/types/SavedByProviderBreakdownResponse.ts +12 -0
- package/api/types/SavedByProviderItem.ts +29 -0
- package/api/types/SavedItem.ts +20 -0
- package/api/types/SavedProviderSummary.ts +13 -0
- package/api/types/SavedSummaryData.ts +23 -0
- package/api/types/SavedSummaryResponse.ts +12 -0
- package/api/types/SavingsDecisionData.ts +13 -0
- package/api/types/SavingsDecisionResponse.ts +12 -0
- package/api/types/SpendingByDateItem.ts +13 -0
- package/api/types/TopRecommendation.ts +21 -0
- package/api/types/TriggerInfo.ts +8 -0
- package/api/types/UpdateTagData.ts +6 -0
- package/api/types/UpdateTagResponse.ts +9 -0
- package/api/types/ValidationError.ts +17 -0
- package/api/types/index.ts +115 -0
- package/core/exports.ts +1 -0
- package/core/fetcher/APIResponse.ts +23 -0
- package/core/fetcher/BinaryResponse.ts +34 -0
- package/core/fetcher/EndpointMetadata.ts +13 -0
- package/core/fetcher/EndpointSupplier.ts +14 -0
- package/core/fetcher/Fetcher.ts +398 -0
- package/core/fetcher/Headers.ts +93 -0
- package/core/fetcher/HttpResponsePromise.ts +116 -0
- package/core/fetcher/RawResponse.ts +61 -0
- package/core/fetcher/Supplier.ts +11 -0
- package/core/fetcher/createRequestUrl.ts +6 -0
- package/core/fetcher/getErrorResponseBody.ts +33 -0
- package/core/fetcher/getFetchFn.ts +3 -0
- package/core/fetcher/getHeader.ts +8 -0
- package/core/fetcher/getRequestBody.ts +20 -0
- package/core/fetcher/getResponseBody.ts +58 -0
- package/core/fetcher/index.ts +11 -0
- package/core/fetcher/makeRequest.ts +70 -0
- package/core/fetcher/requestWithRetries.ts +64 -0
- package/core/fetcher/signals.ts +26 -0
- package/core/headers.ts +33 -0
- package/core/index.ts +4 -0
- package/core/json.ts +27 -0
- package/core/logging/exports.ts +19 -0
- package/core/logging/index.ts +1 -0
- package/core/logging/logger.ts +203 -0
- package/core/runtime/index.ts +1 -0
- package/core/runtime/runtime.ts +134 -0
- package/core/url/encodePathParam.ts +18 -0
- package/core/url/index.ts +3 -0
- package/core/url/join.ts +79 -0
- package/core/url/qs.ts +74 -0
- package/errors/LevelFourError.ts +58 -0
- package/errors/LevelFourTimeoutError.ts +13 -0
- package/errors/handleNonStatusCodeError.ts +37 -0
- package/errors/index.ts +2 -0
- package/errors.ts +100 -0
- package/exports.ts +1 -0
- package/index.ts +22 -0
- package/jest.config.js +17 -0
- package/package.json +35 -0
- package/pagination.ts +54 -0
- package/telemetry.ts +64 -0
- package/tests/auth.test.ts +64 -0
- package/tests/errors.test.ts +92 -0
- package/tests/pagination.test.ts +72 -0
- package/tests/telemetry.test.ts +110 -0
- package/tsconfig.json +22 -0
- package/webhooks.ts +77 -0
package/.fernignore
ADDED
package/BaseClient.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import { mergeHeaders } from "./core/headers.js";
|
|
4
|
+
import * as core from "./core/index.js";
|
|
5
|
+
|
|
6
|
+
export interface BaseClientOptions {
|
|
7
|
+
environment: core.Supplier<string>;
|
|
8
|
+
/** Specify a custom URL to connect the client to. */
|
|
9
|
+
baseUrl?: core.Supplier<string>;
|
|
10
|
+
/** Additional headers to include in requests. */
|
|
11
|
+
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
12
|
+
/** The default maximum time to wait for a response in seconds. */
|
|
13
|
+
timeoutInSeconds?: number;
|
|
14
|
+
/** The default number of times to retry the request. Defaults to 2. */
|
|
15
|
+
maxRetries?: number;
|
|
16
|
+
/** Provide a custom fetch implementation. Useful for platforms that don't have a built-in fetch or need a custom implementation. */
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
/** Configure logging for the client. */
|
|
19
|
+
logging?: core.logging.LogConfig | core.logging.Logger;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface BaseRequestOptions {
|
|
23
|
+
/** The maximum time to wait for a response in seconds. */
|
|
24
|
+
timeoutInSeconds?: number;
|
|
25
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
26
|
+
maxRetries?: number;
|
|
27
|
+
/** A hook to abort the request. */
|
|
28
|
+
abortSignal?: AbortSignal;
|
|
29
|
+
/** Additional query string parameters to include in the request. */
|
|
30
|
+
queryParams?: Record<string, unknown>;
|
|
31
|
+
/** Additional headers to include in the request. */
|
|
32
|
+
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
|
|
36
|
+
logging: core.logging.Logger;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(
|
|
40
|
+
options: T,
|
|
41
|
+
): NormalizedClientOptions<T> {
|
|
42
|
+
const headers = mergeHeaders(
|
|
43
|
+
{
|
|
44
|
+
"X-Fern-Language": "JavaScript",
|
|
45
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
46
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
47
|
+
},
|
|
48
|
+
options?.headers,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
...options,
|
|
53
|
+
logging: core.logging.createLogger(options?.logging),
|
|
54
|
+
headers,
|
|
55
|
+
} as NormalizedClientOptions<T>;
|
|
56
|
+
}
|
package/Client.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import { ApiKeysClient } from "./api/resources/apiKeys/client/Client.js";
|
|
4
|
+
import { EvaluationClient } from "./api/resources/evaluation/client/Client.js";
|
|
5
|
+
import { HealthClient } from "./api/resources/health/client/Client.js";
|
|
6
|
+
import { PrAnalysisClient } from "./api/resources/prAnalysis/client/Client.js";
|
|
7
|
+
import { PrAnalysisActionsClient } from "./api/resources/prAnalysisActions/client/Client.js";
|
|
8
|
+
import { PrAnalysisInstallationsClient } from "./api/resources/prAnalysisInstallations/client/Client.js";
|
|
9
|
+
import { PrAnalysisQueryClient } from "./api/resources/prAnalysisQuery/client/Client.js";
|
|
10
|
+
import { ProvidersClient } from "./api/resources/providers/client/Client.js";
|
|
11
|
+
import { RecommendationsClient } from "./api/resources/recommendations/client/Client.js";
|
|
12
|
+
import { SavingsClient } from "./api/resources/savings/client/Client.js";
|
|
13
|
+
import { SpendingClient } from "./api/resources/spending/client/Client.js";
|
|
14
|
+
import { WebhooksClient } from "./api/resources/webhooks/client/Client.js";
|
|
15
|
+
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
16
|
+
import { type NormalizedClientOptions, normalizeClientOptions } from "./BaseClient.js";
|
|
17
|
+
|
|
18
|
+
export declare namespace LevelFourClient {
|
|
19
|
+
export type Options = BaseClientOptions;
|
|
20
|
+
|
|
21
|
+
export interface RequestOptions extends BaseRequestOptions {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class LevelFourClient {
|
|
25
|
+
protected readonly _options: NormalizedClientOptions<LevelFourClient.Options>;
|
|
26
|
+
protected _apiKeys: ApiKeysClient | undefined;
|
|
27
|
+
protected _webhooks: WebhooksClient | undefined;
|
|
28
|
+
protected _recommendations: RecommendationsClient | undefined;
|
|
29
|
+
protected _savings: SavingsClient | undefined;
|
|
30
|
+
protected _spending: SpendingClient | undefined;
|
|
31
|
+
protected _providers: ProvidersClient | undefined;
|
|
32
|
+
protected _evaluation: EvaluationClient | undefined;
|
|
33
|
+
protected _prAnalysis: PrAnalysisClient | undefined;
|
|
34
|
+
protected _prAnalysisInstallations: PrAnalysisInstallationsClient | undefined;
|
|
35
|
+
protected _prAnalysisActions: PrAnalysisActionsClient | undefined;
|
|
36
|
+
protected _prAnalysisQuery: PrAnalysisQueryClient | undefined;
|
|
37
|
+
protected _health: HealthClient | undefined;
|
|
38
|
+
|
|
39
|
+
constructor(options: LevelFourClient.Options) {
|
|
40
|
+
this._options = normalizeClientOptions(options);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public get apiKeys(): ApiKeysClient {
|
|
44
|
+
return (this._apiKeys ??= new ApiKeysClient(this._options));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public get webhooks(): WebhooksClient {
|
|
48
|
+
return (this._webhooks ??= new WebhooksClient(this._options));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public get recommendations(): RecommendationsClient {
|
|
52
|
+
return (this._recommendations ??= new RecommendationsClient(this._options));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public get savings(): SavingsClient {
|
|
56
|
+
return (this._savings ??= new SavingsClient(this._options));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public get spending(): SpendingClient {
|
|
60
|
+
return (this._spending ??= new SpendingClient(this._options));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public get providers(): ProvidersClient {
|
|
64
|
+
return (this._providers ??= new ProvidersClient(this._options));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public get evaluation(): EvaluationClient {
|
|
68
|
+
return (this._evaluation ??= new EvaluationClient(this._options));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public get prAnalysis(): PrAnalysisClient {
|
|
72
|
+
return (this._prAnalysis ??= new PrAnalysisClient(this._options));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public get prAnalysisInstallations(): PrAnalysisInstallationsClient {
|
|
76
|
+
return (this._prAnalysisInstallations ??= new PrAnalysisInstallationsClient(this._options));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public get prAnalysisActions(): PrAnalysisActionsClient {
|
|
80
|
+
return (this._prAnalysisActions ??= new PrAnalysisActionsClient(this._options));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public get prAnalysisQuery(): PrAnalysisQueryClient {
|
|
84
|
+
return (this._prAnalysisQuery ??= new PrAnalysisQueryClient(this._options));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public get health(): HealthClient {
|
|
88
|
+
return (this._health ??= new HealthClient(this._options));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LevelFourClient as BaseLevelFourClient } from "./Client.js";
|
|
2
|
+
import { AuthenticationError } from "./errors.js";
|
|
3
|
+
import { createTracedFetch } from "./telemetry.js";
|
|
4
|
+
|
|
5
|
+
const VALID_PREFIXES = ["l4_live_", "l4_test_"] as const;
|
|
6
|
+
const DEFAULT_BASE_URL = "https://api.levelfour.ai";
|
|
7
|
+
|
|
8
|
+
function resolveApiKey(apiKey?: string): string {
|
|
9
|
+
const key = apiKey ?? (typeof process !== "undefined" ? process.env.LEVELFOUR_API_KEY : undefined);
|
|
10
|
+
if (!key) {
|
|
11
|
+
throw new AuthenticationError(
|
|
12
|
+
"No API key provided. Set LEVELFOUR_API_KEY environment variable or pass apiKey to the constructor.",
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
if (!VALID_PREFIXES.some((prefix) => key.startsWith(prefix))) {
|
|
16
|
+
throw new AuthenticationError(
|
|
17
|
+
`Invalid API key format. Key must start with one of: ${VALID_PREFIXES.join(", ")}`,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return key;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface LevelFourClientOptions {
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
timeoutInSeconds?: number;
|
|
27
|
+
maxRetries?: number;
|
|
28
|
+
fetch?: typeof fetch;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class LevelFourClient extends BaseLevelFourClient {
|
|
32
|
+
private readonly _apiKey: string;
|
|
33
|
+
|
|
34
|
+
constructor(options: LevelFourClientOptions = {}) {
|
|
35
|
+
const resolvedKey = resolveApiKey(options.apiKey);
|
|
36
|
+
const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
37
|
+
|
|
38
|
+
super({
|
|
39
|
+
environment: baseUrl,
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${resolvedKey}`,
|
|
42
|
+
},
|
|
43
|
+
timeoutInSeconds: options.timeoutInSeconds ?? 30,
|
|
44
|
+
maxRetries: options.maxRetries ?? 2,
|
|
45
|
+
fetch: createTracedFetch(options.fetch),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
this._apiKey = resolvedKey;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import type * as core from "../../core/index.js";
|
|
4
|
+
import * as errors from "../../errors/index.js";
|
|
5
|
+
import type * as LevelFour from "../index.js";
|
|
6
|
+
|
|
7
|
+
export class UnprocessableEntityError extends errors.LevelFourError {
|
|
8
|
+
constructor(body: LevelFour.HttpValidationError, rawResponse?: core.RawResponse) {
|
|
9
|
+
super({
|
|
10
|
+
message: "UnprocessableEntityError",
|
|
11
|
+
statusCode: 422,
|
|
12
|
+
body: body,
|
|
13
|
+
rawResponse: rawResponse,
|
|
14
|
+
});
|
|
15
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16
|
+
if (Error.captureStackTrace) {
|
|
17
|
+
Error.captureStackTrace(this, this.constructor);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.name = this.constructor.name;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./UnprocessableEntityError.js";
|
package/api/index.ts
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
4
|
+
import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";
|
|
5
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
|
|
6
|
+
import * as core from "../../../../core/index.js";
|
|
7
|
+
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
|
|
8
|
+
import * as errors from "../../../../errors/index.js";
|
|
9
|
+
import * as LevelFour from "../../../index.js";
|
|
10
|
+
|
|
11
|
+
export declare namespace ApiKeysClient {
|
|
12
|
+
export type Options = BaseClientOptions;
|
|
13
|
+
|
|
14
|
+
export interface RequestOptions extends BaseRequestOptions {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class ApiKeysClient {
|
|
18
|
+
protected readonly _options: NormalizedClientOptions<ApiKeysClient.Options>;
|
|
19
|
+
|
|
20
|
+
constructor(options: ApiKeysClient.Options) {
|
|
21
|
+
this._options = normalizeClientOptions(options);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {LevelFour.ListApiKeysApiV1ApiKeysGetRequest} request
|
|
26
|
+
* @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
27
|
+
*
|
|
28
|
+
* @throws {@link LevelFour.UnprocessableEntityError}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* await client.apiKeys.listApiKeys({
|
|
32
|
+
* authorization: "authorization"
|
|
33
|
+
* })
|
|
34
|
+
*/
|
|
35
|
+
public listApiKeys(
|
|
36
|
+
request: LevelFour.ListApiKeysApiV1ApiKeysGetRequest,
|
|
37
|
+
requestOptions?: ApiKeysClient.RequestOptions,
|
|
38
|
+
): core.HttpResponsePromise<LevelFour.ListApiKeysResponse> {
|
|
39
|
+
return core.HttpResponsePromise.fromPromise(this.__listApiKeys(request, requestOptions));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private async __listApiKeys(
|
|
43
|
+
request: LevelFour.ListApiKeysApiV1ApiKeysGetRequest,
|
|
44
|
+
requestOptions?: ApiKeysClient.RequestOptions,
|
|
45
|
+
): Promise<core.WithRawResponse<LevelFour.ListApiKeysResponse>> {
|
|
46
|
+
const { authorization } = request;
|
|
47
|
+
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
48
|
+
this._options?.headers,
|
|
49
|
+
mergeOnlyDefinedHeaders({ authorization: authorization }),
|
|
50
|
+
requestOptions?.headers,
|
|
51
|
+
);
|
|
52
|
+
const _response = await core.fetcher({
|
|
53
|
+
url: core.url.join(
|
|
54
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
55
|
+
(await core.Supplier.get(this._options.environment)),
|
|
56
|
+
"api/v1/api-keys",
|
|
57
|
+
),
|
|
58
|
+
method: "GET",
|
|
59
|
+
headers: _headers,
|
|
60
|
+
queryParameters: requestOptions?.queryParams,
|
|
61
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
62
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
63
|
+
abortSignal: requestOptions?.abortSignal,
|
|
64
|
+
fetchFn: this._options?.fetch,
|
|
65
|
+
logging: this._options.logging,
|
|
66
|
+
});
|
|
67
|
+
if (_response.ok) {
|
|
68
|
+
return { data: _response.body as LevelFour.ListApiKeysResponse, rawResponse: _response.rawResponse };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (_response.error.reason === "status-code") {
|
|
72
|
+
switch (_response.error.statusCode) {
|
|
73
|
+
case 422:
|
|
74
|
+
throw new LevelFour.UnprocessableEntityError(
|
|
75
|
+
_response.error.body as LevelFour.HttpValidationError,
|
|
76
|
+
_response.rawResponse,
|
|
77
|
+
);
|
|
78
|
+
default:
|
|
79
|
+
throw new errors.LevelFourError({
|
|
80
|
+
statusCode: _response.error.statusCode,
|
|
81
|
+
body: _response.error.body,
|
|
82
|
+
rawResponse: _response.rawResponse,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/v1/api-keys");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {LevelFour.CreateApiKeyRequest} request
|
|
92
|
+
* @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
93
|
+
*
|
|
94
|
+
* @throws {@link LevelFour.UnprocessableEntityError}
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* await client.apiKeys.createApiKey({
|
|
98
|
+
* authorization: "authorization",
|
|
99
|
+
* name: "name"
|
|
100
|
+
* })
|
|
101
|
+
*/
|
|
102
|
+
public createApiKey(
|
|
103
|
+
request: LevelFour.CreateApiKeyRequest,
|
|
104
|
+
requestOptions?: ApiKeysClient.RequestOptions,
|
|
105
|
+
): core.HttpResponsePromise<LevelFour.CreateApiKeyResponse> {
|
|
106
|
+
return core.HttpResponsePromise.fromPromise(this.__createApiKey(request, requestOptions));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private async __createApiKey(
|
|
110
|
+
request: LevelFour.CreateApiKeyRequest,
|
|
111
|
+
requestOptions?: ApiKeysClient.RequestOptions,
|
|
112
|
+
): Promise<core.WithRawResponse<LevelFour.CreateApiKeyResponse>> {
|
|
113
|
+
const { authorization, ..._body } = request;
|
|
114
|
+
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
115
|
+
this._options?.headers,
|
|
116
|
+
mergeOnlyDefinedHeaders({ authorization: authorization }),
|
|
117
|
+
requestOptions?.headers,
|
|
118
|
+
);
|
|
119
|
+
const _response = await core.fetcher({
|
|
120
|
+
url: core.url.join(
|
|
121
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
122
|
+
(await core.Supplier.get(this._options.environment)),
|
|
123
|
+
"api/v1/api-keys",
|
|
124
|
+
),
|
|
125
|
+
method: "POST",
|
|
126
|
+
headers: _headers,
|
|
127
|
+
contentType: "application/json",
|
|
128
|
+
queryParameters: requestOptions?.queryParams,
|
|
129
|
+
requestType: "json",
|
|
130
|
+
body: _body,
|
|
131
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
132
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
133
|
+
abortSignal: requestOptions?.abortSignal,
|
|
134
|
+
fetchFn: this._options?.fetch,
|
|
135
|
+
logging: this._options.logging,
|
|
136
|
+
});
|
|
137
|
+
if (_response.ok) {
|
|
138
|
+
return { data: _response.body as LevelFour.CreateApiKeyResponse, rawResponse: _response.rawResponse };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (_response.error.reason === "status-code") {
|
|
142
|
+
switch (_response.error.statusCode) {
|
|
143
|
+
case 422:
|
|
144
|
+
throw new LevelFour.UnprocessableEntityError(
|
|
145
|
+
_response.error.body as LevelFour.HttpValidationError,
|
|
146
|
+
_response.rawResponse,
|
|
147
|
+
);
|
|
148
|
+
default:
|
|
149
|
+
throw new errors.LevelFourError({
|
|
150
|
+
statusCode: _response.error.statusCode,
|
|
151
|
+
body: _response.error.body,
|
|
152
|
+
rawResponse: _response.rawResponse,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/api/v1/api-keys");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @param {LevelFour.RevokeApiKeyApiV1ApiKeysKeyIdDeleteRequest} request
|
|
162
|
+
* @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
163
|
+
*
|
|
164
|
+
* @throws {@link LevelFour.UnprocessableEntityError}
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* await client.apiKeys.revokeApiKey({
|
|
168
|
+
* authorization: "authorization",
|
|
169
|
+
* key_id: "key_id"
|
|
170
|
+
* })
|
|
171
|
+
*/
|
|
172
|
+
public revokeApiKey(
|
|
173
|
+
request: LevelFour.RevokeApiKeyApiV1ApiKeysKeyIdDeleteRequest,
|
|
174
|
+
requestOptions?: ApiKeysClient.RequestOptions,
|
|
175
|
+
): core.HttpResponsePromise<LevelFour.RevokeApiKeyResponse> {
|
|
176
|
+
return core.HttpResponsePromise.fromPromise(this.__revokeApiKey(request, requestOptions));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private async __revokeApiKey(
|
|
180
|
+
request: LevelFour.RevokeApiKeyApiV1ApiKeysKeyIdDeleteRequest,
|
|
181
|
+
requestOptions?: ApiKeysClient.RequestOptions,
|
|
182
|
+
): Promise<core.WithRawResponse<LevelFour.RevokeApiKeyResponse>> {
|
|
183
|
+
const { key_id: keyId, authorization } = request;
|
|
184
|
+
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
185
|
+
this._options?.headers,
|
|
186
|
+
mergeOnlyDefinedHeaders({ authorization: authorization }),
|
|
187
|
+
requestOptions?.headers,
|
|
188
|
+
);
|
|
189
|
+
const _response = await core.fetcher({
|
|
190
|
+
url: core.url.join(
|
|
191
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
192
|
+
(await core.Supplier.get(this._options.environment)),
|
|
193
|
+
`api/v1/api-keys/${core.url.encodePathParam(keyId)}`,
|
|
194
|
+
),
|
|
195
|
+
method: "DELETE",
|
|
196
|
+
headers: _headers,
|
|
197
|
+
queryParameters: requestOptions?.queryParams,
|
|
198
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
199
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
200
|
+
abortSignal: requestOptions?.abortSignal,
|
|
201
|
+
fetchFn: this._options?.fetch,
|
|
202
|
+
logging: this._options.logging,
|
|
203
|
+
});
|
|
204
|
+
if (_response.ok) {
|
|
205
|
+
return { data: _response.body as LevelFour.RevokeApiKeyResponse, rawResponse: _response.rawResponse };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (_response.error.reason === "status-code") {
|
|
209
|
+
switch (_response.error.statusCode) {
|
|
210
|
+
case 422:
|
|
211
|
+
throw new LevelFour.UnprocessableEntityError(
|
|
212
|
+
_response.error.body as LevelFour.HttpValidationError,
|
|
213
|
+
_response.rawResponse,
|
|
214
|
+
);
|
|
215
|
+
default:
|
|
216
|
+
throw new errors.LevelFourError({
|
|
217
|
+
statusCode: _response.error.statusCode,
|
|
218
|
+
body: _response.error.body,
|
|
219
|
+
rawResponse: _response.rawResponse,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/api/v1/api-keys/{key_id}");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @param {LevelFour.RotateApiKeyApiV1ApiKeysKeyIdRotatePostRequest} request
|
|
229
|
+
* @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
230
|
+
*
|
|
231
|
+
* @throws {@link LevelFour.UnprocessableEntityError}
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* await client.apiKeys.rotateApiKey({
|
|
235
|
+
* authorization: "authorization",
|
|
236
|
+
* key_id: "key_id"
|
|
237
|
+
* })
|
|
238
|
+
*/
|
|
239
|
+
public rotateApiKey(
|
|
240
|
+
request: LevelFour.RotateApiKeyApiV1ApiKeysKeyIdRotatePostRequest,
|
|
241
|
+
requestOptions?: ApiKeysClient.RequestOptions,
|
|
242
|
+
): core.HttpResponsePromise<LevelFour.CreateApiKeyResponse> {
|
|
243
|
+
return core.HttpResponsePromise.fromPromise(this.__rotateApiKey(request, requestOptions));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private async __rotateApiKey(
|
|
247
|
+
request: LevelFour.RotateApiKeyApiV1ApiKeysKeyIdRotatePostRequest,
|
|
248
|
+
requestOptions?: ApiKeysClient.RequestOptions,
|
|
249
|
+
): Promise<core.WithRawResponse<LevelFour.CreateApiKeyResponse>> {
|
|
250
|
+
const { key_id: keyId, authorization } = request;
|
|
251
|
+
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
252
|
+
this._options?.headers,
|
|
253
|
+
mergeOnlyDefinedHeaders({ authorization: authorization }),
|
|
254
|
+
requestOptions?.headers,
|
|
255
|
+
);
|
|
256
|
+
const _response = await core.fetcher({
|
|
257
|
+
url: core.url.join(
|
|
258
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
259
|
+
(await core.Supplier.get(this._options.environment)),
|
|
260
|
+
`api/v1/api-keys/${core.url.encodePathParam(keyId)}/rotate`,
|
|
261
|
+
),
|
|
262
|
+
method: "POST",
|
|
263
|
+
headers: _headers,
|
|
264
|
+
queryParameters: requestOptions?.queryParams,
|
|
265
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
266
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
267
|
+
abortSignal: requestOptions?.abortSignal,
|
|
268
|
+
fetchFn: this._options?.fetch,
|
|
269
|
+
logging: this._options.logging,
|
|
270
|
+
});
|
|
271
|
+
if (_response.ok) {
|
|
272
|
+
return { data: _response.body as LevelFour.CreateApiKeyResponse, rawResponse: _response.rawResponse };
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (_response.error.reason === "status-code") {
|
|
276
|
+
switch (_response.error.statusCode) {
|
|
277
|
+
case 422:
|
|
278
|
+
throw new LevelFour.UnprocessableEntityError(
|
|
279
|
+
_response.error.body as LevelFour.HttpValidationError,
|
|
280
|
+
_response.rawResponse,
|
|
281
|
+
);
|
|
282
|
+
default:
|
|
283
|
+
throw new errors.LevelFourError({
|
|
284
|
+
statusCode: _response.error.statusCode,
|
|
285
|
+
body: _response.error.body,
|
|
286
|
+
rawResponse: _response.rawResponse,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return handleNonStatusCodeError(
|
|
292
|
+
_response.error,
|
|
293
|
+
_response.rawResponse,
|
|
294
|
+
"POST",
|
|
295
|
+
"/api/v1/api-keys/{key_id}/rotate",
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @example
|
|
5
|
+
* {
|
|
6
|
+
* authorization: "authorization",
|
|
7
|
+
* name: "name"
|
|
8
|
+
* }
|
|
9
|
+
*/
|
|
10
|
+
export interface CreateApiKeyRequest {
|
|
11
|
+
authorization: string;
|
|
12
|
+
name: string;
|
|
13
|
+
scope?: CreateApiKeyRequest.Scope;
|
|
14
|
+
expires_at?: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export namespace CreateApiKeyRequest {
|
|
18
|
+
export const Scope = {
|
|
19
|
+
Read: "read",
|
|
20
|
+
ReadWrite: "read-write",
|
|
21
|
+
} as const;
|
|
22
|
+
export type Scope = (typeof Scope)[keyof typeof Scope];
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @example
|
|
5
|
+
* {
|
|
6
|
+
* authorization: "authorization",
|
|
7
|
+
* key_id: "key_id"
|
|
8
|
+
* }
|
|
9
|
+
*/
|
|
10
|
+
export interface RevokeApiKeyApiV1ApiKeysKeyIdDeleteRequest {
|
|
11
|
+
/** API key UUID */
|
|
12
|
+
key_id: string;
|
|
13
|
+
authorization: string;
|
|
14
|
+
}
|
package/api/resources/apiKeys/client/requests/RotateApiKeyApiV1ApiKeysKeyIdRotatePostRequest.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @example
|
|
5
|
+
* {
|
|
6
|
+
* authorization: "authorization",
|
|
7
|
+
* key_id: "key_id"
|
|
8
|
+
* }
|
|
9
|
+
*/
|
|
10
|
+
export interface RotateApiKeyApiV1ApiKeysKeyIdRotatePostRequest {
|
|
11
|
+
/** API key UUID to rotate */
|
|
12
|
+
key_id: string;
|
|
13
|
+
authorization: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CreateApiKeyRequest } from "./CreateApiKeyRequest.js";
|
|
2
|
+
export type { ListApiKeysApiV1ApiKeysGetRequest } from "./ListApiKeysApiV1ApiKeysGetRequest.js";
|
|
3
|
+
export type { RevokeApiKeyApiV1ApiKeysKeyIdDeleteRequest } from "./RevokeApiKeyApiV1ApiKeysKeyIdDeleteRequest.js";
|
|
4
|
+
export type { RotateApiKeyApiV1ApiKeysKeyIdRotatePostRequest } from "./RotateApiKeyApiV1ApiKeysKeyIdRotatePostRequest.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./client/index.js";
|