From 35b04c614317c7a7b5e3ca44c14501cc6941c043 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 21 Sep 2023 14:17:25 +0000 Subject: [PATCH] feat: update generated APIs --- .../clients/src/api/ipfs/v1alpha1/api.gen.ts | 186 +----------------- .../src/api/ipfs/v1alpha1/content.gen.ts | 5 +- .../src/api/ipfs/v1alpha1/index.gen.ts | 12 -- .../src/api/ipfs/v1alpha1/marshalling.gen.ts | 84 -------- .../src/api/ipfs/v1alpha1/types.gen.ts | 110 ----------- 5 files changed, 2 insertions(+), 395 deletions(-) diff --git a/packages/clients/src/api/ipfs/v1alpha1/api.gen.ts b/packages/clients/src/api/ipfs/v1alpha1/api.gen.ts index abfa19fdb..ea266a15e 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/api.gen.ts @@ -8,50 +8,34 @@ import { waitForResource, } from '../../../bridge' import type { Region, WaitForOptions } from '../../../bridge' -import { NAME_TRANSIENT_STATUSES, PIN_TRANSIENT_STATUSES } from './content.gen' +import { PIN_TRANSIENT_STATUSES } from './content.gen' import { - marshalCreateNameRequest, marshalCreatePinByCIDRequest, marshalCreatePinByURLRequest, marshalCreateVolumeRequest, - marshalImportKeyNameRequest, marshalReplacePinRequest, - marshalUpdateNameRequest, marshalUpdateVolumeRequest, - unmarshalExportKeyNameResponse, - unmarshalListNamesResponse, unmarshalListPinsResponse, unmarshalListVolumesResponse, - unmarshalName, unmarshalPin, unmarshalReplacePinResponse, unmarshalVolume, } from './marshalling.gen' import type { - CreateNameRequest, CreatePinByCIDRequest, CreatePinByURLRequest, CreateVolumeRequest, - DeleteNameRequest, DeletePinRequest, DeleteVolumeRequest, - ExportKeyNameRequest, - ExportKeyNameResponse, - GetNameRequest, GetPinRequest, GetVolumeRequest, - ImportKeyNameRequest, - ListNamesRequest, - ListNamesResponse, ListPinsRequest, ListPinsResponse, ListVolumesRequest, ListVolumesResponse, - Name, Pin, ReplacePinRequest, ReplacePinResponse, - UpdateNameRequest, UpdateVolumeRequest, Volume, } from './types.gen' @@ -343,172 +327,4 @@ export class API extends ParentAPI { )}/pins/${validatePathParam('pinId', request.pinId)}`, urlParams: urlParams(['volume_id', request.volumeId]), }) - - /** - * Create a new name. You can use the `ipfs key` command to list and generate - * more names and their respective keys. - * - * @param request - The request {@link CreateNameRequest} - * @returns A Promise of Name - */ - createName = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalCreateNameRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/ipfs/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/names`, - }, - unmarshalName, - ) - - /** - * Get information about a name. Retrieve information about a specific name. - * - * @param request - The request {@link GetNameRequest} - * @returns A Promise of Name - */ - getName = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/ipfs/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/names/${validatePathParam('nameId', request.nameId)}`, - }, - unmarshalName, - ) - - /** - * Waits for {@link Name} to be in a final state. - * - * @param request - The request {@link GetNameRequest} - * @param options - The waiting options - * @returns A Promise of Name - */ - waitForName = ( - request: Readonly, - options?: Readonly>, - ) => - waitForResource( - options?.stop ?? - (res => Promise.resolve(!NAME_TRANSIENT_STATUSES.includes(res.status))), - this.getName, - request, - options, - ) - - /** - * Delete an existing name. Delete a name by its ID. - * - * @param request - The request {@link DeleteNameRequest} - */ - deleteName = (request: Readonly) => - this.client.fetch({ - method: 'DELETE', - path: `/ipfs/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/names/${validatePathParam('nameId', request.nameId)}`, - }) - - protected pageOfListNames = (request: Readonly = {}) => - this.client.fetch( - { - method: 'GET', - path: `/ipfs/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/names`, - urlParams: urlParams( - ['order_by', request.orderBy ?? 'created_at_asc'], - ['organization_id', request.organizationId], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ['project_id', request.projectId], - ), - }, - unmarshalListNamesResponse, - ) - - /** - * List all names by a Project ID. Retrieve information about all names from a - * Project ID. - * - * @param request - The request {@link ListNamesRequest} - * @returns A Promise of ListNamesResponse - */ - listNames = (request: Readonly = {}) => - enrichForPagination('names', this.pageOfListNames, request) - - /** - * Update name information. Update name information (CID, tag, name...). - * - * @param request - The request {@link UpdateNameRequest} - * @returns A Promise of Name - */ - updateName = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalUpdateNameRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PATCH', - path: `/ipfs/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/names/${validatePathParam('nameId', request.nameId)}`, - }, - unmarshalName, - ) - - /** - * Export your private key. Export a private key by its ID. - * - * @param request - The request {@link ExportKeyNameRequest} - * @returns A Promise of ExportKeyNameResponse - */ - 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, - ) - - /** - * Import your private key. Import a private key. - * - * @param request - The request {@link ImportKeyNameRequest} - * @returns A Promise of Name - */ - 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/content.gen.ts b/packages/clients/src/api/ipfs/v1alpha1/content.gen.ts index 703dee887..0e003479e 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/content.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/content.gen.ts @@ -1,9 +1,6 @@ // This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. -import type { NameStatus, PinStatus } from './types.gen' - -/** Lists transient statutes of the enum {@link NameStatus}. */ -export const NAME_TRANSIENT_STATUSES: NameStatus[] = ['queued', 'publishing'] +import type { PinStatus } from './types.gen' /** Lists transient statutes of the enum {@link PinStatus}. */ export const PIN_TRANSIENT_STATUSES: PinStatus[] = ['queued', 'pinning'] diff --git a/packages/clients/src/api/ipfs/v1alpha1/index.gen.ts b/packages/clients/src/api/ipfs/v1alpha1/index.gen.ts index e1a78ce7a..75f4571bb 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/index.gen.ts @@ -3,30 +3,19 @@ export { API } from './api.gen' export * from './content.gen' export type { - CreateNameRequest, CreatePinByCIDRequest, CreatePinByURLRequest, CreateVolumeRequest, - DeleteNameRequest, DeletePinRequest, DeleteVolumeRequest, - ExportKeyNameRequest, - ExportKeyNameResponse, - GetNameRequest, GetPinRequest, GetVolumeRequest, - ImportKeyNameRequest, - ListNamesRequest, - ListNamesRequestOrderBy, - ListNamesResponse, ListPinsRequest, ListPinsRequestOrderBy, ListPinsResponse, ListVolumesRequest, ListVolumesRequestOrderBy, ListVolumesResponse, - Name, - NameStatus, Pin, PinCID, PinCIDMeta, @@ -36,7 +25,6 @@ export type { PinStatus, ReplacePinRequest, ReplacePinResponse, - UpdateNameRequest, UpdateVolumeRequest, Volume, } from './types.gen' diff --git a/packages/clients/src/api/ipfs/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/ipfs/v1alpha1/marshalling.gen.ts index 0c601d564..5669009e4 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/marshalling.gen.ts @@ -7,16 +7,11 @@ import { } from '../../../bridge' import type { DefaultValues } from '../../../bridge' import type { - CreateNameRequest, CreatePinByCIDRequest, CreatePinByURLRequest, CreateVolumeRequest, - ExportKeyNameResponse, - ImportKeyNameRequest, - ListNamesResponse, ListPinsResponse, ListVolumesResponse, - Name, Pin, PinCID, PinCIDMeta, @@ -24,7 +19,6 @@ import type { PinOptions, ReplacePinRequest, ReplacePinResponse, - UpdateNameRequest, UpdateVolumeRequest, Volume, } from './types.gen' @@ -70,26 +64,6 @@ const unmarshalPinInfo = (data: unknown) => { } as PinInfo } -export const unmarshalName = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Name' failed as data isn't a dictionary.`, - ) - } - - return { - createdAt: unmarshalDate(data.created_at), - key: data.key, - name: data.name, - nameId: data.name_id, - projectId: data.project_id, - status: data.status, - tags: data.tags, - updatedAt: unmarshalDate(data.updated_at), - value: data.value, - } as Name -} - export const unmarshalPin = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( @@ -127,36 +101,6 @@ 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( - `Unmarshalling the type 'ListNamesResponse' failed as data isn't a dictionary.`, - ) - } - - return { - names: unmarshalArrayOfObject(data.names, unmarshalName), - totalCount: data.total_count, - } as ListNamesResponse -} - export const unmarshalListPinsResponse = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( @@ -203,15 +147,6 @@ const marshalPinOptions = ( required_zones: request.requiredZones, }) -export const marshalCreateNameRequest = ( - request: CreateNameRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name, - project_id: request.projectId ?? defaults.defaultProjectId, - value: request.value, -}) - export const marshalCreatePinByCIDRequest = ( request: CreatePinByCIDRequest, defaults: DefaultValues, @@ -245,16 +180,6 @@ 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, - value: request.value, -}) - export const marshalReplacePinRequest = ( request: ReplacePinRequest, defaults: DefaultValues, @@ -268,15 +193,6 @@ export const marshalReplacePinRequest = ( volume_id: request.volumeId, }) -export const marshalUpdateNameRequest = ( - request: UpdateNameRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name, - tags: request.tags, - value: request.value, -}) - export const marshalUpdateVolumeRequest = ( request: UpdateVolumeRequest, 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 deb77bc81..3553940ea 100644 --- a/packages/clients/src/api/ipfs/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/ipfs/v1alpha1/types.gen.ts @@ -2,19 +2,10 @@ // If you have any remark or suggestion do not hesitate to open an issue. import type { Region } from '../../../bridge' -export type ListNamesRequestOrderBy = 'created_at_asc' | 'created_at_desc' - export type ListPinsRequestOrderBy = 'created_at_asc' | 'created_at_desc' export type ListVolumesRequestOrderBy = 'created_at_asc' | 'created_at_desc' -export type NameStatus = - | 'unknown_status' - | 'queued' - | 'publishing' - | 'failed' - | 'published' - export type PinDetails = | 'unknown_details' | 'pinning_looking_for_provider' @@ -45,20 +36,6 @@ 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 -} - export interface ListPinsResponse { totalCount: number pins: Pin[] @@ -69,18 +46,6 @@ export interface ListVolumesResponse { totalCount: number } -export interface Name { - nameId: string - projectId: string - createdAt?: Date - updatedAt?: Date - tags: string[] - name: string - key: string - status: NameStatus - value: string -} - export interface Pin { pinId: string status: PinStatus @@ -254,78 +219,3 @@ export type DeletePinRequest = { pinId: string volumeId: string } - -export type CreateNameRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - projectId?: string - name: string - value: string -} - -export type GetNameRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - nameId: string -} - -export type DeleteNameRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - nameId: string -} - -export type ListNamesRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - page?: number - pageSize?: number - orderBy?: ListNamesRequestOrderBy - projectId?: string - organizationId?: string -} - -export type UpdateNameRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - nameId: string - name?: string - tags?: string[] - value?: 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 - value: string -}