9
9
import type { Zone } from '../../../bridge'
10
10
import {
11
11
marshalApplyBlockMigrationRequest ,
12
+ marshalAttachServerVolumeRequest ,
12
13
marshalCreateImageRequest ,
13
14
marshalCreateIpRequest ,
14
15
marshalCreatePlacementGroupRequest ,
@@ -18,6 +19,7 @@ import {
18
19
marshalCreateServerRequest ,
19
20
marshalCreateSnapshotRequest ,
20
21
marshalCreateVolumeRequest ,
22
+ marshalDetachServerVolumeRequest ,
21
23
marshalExportSnapshotRequest ,
22
24
marshalPlanBlockMigrationRequest ,
23
25
marshalServerActionRequest ,
@@ -35,6 +37,7 @@ import {
35
37
marshalUpdatePrivateNICRequest ,
36
38
marshalUpdateServerRequest ,
37
39
marshalUpdateVolumeRequest ,
40
+ unmarshalAttachServerVolumeResponse ,
38
41
unmarshalCreateImageResponse ,
39
42
unmarshalCreateIpResponse ,
40
43
unmarshalCreatePlacementGroupResponse ,
@@ -44,6 +47,7 @@ import {
44
47
unmarshalCreateServerResponse ,
45
48
unmarshalCreateSnapshotResponse ,
46
49
unmarshalCreateVolumeResponse ,
50
+ unmarshalDetachServerVolumeResponse ,
47
51
unmarshalExportSnapshotResponse ,
48
52
unmarshalGetBootscriptResponse ,
49
53
unmarshalGetDashboardResponse ,
@@ -91,6 +95,8 @@ import {
91
95
} from './marshalling.gen'
92
96
import type {
93
97
ApplyBlockMigrationRequest ,
98
+ AttachServerVolumeRequest ,
99
+ AttachServerVolumeResponse ,
94
100
CreateImageRequest ,
95
101
CreateImageResponse ,
96
102
CreateIpRequest ,
@@ -119,6 +125,8 @@ import type {
119
125
DeleteServerUserDataRequest ,
120
126
DeleteSnapshotRequest ,
121
127
DeleteVolumeRequest ,
128
+ DetachServerVolumeRequest ,
129
+ DetachServerVolumeResponse ,
122
130
ExportSnapshotRequest ,
123
131
ExportSnapshotResponse ,
124
132
GetBootscriptRequest ,
@@ -526,6 +534,56 @@ export class API extends ParentAPI {
526
534
) } /user_data/${ validatePathParam ( 'key' , request . key ) } `,
527
535
} )
528
536
537
+ /**
538
+ * Attach a volume to a server.
539
+ *
540
+ * @param request - The request {@link AttachServerVolumeRequest}
541
+ * @returns A Promise of AttachServerVolumeResponse
542
+ */
543
+ attachServerVolume = ( request : Readonly < AttachServerVolumeRequest > ) =>
544
+ this . client . fetch < AttachServerVolumeResponse > (
545
+ {
546
+ body : JSON . stringify (
547
+ marshalAttachServerVolumeRequest ( request , this . client . settings ) ,
548
+ ) ,
549
+ headers : jsonContentHeaders ,
550
+ method : 'POST' ,
551
+ path : `/instance/v1/zones/${ validatePathParam (
552
+ 'zone' ,
553
+ request . zone ?? this . client . settings . defaultZone ,
554
+ ) } /servers/${ validatePathParam (
555
+ 'serverId' ,
556
+ request . serverId ,
557
+ ) } /attach-volume`,
558
+ } ,
559
+ unmarshalAttachServerVolumeResponse ,
560
+ )
561
+
562
+ /**
563
+ * Detach a volume from a server.
564
+ *
565
+ * @param request - The request {@link DetachServerVolumeRequest}
566
+ * @returns A Promise of DetachServerVolumeResponse
567
+ */
568
+ detachServerVolume = ( request : Readonly < DetachServerVolumeRequest > ) =>
569
+ this . client . fetch < DetachServerVolumeResponse > (
570
+ {
571
+ body : JSON . stringify (
572
+ marshalDetachServerVolumeRequest ( request , this . client . settings ) ,
573
+ ) ,
574
+ headers : jsonContentHeaders ,
575
+ method : 'POST' ,
576
+ path : `/instance/v1/zones/${ validatePathParam (
577
+ 'zone' ,
578
+ request . zone ?? this . client . settings . defaultZone ,
579
+ ) } /servers/${ validatePathParam (
580
+ 'serverId' ,
581
+ request . serverId ,
582
+ ) } /detach-volume`,
583
+ } ,
584
+ unmarshalDetachServerVolumeResponse ,
585
+ )
586
+
529
587
protected pageOfListImages = ( request : Readonly < ListImagesRequest > = { } ) =>
530
588
this . client . fetch < ListImagesResponse > (
531
589
{
0 commit comments