@@ -12,6 +12,8 @@ import (
1212type NfsActionsService interface {
1313 Resize (ctx context.Context , nfsShareId string , size uint64 , region string ) (* NfsAction , * Response , error )
1414 Snapshot (ctx context.Context , nfsShareId string , nfsSnapshotName string , region string ) (* NfsAction , * Response , error )
15+ Attach (ctx context.Context , nfsShareId string , vpcID string , region string ) (* NfsAction , * Response , error )
16+ Detach (ctx context.Context , nfsShareId string , vpcID string , region string ) (* NfsAction , * Response , error )
1517}
1618
1719// NfsActionsServiceOp handles communication with the NFS action related
@@ -57,6 +59,16 @@ type NfsSnapshotParams struct {
5759 Name string `json:"name"`
5860}
5961
62+ // NfsAttachParams represents parameters for attaching an NFS share to a VPC
63+ type NfsAttachParams struct {
64+ VpcID string `json:"vpc_id"`
65+ }
66+
67+ // NfsDetachParams represents parameters for detaching an NFS share from a VPC
68+ type NfsDetachParams struct {
69+ VpcID string `json:"vpc_id"`
70+ }
71+
6072// Resize an NFS share
6173func (s * NfsActionsServiceOp ) Resize (ctx context.Context , nfsShareId string , size uint64 , region string ) (* NfsAction , * Response , error ) {
6274 request := & NfsActionRequest {
@@ -83,6 +95,32 @@ func (s *NfsActionsServiceOp) Snapshot(ctx context.Context, nfsShareId, nfsSnaps
8395 return s .doAction (ctx , nfsShareId , request )
8496}
8597
98+ // Attach an NFS share
99+ func (s * NfsActionsServiceOp ) Attach (ctx context.Context , nfsShareId , vpcID , region string ) (* NfsAction , * Response , error ) {
100+ request := & NfsActionRequest {
101+ Type : "attach" ,
102+ Region : region ,
103+ Params : & NfsAttachParams {
104+ VpcID : vpcID ,
105+ },
106+ }
107+
108+ return s .doAction (ctx , nfsShareId , request )
109+ }
110+
111+ // Detach an NFS share
112+ func (s * NfsActionsServiceOp ) Detach (ctx context.Context , nfsShareId , vpcID , region string ) (* NfsAction , * Response , error ) {
113+ request := & NfsActionRequest {
114+ Type : "detach" ,
115+ Region : region ,
116+ Params : & NfsAttachParams {
117+ VpcID : vpcID ,
118+ },
119+ }
120+
121+ return s .doAction (ctx , nfsShareId , request )
122+ }
123+
86124func (s * NfsActionsServiceOp ) doAction (ctx context.Context , nfsShareId string , request * NfsActionRequest ) (* NfsAction , * Response , error ) {
87125 if request == nil {
88126 return nil , nil , NewArgError ("request" , "request can't be nil" )
0 commit comments