From 2d8579890b9ea375fb8824a526f9eef82696ec24 Mon Sep 17 00:00:00 2001 From: Omri Eival Date: Thu, 21 Dec 2023 15:15:59 +0200 Subject: [PATCH] fu --- .../internal/clients/abe/api/swagger.yaml | 31 + .../abe/api_a_bit_of_everything_service.go | 6940 +++++++++++++++++ examples/internal/clients/abe/client.go | 3 + .../a_bit_of_everything.swagger.json | 31 + .../internal/genopenapi/template.go | 6 +- .../internal/genopenapi/template_test.go | 6 +- 6 files changed, 7013 insertions(+), 4 deletions(-) create mode 100644 examples/internal/clients/abe/api_a_bit_of_everything_service.go diff --git a/examples/internal/clients/abe/api/swagger.yaml b/examples/internal/clients/abe/api/swagger.yaml index 6865bd881e1..a9fcc78441c 100644 --- a/examples/internal/clients/abe/api/swagger.yaml +++ b/examples/internal/clients/abe/api/swagger.yaml @@ -45,6 +45,7 @@ paths: /v1/example/a_bit_of_everything: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_CreateBody" parameters: @@ -134,6 +135,7 @@ paths: /v1/example/a_bit_of_everything/params/get/nested_enum/{singleNested.ok}: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckNestedEnumGetQueryParams" parameters: @@ -556,6 +558,7 @@ paths: /v1/example/a_bit_of_everything/params/get/{singleNested.name}: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckGetQueryParams" parameters: @@ -985,6 +988,7 @@ paths: /v1/example/a_bit_of_everything/params/post/{stringValue}: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckPostQueryParams" parameters: @@ -1401,6 +1405,7 @@ paths: /v1/example/a_bit_of_everything/query/{uuidName}: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_GetQuery" parameters: @@ -1842,6 +1847,7 @@ paths: ? /v1/example/a_bit_of_everything/{floatValue}/{doubleValue}/{int64Value}/separator/{uint64Value}/{int32Value}/{fixed64Value}/{fixed32Value}/{boolValue}/{stringValue}/{uint32Value}/{sfixed32Value}/{sfixed64Value}/{sint32Value}/{sint64Value}/{nonConventionalNameValue}/{enumValue}/{pathEnumValue}/{nestedPathEnumValue}/{enumValueAnnotation} : post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" summary: "Create a new ABitOfEverything" description: "This API creates a new ABitOfEverything" @@ -2260,6 +2266,7 @@ paths: /v1/example/a_bit_of_everything/{uuidName}: head: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_Exists" parameters: @@ -2678,6 +2685,7 @@ paths: $ref: "#/definitions/rpcStatus" put: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_Update" parameters: @@ -2722,6 +2730,7 @@ paths: $ref: "#/definitions/rpcStatus" options: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_CustomOptionsRequest" parameters: @@ -3141,6 +3150,7 @@ paths: /v1/example/a_bit_of_everything/{uuidName}:custom: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_Custom" parameters: @@ -3577,6 +3587,7 @@ paths: /v1/example/a_bit_of_everything/{uuidName}:custom:custom: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_DoubleColon" parameters: @@ -4013,6 +4024,7 @@ paths: /v1/example/a_bit_of_everything/{uuid}: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_Lookup" parameters: @@ -4049,6 +4061,7 @@ paths: $ref: "#/definitions/rpcStatus" delete: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_Delete" parameters: @@ -4092,6 +4105,7 @@ paths: ? /v1/example/a_bit_of_everything_repeated/{pathRepeatedFloatValue}/{pathRepeatedDoubleValue}/{pathRepeatedInt64Value}/{pathRepeatedUint64Value}/{pathRepeatedInt32Value}/{pathRepeatedFixed64Value}/{pathRepeatedFixed32Value}/{pathRepeatedBoolValue}/{pathRepeatedStringValue}/{pathRepeatedBytesValue}/{pathRepeatedUint32Value}/{pathRepeatedEnumValue}/{pathRepeatedSfixed32Value}/{pathRepeatedSfixed64Value}/{pathRepeatedSint32Value}/{pathRepeatedSint64Value} : get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_GetRepeatedQuery" parameters: @@ -4286,6 +4300,7 @@ paths: /v1/example/checkStatus: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckStatus" parameters: [] @@ -4318,6 +4333,7 @@ paths: /v1/example/deep_path/{singleNested.name}: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_DeepPathEcho" parameters: @@ -4362,6 +4378,7 @@ paths: /v1/example/oneofenum: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_PostOneofEnum" parameters: @@ -4400,6 +4417,7 @@ paths: /v1/example/requiredmessagetype: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_PostRequiredMessageType" parameters: @@ -4494,6 +4512,7 @@ paths: /v1/{book.name}: patch: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_UpdateBook" parameters: @@ -4550,6 +4569,7 @@ paths: /v1/{parent}/books: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" summary: "Create a book." operationId: "ABitOfEverythingService_CreateBook" @@ -4606,6 +4626,7 @@ paths: /v2/example/a_bit_of_everything/{uuidName}: put: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_UpdateV2" parameters: @@ -4659,6 +4680,7 @@ paths: $ref: "#/definitions/rpcStatus" patch: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_UpdateV22" parameters: @@ -4837,6 +4859,7 @@ paths: /v2/example/errorwithdetails: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_ErrorWithDetails" parameters: [] @@ -4869,6 +4892,7 @@ paths: /v2/example/overwriterequestcontenttype: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_OverwriteRequestContentType" consumes: @@ -4909,6 +4933,7 @@ paths: /v2/example/overwriteresponsecontenttype: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_OverwriteResponseContentType" produces: @@ -4943,6 +4968,7 @@ paths: /v2/example/postwithemptybody/{name}: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_PostWithEmptyBody" parameters: @@ -4986,6 +5012,7 @@ paths: /v2/example/timeout: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_Timeout" parameters: [] @@ -5018,6 +5045,7 @@ paths: /v2/example/withbody/{id}: post: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_GetMessageWithBody" parameters: @@ -5061,6 +5089,7 @@ paths: /v2/{value}:check: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckExternalPathEnum" parameters: @@ -5101,6 +5130,7 @@ paths: /v2a/example/a_bit_of_everything/{uuidName}: patch: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_UpdateV23" parameters: @@ -5147,6 +5177,7 @@ paths: /v3/{value}:check: get: tags: + - "ABitOfEverythingService" - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckExternalNestedPathEnum" parameters: diff --git a/examples/internal/clients/abe/api_a_bit_of_everything_service.go b/examples/internal/clients/abe/api_a_bit_of_everything_service.go new file mode 100644 index 00000000000..8153f7f8c3b --- /dev/null +++ b/examples/internal/clients/abe/api_a_bit_of_everything_service.go @@ -0,0 +1,6940 @@ +/* + * A Bit of Everything + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0 + * Contact: none@example.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package abe + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "fmt" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type ABitOfEverythingServiceApiService service + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param value + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCheckExternalNestedPathEnum(ctx context.Context, value string) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v3/{value}:check" + localVarPath = strings.Replace(localVarPath, "{"+"value"+"}", fmt.Sprintf("%v", value), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param value + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCheckExternalPathEnum(ctx context.Context, value string) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/{value}:check" + localVarPath = strings.Replace(localVarPath, "{"+"value"+"}", fmt.Sprintf("%v", value), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param singleNestedName name is nested field. + * @param uuid + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceCheckGetQueryParamsOpts - Optional Parameters: + * @param "SingleNestedAmount" (optional.Int64) - + * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Uint64Value" (optional.String) - + * @param "Int32Value" (optional.Int32) - + * @param "Fixed64Value" (optional.String) - + * @param "Fixed32Value" (optional.Int64) - + * @param "BoolValue" (optional.Bool) - + * @param "StringValue" (optional.String) - + * @param "BytesValue" (optional.String) - + * @param "Uint32Value" (optional.Int64) - + * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "PathEnumValue" (optional.String) - + * @param "NestedPathEnumValue" (optional.String) - + * @param "Sfixed32Value" (optional.Int32) - + * @param "Sfixed64Value" (optional.String) - + * @param "Sint32Value" (optional.Int32) - + * @param "Sint64Value" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "NonConventionalNameValue" (optional.String) - + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return ExamplepbABitOfEverything +*/ + +type ABitOfEverythingServiceCheckGetQueryParamsOpts struct { + SingleNestedAmount optional.Int64 + SingleNestedOk optional.String + Uint64Value optional.String + Int32Value optional.Int32 + Fixed64Value optional.String + Fixed32Value optional.Int64 + BoolValue optional.Bool + StringValue optional.String + BytesValue optional.String + Uint32Value optional.Int64 + EnumValue optional.String + PathEnumValue optional.String + NestedPathEnumValue optional.String + Sfixed32Value optional.Int32 + Sfixed64Value optional.String + Sint32Value optional.Int32 + Sint64Value optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + NonConventionalNameValue optional.String + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + EnumValueAnnotation optional.String + RepeatedStringAnnotation optional.Interface + NestedAnnotationAmount optional.Int64 + NestedAnnotationOk optional.String + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCheckGetQueryParams(ctx context.Context, singleNestedName string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckGetQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/params/get/{singleNested.name}" + localVarPath = strings.Replace(localVarPath, "{"+"singleNested.name"+"}", fmt.Sprintf("%v", singleNestedName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { + localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { + localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) + } + localVarQueryParams.Add("uuid", parameterToString(uuid, "")) + localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) + localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) + localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) + if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { + localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { + localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { + localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { + localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { + localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { + localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { + localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { + localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { + localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { + localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { + localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { + localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { + localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { + localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { + localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { + localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param singleNestedOk DeepEnum description. + * @param uuid + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts - Optional Parameters: + * @param "SingleNestedName" (optional.String) - name is nested field. + * @param "SingleNestedAmount" (optional.Int64) - + * @param "Uint64Value" (optional.String) - + * @param "Int32Value" (optional.Int32) - + * @param "Fixed64Value" (optional.String) - + * @param "Fixed32Value" (optional.Int64) - + * @param "BoolValue" (optional.Bool) - + * @param "StringValue" (optional.String) - + * @param "BytesValue" (optional.String) - + * @param "Uint32Value" (optional.Int64) - + * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "PathEnumValue" (optional.String) - + * @param "NestedPathEnumValue" (optional.String) - + * @param "Sfixed32Value" (optional.Int32) - + * @param "Sfixed64Value" (optional.String) - + * @param "Sint32Value" (optional.Int32) - + * @param "Sint64Value" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "NonConventionalNameValue" (optional.String) - + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationName" (optional.String) - name is nested field. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return ExamplepbABitOfEverything +*/ + +type ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts struct { + SingleNestedName optional.String + SingleNestedAmount optional.Int64 + Uint64Value optional.String + Int32Value optional.Int32 + Fixed64Value optional.String + Fixed32Value optional.Int64 + BoolValue optional.Bool + StringValue optional.String + BytesValue optional.String + Uint32Value optional.Int64 + EnumValue optional.String + PathEnumValue optional.String + NestedPathEnumValue optional.String + Sfixed32Value optional.Int32 + Sfixed64Value optional.String + Sint32Value optional.Int32 + Sint64Value optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + NonConventionalNameValue optional.String + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + EnumValueAnnotation optional.String + RepeatedStringAnnotation optional.Interface + NestedAnnotationName optional.String + NestedAnnotationAmount optional.Int64 + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCheckNestedEnumGetQueryParams(ctx context.Context, singleNestedOk string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/params/get/nested_enum/{singleNested.ok}" + localVarPath = strings.Replace(localVarPath, "{"+"singleNested.ok"+"}", fmt.Sprintf("%v", singleNestedOk), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { + localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { + localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) + } + localVarQueryParams.Add("uuid", parameterToString(uuid, "")) + localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) + localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) + localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) + if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { + localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { + localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { + localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { + localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { + localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { + localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { + localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { + localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { + localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { + localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { + localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { + localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { + localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { + localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { + localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { + localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param stringValue + * @param singleNested + * @param uuid + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceCheckPostQueryParamsOpts - Optional Parameters: + * @param "Uint64Value" (optional.String) - + * @param "Int32Value" (optional.Int32) - + * @param "Fixed64Value" (optional.String) - + * @param "Fixed32Value" (optional.Int64) - + * @param "BoolValue" (optional.Bool) - + * @param "BytesValue" (optional.String) - + * @param "Uint32Value" (optional.Int64) - + * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "PathEnumValue" (optional.String) - + * @param "NestedPathEnumValue" (optional.String) - + * @param "Sfixed32Value" (optional.Int32) - + * @param "Sfixed64Value" (optional.String) - + * @param "Sint32Value" (optional.Int32) - + * @param "Sint64Value" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "NonConventionalNameValue" (optional.String) - + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationName" (optional.String) - name is nested field. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return ExamplepbABitOfEverything +*/ + +type ABitOfEverythingServiceCheckPostQueryParamsOpts struct { + Uint64Value optional.String + Int32Value optional.Int32 + Fixed64Value optional.String + Fixed32Value optional.Int64 + BoolValue optional.Bool + BytesValue optional.String + Uint32Value optional.Int64 + EnumValue optional.String + PathEnumValue optional.String + NestedPathEnumValue optional.String + Sfixed32Value optional.Int32 + Sfixed64Value optional.String + Sint32Value optional.Int32 + Sint64Value optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + NonConventionalNameValue optional.String + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + EnumValueAnnotation optional.String + RepeatedStringAnnotation optional.Interface + NestedAnnotationName optional.String + NestedAnnotationAmount optional.Int64 + NestedAnnotationOk optional.String + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCheckPostQueryParams(ctx context.Context, stringValue string, singleNested ABitOfEverythingNested, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckPostQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/params/post/{stringValue}" + localVarPath = strings.Replace(localVarPath, "{"+"stringValue"+"}", fmt.Sprintf("%v", stringValue), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + localVarQueryParams.Add("uuid", parameterToString(uuid, "")) + localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) + localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) + localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) + if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { + localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { + localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { + localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { + localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { + localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { + localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { + localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { + localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { + localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { + localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { + localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { + localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { + localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { + localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { + localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { + localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &singleNested + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return ExamplepbCheckStatusResponse +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCheckStatus(ctx context.Context) (ExamplepbCheckStatusResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbCheckStatusResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/checkStatus" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbCheckStatusResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService Create a new ABitOfEverything +This API creates a new ABitOfEverything + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param uint64Value + * @param int32Value + * @param fixed64Value + * @param fixed32Value + * @param boolValue + * @param stringValue + * @param uint32Value + * @param sfixed32Value + * @param sfixed64Value + * @param sint32Value + * @param sint64Value + * @param nonConventionalNameValue + * @param enumValue + * @param pathEnumValue + * @param nestedPathEnumValue + * @param enumValueAnnotation Numeric enum description. + * @param uuid + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceCreateOpts - Optional Parameters: + * @param "SingleNestedName" (optional.String) - name is nested field. + * @param "SingleNestedAmount" (optional.Int64) - + * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "BytesValue" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationName" (optional.String) - name is nested field. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return ExamplepbABitOfEverything +*/ + +type ABitOfEverythingServiceCreateOpts struct { + SingleNestedName optional.String + SingleNestedAmount optional.Int64 + SingleNestedOk optional.String + BytesValue optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + RepeatedStringAnnotation optional.Interface + NestedAnnotationName optional.String + NestedAnnotationAmount optional.Int64 + NestedAnnotationOk optional.String + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCreate(ctx context.Context, floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string, enumValueAnnotation string, uuid string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCreateOpts) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{floatValue}/{doubleValue}/{int64Value}/separator/{uint64Value}/{int32Value}/{fixed64Value}/{fixed32Value}/{boolValue}/{stringValue}/{uint32Value}/{sfixed32Value}/{sfixed64Value}/{sint32Value}/{sint64Value}/{nonConventionalNameValue}/{enumValue}/{pathEnumValue}/{nestedPathEnumValue}/{enumValueAnnotation}" + localVarPath = strings.Replace(localVarPath, "{"+"floatValue"+"}", fmt.Sprintf("%v", floatValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"doubleValue"+"}", fmt.Sprintf("%v", doubleValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"int64Value"+"}", fmt.Sprintf("%v", int64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"uint64Value"+"}", fmt.Sprintf("%v", uint64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"int32Value"+"}", fmt.Sprintf("%v", int32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"fixed64Value"+"}", fmt.Sprintf("%v", fixed64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"fixed32Value"+"}", fmt.Sprintf("%v", fixed32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"boolValue"+"}", fmt.Sprintf("%v", boolValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"stringValue"+"}", fmt.Sprintf("%v", stringValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"uint32Value"+"}", fmt.Sprintf("%v", uint32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"sfixed32Value"+"}", fmt.Sprintf("%v", sfixed32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"sfixed64Value"+"}", fmt.Sprintf("%v", sfixed64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"sint32Value"+"}", fmt.Sprintf("%v", sint32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"sint64Value"+"}", fmt.Sprintf("%v", sint64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"nonConventionalNameValue"+"}", fmt.Sprintf("%v", nonConventionalNameValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"enumValue"+"}", fmt.Sprintf("%v", enumValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathEnumValue"+"}", fmt.Sprintf("%v", pathEnumValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"nestedPathEnumValue"+"}", fmt.Sprintf("%v", nestedPathEnumValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"enumValueAnnotation"+"}", fmt.Sprintf("%v", enumValueAnnotation), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { + localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { + localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { + localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) + } + localVarQueryParams.Add("uuid", parameterToString(uuid, "")) + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { + localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { + localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param body Intentionally complicated message type to cover many features of Protobuf. + +@return ExamplepbABitOfEverything +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCreateBody(ctx context.Context, body ExamplepbABitOfEverything) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService Create a book. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param parent The publisher in which to create the book. Format: `publishers/{publisher}` Example: `publishers/1257894000000000000` + * @param book The book to create. + * @param optional nil or *ABitOfEverythingServiceCreateBookOpts - Optional Parameters: + * @param "BookId" (optional.String) - The ID to use for the book. This must start with an alphanumeric character. + +@return ExamplepbBook +*/ + +type ABitOfEverythingServiceCreateBookOpts struct { + BookId optional.String +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCreateBook(ctx context.Context, parent string, book ExamplepbBook, localVarOptionals *ABitOfEverythingServiceCreateBookOpts) (ExamplepbBook, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbBook + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/{parent}/books" + localVarPath = strings.Replace(localVarPath, "{"+"parent"+"}", fmt.Sprintf("%v", parent), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.BookId.IsSet() { + localVarQueryParams.Add("bookId", parameterToString(localVarOptionals.BookId.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &book + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbBook + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceCustomOpts - Optional Parameters: + * @param "SingleNestedName" (optional.String) - name is nested field. + * @param "SingleNestedAmount" (optional.Int64) - + * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Uint64Value" (optional.String) - + * @param "Int32Value" (optional.Int32) - + * @param "Fixed64Value" (optional.String) - + * @param "Fixed32Value" (optional.Int64) - + * @param "BoolValue" (optional.Bool) - + * @param "StringValue" (optional.String) - + * @param "BytesValue" (optional.String) - + * @param "Uint32Value" (optional.Int64) - + * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "PathEnumValue" (optional.String) - + * @param "NestedPathEnumValue" (optional.String) - + * @param "Sfixed32Value" (optional.Int32) - + * @param "Sfixed64Value" (optional.String) - + * @param "Sint32Value" (optional.Int32) - + * @param "Sint64Value" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "NonConventionalNameValue" (optional.String) - + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationName" (optional.String) - name is nested field. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return ExamplepbABitOfEverything +*/ + +type ABitOfEverythingServiceCustomOpts struct { + SingleNestedName optional.String + SingleNestedAmount optional.Int64 + SingleNestedOk optional.String + Uint64Value optional.String + Int32Value optional.Int32 + Fixed64Value optional.String + Fixed32Value optional.Int64 + BoolValue optional.Bool + StringValue optional.String + BytesValue optional.String + Uint32Value optional.Int64 + EnumValue optional.String + PathEnumValue optional.String + NestedPathEnumValue optional.String + Sfixed32Value optional.Int32 + Sfixed64Value optional.String + Sint32Value optional.Int32 + Sint64Value optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + NonConventionalNameValue optional.String + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + EnumValueAnnotation optional.String + RepeatedStringAnnotation optional.Interface + NestedAnnotationName optional.String + NestedAnnotationAmount optional.Int64 + NestedAnnotationOk optional.String + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCustom(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCustomOpts) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}:custom" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { + localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { + localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { + localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) + } + localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) + localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) + localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) + if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { + localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { + localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { + localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { + localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { + localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { + localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { + localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { + localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { + localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { + localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { + localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { + localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { + localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { + localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { + localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { + localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { + localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceCustomOptionsRequestOpts - Optional Parameters: + * @param "SingleNestedName" (optional.String) - name is nested field. + * @param "SingleNestedAmount" (optional.Int64) - + * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Uint64Value" (optional.String) - + * @param "Int32Value" (optional.Int32) - + * @param "Fixed64Value" (optional.String) - + * @param "Fixed32Value" (optional.Int64) - + * @param "BoolValue" (optional.Bool) - + * @param "StringValue" (optional.String) - + * @param "BytesValue" (optional.String) - + * @param "Uint32Value" (optional.Int64) - + * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "PathEnumValue" (optional.String) - + * @param "NestedPathEnumValue" (optional.String) - + * @param "Sfixed32Value" (optional.Int32) - + * @param "Sfixed64Value" (optional.String) - + * @param "Sint32Value" (optional.Int32) - + * @param "Sint64Value" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "NonConventionalNameValue" (optional.String) - + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationName" (optional.String) - name is nested field. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return interface{} +*/ + +type ABitOfEverythingServiceCustomOptionsRequestOpts struct { + SingleNestedName optional.String + SingleNestedAmount optional.Int64 + SingleNestedOk optional.String + Uint64Value optional.String + Int32Value optional.Int32 + Fixed64Value optional.String + Fixed32Value optional.Int64 + BoolValue optional.Bool + StringValue optional.String + BytesValue optional.String + Uint32Value optional.Int64 + EnumValue optional.String + PathEnumValue optional.String + NestedPathEnumValue optional.String + Sfixed32Value optional.Int32 + Sfixed64Value optional.String + Sint32Value optional.Int32 + Sint64Value optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + NonConventionalNameValue optional.String + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + EnumValueAnnotation optional.String + RepeatedStringAnnotation optional.Interface + NestedAnnotationName optional.String + NestedAnnotationAmount optional.Int64 + NestedAnnotationOk optional.String + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCustomOptionsRequest(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCustomOptionsRequestOpts) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Options") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { + localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { + localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { + localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) + } + localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) + localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) + localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) + if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { + localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { + localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { + localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { + localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { + localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { + localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { + localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { + localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { + localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { + localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { + localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { + localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { + localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { + localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { + localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { + localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { + localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param singleNestedName name is nested field. + * @param body + +@return ExamplepbABitOfEverything +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceDeepPathEcho(ctx context.Context, singleNestedName string, body ABitOfEverything1) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/deep_path/{singleNested.name}" + localVarPath = strings.Replace(localVarPath, "{"+"singleNested.name"+"}", fmt.Sprintf("%v", singleNestedName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuid + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceDelete(ctx context.Context, uuid string) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuid}" + localVarPath = strings.Replace(localVarPath, "{"+"uuid"+"}", fmt.Sprintf("%v", uuid), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceDoubleColonOpts - Optional Parameters: + * @param "SingleNestedName" (optional.String) - name is nested field. + * @param "SingleNestedAmount" (optional.Int64) - + * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Uint64Value" (optional.String) - + * @param "Int32Value" (optional.Int32) - + * @param "Fixed64Value" (optional.String) - + * @param "Fixed32Value" (optional.Int64) - + * @param "BoolValue" (optional.Bool) - + * @param "StringValue" (optional.String) - + * @param "BytesValue" (optional.String) - + * @param "Uint32Value" (optional.Int64) - + * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "PathEnumValue" (optional.String) - + * @param "NestedPathEnumValue" (optional.String) - + * @param "Sfixed32Value" (optional.Int32) - + * @param "Sfixed64Value" (optional.String) - + * @param "Sint32Value" (optional.Int32) - + * @param "Sint64Value" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "NonConventionalNameValue" (optional.String) - + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationName" (optional.String) - name is nested field. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return ExamplepbABitOfEverything +*/ + +type ABitOfEverythingServiceDoubleColonOpts struct { + SingleNestedName optional.String + SingleNestedAmount optional.Int64 + SingleNestedOk optional.String + Uint64Value optional.String + Int32Value optional.Int32 + Fixed64Value optional.String + Fixed32Value optional.Int64 + BoolValue optional.Bool + StringValue optional.String + BytesValue optional.String + Uint32Value optional.Int64 + EnumValue optional.String + PathEnumValue optional.String + NestedPathEnumValue optional.String + Sfixed32Value optional.Int32 + Sfixed64Value optional.String + Sint32Value optional.Int32 + Sint64Value optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + NonConventionalNameValue optional.String + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + EnumValueAnnotation optional.String + RepeatedStringAnnotation optional.Interface + NestedAnnotationName optional.String + NestedAnnotationAmount optional.Int64 + NestedAnnotationOk optional.String + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceDoubleColon(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceDoubleColonOpts) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}:custom:custom" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { + localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { + localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { + localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) + } + localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) + localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) + localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) + if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { + localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { + localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { + localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { + localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { + localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { + localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { + localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { + localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { + localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { + localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { + localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { + localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { + localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { + localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { + localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { + localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { + localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceErrorWithDetails(ctx context.Context) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/example/errorwithdetails" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceExistsOpts - Optional Parameters: + * @param "SingleNestedName" (optional.String) - name is nested field. + * @param "SingleNestedAmount" (optional.Int64) - + * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Uint64Value" (optional.String) - + * @param "Int32Value" (optional.Int32) - + * @param "Fixed64Value" (optional.String) - + * @param "Fixed32Value" (optional.Int64) - + * @param "BoolValue" (optional.Bool) - + * @param "StringValue" (optional.String) - + * @param "BytesValue" (optional.String) - + * @param "Uint32Value" (optional.Int64) - + * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "PathEnumValue" (optional.String) - + * @param "NestedPathEnumValue" (optional.String) - + * @param "Sfixed32Value" (optional.Int32) - + * @param "Sfixed64Value" (optional.String) - + * @param "Sint32Value" (optional.Int32) - + * @param "Sint64Value" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "NonConventionalNameValue" (optional.String) - + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationName" (optional.String) - name is nested field. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return interface{} +*/ + +type ABitOfEverythingServiceExistsOpts struct { + SingleNestedName optional.String + SingleNestedAmount optional.Int64 + SingleNestedOk optional.String + Uint64Value optional.String + Int32Value optional.Int32 + Fixed64Value optional.String + Fixed32Value optional.Int64 + BoolValue optional.Bool + StringValue optional.String + BytesValue optional.String + Uint32Value optional.Int64 + EnumValue optional.String + PathEnumValue optional.String + NestedPathEnumValue optional.String + Sfixed32Value optional.Int32 + Sfixed64Value optional.String + Sint32Value optional.Int32 + Sint64Value optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + NonConventionalNameValue optional.String + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + EnumValueAnnotation optional.String + RepeatedStringAnnotation optional.Interface + NestedAnnotationName optional.String + NestedAnnotationAmount optional.Int64 + NestedAnnotationOk optional.String + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceExists(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceExistsOpts) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Head") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { + localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { + localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { + localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) + } + localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) + localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) + localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) + if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { + localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { + localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { + localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { + localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { + localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { + localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { + localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { + localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { + localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { + localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { + localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { + localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { + localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { + localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { + localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { + localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { + localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param id + * @param data + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceGetMessageWithBody(ctx context.Context, id string, data ExamplepbBody) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/example/withbody/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &data + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param floatValue Float value field + * @param doubleValue + * @param int64Value + * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition + * @param requiredStringField1 + * @param requiredStringField2 + * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields + * @param requiredFieldSchemaJsonNameCustom + * @param optional nil or *ABitOfEverythingServiceGetQueryOpts - Optional Parameters: + * @param "SingleNestedName" (optional.String) - name is nested field. + * @param "SingleNestedAmount" (optional.Int64) - + * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Uint64Value" (optional.String) - + * @param "Int32Value" (optional.Int32) - + * @param "Fixed64Value" (optional.String) - + * @param "Fixed32Value" (optional.Int64) - + * @param "BoolValue" (optional.Bool) - + * @param "StringValue" (optional.String) - + * @param "BytesValue" (optional.String) - + * @param "Uint32Value" (optional.Int64) - + * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "PathEnumValue" (optional.String) - + * @param "NestedPathEnumValue" (optional.String) - + * @param "Sfixed32Value" (optional.Int32) - + * @param "Sfixed64Value" (optional.String) - + * @param "Sint32Value" (optional.Int32) - + * @param "Sint64Value" (optional.String) - + * @param "RepeatedStringValue" (optional.Interface of []string) - + * @param "OneofEmpty" (optional.Interface of map[string]string) - + * @param "OneofString" (optional.String) - + * @param "MapValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedStringValue" (optional.String) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "MappedNestedValue" (optional.Interface of interface{}) - This is a request variable of the map type. The query format is \"map_name[key]=value\", e.g. If the map name is Age, the key type is string, and the value type is integer, the query parameter is expressed as Age[\"bob\"]=18 + * @param "NonConventionalNameValue" (optional.String) - + * @param "TimestampValue" (optional.Time) - + * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 + * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. + * @param "NestedAnnotationName" (optional.String) - name is nested field. + * @param "NestedAnnotationAmount" (optional.Int64) - + * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param "Int64OverrideType" (optional.Int64) - + * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition + * @param "OptionalStringValue" (optional.String) - + * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. + * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce + * @param "TrailingOnly" (optional.String) - Trailing only + * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. + * @param "TrailingBoth" (optional.String) - Leading both Trailing both. + * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. + * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items + +@return interface{} +*/ + +type ABitOfEverythingServiceGetQueryOpts struct { + SingleNestedName optional.String + SingleNestedAmount optional.Int64 + SingleNestedOk optional.String + Uint64Value optional.String + Int32Value optional.Int32 + Fixed64Value optional.String + Fixed32Value optional.Int64 + BoolValue optional.Bool + StringValue optional.String + BytesValue optional.String + Uint32Value optional.Int64 + EnumValue optional.String + PathEnumValue optional.String + NestedPathEnumValue optional.String + Sfixed32Value optional.Int32 + Sfixed64Value optional.String + Sint32Value optional.Int32 + Sint64Value optional.String + RepeatedStringValue optional.Interface + OneofEmpty optional.Interface + OneofString optional.String + MapValue optional.Interface + MappedStringValue optional.String + MappedNestedValue optional.Interface + NonConventionalNameValue optional.String + TimestampValue optional.Time + RepeatedEnumValue optional.Interface + RepeatedEnumAnnotation optional.Interface + EnumValueAnnotation optional.String + RepeatedStringAnnotation optional.Interface + NestedAnnotationName optional.String + NestedAnnotationAmount optional.Int64 + NestedAnnotationOk optional.String + Int64OverrideType optional.Int64 + OutputOnlyStringViaFieldBehaviorAnnotation optional.String + OptionalStringValue optional.String + ProductId optional.Interface + OptionalStringField optional.String + TrailingOnly optional.String + TrailingOnlyDot optional.String + TrailingBoth optional.String + TrailingMultiline optional.String + Uuids optional.Interface +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceGetQuery(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceGetQueryOpts) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/query/{uuidName}" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { + localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { + localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { + localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) + } + localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) + localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) + localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) + if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { + localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { + localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { + localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { + localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { + localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { + localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { + localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { + localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { + localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { + localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { + localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { + localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { + localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { + localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { + localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { + localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { + localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { + localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { + localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { + localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { + localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { + localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { + localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { + localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { + localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { + localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { + localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { + localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { + localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { + localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) + } + localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) + if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { + localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { + localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { + localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) + } + if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { + localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) + } + localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) + localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) + localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) + localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) + if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { + localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { + localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { + localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { + localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { + localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param pathRepeatedFloatValue repeated values. they are comma-separated in path + * @param pathRepeatedDoubleValue + * @param pathRepeatedInt64Value + * @param pathRepeatedUint64Value + * @param pathRepeatedInt32Value + * @param pathRepeatedFixed64Value + * @param pathRepeatedFixed32Value + * @param pathRepeatedBoolValue + * @param pathRepeatedStringValue + * @param pathRepeatedBytesValue + * @param pathRepeatedUint32Value + * @param pathRepeatedEnumValue + * @param pathRepeatedSfixed32Value + * @param pathRepeatedSfixed64Value + * @param pathRepeatedSint32Value + * @param pathRepeatedSint64Value + +@return ExamplepbABitOfEverythingRepeated +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceGetRepeatedQuery(ctx context.Context, pathRepeatedFloatValue []float32, pathRepeatedDoubleValue []float64, pathRepeatedInt64Value []string, pathRepeatedUint64Value []string, pathRepeatedInt32Value []int32, pathRepeatedFixed64Value []string, pathRepeatedFixed32Value []int64, pathRepeatedBoolValue []bool, pathRepeatedStringValue []string, pathRepeatedBytesValue []string, pathRepeatedUint32Value []int64, pathRepeatedEnumValue []string, pathRepeatedSfixed32Value []int32, pathRepeatedSfixed64Value []string, pathRepeatedSint32Value []int32, pathRepeatedSint64Value []string) (ExamplepbABitOfEverythingRepeated, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverythingRepeated + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything_repeated/{pathRepeatedFloatValue}/{pathRepeatedDoubleValue}/{pathRepeatedInt64Value}/{pathRepeatedUint64Value}/{pathRepeatedInt32Value}/{pathRepeatedFixed64Value}/{pathRepeatedFixed32Value}/{pathRepeatedBoolValue}/{pathRepeatedStringValue}/{pathRepeatedBytesValue}/{pathRepeatedUint32Value}/{pathRepeatedEnumValue}/{pathRepeatedSfixed32Value}/{pathRepeatedSfixed64Value}/{pathRepeatedSint32Value}/{pathRepeatedSint64Value}" + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedFloatValue"+"}", fmt.Sprintf("%v", pathRepeatedFloatValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedDoubleValue"+"}", fmt.Sprintf("%v", pathRepeatedDoubleValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedInt64Value"+"}", fmt.Sprintf("%v", pathRepeatedInt64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedUint64Value"+"}", fmt.Sprintf("%v", pathRepeatedUint64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedInt32Value"+"}", fmt.Sprintf("%v", pathRepeatedInt32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedFixed64Value"+"}", fmt.Sprintf("%v", pathRepeatedFixed64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedFixed32Value"+"}", fmt.Sprintf("%v", pathRepeatedFixed32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedBoolValue"+"}", fmt.Sprintf("%v", pathRepeatedBoolValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedStringValue"+"}", fmt.Sprintf("%v", pathRepeatedStringValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedBytesValue"+"}", fmt.Sprintf("%v", pathRepeatedBytesValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedUint32Value"+"}", fmt.Sprintf("%v", pathRepeatedUint32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedEnumValue"+"}", fmt.Sprintf("%v", pathRepeatedEnumValue), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedSfixed32Value"+"}", fmt.Sprintf("%v", pathRepeatedSfixed32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedSfixed64Value"+"}", fmt.Sprintf("%v", pathRepeatedSfixed64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedSint32Value"+"}", fmt.Sprintf("%v", pathRepeatedSint32Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedSint64Value"+"}", fmt.Sprintf("%v", pathRepeatedSint64Value), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if len(pathRepeatedFloatValue) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedFloatValue must have at least 1 elements") + } + if len(pathRepeatedDoubleValue) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedDoubleValue must have at least 1 elements") + } + if len(pathRepeatedInt64Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedInt64Value must have at least 1 elements") + } + if len(pathRepeatedUint64Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedUint64Value must have at least 1 elements") + } + if len(pathRepeatedInt32Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedInt32Value must have at least 1 elements") + } + if len(pathRepeatedFixed64Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedFixed64Value must have at least 1 elements") + } + if len(pathRepeatedFixed32Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedFixed32Value must have at least 1 elements") + } + if len(pathRepeatedBoolValue) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedBoolValue must have at least 1 elements") + } + if len(pathRepeatedStringValue) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedStringValue must have at least 1 elements") + } + if len(pathRepeatedBytesValue) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedBytesValue must have at least 1 elements") + } + if len(pathRepeatedUint32Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedUint32Value must have at least 1 elements") + } + if len(pathRepeatedEnumValue) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedEnumValue must have at least 1 elements") + } + if len(pathRepeatedSfixed32Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedSfixed32Value must have at least 1 elements") + } + if len(pathRepeatedSfixed64Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedSfixed64Value must have at least 1 elements") + } + if len(pathRepeatedSint32Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedSint32Value must have at least 1 elements") + } + if len(pathRepeatedSint64Value) < 1 { + return localVarReturnValue, nil, reportError("pathRepeatedSint64Value must have at least 1 elements") + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverythingRepeated + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuid + +@return ExamplepbABitOfEverything +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceLookup(ctx context.Context, uuid string) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbABitOfEverything + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuid}" + localVarPath = strings.Replace(localVarPath, "{"+"uuid"+"}", fmt.Sprintf("%v", uuid), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbABitOfEverything + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param body + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceOverwriteRequestContentType(ctx context.Context, body ExamplepbBody) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/example/overwriterequestcontenttype" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/x-bar-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return string +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceOverwriteResponseContentType(ctx context.Context) (string, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue string + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/example/overwriteresponsecontenttype" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/text"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param exampleEnum + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServicePostOneofEnum(ctx context.Context, exampleEnum OneofenumExampleEnum) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/oneofenum" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &exampleEnum + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param body + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServicePostRequiredMessageType(ctx context.Context, body ExamplepbRequiredMessageTypeRequest) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/requiredmessagetype" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param name + * @param body + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServicePostWithEmptyBody(ctx context.Context, name string, body interface{}) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/example/postwithemptybody/{name}" + localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", fmt.Sprintf("%v", name), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceTimeout(ctx context.Context) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/example/timeout" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param body + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceUpdate(ctx context.Context, uuidName string, body ABitOfEverything) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param bookName The resource name of the book. Format: `publishers/{publisher}/books/{book}` Example: `publishers/1257894000000000000/books/my-book` + * @param book The book to update. The book's `name` field is used to identify the book to be updated. Format: publishers/{publisher}/books/{book} + * @param optional nil or *ABitOfEverythingServiceUpdateBookOpts - Optional Parameters: + * @param "AllowMissing" (optional.Bool) - If set to true, and the book is not found, a new book will be created. In this situation, `update_mask` is ignored. + +@return ExamplepbBook +*/ + +type ABitOfEverythingServiceUpdateBookOpts struct { + AllowMissing optional.Bool +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceUpdateBook(ctx context.Context, bookName string, book TheBookToUpdate_, localVarOptionals *ABitOfEverythingServiceUpdateBookOpts) (ExamplepbBook, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Patch") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ExamplepbBook + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/{book.name}" + localVarPath = strings.Replace(localVarPath, "{"+"book.name"+"}", fmt.Sprintf("%v", bookName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.AllowMissing.IsSet() { + localVarQueryParams.Add("allowMissing", parameterToString(localVarOptionals.AllowMissing.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &book + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ExamplepbBook + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param abe A bit of everything Intentionally complicated message type to cover many features of Protobuf. + * @param optional nil or *ABitOfEverythingServiceUpdateV2Opts - Optional Parameters: + * @param "UpdateMask" (optional.String) - The paths to update. + +@return interface{} +*/ + +type ABitOfEverythingServiceUpdateV2Opts struct { + UpdateMask optional.String +} + +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceUpdateV2(ctx context.Context, uuidName string, abe ABitOfEverything2, localVarOptionals *ABitOfEverythingServiceUpdateV2Opts) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/example/a_bit_of_everything/{uuidName}" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.UpdateMask.IsSet() { + localVarQueryParams.Add("updateMask", parameterToString(localVarOptionals.UpdateMask.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &abe + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param abe A bit of everything Intentionally complicated message type to cover many features of Protobuf. + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceUpdateV22(ctx context.Context, uuidName string, abe ABitOfEverything3) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Patch") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2/example/a_bit_of_everything/{uuidName}" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &abe + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ABitOfEverythingServiceApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param uuidName + * @param body + +@return interface{} +*/ +func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceUpdateV23(ctx context.Context, uuidName string, body UpdateV2RequestRequestForUpdateIncludesTheMessageAndTheUpdateMask) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Patch") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v2a/example/a_bit_of_everything/{uuidName}" + localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 418 { + var v ExamplepbNumericEnum + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 500 { + var v ExamplepbErrorResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v RpcStatus + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/examples/internal/clients/abe/client.go b/examples/internal/clients/abe/client.go index 3293aadf212..22eb067bda1 100644 --- a/examples/internal/clients/abe/client.go +++ b/examples/internal/clients/abe/client.go @@ -48,6 +48,8 @@ type APIClient struct { ABitOfEverythingApi *ABitOfEverythingApiService + ABitOfEverythingServiceApi *ABitOfEverythingServiceApiService + CamelCaseServiceNameApi *CamelCaseServiceNameApiService EchoRpcApi *EchoRpcApiService @@ -72,6 +74,7 @@ func NewAPIClient(cfg *Configuration) *APIClient { // API Services c.ABitOfEverythingApi = (*ABitOfEverythingApiService)(&c.common) + c.ABitOfEverythingServiceApi = (*ABitOfEverythingServiceApiService)(&c.common) c.CamelCaseServiceNameApi = (*CamelCaseServiceNameApiService)(&c.common) c.EchoRpcApi = (*EchoRpcApiService)(&c.common) c.SnakeEnumServiceApi = (*SnakeEnumServiceApiService)(&c.common) diff --git a/examples/internal/proto/examplepb/a_bit_of_everything.swagger.json b/examples/internal/proto/examplepb/a_bit_of_everything.swagger.json index 78a5747c60d..cd8858a1320 100644 --- a/examples/internal/proto/examplepb/a_bit_of_everything.swagger.json +++ b/examples/internal/proto/examplepb/a_bit_of_everything.swagger.json @@ -104,6 +104,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -627,6 +628,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -1087,6 +1089,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -1536,6 +1539,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -2003,6 +2007,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ], "deprecated": true, @@ -2474,6 +2479,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -2790,6 +2796,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] }, @@ -3232,6 +3239,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] }, @@ -3674,6 +3682,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -4140,6 +4149,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -4606,6 +4616,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -4659,6 +4670,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] }, @@ -4711,6 +4723,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ], "security": [ @@ -4962,6 +4975,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -5007,6 +5021,7 @@ } }, "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -5343,6 +5358,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -5399,6 +5415,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -5455,6 +5472,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -5618,6 +5636,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -5690,6 +5709,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -6014,6 +6034,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] }, @@ -6329,6 +6350,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -6559,6 +6581,7 @@ } }, "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -6615,6 +6638,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ], "consumes": [ @@ -6663,6 +6687,7 @@ } }, "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ], "produces": [ @@ -6728,6 +6753,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -6774,6 +6800,7 @@ } }, "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -6836,6 +6863,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -6894,6 +6922,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -7220,6 +7249,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } @@ -7278,6 +7308,7 @@ } ], "tags": [ + "ABitOfEverythingService", "ABitOfEverything" ] } diff --git a/protoc-gen-openapiv2/internal/genopenapi/template.go b/protoc-gen-openapiv2/internal/genopenapi/template.go index 9a5f16d8ed2..969ddc49cb3 100644 --- a/protoc-gen-openapiv2/internal/genopenapi/template.go +++ b/protoc-gen-openapiv2/internal/genopenapi/template.go @@ -1488,13 +1488,13 @@ func renderServices(services []*descriptor.Service, paths *openapiPathsObject, r return err } tag := svc.GetName() - if opts.GetName() != "" { - tag = opts.GetName() - } if pkg := svc.File.GetPackage(); pkg != "" && reg.IsIncludePackageInTags() { tag = pkg + "." + tag } operationObject.Tags = []string{tag} + if opts.GetName() != "" { + operationObject.Tags = append(operationObject.Tags, opts.GetName()) + } } if !reg.GetDisableDefaultErrors() { diff --git a/protoc-gen-openapiv2/internal/genopenapi/template_test.go b/protoc-gen-openapiv2/internal/genopenapi/template_test.go index d6635d678da..0ceb5ddb7a2 100644 --- a/protoc-gen-openapiv2/internal/genopenapi/template_test.go +++ b/protoc-gen-openapiv2/internal/genopenapi/template_test.go @@ -6344,7 +6344,7 @@ func TestTagsWithGoTemplate(t *testing.T) { }, { Name: "ExampleService", - Description: "ExampleService!", + Description: "", }, { Name: "not a service tag 2", @@ -6354,6 +6354,10 @@ func TestTagsWithGoTemplate(t *testing.T) { Name: "Service with my_key", Description: "the my_value", }, + { + Name: "service tag", + Description: "ExampleService!", + }, } if !reflect.DeepEqual(actual.Tags, expectedTags) { t.Errorf("Expected tags %+v, not %+v", expectedTags, actual.Tags)