├── .circleci └── config.yml ├── .gitignore ├── .swagger-codegen-ignore ├── .swagger-codegen └── VERSION ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── api └── swagger.yaml ├── api_constraint.go ├── api_distribution.go ├── api_evaluation.go ├── api_export.go ├── api_flag.go ├── api_health.go ├── api_segment.go ├── api_variant.go ├── client.go ├── configuration.go ├── docs ├── Constraint.md ├── ConstraintApi.md ├── CreateConstraintRequest.md ├── CreateFlagRequest.md ├── CreateSegmentRequest.md ├── CreateVariantRequest.md ├── Distribution.md ├── DistributionApi.md ├── EvalContext.md ├── EvalDebugLog.md ├── EvalResult.md ├── EvaluationApi.md ├── EvaluationBatchRequest.md ├── EvaluationBatchResponse.md ├── EvaluationEntity.md ├── ExportApi.md ├── Flag.md ├── FlagApi.md ├── FlagSnapshot.md ├── Health.md ├── HealthApi.md ├── ModelError.md ├── PutDistributionsRequest.md ├── PutFlagRequest.md ├── PutSegmentReorderRequest.md ├── PutSegmentRequest.md ├── PutVariantRequest.md ├── Segment.md ├── SegmentApi.md ├── SegmentDebugLog.md ├── SetFlagEnabledRequest.md ├── Variant.md └── VariantApi.md ├── git_push.sh ├── go.mod ├── go.sum ├── model_constraint.go ├── model_create_constraint_request.go ├── model_create_flag_request.go ├── model_create_segment_request.go ├── model_create_variant_request.go ├── model_distribution.go ├── model_error.go ├── model_eval_context.go ├── model_eval_debug_log.go ├── model_eval_result.go ├── model_evaluation_batch_request.go ├── model_evaluation_batch_response.go ├── model_evaluation_entity.go ├── model_flag.go ├── model_flag_snapshot.go ├── model_health.go ├── model_put_distributions_request.go ├── model_put_flag_request.go ├── model_put_segment_reorder_request.go ├── model_put_segment_request.go ├── model_put_variant_request.go ├── model_segment.go ├── model_segment_debug_log.go ├── model_set_flag_enabled_request.go ├── model_variant.go ├── response.go ├── swagger.yaml ├── swagger_go.json └── tests ├── doc.go └── model_eval_context_test.go /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: circleci/golang:1.9 6 | working_directory: /go/src/github.com/checkr/goflagr 7 | steps: 8 | - checkout 9 | - run: go get -v -t -d ./... 10 | - run: make build 11 | - run: make test 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /.swagger-codegen-ignore: -------------------------------------------------------------------------------- 1 | # Swagger Codegen Ignore 2 | # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | -------------------------------------------------------------------------------- /.swagger-codegen/VERSION: -------------------------------------------------------------------------------- 1 | 2.4.10 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | install: 4 | - go get -d -v . 5 | 6 | script: 7 | - go build -v ./ 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | 7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 8 | 9 | 1. Definitions. 10 | 11 | "License" shall mean the terms and conditions for use, reproduction, 12 | and distribution as defined by Sections 1 through 9 of this document. 13 | 14 | "Licensor" shall mean the copyright owner or entity authorized by 15 | the copyright owner that is granting the License. 16 | 17 | "Legal Entity" shall mean the union of the acting entity and all 18 | other entities that control, are controlled by, or are under common 19 | control with that entity. For the purposes of this definition, 20 | "control" means (i) the power, direct or indirect, to cause the 21 | direction or management of such entity, whether by contract or 22 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 23 | outstanding shares, or (iii) beneficial ownership of such entity. 24 | 25 | "You" (or "Your") shall mean an individual or Legal Entity 26 | exercising permissions granted by this License. 27 | 28 | "Source" form shall mean the preferred form for making modifications, 29 | including but not limited to software source code, documentation 30 | source, and configuration files. 31 | 32 | "Object" form shall mean any form resulting from mechanical 33 | transformation or translation of a Source form, including but 34 | not limited to compiled object code, generated documentation, 35 | and conversions to other media types. 36 | 37 | "Work" shall mean the work of authorship, whether in Source or 38 | Object form, made available under the License, as indicated by a 39 | copyright notice that is included in or attached to the work 40 | (an example is provided in the Appendix below). 41 | 42 | "Derivative Works" shall mean any work, whether in Source or Object 43 | form, that is based on (or derived from) the Work and for which the 44 | editorial revisions, annotations, elaborations, or other modifications 45 | represent, as a whole, an original work of authorship. For the purposes 46 | of this License, Derivative Works shall not include works that remain 47 | separable from, or merely link (or bind by name) to the interfaces of, 48 | the Work and Derivative Works thereof. 49 | 50 | "Contribution" shall mean any work of authorship, including 51 | the original version of the Work and any modifications or additions 52 | to that Work or Derivative Works thereof, that is intentionally 53 | submitted to Licensor for inclusion in the Work by the copyright owner 54 | or by an individual or Legal Entity authorized to submit on behalf of 55 | the copyright owner. For the purposes of this definition, "submitted" 56 | means any form of electronic, verbal, or written communication sent 57 | to the Licensor or its representatives, including but not limited to 58 | communication on electronic mailing lists, source code control systems, 59 | and issue tracking systems that are managed by, or on behalf of, the 60 | Licensor for the purpose of discussing and improving the Work, but 61 | excluding communication that is conspicuously marked or otherwise 62 | designated in writing by the copyright owner as "Not a Contribution." 63 | 64 | "Contributor" shall mean Licensor and any individual or Legal Entity 65 | on behalf of whom a Contribution has been received by Licensor and 66 | subsequently incorporated within the Work. 67 | 68 | 2. Grant of Copyright License. Subject to the terms and conditions of 69 | this License, each Contributor hereby grants to You a perpetual, 70 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 71 | copyright license to reproduce, prepare Derivative Works of, 72 | publicly display, publicly perform, sublicense, and distribute the 73 | Work and such Derivative Works in Source or Object form. 74 | 75 | 3. Grant of Patent License. Subject to the terms and conditions of 76 | this License, each Contributor hereby grants to You a perpetual, 77 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 78 | (except as stated in this section) patent license to make, have made, 79 | use, offer to sell, sell, import, and otherwise transfer the Work, 80 | where such license applies only to those patent claims licensable 81 | by such Contributor that are necessarily infringed by their 82 | Contribution(s) alone or by combination of their Contribution(s) 83 | with the Work to which such Contribution(s) was submitted. If You 84 | institute patent litigation against any entity (including a 85 | cross-claim or counterclaim in a lawsuit) alleging that the Work 86 | or a Contribution incorporated within the Work constitutes direct 87 | or contributory patent infringement, then any patent licenses 88 | granted to You under this License for that Work shall terminate 89 | as of the date such litigation is filed. 90 | 91 | 4. Redistribution. You may reproduce and distribute copies of the 92 | Work or Derivative Works thereof in any medium, with or without 93 | modifications, and in Source or Object form, provided that You 94 | meet the following conditions: 95 | 96 | (a) You must give any other recipients of the Work or 97 | Derivative Works a copy of this License; and 98 | 99 | (b) You must cause any modified files to carry prominent notices 100 | stating that You changed the files; and 101 | 102 | (c) You must retain, in the Source form of any Derivative Works 103 | that You distribute, all copyright, patent, trademark, and 104 | attribution notices from the Source form of the Work, 105 | excluding those notices that do not pertain to any part of 106 | the Derivative Works; and 107 | 108 | (d) If the Work includes a "NOTICE" text file as part of its 109 | distribution, then any Derivative Works that You distribute must 110 | include a readable copy of the attribution notices contained 111 | within such NOTICE file, excluding those notices that do not 112 | pertain to any part of the Derivative Works, in at least one 113 | of the following places: within a NOTICE text file distributed 114 | as part of the Derivative Works; within the Source form or 115 | documentation, if provided along with the Derivative Works; or, 116 | within a display generated by the Derivative Works, if and 117 | wherever such third-party notices normally appear. The contents 118 | of the NOTICE file are for informational purposes only and 119 | do not modify the License. You may add Your own attribution 120 | notices within Derivative Works that You distribute, alongside 121 | or as an addendum to the NOTICE text from the Work, provided 122 | that such additional attribution notices cannot be construed 123 | as modifying the License. 124 | 125 | You may add Your own copyright statement to Your modifications and 126 | may provide additional or different license terms and conditions 127 | for use, reproduction, or distribution of Your modifications, or 128 | for any such Derivative Works as a whole, provided Your use, 129 | reproduction, and distribution of the Work otherwise complies with 130 | the conditions stated in this License. 131 | 132 | 5. Submission of Contributions. Unless You explicitly state otherwise, 133 | any Contribution intentionally submitted for inclusion in the Work 134 | by You to the Licensor shall be under the terms and conditions of 135 | this License, without any additional terms or conditions. 136 | Notwithstanding the above, nothing herein shall supersede or modify 137 | the terms of any separate license agreement you may have executed 138 | with Licensor regarding such Contributions. 139 | 140 | 6. Trademarks. This License does not grant permission to use the trade 141 | names, trademarks, service marks, or product names of the Licensor, 142 | except as required for reasonable and customary use in describing the 143 | origin of the Work and reproducing the content of the NOTICE file. 144 | 145 | 7. Disclaimer of Warranty. Unless required by applicable law or 146 | agreed to in writing, Licensor provides the Work (and each 147 | Contributor provides its Contributions) on an "AS IS" BASIS, 148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 149 | implied, including, without limitation, any warranties or conditions 150 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 151 | PARTICULAR PURPOSE. You are solely responsible for determining the 152 | appropriateness of using or redistributing the Work and assume any 153 | risks associated with Your exercise of permissions under this License. 154 | 155 | 8. Limitation of Liability. In no event and under no legal theory, 156 | whether in tort (including negligence), contract, or otherwise, 157 | unless required by applicable law (such as deliberate and grossly 158 | negligent acts) or agreed to in writing, shall any Contributor be 159 | liable to You for damages, including any direct, indirect, special, 160 | incidental, or consequential damages of any character arising as a 161 | result of this License or out of the use or inability to use the 162 | Work (including but not limited to damages for loss of goodwill, 163 | work stoppage, computer failure or malfunction, or any and all 164 | other commercial damages or losses), even if such Contributor 165 | has been advised of the possibility of such damages. 166 | 167 | 9. Accepting Warranty or Additional Liability. While redistributing 168 | the Work or Derivative Works thereof, You may choose to offer, 169 | and charge a fee for, acceptance of support, warranty, indemnity, 170 | or other liability obligations and/or rights consistent with this 171 | License. However, in accepting such obligations, You may act only 172 | on Your own behalf and on Your sole responsibility, not on behalf 173 | of any other Contributor, and only if You agree to indemnify, 174 | defend, and hold each Contributor harmless for any liability 175 | incurred by, or claims asserted against, such Contributor by reason 176 | of your accepting any such warranty or additional liability. 177 | 178 | END OF TERMS AND CONDITIONS 179 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | gen: 2 | rm -rf *.go 3 | rm -rf .swagger-codegen 4 | rm -rf docs 5 | rm -rf api 6 | rm README.md 7 | docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli:2.4.10 generate \ 8 | -i /local/swagger.yaml \ 9 | -l go \ 10 | -o /local/ -c /local/swagger_go.json 11 | go get golang.org/x/tools/cmd/goimports 12 | goimports -w . 13 | 14 | test: 15 | go test -race -covermode=atomic ./tests/... 16 | 17 | build: 18 | go build -v ./... 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Go API client for goflagr 2 | 3 | Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 4 | 5 | ## Overview 6 | This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client. 7 | 8 | - API version: 1.1.4 9 | - Package version: 1.1.1 10 | - Build package: io.swagger.codegen.languages.GoClientCodegen 11 | 12 | ## Installation 13 | Put the package under your project folder and add the following in import: 14 | ```golang 15 | import "./goflagr" 16 | ``` 17 | 18 | ## Documentation for API Endpoints 19 | 20 | All URIs are relative to *http://localhost/api/v1* 21 | 22 | Class | Method | HTTP request | Description 23 | ------------ | ------------- | ------------- | ------------- 24 | *ConstraintApi* | [**CreateConstraint**](docs/ConstraintApi.md#createconstraint) | **Post** /flags/{flagID}/segments/{segmentID}/constraints | 25 | *ConstraintApi* | [**DeleteConstraint**](docs/ConstraintApi.md#deleteconstraint) | **Delete** /flags/{flagID}/segments/{segmentID}/constraints/{constraintID} | 26 | *ConstraintApi* | [**FindConstraints**](docs/ConstraintApi.md#findconstraints) | **Get** /flags/{flagID}/segments/{segmentID}/constraints | 27 | *ConstraintApi* | [**PutConstraint**](docs/ConstraintApi.md#putconstraint) | **Put** /flags/{flagID}/segments/{segmentID}/constraints/{constraintID} | 28 | *DistributionApi* | [**FindDistributions**](docs/DistributionApi.md#finddistributions) | **Get** /flags/{flagID}/segments/{segmentID}/distributions | 29 | *DistributionApi* | [**PutDistributions**](docs/DistributionApi.md#putdistributions) | **Put** /flags/{flagID}/segments/{segmentID}/distributions | 30 | *EvaluationApi* | [**PostEvaluation**](docs/EvaluationApi.md#postevaluation) | **Post** /evaluation | 31 | *EvaluationApi* | [**PostEvaluationBatch**](docs/EvaluationApi.md#postevaluationbatch) | **Post** /evaluation/batch | 32 | *ExportApi* | [**GetExportEvalCacheJSON**](docs/ExportApi.md#getexportevalcachejson) | **Get** /export/eval_cache/json | 33 | *ExportApi* | [**GetExportSqlite**](docs/ExportApi.md#getexportsqlite) | **Get** /export/sqlite | 34 | *FlagApi* | [**CreateFlag**](docs/FlagApi.md#createflag) | **Post** /flags | 35 | *FlagApi* | [**DeleteFlag**](docs/FlagApi.md#deleteflag) | **Delete** /flags/{flagID} | 36 | *FlagApi* | [**FindFlags**](docs/FlagApi.md#findflags) | **Get** /flags | 37 | *FlagApi* | [**GetFlag**](docs/FlagApi.md#getflag) | **Get** /flags/{flagID} | 38 | *FlagApi* | [**GetFlagEntityTypes**](docs/FlagApi.md#getflagentitytypes) | **Get** /flags/entity_types | 39 | *FlagApi* | [**GetFlagSnapshots**](docs/FlagApi.md#getflagsnapshots) | **Get** /flags/{flagID}/snapshots | 40 | *FlagApi* | [**PutFlag**](docs/FlagApi.md#putflag) | **Put** /flags/{flagID} | 41 | *FlagApi* | [**SetFlagEnabled**](docs/FlagApi.md#setflagenabled) | **Put** /flags/{flagID}/enabled | 42 | *HealthApi* | [**GetHealth**](docs/HealthApi.md#gethealth) | **Get** /health | 43 | *SegmentApi* | [**CreateSegment**](docs/SegmentApi.md#createsegment) | **Post** /flags/{flagID}/segments | 44 | *SegmentApi* | [**DeleteSegment**](docs/SegmentApi.md#deletesegment) | **Delete** /flags/{flagID}/segments/{segmentID} | 45 | *SegmentApi* | [**FindSegments**](docs/SegmentApi.md#findsegments) | **Get** /flags/{flagID}/segments | 46 | *SegmentApi* | [**PutSegment**](docs/SegmentApi.md#putsegment) | **Put** /flags/{flagID}/segments/{segmentID} | 47 | *SegmentApi* | [**PutSegmentsReorder**](docs/SegmentApi.md#putsegmentsreorder) | **Put** /flags/{flagID}/segments/reorder | 48 | *VariantApi* | [**CreateVariant**](docs/VariantApi.md#createvariant) | **Post** /flags/{flagID}/variants | 49 | *VariantApi* | [**DeleteVariant**](docs/VariantApi.md#deletevariant) | **Delete** /flags/{flagID}/variants/{variantID} | 50 | *VariantApi* | [**FindVariants**](docs/VariantApi.md#findvariants) | **Get** /flags/{flagID}/variants | 51 | *VariantApi* | [**PutVariant**](docs/VariantApi.md#putvariant) | **Put** /flags/{flagID}/variants/{variantID} | 52 | 53 | 54 | ## Documentation For Models 55 | 56 | - [Constraint](docs/Constraint.md) 57 | - [CreateConstraintRequest](docs/CreateConstraintRequest.md) 58 | - [CreateFlagRequest](docs/CreateFlagRequest.md) 59 | - [CreateSegmentRequest](docs/CreateSegmentRequest.md) 60 | - [CreateVariantRequest](docs/CreateVariantRequest.md) 61 | - [Distribution](docs/Distribution.md) 62 | - [EvalContext](docs/EvalContext.md) 63 | - [EvalDebugLog](docs/EvalDebugLog.md) 64 | - [EvalResult](docs/EvalResult.md) 65 | - [EvaluationBatchRequest](docs/EvaluationBatchRequest.md) 66 | - [EvaluationBatchResponse](docs/EvaluationBatchResponse.md) 67 | - [EvaluationEntity](docs/EvaluationEntity.md) 68 | - [Flag](docs/Flag.md) 69 | - [FlagSnapshot](docs/FlagSnapshot.md) 70 | - [Health](docs/Health.md) 71 | - [ModelError](docs/ModelError.md) 72 | - [PutDistributionsRequest](docs/PutDistributionsRequest.md) 73 | - [PutFlagRequest](docs/PutFlagRequest.md) 74 | - [PutSegmentReorderRequest](docs/PutSegmentReorderRequest.md) 75 | - [PutSegmentRequest](docs/PutSegmentRequest.md) 76 | - [PutVariantRequest](docs/PutVariantRequest.md) 77 | - [Segment](docs/Segment.md) 78 | - [SegmentDebugLog](docs/SegmentDebugLog.md) 79 | - [SetFlagEnabledRequest](docs/SetFlagEnabledRequest.md) 80 | - [Variant](docs/Variant.md) 81 | 82 | 83 | ## Documentation For Authorization 84 | Endpoints do not require authorization. 85 | 86 | 87 | ## Author 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /api_constraint.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "io/ioutil" 16 | "net/http" 17 | "net/url" 18 | "strings" 19 | ) 20 | 21 | // Linger please 22 | var ( 23 | _ context.Context 24 | ) 25 | 26 | type ConstraintApiService service 27 | 28 | /* 29 | ConstraintApiService 30 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 31 | * @param flagID numeric ID of the flag 32 | * @param segmentID numeric ID of the segment 33 | * @param body create a constraint 34 | 35 | @return Constraint 36 | */ 37 | func (a *ConstraintApiService) CreateConstraint(ctx context.Context, flagID int64, segmentID int64, body CreateConstraintRequest) (Constraint, *http.Response, error) { 38 | var ( 39 | localVarHttpMethod = strings.ToUpper("Post") 40 | localVarPostBody interface{} 41 | localVarFileName string 42 | localVarFileBytes []byte 43 | localVarReturnValue Constraint 44 | ) 45 | 46 | // create path and map variables 47 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/{segmentID}/constraints" 48 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 49 | localVarPath = strings.Replace(localVarPath, "{"+"segmentID"+"}", fmt.Sprintf("%v", segmentID), -1) 50 | 51 | localVarHeaderParams := make(map[string]string) 52 | localVarQueryParams := url.Values{} 53 | localVarFormParams := url.Values{} 54 | if flagID < 1 { 55 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 56 | } 57 | if segmentID < 1 { 58 | return localVarReturnValue, nil, reportError("segmentID must be greater than 1") 59 | } 60 | 61 | // to determine the Content-Type header 62 | localVarHttpContentTypes := []string{"application/json"} 63 | 64 | // set Content-Type header 65 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 66 | if localVarHttpContentType != "" { 67 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 68 | } 69 | 70 | // to determine the Accept header 71 | localVarHttpHeaderAccepts := []string{"application/json"} 72 | 73 | // set Accept header 74 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 75 | if localVarHttpHeaderAccept != "" { 76 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 77 | } 78 | // body params 79 | localVarPostBody = &body 80 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 81 | if err != nil { 82 | return localVarReturnValue, nil, err 83 | } 84 | 85 | localVarHttpResponse, err := a.client.callAPI(r) 86 | if err != nil || localVarHttpResponse == nil { 87 | return localVarReturnValue, localVarHttpResponse, err 88 | } 89 | 90 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 91 | localVarHttpResponse.Body.Close() 92 | if err != nil { 93 | return localVarReturnValue, localVarHttpResponse, err 94 | } 95 | 96 | if localVarHttpResponse.StatusCode < 300 { 97 | // If we succeed, return the data, otherwise pass on to decode error. 98 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 99 | if err == nil { 100 | return localVarReturnValue, localVarHttpResponse, err 101 | } 102 | } 103 | 104 | if localVarHttpResponse.StatusCode >= 300 { 105 | newErr := GenericSwaggerError{ 106 | body: localVarBody, 107 | error: localVarHttpResponse.Status, 108 | } 109 | 110 | if localVarHttpResponse.StatusCode == 200 { 111 | var v Constraint 112 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 113 | if err != nil { 114 | newErr.error = err.Error() 115 | return localVarReturnValue, localVarHttpResponse, newErr 116 | } 117 | newErr.model = v 118 | return localVarReturnValue, localVarHttpResponse, newErr 119 | } 120 | 121 | if localVarHttpResponse.StatusCode == 0 { 122 | var v ModelError 123 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 124 | if err != nil { 125 | newErr.error = err.Error() 126 | return localVarReturnValue, localVarHttpResponse, newErr 127 | } 128 | newErr.model = v 129 | return localVarReturnValue, localVarHttpResponse, newErr 130 | } 131 | 132 | return localVarReturnValue, localVarHttpResponse, newErr 133 | } 134 | 135 | return localVarReturnValue, localVarHttpResponse, nil 136 | } 137 | 138 | /* 139 | ConstraintApiService 140 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 141 | * @param flagID numeric ID of the flag 142 | * @param segmentID numeric ID of the segment 143 | * @param constraintID numeric ID of the constraint 144 | 145 | 146 | */ 147 | func (a *ConstraintApiService) DeleteConstraint(ctx context.Context, flagID int64, segmentID int64, constraintID int64) (*http.Response, error) { 148 | var ( 149 | localVarHttpMethod = strings.ToUpper("Delete") 150 | localVarPostBody interface{} 151 | localVarFileName string 152 | localVarFileBytes []byte 153 | ) 154 | 155 | // create path and map variables 156 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/{segmentID}/constraints/{constraintID}" 157 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 158 | localVarPath = strings.Replace(localVarPath, "{"+"segmentID"+"}", fmt.Sprintf("%v", segmentID), -1) 159 | localVarPath = strings.Replace(localVarPath, "{"+"constraintID"+"}", fmt.Sprintf("%v", constraintID), -1) 160 | 161 | localVarHeaderParams := make(map[string]string) 162 | localVarQueryParams := url.Values{} 163 | localVarFormParams := url.Values{} 164 | if flagID < 1 { 165 | return nil, reportError("flagID must be greater than 1") 166 | } 167 | if segmentID < 1 { 168 | return nil, reportError("segmentID must be greater than 1") 169 | } 170 | if constraintID < 1 { 171 | return nil, reportError("constraintID must be greater than 1") 172 | } 173 | 174 | // to determine the Content-Type header 175 | localVarHttpContentTypes := []string{"application/json"} 176 | 177 | // set Content-Type header 178 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 179 | if localVarHttpContentType != "" { 180 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 181 | } 182 | 183 | // to determine the Accept header 184 | localVarHttpHeaderAccepts := []string{"application/json"} 185 | 186 | // set Accept header 187 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 188 | if localVarHttpHeaderAccept != "" { 189 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 190 | } 191 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 192 | if err != nil { 193 | return nil, err 194 | } 195 | 196 | localVarHttpResponse, err := a.client.callAPI(r) 197 | if err != nil || localVarHttpResponse == nil { 198 | return localVarHttpResponse, err 199 | } 200 | 201 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 202 | localVarHttpResponse.Body.Close() 203 | if err != nil { 204 | return localVarHttpResponse, err 205 | } 206 | 207 | if localVarHttpResponse.StatusCode >= 300 { 208 | newErr := GenericSwaggerError{ 209 | body: localVarBody, 210 | error: localVarHttpResponse.Status, 211 | } 212 | 213 | if localVarHttpResponse.StatusCode == 0 { 214 | var v ModelError 215 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 216 | if err != nil { 217 | newErr.error = err.Error() 218 | return localVarHttpResponse, newErr 219 | } 220 | newErr.model = v 221 | return localVarHttpResponse, newErr 222 | } 223 | 224 | return localVarHttpResponse, newErr 225 | } 226 | 227 | return localVarHttpResponse, nil 228 | } 229 | 230 | /* 231 | ConstraintApiService 232 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 233 | * @param flagID numeric ID of the flag 234 | * @param segmentID numeric ID of the segment 235 | 236 | @return []Constraint 237 | */ 238 | func (a *ConstraintApiService) FindConstraints(ctx context.Context, flagID int64, segmentID int64) ([]Constraint, *http.Response, error) { 239 | var ( 240 | localVarHttpMethod = strings.ToUpper("Get") 241 | localVarPostBody interface{} 242 | localVarFileName string 243 | localVarFileBytes []byte 244 | localVarReturnValue []Constraint 245 | ) 246 | 247 | // create path and map variables 248 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/{segmentID}/constraints" 249 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 250 | localVarPath = strings.Replace(localVarPath, "{"+"segmentID"+"}", fmt.Sprintf("%v", segmentID), -1) 251 | 252 | localVarHeaderParams := make(map[string]string) 253 | localVarQueryParams := url.Values{} 254 | localVarFormParams := url.Values{} 255 | if flagID < 1 { 256 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 257 | } 258 | if segmentID < 1 { 259 | return localVarReturnValue, nil, reportError("segmentID must be greater than 1") 260 | } 261 | 262 | // to determine the Content-Type header 263 | localVarHttpContentTypes := []string{"application/json"} 264 | 265 | // set Content-Type header 266 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 267 | if localVarHttpContentType != "" { 268 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 269 | } 270 | 271 | // to determine the Accept header 272 | localVarHttpHeaderAccepts := []string{"application/json"} 273 | 274 | // set Accept header 275 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 276 | if localVarHttpHeaderAccept != "" { 277 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 278 | } 279 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 280 | if err != nil { 281 | return localVarReturnValue, nil, err 282 | } 283 | 284 | localVarHttpResponse, err := a.client.callAPI(r) 285 | if err != nil || localVarHttpResponse == nil { 286 | return localVarReturnValue, localVarHttpResponse, err 287 | } 288 | 289 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 290 | localVarHttpResponse.Body.Close() 291 | if err != nil { 292 | return localVarReturnValue, localVarHttpResponse, err 293 | } 294 | 295 | if localVarHttpResponse.StatusCode < 300 { 296 | // If we succeed, return the data, otherwise pass on to decode error. 297 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 298 | if err == nil { 299 | return localVarReturnValue, localVarHttpResponse, err 300 | } 301 | } 302 | 303 | if localVarHttpResponse.StatusCode >= 300 { 304 | newErr := GenericSwaggerError{ 305 | body: localVarBody, 306 | error: localVarHttpResponse.Status, 307 | } 308 | 309 | if localVarHttpResponse.StatusCode == 200 { 310 | var v []Constraint 311 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 312 | if err != nil { 313 | newErr.error = err.Error() 314 | return localVarReturnValue, localVarHttpResponse, newErr 315 | } 316 | newErr.model = v 317 | return localVarReturnValue, localVarHttpResponse, newErr 318 | } 319 | 320 | if localVarHttpResponse.StatusCode == 0 { 321 | var v ModelError 322 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 323 | if err != nil { 324 | newErr.error = err.Error() 325 | return localVarReturnValue, localVarHttpResponse, newErr 326 | } 327 | newErr.model = v 328 | return localVarReturnValue, localVarHttpResponse, newErr 329 | } 330 | 331 | return localVarReturnValue, localVarHttpResponse, newErr 332 | } 333 | 334 | return localVarReturnValue, localVarHttpResponse, nil 335 | } 336 | 337 | /* 338 | ConstraintApiService 339 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 340 | * @param flagID numeric ID of the flag 341 | * @param segmentID numeric ID of the segment 342 | * @param constraintID numeric ID of the constraint 343 | * @param body create a constraint 344 | 345 | @return Constraint 346 | */ 347 | func (a *ConstraintApiService) PutConstraint(ctx context.Context, flagID int64, segmentID int64, constraintID int64, body CreateConstraintRequest) (Constraint, *http.Response, error) { 348 | var ( 349 | localVarHttpMethod = strings.ToUpper("Put") 350 | localVarPostBody interface{} 351 | localVarFileName string 352 | localVarFileBytes []byte 353 | localVarReturnValue Constraint 354 | ) 355 | 356 | // create path and map variables 357 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/{segmentID}/constraints/{constraintID}" 358 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 359 | localVarPath = strings.Replace(localVarPath, "{"+"segmentID"+"}", fmt.Sprintf("%v", segmentID), -1) 360 | localVarPath = strings.Replace(localVarPath, "{"+"constraintID"+"}", fmt.Sprintf("%v", constraintID), -1) 361 | 362 | localVarHeaderParams := make(map[string]string) 363 | localVarQueryParams := url.Values{} 364 | localVarFormParams := url.Values{} 365 | if flagID < 1 { 366 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 367 | } 368 | if segmentID < 1 { 369 | return localVarReturnValue, nil, reportError("segmentID must be greater than 1") 370 | } 371 | if constraintID < 1 { 372 | return localVarReturnValue, nil, reportError("constraintID must be greater than 1") 373 | } 374 | 375 | // to determine the Content-Type header 376 | localVarHttpContentTypes := []string{"application/json"} 377 | 378 | // set Content-Type header 379 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 380 | if localVarHttpContentType != "" { 381 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 382 | } 383 | 384 | // to determine the Accept header 385 | localVarHttpHeaderAccepts := []string{"application/json"} 386 | 387 | // set Accept header 388 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 389 | if localVarHttpHeaderAccept != "" { 390 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 391 | } 392 | // body params 393 | localVarPostBody = &body 394 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 395 | if err != nil { 396 | return localVarReturnValue, nil, err 397 | } 398 | 399 | localVarHttpResponse, err := a.client.callAPI(r) 400 | if err != nil || localVarHttpResponse == nil { 401 | return localVarReturnValue, localVarHttpResponse, err 402 | } 403 | 404 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 405 | localVarHttpResponse.Body.Close() 406 | if err != nil { 407 | return localVarReturnValue, localVarHttpResponse, err 408 | } 409 | 410 | if localVarHttpResponse.StatusCode < 300 { 411 | // If we succeed, return the data, otherwise pass on to decode error. 412 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 413 | if err == nil { 414 | return localVarReturnValue, localVarHttpResponse, err 415 | } 416 | } 417 | 418 | if localVarHttpResponse.StatusCode >= 300 { 419 | newErr := GenericSwaggerError{ 420 | body: localVarBody, 421 | error: localVarHttpResponse.Status, 422 | } 423 | 424 | if localVarHttpResponse.StatusCode == 200 { 425 | var v Constraint 426 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 427 | if err != nil { 428 | newErr.error = err.Error() 429 | return localVarReturnValue, localVarHttpResponse, newErr 430 | } 431 | newErr.model = v 432 | return localVarReturnValue, localVarHttpResponse, newErr 433 | } 434 | 435 | if localVarHttpResponse.StatusCode == 0 { 436 | var v ModelError 437 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 438 | if err != nil { 439 | newErr.error = err.Error() 440 | return localVarReturnValue, localVarHttpResponse, newErr 441 | } 442 | newErr.model = v 443 | return localVarReturnValue, localVarHttpResponse, newErr 444 | } 445 | 446 | return localVarReturnValue, localVarHttpResponse, newErr 447 | } 448 | 449 | return localVarReturnValue, localVarHttpResponse, nil 450 | } 451 | -------------------------------------------------------------------------------- /api_distribution.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "io/ioutil" 16 | "net/http" 17 | "net/url" 18 | "strings" 19 | ) 20 | 21 | // Linger please 22 | var ( 23 | _ context.Context 24 | ) 25 | 26 | type DistributionApiService service 27 | 28 | /* 29 | DistributionApiService 30 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 31 | * @param flagID numeric ID of the flag 32 | * @param segmentID numeric ID of the segment 33 | 34 | @return []Distribution 35 | */ 36 | func (a *DistributionApiService) FindDistributions(ctx context.Context, flagID int64, segmentID int64) ([]Distribution, *http.Response, error) { 37 | var ( 38 | localVarHttpMethod = strings.ToUpper("Get") 39 | localVarPostBody interface{} 40 | localVarFileName string 41 | localVarFileBytes []byte 42 | localVarReturnValue []Distribution 43 | ) 44 | 45 | // create path and map variables 46 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/{segmentID}/distributions" 47 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 48 | localVarPath = strings.Replace(localVarPath, "{"+"segmentID"+"}", fmt.Sprintf("%v", segmentID), -1) 49 | 50 | localVarHeaderParams := make(map[string]string) 51 | localVarQueryParams := url.Values{} 52 | localVarFormParams := url.Values{} 53 | if flagID < 1 { 54 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 55 | } 56 | if segmentID < 1 { 57 | return localVarReturnValue, nil, reportError("segmentID must be greater than 1") 58 | } 59 | 60 | // to determine the Content-Type header 61 | localVarHttpContentTypes := []string{"application/json"} 62 | 63 | // set Content-Type header 64 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 65 | if localVarHttpContentType != "" { 66 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 67 | } 68 | 69 | // to determine the Accept header 70 | localVarHttpHeaderAccepts := []string{"application/json"} 71 | 72 | // set Accept header 73 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 74 | if localVarHttpHeaderAccept != "" { 75 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 76 | } 77 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 78 | if err != nil { 79 | return localVarReturnValue, nil, err 80 | } 81 | 82 | localVarHttpResponse, err := a.client.callAPI(r) 83 | if err != nil || localVarHttpResponse == nil { 84 | return localVarReturnValue, localVarHttpResponse, err 85 | } 86 | 87 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 88 | localVarHttpResponse.Body.Close() 89 | if err != nil { 90 | return localVarReturnValue, localVarHttpResponse, err 91 | } 92 | 93 | if localVarHttpResponse.StatusCode < 300 { 94 | // If we succeed, return the data, otherwise pass on to decode error. 95 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 96 | if err == nil { 97 | return localVarReturnValue, localVarHttpResponse, err 98 | } 99 | } 100 | 101 | if localVarHttpResponse.StatusCode >= 300 { 102 | newErr := GenericSwaggerError{ 103 | body: localVarBody, 104 | error: localVarHttpResponse.Status, 105 | } 106 | 107 | if localVarHttpResponse.StatusCode == 200 { 108 | var v []Distribution 109 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 110 | if err != nil { 111 | newErr.error = err.Error() 112 | return localVarReturnValue, localVarHttpResponse, newErr 113 | } 114 | newErr.model = v 115 | return localVarReturnValue, localVarHttpResponse, newErr 116 | } 117 | 118 | if localVarHttpResponse.StatusCode == 0 { 119 | var v ModelError 120 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 121 | if err != nil { 122 | newErr.error = err.Error() 123 | return localVarReturnValue, localVarHttpResponse, newErr 124 | } 125 | newErr.model = v 126 | return localVarReturnValue, localVarHttpResponse, newErr 127 | } 128 | 129 | return localVarReturnValue, localVarHttpResponse, newErr 130 | } 131 | 132 | return localVarReturnValue, localVarHttpResponse, nil 133 | } 134 | 135 | /* 136 | DistributionApiService 137 | replace the distribution with the new setting 138 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 139 | * @param flagID numeric ID of the flag 140 | * @param segmentID numeric ID of the segment 141 | * @param body array of distributions 142 | 143 | @return []Distribution 144 | */ 145 | func (a *DistributionApiService) PutDistributions(ctx context.Context, flagID int64, segmentID int64, body PutDistributionsRequest) ([]Distribution, *http.Response, error) { 146 | var ( 147 | localVarHttpMethod = strings.ToUpper("Put") 148 | localVarPostBody interface{} 149 | localVarFileName string 150 | localVarFileBytes []byte 151 | localVarReturnValue []Distribution 152 | ) 153 | 154 | // create path and map variables 155 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/{segmentID}/distributions" 156 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 157 | localVarPath = strings.Replace(localVarPath, "{"+"segmentID"+"}", fmt.Sprintf("%v", segmentID), -1) 158 | 159 | localVarHeaderParams := make(map[string]string) 160 | localVarQueryParams := url.Values{} 161 | localVarFormParams := url.Values{} 162 | if flagID < 1 { 163 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 164 | } 165 | if segmentID < 1 { 166 | return localVarReturnValue, nil, reportError("segmentID must be greater than 1") 167 | } 168 | 169 | // to determine the Content-Type header 170 | localVarHttpContentTypes := []string{"application/json"} 171 | 172 | // set Content-Type header 173 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 174 | if localVarHttpContentType != "" { 175 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 176 | } 177 | 178 | // to determine the Accept header 179 | localVarHttpHeaderAccepts := []string{"application/json"} 180 | 181 | // set Accept header 182 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 183 | if localVarHttpHeaderAccept != "" { 184 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 185 | } 186 | // body params 187 | localVarPostBody = &body 188 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 189 | if err != nil { 190 | return localVarReturnValue, nil, err 191 | } 192 | 193 | localVarHttpResponse, err := a.client.callAPI(r) 194 | if err != nil || localVarHttpResponse == nil { 195 | return localVarReturnValue, localVarHttpResponse, err 196 | } 197 | 198 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 199 | localVarHttpResponse.Body.Close() 200 | if err != nil { 201 | return localVarReturnValue, localVarHttpResponse, err 202 | } 203 | 204 | if localVarHttpResponse.StatusCode < 300 { 205 | // If we succeed, return the data, otherwise pass on to decode error. 206 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 207 | if err == nil { 208 | return localVarReturnValue, localVarHttpResponse, err 209 | } 210 | } 211 | 212 | if localVarHttpResponse.StatusCode >= 300 { 213 | newErr := GenericSwaggerError{ 214 | body: localVarBody, 215 | error: localVarHttpResponse.Status, 216 | } 217 | 218 | if localVarHttpResponse.StatusCode == 200 { 219 | var v []Distribution 220 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 221 | if err != nil { 222 | newErr.error = err.Error() 223 | return localVarReturnValue, localVarHttpResponse, newErr 224 | } 225 | newErr.model = v 226 | return localVarReturnValue, localVarHttpResponse, newErr 227 | } 228 | 229 | if localVarHttpResponse.StatusCode == 0 { 230 | var v ModelError 231 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 232 | if err != nil { 233 | newErr.error = err.Error() 234 | return localVarReturnValue, localVarHttpResponse, newErr 235 | } 236 | newErr.model = v 237 | return localVarReturnValue, localVarHttpResponse, newErr 238 | } 239 | 240 | return localVarReturnValue, localVarHttpResponse, newErr 241 | } 242 | 243 | return localVarReturnValue, localVarHttpResponse, nil 244 | } 245 | -------------------------------------------------------------------------------- /api_evaluation.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "context" 14 | "io/ioutil" 15 | "net/http" 16 | "net/url" 17 | "strings" 18 | ) 19 | 20 | // Linger please 21 | var ( 22 | _ context.Context 23 | ) 24 | 25 | type EvaluationApiService service 26 | 27 | /* 28 | EvaluationApiService 29 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 30 | * @param body evalution context 31 | 32 | @return EvalResult 33 | */ 34 | func (a *EvaluationApiService) PostEvaluation(ctx context.Context, body EvalContext) (EvalResult, *http.Response, error) { 35 | var ( 36 | localVarHttpMethod = strings.ToUpper("Post") 37 | localVarPostBody interface{} 38 | localVarFileName string 39 | localVarFileBytes []byte 40 | localVarReturnValue EvalResult 41 | ) 42 | 43 | // create path and map variables 44 | localVarPath := a.client.cfg.BasePath + "/evaluation" 45 | 46 | localVarHeaderParams := make(map[string]string) 47 | localVarQueryParams := url.Values{} 48 | localVarFormParams := url.Values{} 49 | 50 | // to determine the Content-Type header 51 | localVarHttpContentTypes := []string{"application/json"} 52 | 53 | // set Content-Type header 54 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 55 | if localVarHttpContentType != "" { 56 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 57 | } 58 | 59 | // to determine the Accept header 60 | localVarHttpHeaderAccepts := []string{"application/json"} 61 | 62 | // set Accept header 63 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 64 | if localVarHttpHeaderAccept != "" { 65 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 66 | } 67 | // body params 68 | localVarPostBody = &body 69 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 70 | if err != nil { 71 | return localVarReturnValue, nil, err 72 | } 73 | 74 | localVarHttpResponse, err := a.client.callAPI(r) 75 | if err != nil || localVarHttpResponse == nil { 76 | return localVarReturnValue, localVarHttpResponse, err 77 | } 78 | 79 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 80 | localVarHttpResponse.Body.Close() 81 | if err != nil { 82 | return localVarReturnValue, localVarHttpResponse, err 83 | } 84 | 85 | if localVarHttpResponse.StatusCode < 300 { 86 | // If we succeed, return the data, otherwise pass on to decode error. 87 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 88 | if err == nil { 89 | return localVarReturnValue, localVarHttpResponse, err 90 | } 91 | } 92 | 93 | if localVarHttpResponse.StatusCode >= 300 { 94 | newErr := GenericSwaggerError{ 95 | body: localVarBody, 96 | error: localVarHttpResponse.Status, 97 | } 98 | 99 | if localVarHttpResponse.StatusCode == 200 { 100 | var v EvalResult 101 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 102 | if err != nil { 103 | newErr.error = err.Error() 104 | return localVarReturnValue, localVarHttpResponse, newErr 105 | } 106 | newErr.model = v 107 | return localVarReturnValue, localVarHttpResponse, newErr 108 | } 109 | 110 | if localVarHttpResponse.StatusCode == 0 { 111 | var v ModelError 112 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 113 | if err != nil { 114 | newErr.error = err.Error() 115 | return localVarReturnValue, localVarHttpResponse, newErr 116 | } 117 | newErr.model = v 118 | return localVarReturnValue, localVarHttpResponse, newErr 119 | } 120 | 121 | return localVarReturnValue, localVarHttpResponse, newErr 122 | } 123 | 124 | return localVarReturnValue, localVarHttpResponse, nil 125 | } 126 | 127 | /* 128 | EvaluationApiService 129 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 130 | * @param body evalution batch request 131 | 132 | @return EvaluationBatchResponse 133 | */ 134 | func (a *EvaluationApiService) PostEvaluationBatch(ctx context.Context, body EvaluationBatchRequest) (EvaluationBatchResponse, *http.Response, error) { 135 | var ( 136 | localVarHttpMethod = strings.ToUpper("Post") 137 | localVarPostBody interface{} 138 | localVarFileName string 139 | localVarFileBytes []byte 140 | localVarReturnValue EvaluationBatchResponse 141 | ) 142 | 143 | // create path and map variables 144 | localVarPath := a.client.cfg.BasePath + "/evaluation/batch" 145 | 146 | localVarHeaderParams := make(map[string]string) 147 | localVarQueryParams := url.Values{} 148 | localVarFormParams := url.Values{} 149 | 150 | // to determine the Content-Type header 151 | localVarHttpContentTypes := []string{"application/json"} 152 | 153 | // set Content-Type header 154 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 155 | if localVarHttpContentType != "" { 156 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 157 | } 158 | 159 | // to determine the Accept header 160 | localVarHttpHeaderAccepts := []string{"application/json"} 161 | 162 | // set Accept header 163 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 164 | if localVarHttpHeaderAccept != "" { 165 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 166 | } 167 | // body params 168 | localVarPostBody = &body 169 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 170 | if err != nil { 171 | return localVarReturnValue, nil, err 172 | } 173 | 174 | localVarHttpResponse, err := a.client.callAPI(r) 175 | if err != nil || localVarHttpResponse == nil { 176 | return localVarReturnValue, localVarHttpResponse, err 177 | } 178 | 179 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 180 | localVarHttpResponse.Body.Close() 181 | if err != nil { 182 | return localVarReturnValue, localVarHttpResponse, err 183 | } 184 | 185 | if localVarHttpResponse.StatusCode < 300 { 186 | // If we succeed, return the data, otherwise pass on to decode error. 187 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 188 | if err == nil { 189 | return localVarReturnValue, localVarHttpResponse, err 190 | } 191 | } 192 | 193 | if localVarHttpResponse.StatusCode >= 300 { 194 | newErr := GenericSwaggerError{ 195 | body: localVarBody, 196 | error: localVarHttpResponse.Status, 197 | } 198 | 199 | if localVarHttpResponse.StatusCode == 200 { 200 | var v EvaluationBatchResponse 201 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 202 | if err != nil { 203 | newErr.error = err.Error() 204 | return localVarReturnValue, localVarHttpResponse, newErr 205 | } 206 | newErr.model = v 207 | return localVarReturnValue, localVarHttpResponse, newErr 208 | } 209 | 210 | if localVarHttpResponse.StatusCode == 0 { 211 | var v ModelError 212 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 213 | if err != nil { 214 | newErr.error = err.Error() 215 | return localVarReturnValue, localVarHttpResponse, newErr 216 | } 217 | newErr.model = v 218 | return localVarReturnValue, localVarHttpResponse, newErr 219 | } 220 | 221 | return localVarReturnValue, localVarHttpResponse, newErr 222 | } 223 | 224 | return localVarReturnValue, localVarHttpResponse, nil 225 | } 226 | -------------------------------------------------------------------------------- /api_export.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "context" 14 | "io/ioutil" 15 | "net/http" 16 | "net/url" 17 | "os" 18 | "strings" 19 | ) 20 | 21 | // Linger please 22 | var ( 23 | _ context.Context 24 | ) 25 | 26 | type ExportApiService service 27 | 28 | /* 29 | ExportApiService 30 | Export JSON format of the eval cache dump 31 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 32 | 33 | @return interface{} 34 | */ 35 | func (a *ExportApiService) GetExportEvalCacheJSON(ctx context.Context) (interface{}, *http.Response, error) { 36 | var ( 37 | localVarHttpMethod = strings.ToUpper("Get") 38 | localVarPostBody interface{} 39 | localVarFileName string 40 | localVarFileBytes []byte 41 | localVarReturnValue interface{} 42 | ) 43 | 44 | // create path and map variables 45 | localVarPath := a.client.cfg.BasePath + "/export/eval_cache/json" 46 | 47 | localVarHeaderParams := make(map[string]string) 48 | localVarQueryParams := url.Values{} 49 | localVarFormParams := url.Values{} 50 | 51 | // to determine the Content-Type header 52 | localVarHttpContentTypes := []string{"application/json"} 53 | 54 | // set Content-Type header 55 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 56 | if localVarHttpContentType != "" { 57 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 58 | } 59 | 60 | // to determine the Accept header 61 | localVarHttpHeaderAccepts := []string{"application/json"} 62 | 63 | // set Accept header 64 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 65 | if localVarHttpHeaderAccept != "" { 66 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 67 | } 68 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 69 | if err != nil { 70 | return localVarReturnValue, nil, err 71 | } 72 | 73 | localVarHttpResponse, err := a.client.callAPI(r) 74 | if err != nil || localVarHttpResponse == nil { 75 | return localVarReturnValue, localVarHttpResponse, err 76 | } 77 | 78 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 79 | localVarHttpResponse.Body.Close() 80 | if err != nil { 81 | return localVarReturnValue, localVarHttpResponse, err 82 | } 83 | 84 | if localVarHttpResponse.StatusCode < 300 { 85 | // If we succeed, return the data, otherwise pass on to decode error. 86 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 87 | if err == nil { 88 | return localVarReturnValue, localVarHttpResponse, err 89 | } 90 | } 91 | 92 | if localVarHttpResponse.StatusCode >= 300 { 93 | newErr := GenericSwaggerError{ 94 | body: localVarBody, 95 | error: localVarHttpResponse.Status, 96 | } 97 | 98 | if localVarHttpResponse.StatusCode == 200 { 99 | var v interface{} 100 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 101 | if err != nil { 102 | newErr.error = err.Error() 103 | return localVarReturnValue, localVarHttpResponse, newErr 104 | } 105 | newErr.model = v 106 | return localVarReturnValue, localVarHttpResponse, newErr 107 | } 108 | 109 | if localVarHttpResponse.StatusCode == 0 { 110 | var v ModelError 111 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 112 | if err != nil { 113 | newErr.error = err.Error() 114 | return localVarReturnValue, localVarHttpResponse, newErr 115 | } 116 | newErr.model = v 117 | return localVarReturnValue, localVarHttpResponse, newErr 118 | } 119 | 120 | return localVarReturnValue, localVarHttpResponse, newErr 121 | } 122 | 123 | return localVarReturnValue, localVarHttpResponse, nil 124 | } 125 | 126 | /* 127 | ExportApiService 128 | Export sqlite3 format of the db dump, which is converted from the main database. 129 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 130 | 131 | @return *os.File 132 | */ 133 | func (a *ExportApiService) GetExportSqlite(ctx context.Context) (*os.File, *http.Response, error) { 134 | var ( 135 | localVarHttpMethod = strings.ToUpper("Get") 136 | localVarPostBody interface{} 137 | localVarFileName string 138 | localVarFileBytes []byte 139 | localVarReturnValue *os.File 140 | ) 141 | 142 | // create path and map variables 143 | localVarPath := a.client.cfg.BasePath + "/export/sqlite" 144 | 145 | localVarHeaderParams := make(map[string]string) 146 | localVarQueryParams := url.Values{} 147 | localVarFormParams := url.Values{} 148 | 149 | // to determine the Content-Type header 150 | localVarHttpContentTypes := []string{"application/json"} 151 | 152 | // set Content-Type header 153 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 154 | if localVarHttpContentType != "" { 155 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 156 | } 157 | 158 | // to determine the Accept header 159 | localVarHttpHeaderAccepts := []string{"application/octet-stream"} 160 | 161 | // set Accept header 162 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 163 | if localVarHttpHeaderAccept != "" { 164 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 165 | } 166 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 167 | if err != nil { 168 | return localVarReturnValue, nil, err 169 | } 170 | 171 | localVarHttpResponse, err := a.client.callAPI(r) 172 | if err != nil || localVarHttpResponse == nil { 173 | return localVarReturnValue, localVarHttpResponse, err 174 | } 175 | 176 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 177 | localVarHttpResponse.Body.Close() 178 | if err != nil { 179 | return localVarReturnValue, localVarHttpResponse, err 180 | } 181 | 182 | if localVarHttpResponse.StatusCode < 300 { 183 | // If we succeed, return the data, otherwise pass on to decode error. 184 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 185 | if err == nil { 186 | return localVarReturnValue, localVarHttpResponse, err 187 | } 188 | } 189 | 190 | if localVarHttpResponse.StatusCode >= 300 { 191 | newErr := GenericSwaggerError{ 192 | body: localVarBody, 193 | error: localVarHttpResponse.Status, 194 | } 195 | 196 | if localVarHttpResponse.StatusCode == 200 { 197 | var v *os.File 198 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 199 | if err != nil { 200 | newErr.error = err.Error() 201 | return localVarReturnValue, localVarHttpResponse, newErr 202 | } 203 | newErr.model = v 204 | return localVarReturnValue, localVarHttpResponse, newErr 205 | } 206 | 207 | if localVarHttpResponse.StatusCode == 0 { 208 | var v ModelError 209 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 210 | if err != nil { 211 | newErr.error = err.Error() 212 | return localVarReturnValue, localVarHttpResponse, newErr 213 | } 214 | newErr.model = v 215 | return localVarReturnValue, localVarHttpResponse, newErr 216 | } 217 | 218 | return localVarReturnValue, localVarHttpResponse, newErr 219 | } 220 | 221 | return localVarReturnValue, localVarHttpResponse, nil 222 | } 223 | -------------------------------------------------------------------------------- /api_flag.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "io/ioutil" 16 | "net/http" 17 | "net/url" 18 | "strings" 19 | 20 | "github.com/antihax/optional" 21 | ) 22 | 23 | // Linger please 24 | var ( 25 | _ context.Context 26 | ) 27 | 28 | type FlagApiService service 29 | 30 | /* 31 | FlagApiService 32 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 33 | * @param body create a flag 34 | 35 | @return Flag 36 | */ 37 | func (a *FlagApiService) CreateFlag(ctx context.Context, body CreateFlagRequest) (Flag, *http.Response, error) { 38 | var ( 39 | localVarHttpMethod = strings.ToUpper("Post") 40 | localVarPostBody interface{} 41 | localVarFileName string 42 | localVarFileBytes []byte 43 | localVarReturnValue Flag 44 | ) 45 | 46 | // create path and map variables 47 | localVarPath := a.client.cfg.BasePath + "/flags" 48 | 49 | localVarHeaderParams := make(map[string]string) 50 | localVarQueryParams := url.Values{} 51 | localVarFormParams := url.Values{} 52 | 53 | // to determine the Content-Type header 54 | localVarHttpContentTypes := []string{"application/json"} 55 | 56 | // set Content-Type header 57 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 58 | if localVarHttpContentType != "" { 59 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 60 | } 61 | 62 | // to determine the Accept header 63 | localVarHttpHeaderAccepts := []string{"application/json"} 64 | 65 | // set Accept header 66 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 67 | if localVarHttpHeaderAccept != "" { 68 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 69 | } 70 | // body params 71 | localVarPostBody = &body 72 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 73 | if err != nil { 74 | return localVarReturnValue, nil, err 75 | } 76 | 77 | localVarHttpResponse, err := a.client.callAPI(r) 78 | if err != nil || localVarHttpResponse == nil { 79 | return localVarReturnValue, localVarHttpResponse, err 80 | } 81 | 82 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 83 | localVarHttpResponse.Body.Close() 84 | if err != nil { 85 | return localVarReturnValue, localVarHttpResponse, err 86 | } 87 | 88 | if localVarHttpResponse.StatusCode < 300 { 89 | // If we succeed, return the data, otherwise pass on to decode error. 90 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 91 | if err == nil { 92 | return localVarReturnValue, localVarHttpResponse, err 93 | } 94 | } 95 | 96 | if localVarHttpResponse.StatusCode >= 300 { 97 | newErr := GenericSwaggerError{ 98 | body: localVarBody, 99 | error: localVarHttpResponse.Status, 100 | } 101 | 102 | if localVarHttpResponse.StatusCode == 200 { 103 | var v Flag 104 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 105 | if err != nil { 106 | newErr.error = err.Error() 107 | return localVarReturnValue, localVarHttpResponse, newErr 108 | } 109 | newErr.model = v 110 | return localVarReturnValue, localVarHttpResponse, newErr 111 | } 112 | 113 | if localVarHttpResponse.StatusCode == 0 { 114 | var v ModelError 115 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 116 | if err != nil { 117 | newErr.error = err.Error() 118 | return localVarReturnValue, localVarHttpResponse, newErr 119 | } 120 | newErr.model = v 121 | return localVarReturnValue, localVarHttpResponse, newErr 122 | } 123 | 124 | return localVarReturnValue, localVarHttpResponse, newErr 125 | } 126 | 127 | return localVarReturnValue, localVarHttpResponse, nil 128 | } 129 | 130 | /* 131 | FlagApiService 132 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 133 | * @param flagID numeric ID of the flag 134 | 135 | 136 | */ 137 | func (a *FlagApiService) DeleteFlag(ctx context.Context, flagID int64) (*http.Response, error) { 138 | var ( 139 | localVarHttpMethod = strings.ToUpper("Delete") 140 | localVarPostBody interface{} 141 | localVarFileName string 142 | localVarFileBytes []byte 143 | ) 144 | 145 | // create path and map variables 146 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}" 147 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 148 | 149 | localVarHeaderParams := make(map[string]string) 150 | localVarQueryParams := url.Values{} 151 | localVarFormParams := url.Values{} 152 | if flagID < 1 { 153 | return nil, reportError("flagID must be greater than 1") 154 | } 155 | 156 | // to determine the Content-Type header 157 | localVarHttpContentTypes := []string{"application/json"} 158 | 159 | // set Content-Type header 160 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 161 | if localVarHttpContentType != "" { 162 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 163 | } 164 | 165 | // to determine the Accept header 166 | localVarHttpHeaderAccepts := []string{"application/json"} 167 | 168 | // set Accept header 169 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 170 | if localVarHttpHeaderAccept != "" { 171 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 172 | } 173 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 174 | if err != nil { 175 | return nil, err 176 | } 177 | 178 | localVarHttpResponse, err := a.client.callAPI(r) 179 | if err != nil || localVarHttpResponse == nil { 180 | return localVarHttpResponse, err 181 | } 182 | 183 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 184 | localVarHttpResponse.Body.Close() 185 | if err != nil { 186 | return localVarHttpResponse, err 187 | } 188 | 189 | if localVarHttpResponse.StatusCode >= 300 { 190 | newErr := GenericSwaggerError{ 191 | body: localVarBody, 192 | error: localVarHttpResponse.Status, 193 | } 194 | 195 | if localVarHttpResponse.StatusCode == 0 { 196 | var v ModelError 197 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 198 | if err != nil { 199 | newErr.error = err.Error() 200 | return localVarHttpResponse, newErr 201 | } 202 | newErr.model = v 203 | return localVarHttpResponse, newErr 204 | } 205 | 206 | return localVarHttpResponse, newErr 207 | } 208 | 209 | return localVarHttpResponse, nil 210 | } 211 | 212 | /* 213 | FlagApiService 214 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 215 | * @param optional nil or *FindFlagsOpts - Optional Parameters: 216 | * @param "Limit" (optional.Int64) - the numbers of flags to return 217 | * @param "Enabled" (optional.Bool) - return flags having given enabled status 218 | * @param "Description" (optional.String) - return flags exactly matching given description 219 | * @param "DescriptionLike" (optional.String) - return flags partially matching given description 220 | * @param "Key" (optional.String) - return flags matching given key 221 | * @param "Offset" (optional.Int64) - return flags given the offset, it should usually set together with limit 222 | * @param "Preload" (optional.Bool) - return flags with preloaded segments and variants 223 | 224 | @return []Flag 225 | */ 226 | 227 | type FindFlagsOpts struct { 228 | Limit optional.Int64 229 | Enabled optional.Bool 230 | Description optional.String 231 | DescriptionLike optional.String 232 | Key optional.String 233 | Offset optional.Int64 234 | Preload optional.Bool 235 | } 236 | 237 | func (a *FlagApiService) FindFlags(ctx context.Context, localVarOptionals *FindFlagsOpts) ([]Flag, *http.Response, error) { 238 | var ( 239 | localVarHttpMethod = strings.ToUpper("Get") 240 | localVarPostBody interface{} 241 | localVarFileName string 242 | localVarFileBytes []byte 243 | localVarReturnValue []Flag 244 | ) 245 | 246 | // create path and map variables 247 | localVarPath := a.client.cfg.BasePath + "/flags" 248 | 249 | localVarHeaderParams := make(map[string]string) 250 | localVarQueryParams := url.Values{} 251 | localVarFormParams := url.Values{} 252 | 253 | if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { 254 | localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) 255 | } 256 | if localVarOptionals != nil && localVarOptionals.Enabled.IsSet() { 257 | localVarQueryParams.Add("enabled", parameterToString(localVarOptionals.Enabled.Value(), "")) 258 | } 259 | if localVarOptionals != nil && localVarOptionals.Description.IsSet() { 260 | localVarQueryParams.Add("description", parameterToString(localVarOptionals.Description.Value(), "")) 261 | } 262 | if localVarOptionals != nil && localVarOptionals.DescriptionLike.IsSet() { 263 | localVarQueryParams.Add("description_like", parameterToString(localVarOptionals.DescriptionLike.Value(), "")) 264 | } 265 | if localVarOptionals != nil && localVarOptionals.Key.IsSet() { 266 | localVarQueryParams.Add("key", parameterToString(localVarOptionals.Key.Value(), "")) 267 | } 268 | if localVarOptionals != nil && localVarOptionals.Offset.IsSet() { 269 | localVarQueryParams.Add("offset", parameterToString(localVarOptionals.Offset.Value(), "")) 270 | } 271 | if localVarOptionals != nil && localVarOptionals.Preload.IsSet() { 272 | localVarQueryParams.Add("preload", parameterToString(localVarOptionals.Preload.Value(), "")) 273 | } 274 | // to determine the Content-Type header 275 | localVarHttpContentTypes := []string{"application/json"} 276 | 277 | // set Content-Type header 278 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 279 | if localVarHttpContentType != "" { 280 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 281 | } 282 | 283 | // to determine the Accept header 284 | localVarHttpHeaderAccepts := []string{"application/json"} 285 | 286 | // set Accept header 287 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 288 | if localVarHttpHeaderAccept != "" { 289 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 290 | } 291 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 292 | if err != nil { 293 | return localVarReturnValue, nil, err 294 | } 295 | 296 | localVarHttpResponse, err := a.client.callAPI(r) 297 | if err != nil || localVarHttpResponse == nil { 298 | return localVarReturnValue, localVarHttpResponse, err 299 | } 300 | 301 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 302 | localVarHttpResponse.Body.Close() 303 | if err != nil { 304 | return localVarReturnValue, localVarHttpResponse, err 305 | } 306 | 307 | if localVarHttpResponse.StatusCode < 300 { 308 | // If we succeed, return the data, otherwise pass on to decode error. 309 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 310 | if err == nil { 311 | return localVarReturnValue, localVarHttpResponse, err 312 | } 313 | } 314 | 315 | if localVarHttpResponse.StatusCode >= 300 { 316 | newErr := GenericSwaggerError{ 317 | body: localVarBody, 318 | error: localVarHttpResponse.Status, 319 | } 320 | 321 | if localVarHttpResponse.StatusCode == 200 { 322 | var v []Flag 323 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 324 | if err != nil { 325 | newErr.error = err.Error() 326 | return localVarReturnValue, localVarHttpResponse, newErr 327 | } 328 | newErr.model = v 329 | return localVarReturnValue, localVarHttpResponse, newErr 330 | } 331 | 332 | if localVarHttpResponse.StatusCode == 0 { 333 | var v ModelError 334 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 335 | if err != nil { 336 | newErr.error = err.Error() 337 | return localVarReturnValue, localVarHttpResponse, newErr 338 | } 339 | newErr.model = v 340 | return localVarReturnValue, localVarHttpResponse, newErr 341 | } 342 | 343 | return localVarReturnValue, localVarHttpResponse, newErr 344 | } 345 | 346 | return localVarReturnValue, localVarHttpResponse, nil 347 | } 348 | 349 | /* 350 | FlagApiService 351 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 352 | * @param flagID numeric ID of the flag to get 353 | 354 | @return Flag 355 | */ 356 | func (a *FlagApiService) GetFlag(ctx context.Context, flagID int64) (Flag, *http.Response, error) { 357 | var ( 358 | localVarHttpMethod = strings.ToUpper("Get") 359 | localVarPostBody interface{} 360 | localVarFileName string 361 | localVarFileBytes []byte 362 | localVarReturnValue Flag 363 | ) 364 | 365 | // create path and map variables 366 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}" 367 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 368 | 369 | localVarHeaderParams := make(map[string]string) 370 | localVarQueryParams := url.Values{} 371 | localVarFormParams := url.Values{} 372 | if flagID < 1 { 373 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 374 | } 375 | 376 | // to determine the Content-Type header 377 | localVarHttpContentTypes := []string{"application/json"} 378 | 379 | // set Content-Type header 380 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 381 | if localVarHttpContentType != "" { 382 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 383 | } 384 | 385 | // to determine the Accept header 386 | localVarHttpHeaderAccepts := []string{"application/json"} 387 | 388 | // set Accept header 389 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 390 | if localVarHttpHeaderAccept != "" { 391 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 392 | } 393 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 394 | if err != nil { 395 | return localVarReturnValue, nil, err 396 | } 397 | 398 | localVarHttpResponse, err := a.client.callAPI(r) 399 | if err != nil || localVarHttpResponse == nil { 400 | return localVarReturnValue, localVarHttpResponse, err 401 | } 402 | 403 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 404 | localVarHttpResponse.Body.Close() 405 | if err != nil { 406 | return localVarReturnValue, localVarHttpResponse, err 407 | } 408 | 409 | if localVarHttpResponse.StatusCode < 300 { 410 | // If we succeed, return the data, otherwise pass on to decode error. 411 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 412 | if err == nil { 413 | return localVarReturnValue, localVarHttpResponse, err 414 | } 415 | } 416 | 417 | if localVarHttpResponse.StatusCode >= 300 { 418 | newErr := GenericSwaggerError{ 419 | body: localVarBody, 420 | error: localVarHttpResponse.Status, 421 | } 422 | 423 | if localVarHttpResponse.StatusCode == 200 { 424 | var v Flag 425 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 426 | if err != nil { 427 | newErr.error = err.Error() 428 | return localVarReturnValue, localVarHttpResponse, newErr 429 | } 430 | newErr.model = v 431 | return localVarReturnValue, localVarHttpResponse, newErr 432 | } 433 | 434 | if localVarHttpResponse.StatusCode == 0 { 435 | var v ModelError 436 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 437 | if err != nil { 438 | newErr.error = err.Error() 439 | return localVarReturnValue, localVarHttpResponse, newErr 440 | } 441 | newErr.model = v 442 | return localVarReturnValue, localVarHttpResponse, newErr 443 | } 444 | 445 | return localVarReturnValue, localVarHttpResponse, newErr 446 | } 447 | 448 | return localVarReturnValue, localVarHttpResponse, nil 449 | } 450 | 451 | /* 452 | FlagApiService 453 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 454 | 455 | @return []string 456 | */ 457 | func (a *FlagApiService) GetFlagEntityTypes(ctx context.Context) ([]string, *http.Response, error) { 458 | var ( 459 | localVarHttpMethod = strings.ToUpper("Get") 460 | localVarPostBody interface{} 461 | localVarFileName string 462 | localVarFileBytes []byte 463 | localVarReturnValue []string 464 | ) 465 | 466 | // create path and map variables 467 | localVarPath := a.client.cfg.BasePath + "/flags/entity_types" 468 | 469 | localVarHeaderParams := make(map[string]string) 470 | localVarQueryParams := url.Values{} 471 | localVarFormParams := url.Values{} 472 | 473 | // to determine the Content-Type header 474 | localVarHttpContentTypes := []string{"application/json"} 475 | 476 | // set Content-Type header 477 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 478 | if localVarHttpContentType != "" { 479 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 480 | } 481 | 482 | // to determine the Accept header 483 | localVarHttpHeaderAccepts := []string{"application/json"} 484 | 485 | // set Accept header 486 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 487 | if localVarHttpHeaderAccept != "" { 488 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 489 | } 490 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 491 | if err != nil { 492 | return localVarReturnValue, nil, err 493 | } 494 | 495 | localVarHttpResponse, err := a.client.callAPI(r) 496 | if err != nil || localVarHttpResponse == nil { 497 | return localVarReturnValue, localVarHttpResponse, err 498 | } 499 | 500 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 501 | localVarHttpResponse.Body.Close() 502 | if err != nil { 503 | return localVarReturnValue, localVarHttpResponse, err 504 | } 505 | 506 | if localVarHttpResponse.StatusCode < 300 { 507 | // If we succeed, return the data, otherwise pass on to decode error. 508 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 509 | if err == nil { 510 | return localVarReturnValue, localVarHttpResponse, err 511 | } 512 | } 513 | 514 | if localVarHttpResponse.StatusCode >= 300 { 515 | newErr := GenericSwaggerError{ 516 | body: localVarBody, 517 | error: localVarHttpResponse.Status, 518 | } 519 | 520 | if localVarHttpResponse.StatusCode == 200 { 521 | var v []string 522 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 523 | if err != nil { 524 | newErr.error = err.Error() 525 | return localVarReturnValue, localVarHttpResponse, newErr 526 | } 527 | newErr.model = v 528 | return localVarReturnValue, localVarHttpResponse, newErr 529 | } 530 | 531 | if localVarHttpResponse.StatusCode == 0 { 532 | var v ModelError 533 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 534 | if err != nil { 535 | newErr.error = err.Error() 536 | return localVarReturnValue, localVarHttpResponse, newErr 537 | } 538 | newErr.model = v 539 | return localVarReturnValue, localVarHttpResponse, newErr 540 | } 541 | 542 | return localVarReturnValue, localVarHttpResponse, newErr 543 | } 544 | 545 | return localVarReturnValue, localVarHttpResponse, nil 546 | } 547 | 548 | /* 549 | FlagApiService 550 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 551 | * @param flagID numeric ID of the flag to get 552 | 553 | @return []FlagSnapshot 554 | */ 555 | func (a *FlagApiService) GetFlagSnapshots(ctx context.Context, flagID int64) ([]FlagSnapshot, *http.Response, error) { 556 | var ( 557 | localVarHttpMethod = strings.ToUpper("Get") 558 | localVarPostBody interface{} 559 | localVarFileName string 560 | localVarFileBytes []byte 561 | localVarReturnValue []FlagSnapshot 562 | ) 563 | 564 | // create path and map variables 565 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/snapshots" 566 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 567 | 568 | localVarHeaderParams := make(map[string]string) 569 | localVarQueryParams := url.Values{} 570 | localVarFormParams := url.Values{} 571 | if flagID < 1 { 572 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 573 | } 574 | 575 | // to determine the Content-Type header 576 | localVarHttpContentTypes := []string{"application/json"} 577 | 578 | // set Content-Type header 579 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 580 | if localVarHttpContentType != "" { 581 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 582 | } 583 | 584 | // to determine the Accept header 585 | localVarHttpHeaderAccepts := []string{"application/json"} 586 | 587 | // set Accept header 588 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 589 | if localVarHttpHeaderAccept != "" { 590 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 591 | } 592 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 593 | if err != nil { 594 | return localVarReturnValue, nil, err 595 | } 596 | 597 | localVarHttpResponse, err := a.client.callAPI(r) 598 | if err != nil || localVarHttpResponse == nil { 599 | return localVarReturnValue, localVarHttpResponse, err 600 | } 601 | 602 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 603 | localVarHttpResponse.Body.Close() 604 | if err != nil { 605 | return localVarReturnValue, localVarHttpResponse, err 606 | } 607 | 608 | if localVarHttpResponse.StatusCode < 300 { 609 | // If we succeed, return the data, otherwise pass on to decode error. 610 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 611 | if err == nil { 612 | return localVarReturnValue, localVarHttpResponse, err 613 | } 614 | } 615 | 616 | if localVarHttpResponse.StatusCode >= 300 { 617 | newErr := GenericSwaggerError{ 618 | body: localVarBody, 619 | error: localVarHttpResponse.Status, 620 | } 621 | 622 | if localVarHttpResponse.StatusCode == 200 { 623 | var v []FlagSnapshot 624 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 625 | if err != nil { 626 | newErr.error = err.Error() 627 | return localVarReturnValue, localVarHttpResponse, newErr 628 | } 629 | newErr.model = v 630 | return localVarReturnValue, localVarHttpResponse, newErr 631 | } 632 | 633 | if localVarHttpResponse.StatusCode == 0 { 634 | var v ModelError 635 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 636 | if err != nil { 637 | newErr.error = err.Error() 638 | return localVarReturnValue, localVarHttpResponse, newErr 639 | } 640 | newErr.model = v 641 | return localVarReturnValue, localVarHttpResponse, newErr 642 | } 643 | 644 | return localVarReturnValue, localVarHttpResponse, newErr 645 | } 646 | 647 | return localVarReturnValue, localVarHttpResponse, nil 648 | } 649 | 650 | /* 651 | FlagApiService 652 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 653 | * @param flagID numeric ID of the flag to get 654 | * @param body update a flag 655 | 656 | @return Flag 657 | */ 658 | func (a *FlagApiService) PutFlag(ctx context.Context, flagID int64, body PutFlagRequest) (Flag, *http.Response, error) { 659 | var ( 660 | localVarHttpMethod = strings.ToUpper("Put") 661 | localVarPostBody interface{} 662 | localVarFileName string 663 | localVarFileBytes []byte 664 | localVarReturnValue Flag 665 | ) 666 | 667 | // create path and map variables 668 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}" 669 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 670 | 671 | localVarHeaderParams := make(map[string]string) 672 | localVarQueryParams := url.Values{} 673 | localVarFormParams := url.Values{} 674 | if flagID < 1 { 675 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 676 | } 677 | 678 | // to determine the Content-Type header 679 | localVarHttpContentTypes := []string{"application/json"} 680 | 681 | // set Content-Type header 682 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 683 | if localVarHttpContentType != "" { 684 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 685 | } 686 | 687 | // to determine the Accept header 688 | localVarHttpHeaderAccepts := []string{"application/json"} 689 | 690 | // set Accept header 691 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 692 | if localVarHttpHeaderAccept != "" { 693 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 694 | } 695 | // body params 696 | localVarPostBody = &body 697 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 698 | if err != nil { 699 | return localVarReturnValue, nil, err 700 | } 701 | 702 | localVarHttpResponse, err := a.client.callAPI(r) 703 | if err != nil || localVarHttpResponse == nil { 704 | return localVarReturnValue, localVarHttpResponse, err 705 | } 706 | 707 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 708 | localVarHttpResponse.Body.Close() 709 | if err != nil { 710 | return localVarReturnValue, localVarHttpResponse, err 711 | } 712 | 713 | if localVarHttpResponse.StatusCode < 300 { 714 | // If we succeed, return the data, otherwise pass on to decode error. 715 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 716 | if err == nil { 717 | return localVarReturnValue, localVarHttpResponse, err 718 | } 719 | } 720 | 721 | if localVarHttpResponse.StatusCode >= 300 { 722 | newErr := GenericSwaggerError{ 723 | body: localVarBody, 724 | error: localVarHttpResponse.Status, 725 | } 726 | 727 | if localVarHttpResponse.StatusCode == 200 { 728 | var v Flag 729 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 730 | if err != nil { 731 | newErr.error = err.Error() 732 | return localVarReturnValue, localVarHttpResponse, newErr 733 | } 734 | newErr.model = v 735 | return localVarReturnValue, localVarHttpResponse, newErr 736 | } 737 | 738 | if localVarHttpResponse.StatusCode == 0 { 739 | var v ModelError 740 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 741 | if err != nil { 742 | newErr.error = err.Error() 743 | return localVarReturnValue, localVarHttpResponse, newErr 744 | } 745 | newErr.model = v 746 | return localVarReturnValue, localVarHttpResponse, newErr 747 | } 748 | 749 | return localVarReturnValue, localVarHttpResponse, newErr 750 | } 751 | 752 | return localVarReturnValue, localVarHttpResponse, nil 753 | } 754 | 755 | /* 756 | FlagApiService 757 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 758 | * @param flagID numeric ID of the flag to get 759 | * @param body set flag enabled state 760 | 761 | @return Flag 762 | */ 763 | func (a *FlagApiService) SetFlagEnabled(ctx context.Context, flagID int64, body SetFlagEnabledRequest) (Flag, *http.Response, error) { 764 | var ( 765 | localVarHttpMethod = strings.ToUpper("Put") 766 | localVarPostBody interface{} 767 | localVarFileName string 768 | localVarFileBytes []byte 769 | localVarReturnValue Flag 770 | ) 771 | 772 | // create path and map variables 773 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/enabled" 774 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 775 | 776 | localVarHeaderParams := make(map[string]string) 777 | localVarQueryParams := url.Values{} 778 | localVarFormParams := url.Values{} 779 | if flagID < 1 { 780 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 781 | } 782 | 783 | // to determine the Content-Type header 784 | localVarHttpContentTypes := []string{"application/json"} 785 | 786 | // set Content-Type header 787 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 788 | if localVarHttpContentType != "" { 789 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 790 | } 791 | 792 | // to determine the Accept header 793 | localVarHttpHeaderAccepts := []string{"application/json"} 794 | 795 | // set Accept header 796 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 797 | if localVarHttpHeaderAccept != "" { 798 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 799 | } 800 | // body params 801 | localVarPostBody = &body 802 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 803 | if err != nil { 804 | return localVarReturnValue, nil, err 805 | } 806 | 807 | localVarHttpResponse, err := a.client.callAPI(r) 808 | if err != nil || localVarHttpResponse == nil { 809 | return localVarReturnValue, localVarHttpResponse, err 810 | } 811 | 812 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 813 | localVarHttpResponse.Body.Close() 814 | if err != nil { 815 | return localVarReturnValue, localVarHttpResponse, err 816 | } 817 | 818 | if localVarHttpResponse.StatusCode < 300 { 819 | // If we succeed, return the data, otherwise pass on to decode error. 820 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 821 | if err == nil { 822 | return localVarReturnValue, localVarHttpResponse, err 823 | } 824 | } 825 | 826 | if localVarHttpResponse.StatusCode >= 300 { 827 | newErr := GenericSwaggerError{ 828 | body: localVarBody, 829 | error: localVarHttpResponse.Status, 830 | } 831 | 832 | if localVarHttpResponse.StatusCode == 200 { 833 | var v Flag 834 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 835 | if err != nil { 836 | newErr.error = err.Error() 837 | return localVarReturnValue, localVarHttpResponse, newErr 838 | } 839 | newErr.model = v 840 | return localVarReturnValue, localVarHttpResponse, newErr 841 | } 842 | 843 | if localVarHttpResponse.StatusCode == 0 { 844 | var v ModelError 845 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 846 | if err != nil { 847 | newErr.error = err.Error() 848 | return localVarReturnValue, localVarHttpResponse, newErr 849 | } 850 | newErr.model = v 851 | return localVarReturnValue, localVarHttpResponse, newErr 852 | } 853 | 854 | return localVarReturnValue, localVarHttpResponse, newErr 855 | } 856 | 857 | return localVarReturnValue, localVarHttpResponse, nil 858 | } 859 | -------------------------------------------------------------------------------- /api_health.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "context" 14 | "io/ioutil" 15 | "net/http" 16 | "net/url" 17 | "strings" 18 | ) 19 | 20 | // Linger please 21 | var ( 22 | _ context.Context 23 | ) 24 | 25 | type HealthApiService service 26 | 27 | /* 28 | HealthApiService 29 | Check if Flagr is healthy 30 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 31 | 32 | @return Health 33 | */ 34 | func (a *HealthApiService) GetHealth(ctx context.Context) (Health, *http.Response, error) { 35 | var ( 36 | localVarHttpMethod = strings.ToUpper("Get") 37 | localVarPostBody interface{} 38 | localVarFileName string 39 | localVarFileBytes []byte 40 | localVarReturnValue Health 41 | ) 42 | 43 | // create path and map variables 44 | localVarPath := a.client.cfg.BasePath + "/health" 45 | 46 | localVarHeaderParams := make(map[string]string) 47 | localVarQueryParams := url.Values{} 48 | localVarFormParams := url.Values{} 49 | 50 | // to determine the Content-Type header 51 | localVarHttpContentTypes := []string{"application/json"} 52 | 53 | // set Content-Type header 54 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 55 | if localVarHttpContentType != "" { 56 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 57 | } 58 | 59 | // to determine the Accept header 60 | localVarHttpHeaderAccepts := []string{"application/json"} 61 | 62 | // set Accept header 63 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 64 | if localVarHttpHeaderAccept != "" { 65 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 66 | } 67 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 68 | if err != nil { 69 | return localVarReturnValue, nil, err 70 | } 71 | 72 | localVarHttpResponse, err := a.client.callAPI(r) 73 | if err != nil || localVarHttpResponse == nil { 74 | return localVarReturnValue, localVarHttpResponse, err 75 | } 76 | 77 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 78 | localVarHttpResponse.Body.Close() 79 | if err != nil { 80 | return localVarReturnValue, localVarHttpResponse, err 81 | } 82 | 83 | if localVarHttpResponse.StatusCode < 300 { 84 | // If we succeed, return the data, otherwise pass on to decode error. 85 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 86 | if err == nil { 87 | return localVarReturnValue, localVarHttpResponse, err 88 | } 89 | } 90 | 91 | if localVarHttpResponse.StatusCode >= 300 { 92 | newErr := GenericSwaggerError{ 93 | body: localVarBody, 94 | error: localVarHttpResponse.Status, 95 | } 96 | 97 | if localVarHttpResponse.StatusCode == 200 { 98 | var v Health 99 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 100 | if err != nil { 101 | newErr.error = err.Error() 102 | return localVarReturnValue, localVarHttpResponse, newErr 103 | } 104 | newErr.model = v 105 | return localVarReturnValue, localVarHttpResponse, newErr 106 | } 107 | 108 | if localVarHttpResponse.StatusCode == 0 { 109 | var v ModelError 110 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 111 | if err != nil { 112 | newErr.error = err.Error() 113 | return localVarReturnValue, localVarHttpResponse, newErr 114 | } 115 | newErr.model = v 116 | return localVarReturnValue, localVarHttpResponse, newErr 117 | } 118 | 119 | return localVarReturnValue, localVarHttpResponse, newErr 120 | } 121 | 122 | return localVarReturnValue, localVarHttpResponse, nil 123 | } 124 | -------------------------------------------------------------------------------- /api_segment.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "io/ioutil" 16 | "net/http" 17 | "net/url" 18 | "strings" 19 | ) 20 | 21 | // Linger please 22 | var ( 23 | _ context.Context 24 | ) 25 | 26 | type SegmentApiService service 27 | 28 | /* 29 | SegmentApiService 30 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 31 | * @param flagID numeric ID of the flag to get 32 | * @param body create a segment under a flag 33 | 34 | @return Segment 35 | */ 36 | func (a *SegmentApiService) CreateSegment(ctx context.Context, flagID int64, body CreateSegmentRequest) (Segment, *http.Response, error) { 37 | var ( 38 | localVarHttpMethod = strings.ToUpper("Post") 39 | localVarPostBody interface{} 40 | localVarFileName string 41 | localVarFileBytes []byte 42 | localVarReturnValue Segment 43 | ) 44 | 45 | // create path and map variables 46 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments" 47 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 48 | 49 | localVarHeaderParams := make(map[string]string) 50 | localVarQueryParams := url.Values{} 51 | localVarFormParams := url.Values{} 52 | if flagID < 1 { 53 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 54 | } 55 | 56 | // to determine the Content-Type header 57 | localVarHttpContentTypes := []string{"application/json"} 58 | 59 | // set Content-Type header 60 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 61 | if localVarHttpContentType != "" { 62 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 63 | } 64 | 65 | // to determine the Accept header 66 | localVarHttpHeaderAccepts := []string{"application/json"} 67 | 68 | // set Accept header 69 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 70 | if localVarHttpHeaderAccept != "" { 71 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 72 | } 73 | // body params 74 | localVarPostBody = &body 75 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 76 | if err != nil { 77 | return localVarReturnValue, nil, err 78 | } 79 | 80 | localVarHttpResponse, err := a.client.callAPI(r) 81 | if err != nil || localVarHttpResponse == nil { 82 | return localVarReturnValue, localVarHttpResponse, err 83 | } 84 | 85 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 86 | localVarHttpResponse.Body.Close() 87 | if err != nil { 88 | return localVarReturnValue, localVarHttpResponse, err 89 | } 90 | 91 | if localVarHttpResponse.StatusCode < 300 { 92 | // If we succeed, return the data, otherwise pass on to decode error. 93 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 94 | if err == nil { 95 | return localVarReturnValue, localVarHttpResponse, err 96 | } 97 | } 98 | 99 | if localVarHttpResponse.StatusCode >= 300 { 100 | newErr := GenericSwaggerError{ 101 | body: localVarBody, 102 | error: localVarHttpResponse.Status, 103 | } 104 | 105 | if localVarHttpResponse.StatusCode == 200 { 106 | var v Segment 107 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 108 | if err != nil { 109 | newErr.error = err.Error() 110 | return localVarReturnValue, localVarHttpResponse, newErr 111 | } 112 | newErr.model = v 113 | return localVarReturnValue, localVarHttpResponse, newErr 114 | } 115 | 116 | if localVarHttpResponse.StatusCode == 0 { 117 | var v ModelError 118 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 119 | if err != nil { 120 | newErr.error = err.Error() 121 | return localVarReturnValue, localVarHttpResponse, newErr 122 | } 123 | newErr.model = v 124 | return localVarReturnValue, localVarHttpResponse, newErr 125 | } 126 | 127 | return localVarReturnValue, localVarHttpResponse, newErr 128 | } 129 | 130 | return localVarReturnValue, localVarHttpResponse, nil 131 | } 132 | 133 | /* 134 | SegmentApiService 135 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 136 | * @param flagID numeric ID of the flag 137 | * @param segmentID numeric ID of the segment 138 | 139 | 140 | */ 141 | func (a *SegmentApiService) DeleteSegment(ctx context.Context, flagID int64, segmentID int64) (*http.Response, error) { 142 | var ( 143 | localVarHttpMethod = strings.ToUpper("Delete") 144 | localVarPostBody interface{} 145 | localVarFileName string 146 | localVarFileBytes []byte 147 | ) 148 | 149 | // create path and map variables 150 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/{segmentID}" 151 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 152 | localVarPath = strings.Replace(localVarPath, "{"+"segmentID"+"}", fmt.Sprintf("%v", segmentID), -1) 153 | 154 | localVarHeaderParams := make(map[string]string) 155 | localVarQueryParams := url.Values{} 156 | localVarFormParams := url.Values{} 157 | if flagID < 1 { 158 | return nil, reportError("flagID must be greater than 1") 159 | } 160 | if segmentID < 1 { 161 | return nil, reportError("segmentID must be greater than 1") 162 | } 163 | 164 | // to determine the Content-Type header 165 | localVarHttpContentTypes := []string{"application/json"} 166 | 167 | // set Content-Type header 168 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 169 | if localVarHttpContentType != "" { 170 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 171 | } 172 | 173 | // to determine the Accept header 174 | localVarHttpHeaderAccepts := []string{"application/json"} 175 | 176 | // set Accept header 177 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 178 | if localVarHttpHeaderAccept != "" { 179 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 180 | } 181 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 182 | if err != nil { 183 | return nil, err 184 | } 185 | 186 | localVarHttpResponse, err := a.client.callAPI(r) 187 | if err != nil || localVarHttpResponse == nil { 188 | return localVarHttpResponse, err 189 | } 190 | 191 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 192 | localVarHttpResponse.Body.Close() 193 | if err != nil { 194 | return localVarHttpResponse, err 195 | } 196 | 197 | if localVarHttpResponse.StatusCode >= 300 { 198 | newErr := GenericSwaggerError{ 199 | body: localVarBody, 200 | error: localVarHttpResponse.Status, 201 | } 202 | 203 | if localVarHttpResponse.StatusCode == 0 { 204 | var v ModelError 205 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 206 | if err != nil { 207 | newErr.error = err.Error() 208 | return localVarHttpResponse, newErr 209 | } 210 | newErr.model = v 211 | return localVarHttpResponse, newErr 212 | } 213 | 214 | return localVarHttpResponse, newErr 215 | } 216 | 217 | return localVarHttpResponse, nil 218 | } 219 | 220 | /* 221 | SegmentApiService 222 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 223 | * @param flagID numeric ID of the flag to get 224 | 225 | @return []Segment 226 | */ 227 | func (a *SegmentApiService) FindSegments(ctx context.Context, flagID int64) ([]Segment, *http.Response, error) { 228 | var ( 229 | localVarHttpMethod = strings.ToUpper("Get") 230 | localVarPostBody interface{} 231 | localVarFileName string 232 | localVarFileBytes []byte 233 | localVarReturnValue []Segment 234 | ) 235 | 236 | // create path and map variables 237 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments" 238 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 239 | 240 | localVarHeaderParams := make(map[string]string) 241 | localVarQueryParams := url.Values{} 242 | localVarFormParams := url.Values{} 243 | if flagID < 1 { 244 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 245 | } 246 | 247 | // to determine the Content-Type header 248 | localVarHttpContentTypes := []string{"application/json"} 249 | 250 | // set Content-Type header 251 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 252 | if localVarHttpContentType != "" { 253 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 254 | } 255 | 256 | // to determine the Accept header 257 | localVarHttpHeaderAccepts := []string{"application/json"} 258 | 259 | // set Accept header 260 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 261 | if localVarHttpHeaderAccept != "" { 262 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 263 | } 264 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 265 | if err != nil { 266 | return localVarReturnValue, nil, err 267 | } 268 | 269 | localVarHttpResponse, err := a.client.callAPI(r) 270 | if err != nil || localVarHttpResponse == nil { 271 | return localVarReturnValue, localVarHttpResponse, err 272 | } 273 | 274 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 275 | localVarHttpResponse.Body.Close() 276 | if err != nil { 277 | return localVarReturnValue, localVarHttpResponse, err 278 | } 279 | 280 | if localVarHttpResponse.StatusCode < 300 { 281 | // If we succeed, return the data, otherwise pass on to decode error. 282 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 283 | if err == nil { 284 | return localVarReturnValue, localVarHttpResponse, err 285 | } 286 | } 287 | 288 | if localVarHttpResponse.StatusCode >= 300 { 289 | newErr := GenericSwaggerError{ 290 | body: localVarBody, 291 | error: localVarHttpResponse.Status, 292 | } 293 | 294 | if localVarHttpResponse.StatusCode == 200 { 295 | var v []Segment 296 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 297 | if err != nil { 298 | newErr.error = err.Error() 299 | return localVarReturnValue, localVarHttpResponse, newErr 300 | } 301 | newErr.model = v 302 | return localVarReturnValue, localVarHttpResponse, newErr 303 | } 304 | 305 | if localVarHttpResponse.StatusCode == 0 { 306 | var v ModelError 307 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 308 | if err != nil { 309 | newErr.error = err.Error() 310 | return localVarReturnValue, localVarHttpResponse, newErr 311 | } 312 | newErr.model = v 313 | return localVarReturnValue, localVarHttpResponse, newErr 314 | } 315 | 316 | return localVarReturnValue, localVarHttpResponse, newErr 317 | } 318 | 319 | return localVarReturnValue, localVarHttpResponse, nil 320 | } 321 | 322 | /* 323 | SegmentApiService 324 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 325 | * @param flagID numeric ID of the flag 326 | * @param segmentID numeric ID of the segment 327 | * @param body update a segment 328 | 329 | @return Segment 330 | */ 331 | func (a *SegmentApiService) PutSegment(ctx context.Context, flagID int64, segmentID int64, body PutSegmentRequest) (Segment, *http.Response, error) { 332 | var ( 333 | localVarHttpMethod = strings.ToUpper("Put") 334 | localVarPostBody interface{} 335 | localVarFileName string 336 | localVarFileBytes []byte 337 | localVarReturnValue Segment 338 | ) 339 | 340 | // create path and map variables 341 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/{segmentID}" 342 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 343 | localVarPath = strings.Replace(localVarPath, "{"+"segmentID"+"}", fmt.Sprintf("%v", segmentID), -1) 344 | 345 | localVarHeaderParams := make(map[string]string) 346 | localVarQueryParams := url.Values{} 347 | localVarFormParams := url.Values{} 348 | if flagID < 1 { 349 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 350 | } 351 | if segmentID < 1 { 352 | return localVarReturnValue, nil, reportError("segmentID must be greater than 1") 353 | } 354 | 355 | // to determine the Content-Type header 356 | localVarHttpContentTypes := []string{"application/json"} 357 | 358 | // set Content-Type header 359 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 360 | if localVarHttpContentType != "" { 361 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 362 | } 363 | 364 | // to determine the Accept header 365 | localVarHttpHeaderAccepts := []string{"application/json"} 366 | 367 | // set Accept header 368 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 369 | if localVarHttpHeaderAccept != "" { 370 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 371 | } 372 | // body params 373 | localVarPostBody = &body 374 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 375 | if err != nil { 376 | return localVarReturnValue, nil, err 377 | } 378 | 379 | localVarHttpResponse, err := a.client.callAPI(r) 380 | if err != nil || localVarHttpResponse == nil { 381 | return localVarReturnValue, localVarHttpResponse, err 382 | } 383 | 384 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 385 | localVarHttpResponse.Body.Close() 386 | if err != nil { 387 | return localVarReturnValue, localVarHttpResponse, err 388 | } 389 | 390 | if localVarHttpResponse.StatusCode < 300 { 391 | // If we succeed, return the data, otherwise pass on to decode error. 392 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 393 | if err == nil { 394 | return localVarReturnValue, localVarHttpResponse, err 395 | } 396 | } 397 | 398 | if localVarHttpResponse.StatusCode >= 300 { 399 | newErr := GenericSwaggerError{ 400 | body: localVarBody, 401 | error: localVarHttpResponse.Status, 402 | } 403 | 404 | if localVarHttpResponse.StatusCode == 200 { 405 | var v Segment 406 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 407 | if err != nil { 408 | newErr.error = err.Error() 409 | return localVarReturnValue, localVarHttpResponse, newErr 410 | } 411 | newErr.model = v 412 | return localVarReturnValue, localVarHttpResponse, newErr 413 | } 414 | 415 | if localVarHttpResponse.StatusCode == 0 { 416 | var v ModelError 417 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 418 | if err != nil { 419 | newErr.error = err.Error() 420 | return localVarReturnValue, localVarHttpResponse, newErr 421 | } 422 | newErr.model = v 423 | return localVarReturnValue, localVarHttpResponse, newErr 424 | } 425 | 426 | return localVarReturnValue, localVarHttpResponse, newErr 427 | } 428 | 429 | return localVarReturnValue, localVarHttpResponse, nil 430 | } 431 | 432 | /* 433 | SegmentApiService 434 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 435 | * @param flagID numeric ID of the flag 436 | * @param body reorder segments 437 | 438 | 439 | */ 440 | func (a *SegmentApiService) PutSegmentsReorder(ctx context.Context, flagID int64, body PutSegmentReorderRequest) (*http.Response, error) { 441 | var ( 442 | localVarHttpMethod = strings.ToUpper("Put") 443 | localVarPostBody interface{} 444 | localVarFileName string 445 | localVarFileBytes []byte 446 | ) 447 | 448 | // create path and map variables 449 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/segments/reorder" 450 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 451 | 452 | localVarHeaderParams := make(map[string]string) 453 | localVarQueryParams := url.Values{} 454 | localVarFormParams := url.Values{} 455 | if flagID < 1 { 456 | return nil, reportError("flagID must be greater than 1") 457 | } 458 | 459 | // to determine the Content-Type header 460 | localVarHttpContentTypes := []string{"application/json"} 461 | 462 | // set Content-Type header 463 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 464 | if localVarHttpContentType != "" { 465 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 466 | } 467 | 468 | // to determine the Accept header 469 | localVarHttpHeaderAccepts := []string{"application/json"} 470 | 471 | // set Accept header 472 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 473 | if localVarHttpHeaderAccept != "" { 474 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 475 | } 476 | // body params 477 | localVarPostBody = &body 478 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 479 | if err != nil { 480 | return nil, err 481 | } 482 | 483 | localVarHttpResponse, err := a.client.callAPI(r) 484 | if err != nil || localVarHttpResponse == nil { 485 | return localVarHttpResponse, err 486 | } 487 | 488 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 489 | localVarHttpResponse.Body.Close() 490 | if err != nil { 491 | return localVarHttpResponse, err 492 | } 493 | 494 | if localVarHttpResponse.StatusCode >= 300 { 495 | newErr := GenericSwaggerError{ 496 | body: localVarBody, 497 | error: localVarHttpResponse.Status, 498 | } 499 | 500 | if localVarHttpResponse.StatusCode == 0 { 501 | var v ModelError 502 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 503 | if err != nil { 504 | newErr.error = err.Error() 505 | return localVarHttpResponse, newErr 506 | } 507 | newErr.model = v 508 | return localVarHttpResponse, newErr 509 | } 510 | 511 | return localVarHttpResponse, newErr 512 | } 513 | 514 | return localVarHttpResponse, nil 515 | } 516 | -------------------------------------------------------------------------------- /api_variant.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "io/ioutil" 16 | "net/http" 17 | "net/url" 18 | "strings" 19 | ) 20 | 21 | // Linger please 22 | var ( 23 | _ context.Context 24 | ) 25 | 26 | type VariantApiService service 27 | 28 | /* 29 | VariantApiService 30 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 31 | * @param flagID numeric ID of the flag 32 | * @param body create a variant 33 | 34 | @return Variant 35 | */ 36 | func (a *VariantApiService) CreateVariant(ctx context.Context, flagID int64, body CreateVariantRequest) (Variant, *http.Response, error) { 37 | var ( 38 | localVarHttpMethod = strings.ToUpper("Post") 39 | localVarPostBody interface{} 40 | localVarFileName string 41 | localVarFileBytes []byte 42 | localVarReturnValue Variant 43 | ) 44 | 45 | // create path and map variables 46 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/variants" 47 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 48 | 49 | localVarHeaderParams := make(map[string]string) 50 | localVarQueryParams := url.Values{} 51 | localVarFormParams := url.Values{} 52 | if flagID < 1 { 53 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 54 | } 55 | 56 | // to determine the Content-Type header 57 | localVarHttpContentTypes := []string{"application/json"} 58 | 59 | // set Content-Type header 60 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 61 | if localVarHttpContentType != "" { 62 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 63 | } 64 | 65 | // to determine the Accept header 66 | localVarHttpHeaderAccepts := []string{"application/json"} 67 | 68 | // set Accept header 69 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 70 | if localVarHttpHeaderAccept != "" { 71 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 72 | } 73 | // body params 74 | localVarPostBody = &body 75 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 76 | if err != nil { 77 | return localVarReturnValue, nil, err 78 | } 79 | 80 | localVarHttpResponse, err := a.client.callAPI(r) 81 | if err != nil || localVarHttpResponse == nil { 82 | return localVarReturnValue, localVarHttpResponse, err 83 | } 84 | 85 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 86 | localVarHttpResponse.Body.Close() 87 | if err != nil { 88 | return localVarReturnValue, localVarHttpResponse, err 89 | } 90 | 91 | if localVarHttpResponse.StatusCode < 300 { 92 | // If we succeed, return the data, otherwise pass on to decode error. 93 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 94 | if err == nil { 95 | return localVarReturnValue, localVarHttpResponse, err 96 | } 97 | } 98 | 99 | if localVarHttpResponse.StatusCode >= 300 { 100 | newErr := GenericSwaggerError{ 101 | body: localVarBody, 102 | error: localVarHttpResponse.Status, 103 | } 104 | 105 | if localVarHttpResponse.StatusCode == 200 { 106 | var v Variant 107 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 108 | if err != nil { 109 | newErr.error = err.Error() 110 | return localVarReturnValue, localVarHttpResponse, newErr 111 | } 112 | newErr.model = v 113 | return localVarReturnValue, localVarHttpResponse, newErr 114 | } 115 | 116 | if localVarHttpResponse.StatusCode == 0 { 117 | var v ModelError 118 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 119 | if err != nil { 120 | newErr.error = err.Error() 121 | return localVarReturnValue, localVarHttpResponse, newErr 122 | } 123 | newErr.model = v 124 | return localVarReturnValue, localVarHttpResponse, newErr 125 | } 126 | 127 | return localVarReturnValue, localVarHttpResponse, newErr 128 | } 129 | 130 | return localVarReturnValue, localVarHttpResponse, nil 131 | } 132 | 133 | /* 134 | VariantApiService 135 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 136 | * @param flagID numeric ID of the flag 137 | * @param variantID numeric ID of the variant 138 | 139 | 140 | */ 141 | func (a *VariantApiService) DeleteVariant(ctx context.Context, flagID int64, variantID int64) (*http.Response, error) { 142 | var ( 143 | localVarHttpMethod = strings.ToUpper("Delete") 144 | localVarPostBody interface{} 145 | localVarFileName string 146 | localVarFileBytes []byte 147 | ) 148 | 149 | // create path and map variables 150 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/variants/{variantID}" 151 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 152 | localVarPath = strings.Replace(localVarPath, "{"+"variantID"+"}", fmt.Sprintf("%v", variantID), -1) 153 | 154 | localVarHeaderParams := make(map[string]string) 155 | localVarQueryParams := url.Values{} 156 | localVarFormParams := url.Values{} 157 | if flagID < 1 { 158 | return nil, reportError("flagID must be greater than 1") 159 | } 160 | if variantID < 1 { 161 | return nil, reportError("variantID must be greater than 1") 162 | } 163 | 164 | // to determine the Content-Type header 165 | localVarHttpContentTypes := []string{"application/json"} 166 | 167 | // set Content-Type header 168 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 169 | if localVarHttpContentType != "" { 170 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 171 | } 172 | 173 | // to determine the Accept header 174 | localVarHttpHeaderAccepts := []string{"application/json"} 175 | 176 | // set Accept header 177 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 178 | if localVarHttpHeaderAccept != "" { 179 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 180 | } 181 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 182 | if err != nil { 183 | return nil, err 184 | } 185 | 186 | localVarHttpResponse, err := a.client.callAPI(r) 187 | if err != nil || localVarHttpResponse == nil { 188 | return localVarHttpResponse, err 189 | } 190 | 191 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 192 | localVarHttpResponse.Body.Close() 193 | if err != nil { 194 | return localVarHttpResponse, err 195 | } 196 | 197 | if localVarHttpResponse.StatusCode >= 300 { 198 | newErr := GenericSwaggerError{ 199 | body: localVarBody, 200 | error: localVarHttpResponse.Status, 201 | } 202 | 203 | if localVarHttpResponse.StatusCode == 0 { 204 | var v ModelError 205 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 206 | if err != nil { 207 | newErr.error = err.Error() 208 | return localVarHttpResponse, newErr 209 | } 210 | newErr.model = v 211 | return localVarHttpResponse, newErr 212 | } 213 | 214 | return localVarHttpResponse, newErr 215 | } 216 | 217 | return localVarHttpResponse, nil 218 | } 219 | 220 | /* 221 | VariantApiService 222 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 223 | * @param flagID numeric ID of the flag 224 | 225 | @return []Variant 226 | */ 227 | func (a *VariantApiService) FindVariants(ctx context.Context, flagID int64) ([]Variant, *http.Response, error) { 228 | var ( 229 | localVarHttpMethod = strings.ToUpper("Get") 230 | localVarPostBody interface{} 231 | localVarFileName string 232 | localVarFileBytes []byte 233 | localVarReturnValue []Variant 234 | ) 235 | 236 | // create path and map variables 237 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/variants" 238 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 239 | 240 | localVarHeaderParams := make(map[string]string) 241 | localVarQueryParams := url.Values{} 242 | localVarFormParams := url.Values{} 243 | if flagID < 1 { 244 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 245 | } 246 | 247 | // to determine the Content-Type header 248 | localVarHttpContentTypes := []string{"application/json"} 249 | 250 | // set Content-Type header 251 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 252 | if localVarHttpContentType != "" { 253 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 254 | } 255 | 256 | // to determine the Accept header 257 | localVarHttpHeaderAccepts := []string{"application/json"} 258 | 259 | // set Accept header 260 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 261 | if localVarHttpHeaderAccept != "" { 262 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 263 | } 264 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 265 | if err != nil { 266 | return localVarReturnValue, nil, err 267 | } 268 | 269 | localVarHttpResponse, err := a.client.callAPI(r) 270 | if err != nil || localVarHttpResponse == nil { 271 | return localVarReturnValue, localVarHttpResponse, err 272 | } 273 | 274 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 275 | localVarHttpResponse.Body.Close() 276 | if err != nil { 277 | return localVarReturnValue, localVarHttpResponse, err 278 | } 279 | 280 | if localVarHttpResponse.StatusCode < 300 { 281 | // If we succeed, return the data, otherwise pass on to decode error. 282 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 283 | if err == nil { 284 | return localVarReturnValue, localVarHttpResponse, err 285 | } 286 | } 287 | 288 | if localVarHttpResponse.StatusCode >= 300 { 289 | newErr := GenericSwaggerError{ 290 | body: localVarBody, 291 | error: localVarHttpResponse.Status, 292 | } 293 | 294 | if localVarHttpResponse.StatusCode == 200 { 295 | var v []Variant 296 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 297 | if err != nil { 298 | newErr.error = err.Error() 299 | return localVarReturnValue, localVarHttpResponse, newErr 300 | } 301 | newErr.model = v 302 | return localVarReturnValue, localVarHttpResponse, newErr 303 | } 304 | 305 | if localVarHttpResponse.StatusCode == 0 { 306 | var v ModelError 307 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 308 | if err != nil { 309 | newErr.error = err.Error() 310 | return localVarReturnValue, localVarHttpResponse, newErr 311 | } 312 | newErr.model = v 313 | return localVarReturnValue, localVarHttpResponse, newErr 314 | } 315 | 316 | return localVarReturnValue, localVarHttpResponse, newErr 317 | } 318 | 319 | return localVarReturnValue, localVarHttpResponse, nil 320 | } 321 | 322 | /* 323 | VariantApiService 324 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 325 | * @param flagID numeric ID of the flag 326 | * @param variantID numeric ID of the variant 327 | * @param body update a variant 328 | 329 | @return Variant 330 | */ 331 | func (a *VariantApiService) PutVariant(ctx context.Context, flagID int64, variantID int64, body PutVariantRequest) (Variant, *http.Response, error) { 332 | var ( 333 | localVarHttpMethod = strings.ToUpper("Put") 334 | localVarPostBody interface{} 335 | localVarFileName string 336 | localVarFileBytes []byte 337 | localVarReturnValue Variant 338 | ) 339 | 340 | // create path and map variables 341 | localVarPath := a.client.cfg.BasePath + "/flags/{flagID}/variants/{variantID}" 342 | localVarPath = strings.Replace(localVarPath, "{"+"flagID"+"}", fmt.Sprintf("%v", flagID), -1) 343 | localVarPath = strings.Replace(localVarPath, "{"+"variantID"+"}", fmt.Sprintf("%v", variantID), -1) 344 | 345 | localVarHeaderParams := make(map[string]string) 346 | localVarQueryParams := url.Values{} 347 | localVarFormParams := url.Values{} 348 | if flagID < 1 { 349 | return localVarReturnValue, nil, reportError("flagID must be greater than 1") 350 | } 351 | if variantID < 1 { 352 | return localVarReturnValue, nil, reportError("variantID must be greater than 1") 353 | } 354 | 355 | // to determine the Content-Type header 356 | localVarHttpContentTypes := []string{"application/json"} 357 | 358 | // set Content-Type header 359 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 360 | if localVarHttpContentType != "" { 361 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 362 | } 363 | 364 | // to determine the Accept header 365 | localVarHttpHeaderAccepts := []string{"application/json"} 366 | 367 | // set Accept header 368 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 369 | if localVarHttpHeaderAccept != "" { 370 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 371 | } 372 | // body params 373 | localVarPostBody = &body 374 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 375 | if err != nil { 376 | return localVarReturnValue, nil, err 377 | } 378 | 379 | localVarHttpResponse, err := a.client.callAPI(r) 380 | if err != nil || localVarHttpResponse == nil { 381 | return localVarReturnValue, localVarHttpResponse, err 382 | } 383 | 384 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 385 | localVarHttpResponse.Body.Close() 386 | if err != nil { 387 | return localVarReturnValue, localVarHttpResponse, err 388 | } 389 | 390 | if localVarHttpResponse.StatusCode < 300 { 391 | // If we succeed, return the data, otherwise pass on to decode error. 392 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 393 | if err == nil { 394 | return localVarReturnValue, localVarHttpResponse, err 395 | } 396 | } 397 | 398 | if localVarHttpResponse.StatusCode >= 300 { 399 | newErr := GenericSwaggerError{ 400 | body: localVarBody, 401 | error: localVarHttpResponse.Status, 402 | } 403 | 404 | if localVarHttpResponse.StatusCode == 200 { 405 | var v Variant 406 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 407 | if err != nil { 408 | newErr.error = err.Error() 409 | return localVarReturnValue, localVarHttpResponse, newErr 410 | } 411 | newErr.model = v 412 | return localVarReturnValue, localVarHttpResponse, newErr 413 | } 414 | 415 | if localVarHttpResponse.StatusCode == 0 { 416 | var v ModelError 417 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) 418 | if err != nil { 419 | newErr.error = err.Error() 420 | return localVarReturnValue, localVarHttpResponse, newErr 421 | } 422 | newErr.model = v 423 | return localVarReturnValue, localVarHttpResponse, newErr 424 | } 425 | 426 | return localVarReturnValue, localVarHttpResponse, newErr 427 | } 428 | 429 | return localVarReturnValue, localVarHttpResponse, nil 430 | } 431 | -------------------------------------------------------------------------------- /client.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "bytes" 14 | "context" 15 | "encoding/json" 16 | "encoding/xml" 17 | "errors" 18 | "fmt" 19 | "io" 20 | "mime/multipart" 21 | "net/http" 22 | "net/url" 23 | "os" 24 | "path/filepath" 25 | "reflect" 26 | "regexp" 27 | "strconv" 28 | "strings" 29 | "time" 30 | "unicode/utf8" 31 | 32 | "golang.org/x/oauth2" 33 | ) 34 | 35 | var ( 36 | jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") 37 | xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") 38 | ) 39 | 40 | // APIClient manages communication with the Flagr API v1.1.4 41 | // In most cases there should be only one, shared, APIClient. 42 | type APIClient struct { 43 | cfg *Configuration 44 | common service // Reuse a single struct instead of allocating one for each service on the heap. 45 | 46 | // API Services 47 | 48 | ConstraintApi *ConstraintApiService 49 | 50 | DistributionApi *DistributionApiService 51 | 52 | EvaluationApi *EvaluationApiService 53 | 54 | ExportApi *ExportApiService 55 | 56 | FlagApi *FlagApiService 57 | 58 | HealthApi *HealthApiService 59 | 60 | SegmentApi *SegmentApiService 61 | 62 | VariantApi *VariantApiService 63 | } 64 | 65 | type service struct { 66 | client *APIClient 67 | } 68 | 69 | // NewAPIClient creates a new API client. Requires a userAgent string describing your application. 70 | // optionally a custom http.Client to allow for advanced features such as caching. 71 | func NewAPIClient(cfg *Configuration) *APIClient { 72 | if cfg.HTTPClient == nil { 73 | cfg.HTTPClient = http.DefaultClient 74 | } 75 | 76 | c := &APIClient{} 77 | c.cfg = cfg 78 | c.common.client = c 79 | 80 | // API Services 81 | c.ConstraintApi = (*ConstraintApiService)(&c.common) 82 | c.DistributionApi = (*DistributionApiService)(&c.common) 83 | c.EvaluationApi = (*EvaluationApiService)(&c.common) 84 | c.ExportApi = (*ExportApiService)(&c.common) 85 | c.FlagApi = (*FlagApiService)(&c.common) 86 | c.HealthApi = (*HealthApiService)(&c.common) 87 | c.SegmentApi = (*SegmentApiService)(&c.common) 88 | c.VariantApi = (*VariantApiService)(&c.common) 89 | 90 | return c 91 | } 92 | 93 | func atoi(in string) (int, error) { 94 | return strconv.Atoi(in) 95 | } 96 | 97 | // selectHeaderContentType select a content type from the available list. 98 | func selectHeaderContentType(contentTypes []string) string { 99 | if len(contentTypes) == 0 { 100 | return "" 101 | } 102 | if contains(contentTypes, "application/json") { 103 | return "application/json" 104 | } 105 | return contentTypes[0] // use the first content type specified in 'consumes' 106 | } 107 | 108 | // selectHeaderAccept join all accept types and return 109 | func selectHeaderAccept(accepts []string) string { 110 | if len(accepts) == 0 { 111 | return "" 112 | } 113 | 114 | if contains(accepts, "application/json") { 115 | return "application/json" 116 | } 117 | 118 | return strings.Join(accepts, ",") 119 | } 120 | 121 | // contains is a case insenstive match, finding needle in a haystack 122 | func contains(haystack []string, needle string) bool { 123 | for _, a := range haystack { 124 | if strings.ToLower(a) == strings.ToLower(needle) { 125 | return true 126 | } 127 | } 128 | return false 129 | } 130 | 131 | // Verify optional parameters are of the correct type. 132 | func typeCheckParameter(obj interface{}, expected string, name string) error { 133 | // Make sure there is an object. 134 | if obj == nil { 135 | return nil 136 | } 137 | 138 | // Check the type is as expected. 139 | if reflect.TypeOf(obj).String() != expected { 140 | return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) 141 | } 142 | return nil 143 | } 144 | 145 | // parameterToString convert interface{} parameters to string, using a delimiter if format is provided. 146 | func parameterToString(obj interface{}, collectionFormat string) string { 147 | var delimiter string 148 | 149 | switch collectionFormat { 150 | case "pipes": 151 | delimiter = "|" 152 | case "ssv": 153 | delimiter = " " 154 | case "tsv": 155 | delimiter = "\t" 156 | case "csv": 157 | delimiter = "," 158 | } 159 | 160 | if reflect.TypeOf(obj).Kind() == reflect.Slice { 161 | return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") 162 | } 163 | 164 | return fmt.Sprintf("%v", obj) 165 | } 166 | 167 | // callAPI do the request. 168 | func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { 169 | return c.cfg.HTTPClient.Do(request) 170 | } 171 | 172 | // Change base path to allow switching to mocks 173 | func (c *APIClient) ChangeBasePath(path string) { 174 | c.cfg.BasePath = path 175 | } 176 | 177 | // prepareRequest build the request 178 | func (c *APIClient) prepareRequest( 179 | ctx context.Context, 180 | path string, method string, 181 | postBody interface{}, 182 | headerParams map[string]string, 183 | queryParams url.Values, 184 | formParams url.Values, 185 | fileName string, 186 | fileBytes []byte) (localVarRequest *http.Request, err error) { 187 | 188 | var body *bytes.Buffer 189 | 190 | // Detect postBody type and post. 191 | if postBody != nil { 192 | contentType := headerParams["Content-Type"] 193 | if contentType == "" { 194 | contentType = detectContentType(postBody) 195 | headerParams["Content-Type"] = contentType 196 | } 197 | 198 | body, err = setBody(postBody, contentType) 199 | if err != nil { 200 | return nil, err 201 | } 202 | } 203 | 204 | // add form parameters and file if available. 205 | if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { 206 | if body != nil { 207 | return nil, errors.New("Cannot specify postBody and multipart form at the same time.") 208 | } 209 | body = &bytes.Buffer{} 210 | w := multipart.NewWriter(body) 211 | 212 | for k, v := range formParams { 213 | for _, iv := range v { 214 | if strings.HasPrefix(k, "@") { // file 215 | err = addFile(w, k[1:], iv) 216 | if err != nil { 217 | return nil, err 218 | } 219 | } else { // form value 220 | w.WriteField(k, iv) 221 | } 222 | } 223 | } 224 | if len(fileBytes) > 0 && fileName != "" { 225 | w.Boundary() 226 | //_, fileNm := filepath.Split(fileName) 227 | part, err := w.CreateFormFile("file", filepath.Base(fileName)) 228 | if err != nil { 229 | return nil, err 230 | } 231 | _, err = part.Write(fileBytes) 232 | if err != nil { 233 | return nil, err 234 | } 235 | // Set the Boundary in the Content-Type 236 | headerParams["Content-Type"] = w.FormDataContentType() 237 | } 238 | 239 | // Set Content-Length 240 | headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) 241 | w.Close() 242 | } 243 | 244 | // Setup path and query parameters 245 | url, err := url.Parse(path) 246 | if err != nil { 247 | return nil, err 248 | } 249 | 250 | // Adding Query Param 251 | query := url.Query() 252 | for k, v := range queryParams { 253 | for _, iv := range v { 254 | query.Add(k, iv) 255 | } 256 | } 257 | 258 | // Encode the parameters. 259 | url.RawQuery = query.Encode() 260 | 261 | // Generate a new request 262 | if body != nil { 263 | localVarRequest, err = http.NewRequest(method, url.String(), body) 264 | } else { 265 | localVarRequest, err = http.NewRequest(method, url.String(), nil) 266 | } 267 | if err != nil { 268 | return nil, err 269 | } 270 | 271 | // add header parameters, if any 272 | if len(headerParams) > 0 { 273 | headers := http.Header{} 274 | for h, v := range headerParams { 275 | headers.Set(h, v) 276 | } 277 | localVarRequest.Header = headers 278 | } 279 | 280 | // Override request host, if applicable 281 | if c.cfg.Host != "" { 282 | localVarRequest.Host = c.cfg.Host 283 | } 284 | 285 | // Add the user agent to the request. 286 | localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) 287 | 288 | if ctx != nil { 289 | // add context to the request 290 | localVarRequest = localVarRequest.WithContext(ctx) 291 | 292 | // Walk through any authentication. 293 | 294 | // OAuth2 authentication 295 | if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { 296 | // We were able to grab an oauth2 token from the context 297 | var latestToken *oauth2.Token 298 | if latestToken, err = tok.Token(); err != nil { 299 | return nil, err 300 | } 301 | 302 | latestToken.SetAuthHeader(localVarRequest) 303 | } 304 | 305 | // Basic HTTP Authentication 306 | if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { 307 | localVarRequest.SetBasicAuth(auth.UserName, auth.Password) 308 | } 309 | 310 | // AccessToken Authentication 311 | if auth, ok := ctx.Value(ContextAccessToken).(string); ok { 312 | localVarRequest.Header.Add("Authorization", "Bearer "+auth) 313 | } 314 | } 315 | 316 | for header, value := range c.cfg.DefaultHeader { 317 | localVarRequest.Header.Add(header, value) 318 | } 319 | 320 | return localVarRequest, nil 321 | } 322 | 323 | func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { 324 | if strings.Contains(contentType, "application/xml") { 325 | if err = xml.Unmarshal(b, v); err != nil { 326 | return err 327 | } 328 | return nil 329 | } else if strings.Contains(contentType, "application/json") { 330 | if err = json.Unmarshal(b, v); err != nil { 331 | return err 332 | } 333 | return nil 334 | } 335 | return errors.New("undefined response type") 336 | } 337 | 338 | // Add a file to the multipart request 339 | func addFile(w *multipart.Writer, fieldName, path string) error { 340 | file, err := os.Open(path) 341 | if err != nil { 342 | return err 343 | } 344 | defer file.Close() 345 | 346 | part, err := w.CreateFormFile(fieldName, filepath.Base(path)) 347 | if err != nil { 348 | return err 349 | } 350 | _, err = io.Copy(part, file) 351 | 352 | return err 353 | } 354 | 355 | // Prevent trying to import "fmt" 356 | func reportError(format string, a ...interface{}) error { 357 | return fmt.Errorf(format, a...) 358 | } 359 | 360 | // Set request body from an interface{} 361 | func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { 362 | if bodyBuf == nil { 363 | bodyBuf = &bytes.Buffer{} 364 | } 365 | 366 | if reader, ok := body.(io.Reader); ok { 367 | _, err = bodyBuf.ReadFrom(reader) 368 | } else if b, ok := body.([]byte); ok { 369 | _, err = bodyBuf.Write(b) 370 | } else if s, ok := body.(string); ok { 371 | _, err = bodyBuf.WriteString(s) 372 | } else if s, ok := body.(*string); ok { 373 | _, err = bodyBuf.WriteString(*s) 374 | } else if jsonCheck.MatchString(contentType) { 375 | err = json.NewEncoder(bodyBuf).Encode(body) 376 | } else if xmlCheck.MatchString(contentType) { 377 | xml.NewEncoder(bodyBuf).Encode(body) 378 | } 379 | 380 | if err != nil { 381 | return nil, err 382 | } 383 | 384 | if bodyBuf.Len() == 0 { 385 | err = fmt.Errorf("Invalid body type %s\n", contentType) 386 | return nil, err 387 | } 388 | return bodyBuf, nil 389 | } 390 | 391 | // detectContentType method is used to figure out `Request.Body` content type for request header 392 | func detectContentType(body interface{}) string { 393 | contentType := "text/plain; charset=utf-8" 394 | kind := reflect.TypeOf(body).Kind() 395 | 396 | switch kind { 397 | case reflect.Struct, reflect.Map, reflect.Ptr: 398 | contentType = "application/json; charset=utf-8" 399 | case reflect.String: 400 | contentType = "text/plain; charset=utf-8" 401 | default: 402 | if b, ok := body.([]byte); ok { 403 | contentType = http.DetectContentType(b) 404 | } else if kind == reflect.Slice { 405 | contentType = "application/json; charset=utf-8" 406 | } 407 | } 408 | 409 | return contentType 410 | } 411 | 412 | // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go 413 | type cacheControl map[string]string 414 | 415 | func parseCacheControl(headers http.Header) cacheControl { 416 | cc := cacheControl{} 417 | ccHeader := headers.Get("Cache-Control") 418 | for _, part := range strings.Split(ccHeader, ",") { 419 | part = strings.Trim(part, " ") 420 | if part == "" { 421 | continue 422 | } 423 | if strings.ContainsRune(part, '=') { 424 | keyval := strings.Split(part, "=") 425 | cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") 426 | } else { 427 | cc[part] = "" 428 | } 429 | } 430 | return cc 431 | } 432 | 433 | // CacheExpires helper function to determine remaining time before repeating a request. 434 | func CacheExpires(r *http.Response) time.Time { 435 | // Figure out when the cache expires. 436 | var expires time.Time 437 | now, err := time.Parse(time.RFC1123, r.Header.Get("date")) 438 | if err != nil { 439 | return time.Now() 440 | } 441 | respCacheControl := parseCacheControl(r.Header) 442 | 443 | if maxAge, ok := respCacheControl["max-age"]; ok { 444 | lifetime, err := time.ParseDuration(maxAge + "s") 445 | if err != nil { 446 | expires = now 447 | } 448 | expires = now.Add(lifetime) 449 | } else { 450 | expiresHeader := r.Header.Get("Expires") 451 | if expiresHeader != "" { 452 | expires, err = time.Parse(time.RFC1123, expiresHeader) 453 | if err != nil { 454 | expires = now 455 | } 456 | } 457 | } 458 | return expires 459 | } 460 | 461 | func strlen(s string) int { 462 | return utf8.RuneCountInString(s) 463 | } 464 | 465 | // GenericSwaggerError Provides access to the body, error and model on returned errors. 466 | type GenericSwaggerError struct { 467 | body []byte 468 | error string 469 | model interface{} 470 | } 471 | 472 | // Error returns non-empty string if there was an error. 473 | func (e GenericSwaggerError) Error() string { 474 | return e.error 475 | } 476 | 477 | // Body returns the raw bytes of the response 478 | func (e GenericSwaggerError) Body() []byte { 479 | return e.body 480 | } 481 | 482 | // Model returns the unpacked model of the error 483 | func (e GenericSwaggerError) Model() interface{} { 484 | return e.model 485 | } 486 | -------------------------------------------------------------------------------- /configuration.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // contextKeys are used to identify the type of value in the context. 17 | // Since these are string, it is possible to get a short description of the 18 | // context key for logging and debugging using key.String(). 19 | 20 | type contextKey string 21 | 22 | func (c contextKey) String() string { 23 | return "auth " + string(c) 24 | } 25 | 26 | var ( 27 | // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. 28 | ContextOAuth2 = contextKey("token") 29 | 30 | // ContextBasicAuth takes BasicAuth as authentication for the request. 31 | ContextBasicAuth = contextKey("basic") 32 | 33 | // ContextAccessToken takes a string oauth2 access token as authentication for the request. 34 | ContextAccessToken = contextKey("accesstoken") 35 | 36 | // ContextAPIKey takes an APIKey as authentication for the request 37 | ContextAPIKey = contextKey("apikey") 38 | ) 39 | 40 | // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth 41 | type BasicAuth struct { 42 | UserName string `json:"userName,omitempty"` 43 | Password string `json:"password,omitempty"` 44 | } 45 | 46 | // APIKey provides API key based authentication to a request passed via context using ContextAPIKey 47 | type APIKey struct { 48 | Key string 49 | Prefix string 50 | } 51 | 52 | type Configuration struct { 53 | BasePath string `json:"basePath,omitempty"` 54 | Host string `json:"host,omitempty"` 55 | Scheme string `json:"scheme,omitempty"` 56 | DefaultHeader map[string]string `json:"defaultHeader,omitempty"` 57 | UserAgent string `json:"userAgent,omitempty"` 58 | HTTPClient *http.Client 59 | } 60 | 61 | func NewConfiguration() *Configuration { 62 | cfg := &Configuration{ 63 | BasePath: "http://localhost/api/v1", 64 | DefaultHeader: make(map[string]string), 65 | UserAgent: "Swagger-Codegen/1.1.1/go", 66 | } 67 | return cfg 68 | } 69 | 70 | func (c *Configuration) AddDefaultHeader(key string, value string) { 71 | c.DefaultHeader[key] = value 72 | } 73 | -------------------------------------------------------------------------------- /docs/Constraint.md: -------------------------------------------------------------------------------- 1 | # Constraint 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Id** | **int64** | | [optional] [default to null] 7 | **Property** | **string** | | [default to null] 8 | **Operator** | **string** | | [default to null] 9 | **Value** | **string** | | [default to null] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/ConstraintApi.md: -------------------------------------------------------------------------------- 1 | # \ConstraintApi 2 | 3 | All URIs are relative to *http://localhost/api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**CreateConstraint**](ConstraintApi.md#CreateConstraint) | **Post** /flags/{flagID}/segments/{segmentID}/constraints | 8 | [**DeleteConstraint**](ConstraintApi.md#DeleteConstraint) | **Delete** /flags/{flagID}/segments/{segmentID}/constraints/{constraintID} | 9 | [**FindConstraints**](ConstraintApi.md#FindConstraints) | **Get** /flags/{flagID}/segments/{segmentID}/constraints | 10 | [**PutConstraint**](ConstraintApi.md#PutConstraint) | **Put** /flags/{flagID}/segments/{segmentID}/constraints/{constraintID} | 11 | 12 | 13 | # **CreateConstraint** 14 | > Constraint CreateConstraint(ctx, flagID, segmentID, body) 15 | 16 | 17 | ### Required Parameters 18 | 19 | Name | Type | Description | Notes 20 | ------------- | ------------- | ------------- | ------------- 21 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 22 | **flagID** | **int64**| numeric ID of the flag | 23 | **segmentID** | **int64**| numeric ID of the segment | 24 | **body** | [**CreateConstraintRequest**](CreateConstraintRequest.md)| create a constraint | 25 | 26 | ### Return type 27 | 28 | [**Constraint**](constraint.md) 29 | 30 | ### Authorization 31 | 32 | No authorization required 33 | 34 | ### HTTP request headers 35 | 36 | - **Content-Type**: application/json 37 | - **Accept**: application/json 38 | 39 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 40 | 41 | # **DeleteConstraint** 42 | > DeleteConstraint(ctx, flagID, segmentID, constraintID) 43 | 44 | 45 | ### Required Parameters 46 | 47 | Name | Type | Description | Notes 48 | ------------- | ------------- | ------------- | ------------- 49 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 50 | **flagID** | **int64**| numeric ID of the flag | 51 | **segmentID** | **int64**| numeric ID of the segment | 52 | **constraintID** | **int64**| numeric ID of the constraint | 53 | 54 | ### Return type 55 | 56 | (empty response body) 57 | 58 | ### Authorization 59 | 60 | No authorization required 61 | 62 | ### HTTP request headers 63 | 64 | - **Content-Type**: application/json 65 | - **Accept**: application/json 66 | 67 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 68 | 69 | # **FindConstraints** 70 | > []Constraint FindConstraints(ctx, flagID, segmentID) 71 | 72 | 73 | ### Required Parameters 74 | 75 | Name | Type | Description | Notes 76 | ------------- | ------------- | ------------- | ------------- 77 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 78 | **flagID** | **int64**| numeric ID of the flag | 79 | **segmentID** | **int64**| numeric ID of the segment | 80 | 81 | ### Return type 82 | 83 | [**[]Constraint**](constraint.md) 84 | 85 | ### Authorization 86 | 87 | No authorization required 88 | 89 | ### HTTP request headers 90 | 91 | - **Content-Type**: application/json 92 | - **Accept**: application/json 93 | 94 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 95 | 96 | # **PutConstraint** 97 | > Constraint PutConstraint(ctx, flagID, segmentID, constraintID, body) 98 | 99 | 100 | ### Required Parameters 101 | 102 | Name | Type | Description | Notes 103 | ------------- | ------------- | ------------- | ------------- 104 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 105 | **flagID** | **int64**| numeric ID of the flag | 106 | **segmentID** | **int64**| numeric ID of the segment | 107 | **constraintID** | **int64**| numeric ID of the constraint | 108 | **body** | [**CreateConstraintRequest**](CreateConstraintRequest.md)| create a constraint | 109 | 110 | ### Return type 111 | 112 | [**Constraint**](constraint.md) 113 | 114 | ### Authorization 115 | 116 | No authorization required 117 | 118 | ### HTTP request headers 119 | 120 | - **Content-Type**: application/json 121 | - **Accept**: application/json 122 | 123 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 124 | 125 | -------------------------------------------------------------------------------- /docs/CreateConstraintRequest.md: -------------------------------------------------------------------------------- 1 | # CreateConstraintRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Property** | **string** | | [default to null] 7 | **Operator** | **string** | | [default to null] 8 | **Value** | **string** | | [default to null] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/CreateFlagRequest.md: -------------------------------------------------------------------------------- 1 | # CreateFlagRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Description** | **string** | | [default to null] 7 | **Key** | **string** | unique key representation of the flag | [optional] [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/CreateSegmentRequest.md: -------------------------------------------------------------------------------- 1 | # CreateSegmentRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Description** | **string** | | [default to null] 7 | **RolloutPercent** | **int64** | | [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/CreateVariantRequest.md: -------------------------------------------------------------------------------- 1 | # CreateVariantRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Key** | **string** | | [default to null] 7 | **Attachment** | [***interface{}**](interface{}.md) | | [optional] [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/Distribution.md: -------------------------------------------------------------------------------- 1 | # Distribution 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Id** | **int64** | | [optional] [default to null] 7 | **Percent** | **int64** | | [default to null] 8 | **VariantKey** | **string** | | [default to null] 9 | **VariantID** | **int64** | | [default to null] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/DistributionApi.md: -------------------------------------------------------------------------------- 1 | # \DistributionApi 2 | 3 | All URIs are relative to *http://localhost/api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**FindDistributions**](DistributionApi.md#FindDistributions) | **Get** /flags/{flagID}/segments/{segmentID}/distributions | 8 | [**PutDistributions**](DistributionApi.md#PutDistributions) | **Put** /flags/{flagID}/segments/{segmentID}/distributions | 9 | 10 | 11 | # **FindDistributions** 12 | > []Distribution FindDistributions(ctx, flagID, segmentID) 13 | 14 | 15 | ### Required Parameters 16 | 17 | Name | Type | Description | Notes 18 | ------------- | ------------- | ------------- | ------------- 19 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 20 | **flagID** | **int64**| numeric ID of the flag | 21 | **segmentID** | **int64**| numeric ID of the segment | 22 | 23 | ### Return type 24 | 25 | [**[]Distribution**](distribution.md) 26 | 27 | ### Authorization 28 | 29 | No authorization required 30 | 31 | ### HTTP request headers 32 | 33 | - **Content-Type**: application/json 34 | - **Accept**: application/json 35 | 36 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 37 | 38 | # **PutDistributions** 39 | > []Distribution PutDistributions(ctx, flagID, segmentID, body) 40 | 41 | 42 | replace the distribution with the new setting 43 | 44 | ### Required Parameters 45 | 46 | Name | Type | Description | Notes 47 | ------------- | ------------- | ------------- | ------------- 48 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 49 | **flagID** | **int64**| numeric ID of the flag | 50 | **segmentID** | **int64**| numeric ID of the segment | 51 | **body** | [**PutDistributionsRequest**](PutDistributionsRequest.md)| array of distributions | 52 | 53 | ### Return type 54 | 55 | [**[]Distribution**](distribution.md) 56 | 57 | ### Authorization 58 | 59 | No authorization required 60 | 61 | ### HTTP request headers 62 | 63 | - **Content-Type**: application/json 64 | - **Accept**: application/json 65 | 66 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 67 | 68 | -------------------------------------------------------------------------------- /docs/EvalContext.md: -------------------------------------------------------------------------------- 1 | # EvalContext 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **EntityID** | **string** | entityID is used to deterministically at random to evaluate the flag result. If it's empty, flagr will randomly generate one. | [optional] [default to null] 7 | **EntityType** | **string** | | [optional] [default to null] 8 | **EntityContext** | [***interface{}**](interface{}.md) | | [optional] [default to null] 9 | **EnableDebug** | **bool** | | [optional] [default to null] 10 | **FlagID** | **int64** | flagID | [optional] [default to null] 11 | **FlagKey** | **string** | flagKey. flagID or flagKey will resolve to the same flag. Either works. | [optional] [default to null] 12 | 13 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/EvalDebugLog.md: -------------------------------------------------------------------------------- 1 | # EvalDebugLog 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **SegmentDebugLogs** | [**[]SegmentDebugLog**](segmentDebugLog.md) | | [optional] [default to null] 7 | **Msg** | **string** | | [optional] [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/EvalResult.md: -------------------------------------------------------------------------------- 1 | # EvalResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **FlagID** | **int64** | | [optional] [default to null] 7 | **FlagKey** | **string** | | [optional] [default to null] 8 | **FlagSnapshotID** | **int64** | | [optional] [default to null] 9 | **SegmentID** | **int64** | | [optional] [default to null] 10 | **VariantID** | **int64** | | [optional] [default to null] 11 | **VariantKey** | **string** | | [optional] [default to null] 12 | **VariantAttachment** | [***interface{}**](interface{}.md) | | [optional] [default to null] 13 | **EvalContext** | [***EvalContext**](evalContext.md) | | [optional] [default to null] 14 | **Timestamp** | **string** | | [optional] [default to null] 15 | **EvalDebugLog** | [***EvalDebugLog**](evalDebugLog.md) | | [optional] [default to null] 16 | 17 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/EvaluationApi.md: -------------------------------------------------------------------------------- 1 | # \EvaluationApi 2 | 3 | All URIs are relative to *http://localhost/api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**PostEvaluation**](EvaluationApi.md#PostEvaluation) | **Post** /evaluation | 8 | [**PostEvaluationBatch**](EvaluationApi.md#PostEvaluationBatch) | **Post** /evaluation/batch | 9 | 10 | 11 | # **PostEvaluation** 12 | > EvalResult PostEvaluation(ctx, body) 13 | 14 | 15 | ### Required Parameters 16 | 17 | Name | Type | Description | Notes 18 | ------------- | ------------- | ------------- | ------------- 19 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 20 | **body** | [**EvalContext**](EvalContext.md)| evalution context | 21 | 22 | ### Return type 23 | 24 | [**EvalResult**](evalResult.md) 25 | 26 | ### Authorization 27 | 28 | No authorization required 29 | 30 | ### HTTP request headers 31 | 32 | - **Content-Type**: application/json 33 | - **Accept**: application/json 34 | 35 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 36 | 37 | # **PostEvaluationBatch** 38 | > EvaluationBatchResponse PostEvaluationBatch(ctx, body) 39 | 40 | 41 | ### Required Parameters 42 | 43 | Name | Type | Description | Notes 44 | ------------- | ------------- | ------------- | ------------- 45 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 46 | **body** | [**EvaluationBatchRequest**](EvaluationBatchRequest.md)| evalution batch request | 47 | 48 | ### Return type 49 | 50 | [**EvaluationBatchResponse**](evaluationBatchResponse.md) 51 | 52 | ### Authorization 53 | 54 | No authorization required 55 | 56 | ### HTTP request headers 57 | 58 | - **Content-Type**: application/json 59 | - **Accept**: application/json 60 | 61 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 62 | 63 | -------------------------------------------------------------------------------- /docs/EvaluationBatchRequest.md: -------------------------------------------------------------------------------- 1 | # EvaluationBatchRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Entities** | [**[]EvaluationEntity**](evaluationEntity.md) | | [default to null] 7 | **EnableDebug** | **bool** | | [optional] [default to null] 8 | **FlagIDs** | **[]int64** | flagIDs | [optional] [default to null] 9 | **FlagKeys** | **[]string** | flagKeys. Either flagIDs or flagKeys works. If pass in both, Flagr may return duplicate results. | [optional] [default to null] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/EvaluationBatchResponse.md: -------------------------------------------------------------------------------- 1 | # EvaluationBatchResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **EvaluationResults** | [**[]EvalResult**](evalResult.md) | | [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/EvaluationEntity.md: -------------------------------------------------------------------------------- 1 | # EvaluationEntity 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **EntityID** | **string** | | [optional] [default to null] 7 | **EntityType** | **string** | | [optional] [default to null] 8 | **EntityContext** | [***interface{}**](interface{}.md) | | [optional] [default to null] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/ExportApi.md: -------------------------------------------------------------------------------- 1 | # \ExportApi 2 | 3 | All URIs are relative to *http://localhost/api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetExportEvalCacheJSON**](ExportApi.md#GetExportEvalCacheJSON) | **Get** /export/eval_cache/json | 8 | [**GetExportSqlite**](ExportApi.md#GetExportSqlite) | **Get** /export/sqlite | 9 | 10 | 11 | # **GetExportEvalCacheJSON** 12 | > interface{} GetExportEvalCacheJSON(ctx, ) 13 | 14 | 15 | Export JSON format of the eval cache dump 16 | 17 | ### Required Parameters 18 | This endpoint does not need any parameter. 19 | 20 | ### Return type 21 | 22 | [**interface{}**](interface{}.md) 23 | 24 | ### Authorization 25 | 26 | No authorization required 27 | 28 | ### HTTP request headers 29 | 30 | - **Content-Type**: application/json 31 | - **Accept**: application/json 32 | 33 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 34 | 35 | # **GetExportSqlite** 36 | > *os.File GetExportSqlite(ctx, ) 37 | 38 | 39 | Export sqlite3 format of the db dump, which is converted from the main database. 40 | 41 | ### Required Parameters 42 | This endpoint does not need any parameter. 43 | 44 | ### Return type 45 | 46 | [***os.File**](*os.File.md) 47 | 48 | ### Authorization 49 | 50 | No authorization required 51 | 52 | ### HTTP request headers 53 | 54 | - **Content-Type**: application/json 55 | - **Accept**: application/octet-stream 56 | 57 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 58 | 59 | -------------------------------------------------------------------------------- /docs/Flag.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Id** | **int64** | | [optional] [default to null] 7 | **Key** | **string** | unique key representation of the flag | [optional] [default to null] 8 | **Description** | **string** | | [default to null] 9 | **Enabled** | **bool** | | [default to null] 10 | **Segments** | [**[]Segment**](segment.md) | | [optional] [default to null] 11 | **Variants** | [**[]Variant**](variant.md) | | [optional] [default to null] 12 | **DataRecordsEnabled** | **bool** | enabled data records will get data logging in the metrics pipeline, for example, kafka. | [default to null] 13 | **EntityType** | **string** | it will override the entityType in the evaluation logs if it's not empty | [optional] [default to null] 14 | **Notes** | **string** | flag usage details in markdown format | [optional] [default to null] 15 | **CreatedBy** | **string** | | [optional] [default to null] 16 | **UpdatedBy** | **string** | | [optional] [default to null] 17 | **UpdatedAt** | [**time.Time**](time.Time.md) | | [optional] [default to null] 18 | 19 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/FlagApi.md: -------------------------------------------------------------------------------- 1 | # \FlagApi 2 | 3 | All URIs are relative to *http://localhost/api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**CreateFlag**](FlagApi.md#CreateFlag) | **Post** /flags | 8 | [**DeleteFlag**](FlagApi.md#DeleteFlag) | **Delete** /flags/{flagID} | 9 | [**FindFlags**](FlagApi.md#FindFlags) | **Get** /flags | 10 | [**GetFlag**](FlagApi.md#GetFlag) | **Get** /flags/{flagID} | 11 | [**GetFlagEntityTypes**](FlagApi.md#GetFlagEntityTypes) | **Get** /flags/entity_types | 12 | [**GetFlagSnapshots**](FlagApi.md#GetFlagSnapshots) | **Get** /flags/{flagID}/snapshots | 13 | [**PutFlag**](FlagApi.md#PutFlag) | **Put** /flags/{flagID} | 14 | [**SetFlagEnabled**](FlagApi.md#SetFlagEnabled) | **Put** /flags/{flagID}/enabled | 15 | 16 | 17 | # **CreateFlag** 18 | > Flag CreateFlag(ctx, body) 19 | 20 | 21 | ### Required Parameters 22 | 23 | Name | Type | Description | Notes 24 | ------------- | ------------- | ------------- | ------------- 25 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 26 | **body** | [**CreateFlagRequest**](CreateFlagRequest.md)| create a flag | 27 | 28 | ### Return type 29 | 30 | [**Flag**](flag.md) 31 | 32 | ### Authorization 33 | 34 | No authorization required 35 | 36 | ### HTTP request headers 37 | 38 | - **Content-Type**: application/json 39 | - **Accept**: application/json 40 | 41 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 42 | 43 | # **DeleteFlag** 44 | > DeleteFlag(ctx, flagID) 45 | 46 | 47 | ### Required Parameters 48 | 49 | Name | Type | Description | Notes 50 | ------------- | ------------- | ------------- | ------------- 51 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 52 | **flagID** | **int64**| numeric ID of the flag | 53 | 54 | ### Return type 55 | 56 | (empty response body) 57 | 58 | ### Authorization 59 | 60 | No authorization required 61 | 62 | ### HTTP request headers 63 | 64 | - **Content-Type**: application/json 65 | - **Accept**: application/json 66 | 67 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 68 | 69 | # **FindFlags** 70 | > []Flag FindFlags(ctx, optional) 71 | 72 | 73 | ### Required Parameters 74 | 75 | Name | Type | Description | Notes 76 | ------------- | ------------- | ------------- | ------------- 77 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 78 | **optional** | ***FindFlagsOpts** | optional parameters | nil if no parameters 79 | 80 | ### Optional Parameters 81 | Optional parameters are passed through a pointer to a FindFlagsOpts struct 82 | 83 | Name | Type | Description | Notes 84 | ------------- | ------------- | ------------- | ------------- 85 | **limit** | **optional.Int64**| the numbers of flags to return | 86 | **enabled** | **optional.Bool**| return flags having given enabled status | 87 | **description** | **optional.String**| return flags exactly matching given description | 88 | **descriptionLike** | **optional.String**| return flags partially matching given description | 89 | **key** | **optional.String**| return flags matching given key | 90 | **offset** | **optional.Int64**| return flags given the offset, it should usually set together with limit | 91 | **preload** | **optional.Bool**| return flags with preloaded segments and variants | 92 | 93 | ### Return type 94 | 95 | [**[]Flag**](flag.md) 96 | 97 | ### Authorization 98 | 99 | No authorization required 100 | 101 | ### HTTP request headers 102 | 103 | - **Content-Type**: application/json 104 | - **Accept**: application/json 105 | 106 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 107 | 108 | # **GetFlag** 109 | > Flag GetFlag(ctx, flagID) 110 | 111 | 112 | ### Required Parameters 113 | 114 | Name | Type | Description | Notes 115 | ------------- | ------------- | ------------- | ------------- 116 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 117 | **flagID** | **int64**| numeric ID of the flag to get | 118 | 119 | ### Return type 120 | 121 | [**Flag**](flag.md) 122 | 123 | ### Authorization 124 | 125 | No authorization required 126 | 127 | ### HTTP request headers 128 | 129 | - **Content-Type**: application/json 130 | - **Accept**: application/json 131 | 132 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 133 | 134 | # **GetFlagEntityTypes** 135 | > []string GetFlagEntityTypes(ctx, ) 136 | 137 | 138 | ### Required Parameters 139 | This endpoint does not need any parameter. 140 | 141 | ### Return type 142 | 143 | **[]string** 144 | 145 | ### Authorization 146 | 147 | No authorization required 148 | 149 | ### HTTP request headers 150 | 151 | - **Content-Type**: application/json 152 | - **Accept**: application/json 153 | 154 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 155 | 156 | # **GetFlagSnapshots** 157 | > []FlagSnapshot GetFlagSnapshots(ctx, flagID) 158 | 159 | 160 | ### Required Parameters 161 | 162 | Name | Type | Description | Notes 163 | ------------- | ------------- | ------------- | ------------- 164 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 165 | **flagID** | **int64**| numeric ID of the flag to get | 166 | 167 | ### Return type 168 | 169 | [**[]FlagSnapshot**](flagSnapshot.md) 170 | 171 | ### Authorization 172 | 173 | No authorization required 174 | 175 | ### HTTP request headers 176 | 177 | - **Content-Type**: application/json 178 | - **Accept**: application/json 179 | 180 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 181 | 182 | # **PutFlag** 183 | > Flag PutFlag(ctx, flagID, body) 184 | 185 | 186 | ### Required Parameters 187 | 188 | Name | Type | Description | Notes 189 | ------------- | ------------- | ------------- | ------------- 190 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 191 | **flagID** | **int64**| numeric ID of the flag to get | 192 | **body** | [**PutFlagRequest**](PutFlagRequest.md)| update a flag | 193 | 194 | ### Return type 195 | 196 | [**Flag**](flag.md) 197 | 198 | ### Authorization 199 | 200 | No authorization required 201 | 202 | ### HTTP request headers 203 | 204 | - **Content-Type**: application/json 205 | - **Accept**: application/json 206 | 207 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 208 | 209 | # **SetFlagEnabled** 210 | > Flag SetFlagEnabled(ctx, flagID, body) 211 | 212 | 213 | ### Required Parameters 214 | 215 | Name | Type | Description | Notes 216 | ------------- | ------------- | ------------- | ------------- 217 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 218 | **flagID** | **int64**| numeric ID of the flag to get | 219 | **body** | [**SetFlagEnabledRequest**](SetFlagEnabledRequest.md)| set flag enabled state | 220 | 221 | ### Return type 222 | 223 | [**Flag**](flag.md) 224 | 225 | ### Authorization 226 | 227 | No authorization required 228 | 229 | ### HTTP request headers 230 | 231 | - **Content-Type**: application/json 232 | - **Accept**: application/json 233 | 234 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 235 | 236 | -------------------------------------------------------------------------------- /docs/FlagSnapshot.md: -------------------------------------------------------------------------------- 1 | # FlagSnapshot 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Id** | **int64** | | [default to null] 7 | **UpdatedBy** | **string** | | [optional] [default to null] 8 | **Flag** | [***Flag**](flag.md) | | [default to null] 9 | **UpdatedAt** | **string** | | [default to null] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/Health.md: -------------------------------------------------------------------------------- 1 | # Health 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Status** | **string** | | [optional] [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/HealthApi.md: -------------------------------------------------------------------------------- 1 | # \HealthApi 2 | 3 | All URIs are relative to *http://localhost/api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetHealth**](HealthApi.md#GetHealth) | **Get** /health | 8 | 9 | 10 | # **GetHealth** 11 | > Health GetHealth(ctx, ) 12 | 13 | 14 | Check if Flagr is healthy 15 | 16 | ### Required Parameters 17 | This endpoint does not need any parameter. 18 | 19 | ### Return type 20 | 21 | [**Health**](health.md) 22 | 23 | ### Authorization 24 | 25 | No authorization required 26 | 27 | ### HTTP request headers 28 | 29 | - **Content-Type**: application/json 30 | - **Accept**: application/json 31 | 32 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 33 | 34 | -------------------------------------------------------------------------------- /docs/ModelError.md: -------------------------------------------------------------------------------- 1 | # ModelError 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Message** | **string** | | [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/PutDistributionsRequest.md: -------------------------------------------------------------------------------- 1 | # PutDistributionsRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Distributions** | [**[]Distribution**](distribution.md) | | [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/PutFlagRequest.md: -------------------------------------------------------------------------------- 1 | # PutFlagRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Description** | **string** | | [optional] [default to null] 7 | **DataRecordsEnabled** | **bool** | enabled data records will get data logging in the metrics pipeline, for example, kafka. | [optional] [default to null] 8 | **EntityType** | **string** | it will overwrite entityType into evaluation logs if it's not empty | [optional] [default to null] 9 | **Enabled** | **bool** | | [optional] [default to null] 10 | **Key** | **string** | | [optional] [default to null] 11 | **Notes** | **string** | | [optional] [default to null] 12 | 13 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/PutSegmentReorderRequest.md: -------------------------------------------------------------------------------- 1 | # PutSegmentReorderRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **SegmentIDs** | **[]int64** | | [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/PutSegmentRequest.md: -------------------------------------------------------------------------------- 1 | # PutSegmentRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Description** | **string** | | [default to null] 7 | **RolloutPercent** | **int64** | | [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/PutVariantRequest.md: -------------------------------------------------------------------------------- 1 | # PutVariantRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Key** | **string** | | [default to null] 7 | **Attachment** | [***interface{}**](interface{}.md) | | [optional] [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/Segment.md: -------------------------------------------------------------------------------- 1 | # Segment 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Id** | **int64** | | [optional] [default to null] 7 | **Description** | **string** | | [default to null] 8 | **Constraints** | [**[]Constraint**](constraint.md) | | [optional] [default to null] 9 | **Distributions** | [**[]Distribution**](distribution.md) | | [optional] [default to null] 10 | **Rank** | **int64** | | [default to null] 11 | **RolloutPercent** | **int64** | | [default to null] 12 | 13 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/SegmentApi.md: -------------------------------------------------------------------------------- 1 | # \SegmentApi 2 | 3 | All URIs are relative to *http://localhost/api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**CreateSegment**](SegmentApi.md#CreateSegment) | **Post** /flags/{flagID}/segments | 8 | [**DeleteSegment**](SegmentApi.md#DeleteSegment) | **Delete** /flags/{flagID}/segments/{segmentID} | 9 | [**FindSegments**](SegmentApi.md#FindSegments) | **Get** /flags/{flagID}/segments | 10 | [**PutSegment**](SegmentApi.md#PutSegment) | **Put** /flags/{flagID}/segments/{segmentID} | 11 | [**PutSegmentsReorder**](SegmentApi.md#PutSegmentsReorder) | **Put** /flags/{flagID}/segments/reorder | 12 | 13 | 14 | # **CreateSegment** 15 | > Segment CreateSegment(ctx, flagID, body) 16 | 17 | 18 | ### Required Parameters 19 | 20 | Name | Type | Description | Notes 21 | ------------- | ------------- | ------------- | ------------- 22 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 23 | **flagID** | **int64**| numeric ID of the flag to get | 24 | **body** | [**CreateSegmentRequest**](CreateSegmentRequest.md)| create a segment under a flag | 25 | 26 | ### Return type 27 | 28 | [**Segment**](segment.md) 29 | 30 | ### Authorization 31 | 32 | No authorization required 33 | 34 | ### HTTP request headers 35 | 36 | - **Content-Type**: application/json 37 | - **Accept**: application/json 38 | 39 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 40 | 41 | # **DeleteSegment** 42 | > DeleteSegment(ctx, flagID, segmentID) 43 | 44 | 45 | ### Required Parameters 46 | 47 | Name | Type | Description | Notes 48 | ------------- | ------------- | ------------- | ------------- 49 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 50 | **flagID** | **int64**| numeric ID of the flag | 51 | **segmentID** | **int64**| numeric ID of the segment | 52 | 53 | ### Return type 54 | 55 | (empty response body) 56 | 57 | ### Authorization 58 | 59 | No authorization required 60 | 61 | ### HTTP request headers 62 | 63 | - **Content-Type**: application/json 64 | - **Accept**: application/json 65 | 66 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 67 | 68 | # **FindSegments** 69 | > []Segment FindSegments(ctx, flagID) 70 | 71 | 72 | ### Required Parameters 73 | 74 | Name | Type | Description | Notes 75 | ------------- | ------------- | ------------- | ------------- 76 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 77 | **flagID** | **int64**| numeric ID of the flag to get | 78 | 79 | ### Return type 80 | 81 | [**[]Segment**](segment.md) 82 | 83 | ### Authorization 84 | 85 | No authorization required 86 | 87 | ### HTTP request headers 88 | 89 | - **Content-Type**: application/json 90 | - **Accept**: application/json 91 | 92 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 93 | 94 | # **PutSegment** 95 | > Segment PutSegment(ctx, flagID, segmentID, body) 96 | 97 | 98 | ### Required Parameters 99 | 100 | Name | Type | Description | Notes 101 | ------------- | ------------- | ------------- | ------------- 102 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 103 | **flagID** | **int64**| numeric ID of the flag | 104 | **segmentID** | **int64**| numeric ID of the segment | 105 | **body** | [**PutSegmentRequest**](PutSegmentRequest.md)| update a segment | 106 | 107 | ### Return type 108 | 109 | [**Segment**](segment.md) 110 | 111 | ### Authorization 112 | 113 | No authorization required 114 | 115 | ### HTTP request headers 116 | 117 | - **Content-Type**: application/json 118 | - **Accept**: application/json 119 | 120 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 121 | 122 | # **PutSegmentsReorder** 123 | > PutSegmentsReorder(ctx, flagID, body) 124 | 125 | 126 | ### Required Parameters 127 | 128 | Name | Type | Description | Notes 129 | ------------- | ------------- | ------------- | ------------- 130 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 131 | **flagID** | **int64**| numeric ID of the flag | 132 | **body** | [**PutSegmentReorderRequest**](PutSegmentReorderRequest.md)| reorder segments | 133 | 134 | ### Return type 135 | 136 | (empty response body) 137 | 138 | ### Authorization 139 | 140 | No authorization required 141 | 142 | ### HTTP request headers 143 | 144 | - **Content-Type**: application/json 145 | - **Accept**: application/json 146 | 147 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 148 | 149 | -------------------------------------------------------------------------------- /docs/SegmentDebugLog.md: -------------------------------------------------------------------------------- 1 | # SegmentDebugLog 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **SegmentID** | **int64** | | [optional] [default to null] 7 | **Msg** | **string** | | [optional] [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/SetFlagEnabledRequest.md: -------------------------------------------------------------------------------- 1 | # SetFlagEnabledRequest 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Enabled** | **bool** | | [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/Variant.md: -------------------------------------------------------------------------------- 1 | # Variant 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Id** | **int64** | | [optional] [default to null] 7 | **Key** | **string** | | [default to null] 8 | **Attachment** | [***interface{}**](interface{}.md) | | [optional] [default to null] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/VariantApi.md: -------------------------------------------------------------------------------- 1 | # \VariantApi 2 | 3 | All URIs are relative to *http://localhost/api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**CreateVariant**](VariantApi.md#CreateVariant) | **Post** /flags/{flagID}/variants | 8 | [**DeleteVariant**](VariantApi.md#DeleteVariant) | **Delete** /flags/{flagID}/variants/{variantID} | 9 | [**FindVariants**](VariantApi.md#FindVariants) | **Get** /flags/{flagID}/variants | 10 | [**PutVariant**](VariantApi.md#PutVariant) | **Put** /flags/{flagID}/variants/{variantID} | 11 | 12 | 13 | # **CreateVariant** 14 | > Variant CreateVariant(ctx, flagID, body) 15 | 16 | 17 | ### Required Parameters 18 | 19 | Name | Type | Description | Notes 20 | ------------- | ------------- | ------------- | ------------- 21 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 22 | **flagID** | **int64**| numeric ID of the flag | 23 | **body** | [**CreateVariantRequest**](CreateVariantRequest.md)| create a variant | 24 | 25 | ### Return type 26 | 27 | [**Variant**](variant.md) 28 | 29 | ### Authorization 30 | 31 | No authorization required 32 | 33 | ### HTTP request headers 34 | 35 | - **Content-Type**: application/json 36 | - **Accept**: application/json 37 | 38 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 39 | 40 | # **DeleteVariant** 41 | > DeleteVariant(ctx, flagID, variantID) 42 | 43 | 44 | ### Required Parameters 45 | 46 | Name | Type | Description | Notes 47 | ------------- | ------------- | ------------- | ------------- 48 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 49 | **flagID** | **int64**| numeric ID of the flag | 50 | **variantID** | **int64**| numeric ID of the variant | 51 | 52 | ### Return type 53 | 54 | (empty response body) 55 | 56 | ### Authorization 57 | 58 | No authorization required 59 | 60 | ### HTTP request headers 61 | 62 | - **Content-Type**: application/json 63 | - **Accept**: application/json 64 | 65 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 66 | 67 | # **FindVariants** 68 | > []Variant FindVariants(ctx, flagID) 69 | 70 | 71 | ### Required Parameters 72 | 73 | Name | Type | Description | Notes 74 | ------------- | ------------- | ------------- | ------------- 75 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 76 | **flagID** | **int64**| numeric ID of the flag | 77 | 78 | ### Return type 79 | 80 | [**[]Variant**](variant.md) 81 | 82 | ### Authorization 83 | 84 | No authorization required 85 | 86 | ### HTTP request headers 87 | 88 | - **Content-Type**: application/json 89 | - **Accept**: application/json 90 | 91 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 92 | 93 | # **PutVariant** 94 | > Variant PutVariant(ctx, flagID, variantID, body) 95 | 96 | 97 | ### Required Parameters 98 | 99 | Name | Type | Description | Notes 100 | ------------- | ------------- | ------------- | ------------- 101 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 102 | **flagID** | **int64**| numeric ID of the flag | 103 | **variantID** | **int64**| numeric ID of the variant | 104 | **body** | [**PutVariantRequest**](PutVariantRequest.md)| update a variant | 105 | 106 | ### Return type 107 | 108 | [**Variant**](variant.md) 109 | 110 | ### Authorization 111 | 112 | No authorization required 113 | 114 | ### HTTP request headers 115 | 116 | - **Content-Type**: application/json 117 | - **Accept**: application/json 118 | 119 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 120 | 121 | -------------------------------------------------------------------------------- /git_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ 3 | # 4 | # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" 5 | 6 | git_user_id=$1 7 | git_repo_id=$2 8 | release_note=$3 9 | 10 | if [ "$git_user_id" = "" ]; then 11 | git_user_id="GIT_USER_ID" 12 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" 13 | fi 14 | 15 | if [ "$git_repo_id" = "" ]; then 16 | git_repo_id="GIT_REPO_ID" 17 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" 18 | fi 19 | 20 | if [ "$release_note" = "" ]; then 21 | release_note="Minor update" 22 | echo "[INFO] No command line input provided. Set \$release_note to $release_note" 23 | fi 24 | 25 | # Initialize the local directory as a Git repository 26 | git init 27 | 28 | # Adds the files in the local repository and stages them for commit. 29 | git add . 30 | 31 | # Commits the tracked changes and prepares them to be pushed to a remote repository. 32 | git commit -m "$release_note" 33 | 34 | # Sets the new remote 35 | git_remote=`git remote` 36 | if [ "$git_remote" = "" ]; then # git remote not defined 37 | 38 | if [ "$GIT_TOKEN" = "" ]; then 39 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." 40 | git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git 41 | else 42 | git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git 43 | fi 44 | 45 | fi 46 | 47 | git pull origin master 48 | 49 | # Pushes (Forces) the changes in the local repository up to the remote repository 50 | echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" 51 | git push origin master 2>&1 | grep -v 'To https' 52 | 53 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/checkr/goflagr 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/antihax/optional v1.0.0 7 | golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 8 | ) 9 | -------------------------------------------------------------------------------- /model_constraint.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type Constraint struct { 13 | Id int64 `json:"id,omitempty"` 14 | Property string `json:"property"` 15 | Operator string `json:"operator"` 16 | Value string `json:"value"` 17 | } 18 | -------------------------------------------------------------------------------- /model_create_constraint_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type CreateConstraintRequest struct { 13 | Property string `json:"property"` 14 | Operator string `json:"operator"` 15 | Value string `json:"value"` 16 | } 17 | -------------------------------------------------------------------------------- /model_create_flag_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type CreateFlagRequest struct { 13 | Description string `json:"description"` 14 | // unique key representation of the flag 15 | Key string `json:"key,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /model_create_segment_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type CreateSegmentRequest struct { 13 | Description string `json:"description"` 14 | RolloutPercent int64 `json:"rolloutPercent"` 15 | } 16 | -------------------------------------------------------------------------------- /model_create_variant_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type CreateVariantRequest struct { 13 | Key string `json:"key"` 14 | Attachment *interface{} `json:"attachment,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /model_distribution.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type Distribution struct { 13 | Id int64 `json:"id,omitempty"` 14 | Percent int64 `json:"percent"` 15 | VariantKey string `json:"variantKey"` 16 | VariantID int64 `json:"variantID"` 17 | } 18 | -------------------------------------------------------------------------------- /model_error.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type ModelError struct { 13 | Message string `json:"message"` 14 | } 15 | -------------------------------------------------------------------------------- /model_eval_context.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type EvalContext struct { 13 | // entityID is used to deterministically at random to evaluate the flag result. If it's empty, flagr will randomly generate one. 14 | EntityID string `json:"entityID,omitempty"` 15 | EntityType string `json:"entityType,omitempty"` 16 | EntityContext *interface{} `json:"entityContext,omitempty"` 17 | EnableDebug bool `json:"enableDebug,omitempty"` 18 | // flagID 19 | FlagID int64 `json:"flagID,omitempty"` 20 | // flagKey. flagID or flagKey will resolve to the same flag. Either works. 21 | FlagKey string `json:"flagKey,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /model_eval_debug_log.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type EvalDebugLog struct { 13 | SegmentDebugLogs []SegmentDebugLog `json:"segmentDebugLogs,omitempty"` 14 | Msg string `json:"msg,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /model_eval_result.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type EvalResult struct { 13 | FlagID int64 `json:"flagID,omitempty"` 14 | FlagKey string `json:"flagKey,omitempty"` 15 | FlagSnapshotID int64 `json:"flagSnapshotID,omitempty"` 16 | SegmentID int64 `json:"segmentID,omitempty"` 17 | VariantID int64 `json:"variantID,omitempty"` 18 | VariantKey string `json:"variantKey,omitempty"` 19 | VariantAttachment *interface{} `json:"variantAttachment,omitempty"` 20 | EvalContext *EvalContext `json:"evalContext,omitempty"` 21 | Timestamp string `json:"timestamp,omitempty"` 22 | EvalDebugLog *EvalDebugLog `json:"evalDebugLog,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /model_evaluation_batch_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type EvaluationBatchRequest struct { 13 | Entities []EvaluationEntity `json:"entities"` 14 | EnableDebug bool `json:"enableDebug,omitempty"` 15 | // flagIDs 16 | FlagIDs []int64 `json:"flagIDs,omitempty"` 17 | // flagKeys. Either flagIDs or flagKeys works. If pass in both, Flagr may return duplicate results. 18 | FlagKeys []string `json:"flagKeys,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /model_evaluation_batch_response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type EvaluationBatchResponse struct { 13 | EvaluationResults []EvalResult `json:"evaluationResults"` 14 | } 15 | -------------------------------------------------------------------------------- /model_evaluation_entity.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type EvaluationEntity struct { 13 | EntityID string `json:"entityID,omitempty"` 14 | EntityType string `json:"entityType,omitempty"` 15 | EntityContext *interface{} `json:"entityContext,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /model_flag.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "time" 14 | ) 15 | 16 | type Flag struct { 17 | Id int64 `json:"id,omitempty"` 18 | // unique key representation of the flag 19 | Key string `json:"key,omitempty"` 20 | Description string `json:"description"` 21 | Enabled bool `json:"enabled"` 22 | Segments []Segment `json:"segments,omitempty"` 23 | Variants []Variant `json:"variants,omitempty"` 24 | // enabled data records will get data logging in the metrics pipeline, for example, kafka. 25 | DataRecordsEnabled bool `json:"dataRecordsEnabled"` 26 | // it will override the entityType in the evaluation logs if it's not empty 27 | EntityType string `json:"entityType,omitempty"` 28 | // flag usage details in markdown format 29 | Notes string `json:"notes,omitempty"` 30 | CreatedBy string `json:"createdBy,omitempty"` 31 | UpdatedBy string `json:"updatedBy,omitempty"` 32 | UpdatedAt time.Time `json:"updatedAt,omitempty"` 33 | } 34 | -------------------------------------------------------------------------------- /model_flag_snapshot.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type FlagSnapshot struct { 13 | Id int64 `json:"id"` 14 | UpdatedBy string `json:"updatedBy,omitempty"` 15 | Flag *Flag `json:"flag"` 16 | UpdatedAt string `json:"updatedAt"` 17 | } 18 | -------------------------------------------------------------------------------- /model_health.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type Health struct { 13 | Status string `json:"status,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /model_put_distributions_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type PutDistributionsRequest struct { 13 | Distributions []Distribution `json:"distributions"` 14 | } 15 | -------------------------------------------------------------------------------- /model_put_flag_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type PutFlagRequest struct { 13 | Description string `json:"description,omitempty"` 14 | // enabled data records will get data logging in the metrics pipeline, for example, kafka. 15 | DataRecordsEnabled bool `json:"dataRecordsEnabled,omitempty"` 16 | // it will overwrite entityType into evaluation logs if it's not empty 17 | EntityType string `json:"entityType,omitempty"` 18 | Enabled bool `json:"enabled,omitempty"` 19 | Key string `json:"key,omitempty"` 20 | Notes string `json:"notes,omitempty"` 21 | } 22 | -------------------------------------------------------------------------------- /model_put_segment_reorder_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type PutSegmentReorderRequest struct { 13 | SegmentIDs []int64 `json:"segmentIDs"` 14 | } 15 | -------------------------------------------------------------------------------- /model_put_segment_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type PutSegmentRequest struct { 13 | Description string `json:"description"` 14 | RolloutPercent int64 `json:"rolloutPercent"` 15 | } 16 | -------------------------------------------------------------------------------- /model_put_variant_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type PutVariantRequest struct { 13 | Key string `json:"key"` 14 | Attachment *interface{} `json:"attachment,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /model_segment.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type Segment struct { 13 | Id int64 `json:"id,omitempty"` 14 | Description string `json:"description"` 15 | Constraints []Constraint `json:"constraints,omitempty"` 16 | Distributions []Distribution `json:"distributions,omitempty"` 17 | Rank int64 `json:"rank"` 18 | RolloutPercent int64 `json:"rolloutPercent"` 19 | } 20 | -------------------------------------------------------------------------------- /model_segment_debug_log.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type SegmentDebugLog struct { 13 | SegmentID int64 `json:"segmentID,omitempty"` 14 | Msg string `json:"msg,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /model_set_flag_enabled_request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type SetFlagEnabledRequest struct { 13 | Enabled bool `json:"enabled"` 14 | } 15 | -------------------------------------------------------------------------------- /model_variant.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | type Variant struct { 13 | Id int64 `json:"id,omitempty"` 14 | Key string `json:"key"` 15 | Attachment *interface{} `json:"attachment,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Flagr 3 | * 4 | * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". 5 | * 6 | * API version: 1.1.4 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package goflagr 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | type APIResponse struct { 17 | *http.Response `json:"-"` 18 | Message string `json:"message,omitempty"` 19 | // Operation is the name of the swagger operation. 20 | Operation string `json:"operation,omitempty"` 21 | // RequestURL is the request URL. This value is always available, even if the 22 | // embedded *http.Response is nil. 23 | RequestURL string `json:"url,omitempty"` 24 | // Method is the HTTP method used for the request. This value is always 25 | // available, even if the embedded *http.Response is nil. 26 | Method string `json:"method,omitempty"` 27 | // Payload holds the contents of the response body (which may be nil or empty). 28 | // This is provided here as the raw response.Body() reader will have already 29 | // been drained. 30 | Payload []byte `json:"-"` 31 | } 32 | 33 | func NewAPIResponse(r *http.Response) *APIResponse { 34 | 35 | response := &APIResponse{Response: r} 36 | return response 37 | } 38 | 39 | func NewAPIResponseWithError(errorMessage string) *APIResponse { 40 | 41 | response := &APIResponse{Message: errorMessage} 42 | return response 43 | } 44 | -------------------------------------------------------------------------------- /swagger_go.json: -------------------------------------------------------------------------------- 1 | { 2 | "packageName": "goflagr", 3 | "packageVersion": "1.1.1" 4 | } 5 | -------------------------------------------------------------------------------- /tests/doc.go: -------------------------------------------------------------------------------- 1 | package test 2 | -------------------------------------------------------------------------------- /tests/model_eval_context_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/checkr/goflagr" 7 | ) 8 | 9 | func TestEvalContext(t *testing.T) { 10 | entityContext := interface{}(map[string]string{ 11 | "foo": "bar", 12 | }) 13 | ctx := goflagr.EvalContext{ 14 | EntityID: "123", 15 | EntityType: "type1", 16 | EntityContext: &entityContext, 17 | FlagID: 1, 18 | } 19 | if ctx.EntityContext == nil { 20 | t.Error("empty EvalContext") 21 | } 22 | } 23 | --------------------------------------------------------------------------------