Skip to content

Commit

Permalink
feat(block): remove SnapshotSummary (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Feb 14, 2024
1 parent dc885f0 commit 41f5fef
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 104 deletions.
1 change: 0 additions & 1 deletion packages/clients/src/api/block/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export type {
Snapshot,
SnapshotParentVolume,
SnapshotStatus,
SnapshotSummary,
StorageClass,
UpdateSnapshotRequest,
UpdateVolumeRequest,
Expand Down
81 changes: 28 additions & 53 deletions packages/clients/src/api/block/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import type {
Reference,
Snapshot,
SnapshotParentVolume,
SnapshotSummary,
UpdateSnapshotRequest,
UpdateVolumeRequest,
Volume,
Expand All @@ -44,81 +43,82 @@ export const unmarshalReference = (data: unknown): Reference => {
} as Reference
}

const unmarshalVolumeSpecifications = (data: unknown): VolumeSpecifications => {
const unmarshalSnapshotParentVolume = (data: unknown): SnapshotParentVolume => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'VolumeSpecifications' failed as data isn't a dictionary.`,
`Unmarshalling the type 'SnapshotParentVolume' failed as data isn't a dictionary.`,
)
}

return {
class: data.class,
perfIops: data.perf_iops,
} as VolumeSpecifications
id: data.id,
name: data.name,
status: data.status,
type: data.type,
} as SnapshotParentVolume
}

export const unmarshalVolume = (data: unknown): Volume => {
export const unmarshalSnapshot = (data: unknown): Snapshot => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Volume' failed as data isn't a dictionary.`,
`Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`,
)
}

return {
class: data.class,
createdAt: unmarshalDate(data.created_at),
id: data.id,
lastDetachedAt: unmarshalDate(data.last_detached_at),
name: data.name,
parentSnapshotId: data.parent_snapshot_id,
parentVolume: data.parent_volume
? unmarshalSnapshotParentVolume(data.parent_volume)
: undefined,
projectId: data.project_id,
references: unmarshalArrayOfObject(data.references, unmarshalReference),
size: data.size,
specs: data.specs ? unmarshalVolumeSpecifications(data.specs) : undefined,
status: data.status,
tags: data.tags,
type: data.type,
updatedAt: unmarshalDate(data.updated_at),
zone: data.zone,
} as Volume
} as Snapshot
}

const unmarshalSnapshotParentVolume = (data: unknown): SnapshotParentVolume => {
const unmarshalVolumeSpecifications = (data: unknown): VolumeSpecifications => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'SnapshotParentVolume' failed as data isn't a dictionary.`,
`Unmarshalling the type 'VolumeSpecifications' failed as data isn't a dictionary.`,
)
}

return {
id: data.id,
name: data.name,
status: data.status,
type: data.type,
} as SnapshotParentVolume
class: data.class,
perfIops: data.perf_iops,
} as VolumeSpecifications
}

const unmarshalSnapshotSummary = (data: unknown): SnapshotSummary => {
export const unmarshalVolume = (data: unknown): Volume => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'SnapshotSummary' failed as data isn't a dictionary.`,
`Unmarshalling the type 'Volume' failed as data isn't a dictionary.`,
)
}

return {
class: data.class,
createdAt: unmarshalDate(data.created_at),
id: data.id,
lastDetachedAt: unmarshalDate(data.last_detached_at),
name: data.name,
parentVolume: data.parent_volume
? unmarshalSnapshotParentVolume(data.parent_volume)
: undefined,
parentSnapshotId: data.parent_snapshot_id,
projectId: data.project_id,
references: unmarshalArrayOfObject(data.references, unmarshalReference),
size: data.size,
specs: data.specs ? unmarshalVolumeSpecifications(data.specs) : undefined,
status: data.status,
tags: data.tags,
type: data.type,
updatedAt: unmarshalDate(data.updated_at),
zone: data.zone,
} as SnapshotSummary
} as Volume
}

export const unmarshalListSnapshotsResponse = (
Expand All @@ -131,7 +131,7 @@ export const unmarshalListSnapshotsResponse = (
}

return {
snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshotSummary),
snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot),
totalCount: data.total_count,
} as ListSnapshotsResponse
}
Expand Down Expand Up @@ -183,31 +183,6 @@ export const unmarshalListVolumesResponse = (
} as ListVolumesResponse
}

