Dynamic secret support & rest client fix
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate-api:infisical": "openapi-generator-cli generate -i https://app.infisical.com/api/docs/json -g typescript-axios -o ./src/infisicalapi_client --skip-validate-spec --additional-properties=useSingleRequestParameter=true,withSeparateModelsAndApi=true,apiPackage=server,modelPackage=model --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true && npm run post-generate-api",
|
"generate-api:infisical": "openapi-generator-cli generate -i https://app.infisical.com/api/docs/json -g typescript-axios -o ./src/infisicalapi_client --skip-validate-spec --additional-properties=useSingleRequestParameter=true,withSeparateModelsAndApi=true,apiPackage=server,modelPackage=model --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true && npm run post-generate-api",
|
||||||
|
"generate-api:infisical-dev": "openapi-generator-cli generate -i http://localhost:8080/api/docs/json -g typescript-axios -o ./src/infisicalapi_client --skip-validate-spec --additional-properties=useSingleRequestParameter=true,withSeparateModelsAndApi=true,apiPackage=server,modelPackage=model --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true && npm run post-generate-api",
|
||||||
"post-generate-api": "rm ./src/infisicalapi_client/git_push.sh",
|
"post-generate-api": "rm ./src/infisicalapi_client/git_push.sh",
|
||||||
"build": "tsup src/index.ts --out-dir lib --dts --format cjs,esm --tsconfig tsconfig.json --no-splitting"
|
"build": "tsup src/index.ts --out-dir lib --dts --format cjs,esm --tsconfig tsconfig.json --no-splitting"
|
||||||
},
|
},
|
||||||
|
|||||||
83
src/custom/dynamic-secrets.ts
Normal file
83
src/custom/dynamic-secrets.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
import { RawAxiosRequestConfig } from "axios";
|
||||||
|
import { Configuration, DefaultApi as InfisicalApi } from "../infisicalapi_client";
|
||||||
|
import type {
|
||||||
|
DefaultApiApiV1DynamicSecretsLeasesLeaseIdDeleteRequest,
|
||||||
|
DefaultApiApiV1DynamicSecretsLeasesLeaseIdRenewPostRequest,
|
||||||
|
DefaultApiApiV1DynamicSecretsLeasesPostRequest,
|
||||||
|
DefaultApiApiV1DynamicSecretsNameDeleteRequest,
|
||||||
|
DefaultApiApiV1DynamicSecretsPostRequest
|
||||||
|
} from "../infisicalapi_client";
|
||||||
|
|
||||||
|
export default class DynamicSecretsClient {
|
||||||
|
#apiInstance: InfisicalApi;
|
||||||
|
#requestOptions: RawAxiosRequestConfig | undefined;
|
||||||
|
constructor(apiInstance: InfisicalApi, requestOptions: RawAxiosRequestConfig | undefined) {
|
||||||
|
this.#apiInstance = apiInstance;
|
||||||
|
this.#requestOptions = requestOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(options: DefaultApiApiV1DynamicSecretsPostRequest["apiV1DynamicSecretsPostRequest"]) {
|
||||||
|
const res = await this.#apiInstance.apiV1DynamicSecretsPost(
|
||||||
|
{
|
||||||
|
apiV1DynamicSecretsPostRequest: options
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(dynamicSecretName: string, options: DefaultApiApiV1DynamicSecretsNameDeleteRequest["apiV1DynamicSecretsNameDeleteRequest"]) {
|
||||||
|
const res = await this.#apiInstance.apiV1DynamicSecretsNameDelete(
|
||||||
|
{
|
||||||
|
name: dynamicSecretName,
|
||||||
|
apiV1DynamicSecretsNameDeleteRequest: options
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
leases = {
|
||||||
|
create: async (options: DefaultApiApiV1DynamicSecretsLeasesPostRequest["apiV1DynamicSecretsLeasesPostRequest"]) => {
|
||||||
|
const res = await this.#apiInstance.apiV1DynamicSecretsLeasesPost(
|
||||||
|
{
|
||||||
|
apiV1DynamicSecretsLeasesPostRequest: options
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
delete: async (
|
||||||
|
leaseId: string,
|
||||||
|
options: DefaultApiApiV1DynamicSecretsLeasesLeaseIdDeleteRequest["apiV1DynamicSecretsLeasesLeaseIdDeleteRequest"]
|
||||||
|
) => {
|
||||||
|
const res = await this.#apiInstance.apiV1DynamicSecretsLeasesLeaseIdDelete(
|
||||||
|
{
|
||||||
|
leaseId: leaseId,
|
||||||
|
apiV1DynamicSecretsLeasesLeaseIdDeleteRequest: options
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
renew: async (
|
||||||
|
leaseId: string,
|
||||||
|
options: DefaultApiApiV1DynamicSecretsLeasesLeaseIdRenewPostRequest["apiV1DynamicSecretsLeasesLeaseIdRenewPostRequest"]
|
||||||
|
) => {
|
||||||
|
const res = await this.#apiInstance.apiV1DynamicSecretsLeasesLeaseIdRenewPost(
|
||||||
|
{
|
||||||
|
leaseId: leaseId,
|
||||||
|
apiV1DynamicSecretsLeasesLeaseIdRenewPostRequest: options
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { RawAxiosRequestConfig } from "axios";
|
||||||
import { Configuration, DefaultApi as InfisicalApi } from "../infisicalapi_client";
|
import { Configuration, DefaultApi as InfisicalApi } from "../infisicalapi_client";
|
||||||
import type {
|
import type {
|
||||||
DefaultApiApiV3SecretsRawSecretNameDeleteRequest,
|
DefaultApiApiV3SecretsRawSecretNameDeleteRequest,
|
||||||
@@ -45,67 +46,83 @@ const convertBool = (value: boolean | undefined) => (value ? "true" : "false");
|
|||||||
|
|
||||||
export default class SecretsClient {
|
export default class SecretsClient {
|
||||||
#apiInstance: InfisicalApi;
|
#apiInstance: InfisicalApi;
|
||||||
constructor(apiInstance: InfisicalApi) {
|
#requestOptions: RawAxiosRequestConfig | undefined;
|
||||||
|
constructor(apiInstance: InfisicalApi, requestOptions: RawAxiosRequestConfig | undefined) {
|
||||||
this.#apiInstance = apiInstance;
|
this.#apiInstance = apiInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
listSecrets = async (options: ListSecretsOptions) => {
|
listSecrets = async (options: ListSecretsOptions) => {
|
||||||
const res = await this.#apiInstance.apiV3SecretsRawGet({
|
const res = await this.#apiInstance.apiV3SecretsRawGet(
|
||||||
environment: options.environment,
|
{
|
||||||
workspaceId: options.projectId,
|
environment: options.environment,
|
||||||
expandSecretReferences: convertBool(options.expandSecretReferences),
|
workspaceId: options.projectId,
|
||||||
includeImports: convertBool(options.includeImports),
|
expandSecretReferences: convertBool(options.expandSecretReferences),
|
||||||
recursive: convertBool(options.recursive),
|
includeImports: convertBool(options.includeImports),
|
||||||
secretPath: options.secretPath,
|
recursive: convertBool(options.recursive),
|
||||||
tagSlugs: options.tagSlugs ? options.tagSlugs.join(",") : undefined
|
secretPath: options.secretPath,
|
||||||
});
|
tagSlugs: options.tagSlugs ? options.tagSlugs.join(",") : undefined
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
return res.data;
|
return res.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
getSecret = async (options: GetSecretOptions) => {
|
getSecret = async (options: GetSecretOptions) => {
|
||||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNameGet({
|
const res = await this.#apiInstance.apiV3SecretsRawSecretNameGet(
|
||||||
environment: options.environment,
|
{
|
||||||
secretName: options.secretName,
|
environment: options.environment,
|
||||||
workspaceId: options.projectId,
|
secretName: options.secretName,
|
||||||
expandSecretReferences: convertBool(options.expandSecretReferences),
|
workspaceId: options.projectId,
|
||||||
includeImports: convertBool(options.includeImports),
|
expandSecretReferences: convertBool(options.expandSecretReferences),
|
||||||
secretPath: options.secretPath,
|
includeImports: convertBool(options.includeImports),
|
||||||
type: options.type,
|
secretPath: options.secretPath,
|
||||||
version: options.version
|
type: options.type,
|
||||||
});
|
version: options.version
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
return res.data.secret;
|
return res.data.secret;
|
||||||
};
|
};
|
||||||
|
|
||||||
updateSecret = async (secretName: DefaultApiApiV3SecretsRawSecretNamePatchRequest["secretName"], options: UpdateSecretOptions) => {
|
updateSecret = async (secretName: DefaultApiApiV3SecretsRawSecretNamePatchRequest["secretName"], options: UpdateSecretOptions) => {
|
||||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNamePatch({
|
const res = await this.#apiInstance.apiV3SecretsRawSecretNamePatch(
|
||||||
secretName,
|
{
|
||||||
apiV3SecretsRawSecretNamePatchRequest: {
|
secretName,
|
||||||
...options,
|
apiV3SecretsRawSecretNamePatchRequest: {
|
||||||
workspaceId: options.projectId
|
...options,
|
||||||
}
|
workspaceId: options.projectId
|
||||||
});
|
}
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
return res.data;
|
return res.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
createSecret = async (secretName: DefaultApiApiV3SecretsRawSecretNamePostRequest["secretName"], options: CreateSecretOptions) => {
|
createSecret = async (secretName: DefaultApiApiV3SecretsRawSecretNamePostRequest["secretName"], options: CreateSecretOptions) => {
|
||||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNamePost({
|
const res = await this.#apiInstance.apiV3SecretsRawSecretNamePost(
|
||||||
secretName,
|
{
|
||||||
apiV3SecretsRawSecretNamePostRequest: {
|
secretName,
|
||||||
...options,
|
apiV3SecretsRawSecretNamePostRequest: {
|
||||||
workspaceId: options.projectId
|
...options,
|
||||||
}
|
workspaceId: options.projectId
|
||||||
});
|
}
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
return res.data;
|
return res.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteSecret = async (secretName: DefaultApiApiV3SecretsRawSecretNameDeleteRequest["secretName"], options: DeleteSecretOptions) => {
|
deleteSecret = async (secretName: DefaultApiApiV3SecretsRawSecretNameDeleteRequest["secretName"], options: DeleteSecretOptions) => {
|
||||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNameDelete({
|
const res = await this.#apiInstance.apiV3SecretsRawSecretNameDelete(
|
||||||
secretName,
|
{
|
||||||
apiV3SecretsRawSecretNameDeleteRequest: {
|
secretName,
|
||||||
...options,
|
apiV3SecretsRawSecretNameDeleteRequest: {
|
||||||
workspaceId: options.projectId
|
...options,
|
||||||
}
|
workspaceId: options.projectId
|
||||||
});
|
}
|
||||||
|
},
|
||||||
|
this.#requestOptions
|
||||||
|
);
|
||||||
return res.data;
|
return res.data;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user