From 752a4bcc821ba5af0f3c8891c5f10ac78e379415 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 7 Sep 2023 14:55:11 +0000 Subject: [PATCH] feat: update generated APIs --- .../clients/src/api/ipfs/v1alpha1/api.gen.ts | 33 +++++++++++++++++++ .../src/api/ipfs/v1alpha1/index.gen.ts | 3 ++ .../src/api/ipfs/v1alpha1/marshalling.gen.ts | 28 ++++++++++++++++ .../src/api/ipfs/v1alpha1/types.gen.ts | 29 ++++++++++++++++ 4 files changed, 93 insertions(+) diff --git a/packages/clients/src/api/ipfs/v1alpha1/api.gen.ts b/packages/clients/src/api/ipfs/v1alpha1/api.gen.ts index 448676cd4..11b17a660 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/api.gen.ts @@ -14,9 +14,11 @@ import { marshalCreatePinByCIDRequest, marshalCreatePinByURLRequest, marshalCreateVolumeRequest, + marshalImportKeyNameRequest, marshalReplacePinRequest, marshalUpdateNameRequest, marshalUpdateVolumeRequest, + unmarshalExportKeyNameResponse, unmarshalListNamesResponse, unmarshalListPinsResponse, unmarshalListVolumesResponse, @@ -33,9 +35,12 @@ import type { DeleteNameRequest, DeletePinRequest, DeleteVolumeRequest, + ExportKeyNameRequest, + ExportKeyNameResponse, GetNameRequest, GetPinRequest, GetVolumeRequest, + ImportKeyNameRequest, ListNamesRequest, ListNamesResponse, ListPinsRequest, @@ -435,4 +440,32 @@ export class API extends ParentAPI { }, unmarshalName, ) + + exportKeyName = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/ipfs/v1alpha1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/names/export-key/${validatePathParam('nameId', request.nameId)}`, + }, + unmarshalExportKeyNameResponse, + ) + + importKeyName = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalImportKeyNameRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/ipfs/v1alpha1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/names/import-key`, + }, + unmarshalName, + ) } diff --git a/packages/clients/src/api/ipfs/v1alpha1/index.gen.ts b/packages/clients/src/api/ipfs/v1alpha1/index.gen.ts index 24313d7bf..e1a78ce7a 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/index.gen.ts @@ -10,9 +10,12 @@ export type { DeleteNameRequest, DeletePinRequest, DeleteVolumeRequest, + ExportKeyNameRequest, + ExportKeyNameResponse, GetNameRequest, GetPinRequest, GetVolumeRequest, + ImportKeyNameRequest, ListNamesRequest, ListNamesRequestOrderBy, ListNamesResponse, diff --git a/packages/clients/src/api/ipfs/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/ipfs/v1alpha1/marshalling.gen.ts index 302035a8d..78a7df034 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/marshalling.gen.ts @@ -11,6 +11,8 @@ import type { CreatePinByCIDRequest, CreatePinByURLRequest, CreateVolumeRequest, + ExportKeyNameResponse, + ImportKeyNameRequest, ListNamesResponse, ListPinsResponse, ListVolumesResponse, @@ -125,6 +127,23 @@ export const unmarshalVolume = (data: unknown) => { } as Volume } +export const unmarshalExportKeyNameResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ExportKeyNameResponse' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + nameId: data.name_id, + privateKey: data.private_key, + projectId: data.project_id, + publicKey: data.public_key, + updatedAt: unmarshalDate(data.updated_at), + } as ExportKeyNameResponse +} + export const unmarshalListNamesResponse = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( @@ -226,6 +245,15 @@ export const marshalCreateVolumeRequest = ( project_id: request.projectId ?? defaults.defaultProjectId, }) +export const marshalImportKeyNameRequest = ( + request: ImportKeyNameRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + private_key: request.privateKey, + project_id: request.projectId ?? defaults.defaultProjectId, +}) + export const marshalReplacePinRequest = ( request: ReplacePinRequest, defaults: DefaultValues, diff --git a/packages/clients/src/api/ipfs/v1alpha1/types.gen.ts b/packages/clients/src/api/ipfs/v1alpha1/types.gen.ts index 1a943acf4..430c562e9 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/types.gen.ts @@ -45,6 +45,15 @@ export type PinStatus = | 'failed' | 'pinned' +export interface ExportKeyNameResponse { + nameId: string + projectId: string + createdAt?: Date + updatedAt?: Date + publicKey: string + privateKey: string +} + export interface ListNamesResponse { names: Name[] totalCount: number @@ -299,3 +308,23 @@ export type UpdateNameRequest = { tags?: string[] cid?: string } + +export type ExportKeyNameRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + nameId: string +} + +export type ImportKeyNameRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + projectId?: string + name: string + privateKey: string +}