export const unmarshalSnapshot = (data: unknown): Snapshot => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`,
)
}

return {
class: data.class,
createdAt: unmarshalDate(data.created_at),
id: data.id,
name: data.name,
parentVolume: data.parent_volume
? unmarshalSnapshotParentVolume(data.parent_volume)
: undefined,
projectId: data.project_id,
references: unmarshalArrayOfObject(data.references, unmarshalReference),
size: data.size,
status: data.status,
tags: data.tags,
updatedAt: unmarshalDate(data.updated_at),
zone: data.zone,
} as Snapshot
}

export const marshalCreateSnapshotRequest = (
request: CreateSnapshotRequest,
defaults: DefaultValues,
Expand Down
75 changes: 25 additions & 50 deletions packages/clients/src/api/block/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ export type VolumeStatus =
| 'snapshotting'
| 'locked'

export interface Reference {
/** UUID of the reference. */
id: string
/** Type of resource to which the reference is associated. */
productResourceType: string
/**
* UUID of the product resource it refers to (according to the
* product_resource_type).
*/
productResourceId: string
/** Creation date of the reference. */
createdAt?: Date
/** Type of reference (link, exclusive, read_only). */
type: ReferenceType
/** Status of reference (attaching, attached, detaching). */
status: ReferenceStatus
}

export interface SnapshotParentVolume {
/** Parent volume UUID (volume from which the snapshot originates). */
id: string
Expand All @@ -74,24 +92,6 @@ export interface VolumeSpecifications {
class: StorageClass
}

export interface Reference {
/** UUID of the reference. */
id: string
/** Type of resource to which the reference is associated. */
productResourceType: string
/**
* UUID of the product resource it refers to (according to the
* product_resource_type).
*/
productResourceId: string
/** Creation date of the reference. */
createdAt?: Date
/** Type of reference (link, exclusive, read_only). */
type: ReferenceType
/** Status of reference (attaching, attached, detaching). */
status: ReferenceStatus
}

export interface CreateVolumeRequestFromEmpty {
/** Must be compliant with the minimum (1 GB) and maximum (10 TB) allowed size. */
size: number
Expand All @@ -108,26 +108,28 @@ export interface CreateVolumeRequestFromSnapshot {
snapshotId: string
}

export interface SnapshotSummary {
export interface Snapshot {
/** UUID of the snapshot. */
id: string
/** Name of the snapshot. */
name: string
/** If the parent volume has been deleted, value is null. */
/** If the parent volume was deleted, value is null. */
parentVolume?: SnapshotParentVolume
/** Size of the snapshot in bytes. */
/** Size in bytes of the snapshot. */
size: number
/** UUID of the project the snapshot belongs to. */
projectId: string
/** Creation date of the snapshot. */
createdAt?: Date
/** Last modification date of the properties of a snapshot. */
updatedAt?: Date
/** List of the references to the snapshot. */
references: Reference[]
/** Current status of the snapshot (available, in_use, ...). */
status: SnapshotStatus
/** List of tags assigned to the volume. */
tags: string[]
/** Snapshot Availability Zone. */
/** Snapshot zone. */
zone: Zone
/** Storage class of the snapshot. */
class: StorageClass
Expand Down Expand Up @@ -273,7 +275,7 @@ export type ListSnapshotsRequest = {

export interface ListSnapshotsResponse {
/** Paginated returned list of snapshots. */
snapshots: SnapshotSummary[]
snapshots: Snapshot[]
/** Total number of snpashots in the project. */
totalCount: number
}
Expand Down Expand Up @@ -329,33 +331,6 @@ export interface ListVolumesResponse {
totalCount: number
}

export interface Snapshot {
/** UUID of the snapshot. */
id: string
/** Name of the snapshot. */
name: string
/** If the parent volume was deleted, value is null. */
parentVolume?: SnapshotParentVolume
/** Size in bytes of the snapshot. */
size: number
/** UUID of the project the snapshot belongs to. */
projectId: string
/** Creation date of the snapshot. */
createdAt?: Date
/** Last modification date of the properties of a snapshot. */
updatedAt?: Date
/** List of the references to the snapshot. */
references: Reference[]
/** Current status of the snapshot (available, in_use, ...). */
status: SnapshotStatus
/** List of tags assigned to the volume. */
tags: string[]
/** Snapshot zone. */
zone: Zone
/** Storage class of the snapshot. */
class: StorageClass
}

export type UpdateSnapshotRequest = {
/** Zone to target. If none is passed will use default zone from the config. */
zone?: Zone
Expand Down

0 comments on commit 41f5fef

Please sign in to comment.