@@ -53,38 +53,6 @@ func NewAPI(client *scw.Client) *API {
5353 }
5454}
5555
56- type ListMFAOTPsRequestOrderBy string
57-
58- const (
59- // ListMFAOTPsRequestOrderByCreatedAtAsc is [insert doc].
60- ListMFAOTPsRequestOrderByCreatedAtAsc = ListMFAOTPsRequestOrderBy ("created_at_asc" )
61- // ListMFAOTPsRequestOrderByCreatedAtDesc is [insert doc].
62- ListMFAOTPsRequestOrderByCreatedAtDesc = ListMFAOTPsRequestOrderBy ("created_at_desc" )
63- )
64-
65- func (enum ListMFAOTPsRequestOrderBy ) String () string {
66- if enum == "" {
67- // return default value if empty
68- return "created_at_asc"
69- }
70- return string (enum )
71- }
72-
73- func (enum ListMFAOTPsRequestOrderBy ) MarshalJSON () ([]byte , error ) {
74- return []byte (fmt .Sprintf (`"%s"` , enum )), nil
75- }
76-
77- func (enum * ListMFAOTPsRequestOrderBy ) UnmarshalJSON (data []byte ) error {
78- tmp := ""
79-
80- if err := json .Unmarshal (data , & tmp ); err != nil {
81- return err
82- }
83-
84- * enum = ListMFAOTPsRequestOrderBy (ListMFAOTPsRequestOrderBy (tmp ).String ())
85- return nil
86- }
87-
8856type ListProjectsRequestOrderBy string
8957
9058const (
@@ -121,14 +89,6 @@ func (enum *ListProjectsRequestOrderBy) UnmarshalJSON(data []byte) error {
12189 return nil
12290}
12391
124- // ListMFAOTPsResponse: list mfaot ps response
125- type ListMFAOTPsResponse struct {
126- // TotalCount: the total number of MFA OTPs
127- TotalCount uint32 `json:"total_count"`
128- // MfaOtps: the paginated returned MFA OTPs
129- MfaOtps []* MFAOTP `json:"mfa_otps"`
130- }
131-
13292// ListProjectsResponse: list projects response
13393type ListProjectsResponse struct {
13494 // TotalCount: the total number of projects
@@ -137,12 +97,6 @@ type ListProjectsResponse struct {
13797 Projects []* Project `json:"projects"`
13898}
13999
140- // MFAOTP: mfaotp
141- type MFAOTP struct {
142- // ID: the ID of the MFA OTP
143- ID string `json:"id"`
144- }
145-
146100// Project: project
147101type Project struct {
148102 // ID: the ID of the project
@@ -159,12 +113,6 @@ type Project struct {
159113 Description string `json:"description"`
160114}
161115
162- // ValidateMFAOTPResponse: validate mfaotp response
163- type ValidateMFAOTPResponse struct {
164- // BackupCodes: the backup codes of the MFA OTP
165- BackupCodes []string `json:"backup_codes"`
166- }
167-
168116// Service API
169117
170118type CreateProjectRequest struct {
@@ -366,140 +314,6 @@ func (s *API) UpdateProject(req *UpdateProjectRequest, opts ...scw.RequestOption
366314 return & resp , nil
367315}
368316
369- type ListMFAOTPsRequest struct {
370- // Page: the page number for the returned MFA OTPs
371- Page * int32 `json:"-"`
372- // PageSize: the maximum number of MFA OTP per page
373- PageSize * uint32 `json:"-"`
374- // OrderBy: the sort order of the returned MFA OTPs
375- //
376- // Default value: created_at_asc
377- OrderBy ListMFAOTPsRequestOrderBy `json:"-"`
378- // AccountRootUserID: filter out by a account root user ID
379- AccountRootUserID string `json:"-"`
380- }
381-
382- // ListMFAOTPs: list MFA OTPs
383- func (s * API ) ListMFAOTPs (req * ListMFAOTPsRequest , opts ... scw.RequestOption ) (* ListMFAOTPsResponse , error ) {
384- var err error
385-
386- defaultPageSize , exist := s .client .GetDefaultPageSize ()
387- if (req .PageSize == nil || * req .PageSize == 0 ) && exist {
388- req .PageSize = & defaultPageSize
389- }
390-
391- query := url.Values {}
392- parameter .AddToQuery (query , "page" , req .Page )
393- parameter .AddToQuery (query , "page_size" , req .PageSize )
394- parameter .AddToQuery (query , "order_by" , req .OrderBy )
395- parameter .AddToQuery (query , "account_root_user_id" , req .AccountRootUserID )
396-
397- scwReq := & scw.ScalewayRequest {
398- Method : "GET" ,
399- Path : "/account/v2/mfa/otps" ,
400- Query : query ,
401- Headers : http.Header {},
402- }
403-
404- var resp ListMFAOTPsResponse
405-
406- err = s .client .Do (scwReq , & resp , opts ... )
407- if err != nil {
408- return nil , err
409- }
410- return & resp , nil
411- }
412-
413- type CreateMFAOTPRequest struct {
414- // AccountRootUserID: the account root user ID of the MFA OTP
415- AccountRootUserID string `json:"account_root_user_id"`
416- }
417-
418- // CreateMFAOTP: create MFA OTP
419- func (s * API ) CreateMFAOTP (req * CreateMFAOTPRequest , opts ... scw.RequestOption ) (* MFAOTP , error ) {
420- var err error
421-
422- scwReq := & scw.ScalewayRequest {
423- Method : "POST" ,
424- Path : "/account/v2/mfa/otps" ,
425- Headers : http.Header {},
426- }
427-
428- err = scwReq .SetBody (req )
429- if err != nil {
430- return nil , err
431- }
432-
433- var resp MFAOTP
434-
435- err = s .client .Do (scwReq , & resp , opts ... )
436- if err != nil {
437- return nil , err
438- }
439- return & resp , nil
440- }
441-
442- type ValidateMFAOTPRequest struct {
443- // MfaOtpID: the MFA OTP ID
444- MfaOtpID string `json:"-"`
445- // Otp: the code of the MFA OTP
446- Otp string `json:"otp"`
447- }
448-
449- // ValidateMFAOTP: validate MFA OTP
450- func (s * API ) ValidateMFAOTP (req * ValidateMFAOTPRequest , opts ... scw.RequestOption ) (* ValidateMFAOTPResponse , error ) {
451- var err error
452-
453- if fmt .Sprint (req .MfaOtpID ) == "" {
454- return nil , errors .New ("field MfaOtpID cannot be empty in request" )
455- }
456-
457- scwReq := & scw.ScalewayRequest {
458- Method : "POST" ,
459- Path : "/account/v2/mfa/otps/" + fmt .Sprint (req .MfaOtpID ) + "/validate" ,
460- Headers : http.Header {},
461- }
462-
463- err = scwReq .SetBody (req )
464- if err != nil {
465- return nil , err
466- }
467-
468- var resp ValidateMFAOTPResponse
469-
470- err = s .client .Do (scwReq , & resp , opts ... )
471- if err != nil {
472- return nil , err
473- }
474- return & resp , nil
475- }
476-
477- type DeleteMFAOTPRequest struct {
478- // MfaOtpID: the MFA OTP ID
479- MfaOtpID string `json:"-"`
480- }
481-
482- // DeleteMFAOTP: delete MFA OTP
483- func (s * API ) DeleteMFAOTP (req * DeleteMFAOTPRequest , opts ... scw.RequestOption ) error {
484- var err error
485-
486- if fmt .Sprint (req .MfaOtpID ) == "" {
487- return errors .New ("field MfaOtpID cannot be empty in request" )
488- }
489-
490- scwReq := & scw.ScalewayRequest {
491- Method : "DELETE" ,
492- Path : "/account/v2/mfa/otps/" + fmt .Sprint (req .MfaOtpID ) + "" ,
493- Headers : http.Header {},
494- }
495-
496- err = s .client .Do (scwReq , nil , opts ... )
497- if err != nil {
498- return err
499- }
500- return nil
501- }
502-
503317// UnsafeGetTotalCount should not be used
504318// Internal usage only
505319func (r * ListProjectsResponse ) UnsafeGetTotalCount () uint32 {
@@ -518,22 +332,3 @@ func (r *ListProjectsResponse) UnsafeAppend(res interface{}) (uint32, error) {
518332 r .TotalCount += uint32 (len (results .Projects ))
519333 return uint32 (len (results .Projects )), nil
520334}
521-
522- // UnsafeGetTotalCount should not be used
523- // Internal usage only
524- func (r * ListMFAOTPsResponse ) UnsafeGetTotalCount () uint32 {
525- return r .TotalCount
526- }
527-
528- // UnsafeAppend should not be used
529- // Internal usage only
530- func (r * ListMFAOTPsResponse ) UnsafeAppend (res interface {}) (uint32 , error ) {
531- results , ok := res .(* ListMFAOTPsResponse )
532- if ! ok {
533- return 0 , errors .New ("%T type cannot be appended to type %T" , res , r )
534- }
535-
536- r .MfaOtps = append (r .MfaOtps , results .MfaOtps ... )
537- r .TotalCount += uint32 (len (results .MfaOtps ))
538- return uint32 (len (results .MfaOtps )), nil
539- }
0 commit comments