@@ -17,15 +17,40 @@ import (
1717// KeyApi service type
1818type KeyApi common.Service
1919
20+ // CreateKeyOptionalParameters holds optional parameters for CreateKey.
21+ type CreateKeyOptionalParameters struct {
22+ Body * Key
23+ }
24+
25+ // NewCreateKeyOptionalParameters creates an empty struct for parameters.
26+ func NewCreateKeyOptionalParameters () * CreateKeyOptionalParameters {
27+ this := CreateKeyOptionalParameters {}
28+ return & this
29+ }
30+
31+ // WithBody sets the corresponding parameter name and returns the struct.
32+ func (r * CreateKeyOptionalParameters ) WithBody (body Key ) * CreateKeyOptionalParameters {
33+ r .Body = & body
34+ return r
35+ }
36+
2037// CreateKey Create a new key.
2138// Store a new key in the system.
22- func (a * KeyApi ) CreateKey (ctx _context.Context , body Key ) (Key , * _nethttp.Response , error ) {
39+ func (a * KeyApi ) CreateKey (ctx _context.Context , o ... CreateKeyOptionalParameters ) (Key , * _nethttp.Response , error ) {
2340 var (
2441 localVarHTTPMethod = _nethttp .MethodPost
2542 localVarPostBody interface {}
2643 localVarReturnValue Key
44+ optionalParams CreateKeyOptionalParameters
2745 )
2846
47+ if len (o ) > 1 {
48+ return localVarReturnValue , nil , common .ReportError ("only one argument of type CreateKeyOptionalParameters is allowed" )
49+ }
50+ if len (o ) == 1 {
51+ optionalParams = o [0 ]
52+ }
53+
2954 // Add api info to context
3055 apiInfo := common.APIInfo {
3156 Tag : "key" ,
@@ -46,10 +71,12 @@ func (a *KeyApi) CreateKey(ctx _context.Context, body Key) (Key, *_nethttp.Respo
4671 localVarQueryParams := _neturl.Values {}
4772 localVarFormParams := _neturl.Values {}
4873 localVarHeaderParams ["Content-Type" ] = "application/json"
49- localVarHeaderParams ["Accept" ] = "*/* "
74+ localVarHeaderParams ["Accept" ] = "application/json "
5075
5176 // body params
52- localVarPostBody = & body
77+ if optionalParams .Body != nil {
78+ localVarPostBody = & optionalParams .Body
79+ }
5380 common .SetAuthKeys (
5481 ctx ,
5582 & localVarHeaderParams ,
@@ -75,16 +102,7 @@ func (a *KeyApi) CreateKey(ctx _context.Context, body Key) (Key, *_nethttp.Respo
75102 ErrorBody : localVarBody ,
76103 ErrorMessage : localVarHTTPResponse .Status ,
77104 }
78- if localVarHTTPResponse .StatusCode == 400 {
79- var v None
80- err = a .Client .Decode (& v , localVarBody , localVarHTTPResponse .Header .Get ("Content-Type" ))
81- if err != nil {
82- return localVarReturnValue , localVarHTTPResponse , newErr
83- }
84- newErr .ErrorModel = v
85- return localVarReturnValue , localVarHTTPResponse , newErr
86- }
87- if localVarHTTPResponse .StatusCode == 401 || localVarHTTPResponse .StatusCode == 403 {
105+ if localVarHTTPResponse .StatusCode == 400 || localVarHTTPResponse .StatusCode == 401 || localVarHTTPResponse .StatusCode == 403 {
88106 var v APIErrorResponse
89107 err = a .Client .Decode (& v , localVarBody , localVarHTTPResponse .Header .Get ("Content-Type" ))
90108 if err != nil {
0 commit comments