From 0987e665a489211bccbbbaceef4c5a9522556aab Mon Sep 17 00:00:00 2001 From: zhuojie Date: Mon, 2 Dec 2019 13:18:42 -0800 Subject: [PATCH] Bump swagger and add tests --- .circleci/config.yml | 3 +- .swagger-codegen/VERSION | 2 +- Makefile | 8 ++- README.md | 10 ++- api/swagger.yaml | 95 +++++++++++++++++-------- api_constraint.go | 2 +- api_distribution.go | 2 +- api_evaluation.go | 2 +- api_export.go | 102 ++++++++++++++++++++++++++- api_flag.go | 2 +- api_health.go | 48 +++++++++---- api_segment.go | 2 +- api_variant.go | 2 +- client.go | 4 +- configuration.go | 2 +- docs/ExportApi.md | 31 +++++++- docs/Flag.md | 1 + docs/Health.md | 10 +++ docs/HealthApi.md | 4 +- docs/PutFlagRequest.md | 1 + model_constraint.go | 2 +- model_create_constraint_request.go | 2 +- model_create_flag_request.go | 2 +- model_create_segment_request.go | 2 +- model_create_variant_request.go | 2 +- model_distribution.go | 2 +- model_error.go | 2 +- model_eval_context.go | 2 +- model_eval_debug_log.go | 2 +- model_eval_result.go | 2 +- model_evaluation_batch_request.go | 2 +- model_evaluation_batch_response.go | 2 +- model_evaluation_entity.go | 2 +- model_flag.go | 12 ++-- model_flag_snapshot.go | 2 +- model_health.go | 14 ++++ model_put_distributions_request.go | 2 +- model_put_flag_request.go | 3 +- model_put_segment_reorder_request.go | 2 +- model_put_segment_request.go | 2 +- model_put_variant_request.go | 2 +- model_segment.go | 2 +- model_segment_debug_log.go | 2 +- model_set_flag_enabled_request.go | 2 +- model_variant.go | 2 +- response.go | 2 +- swagger.yaml | 36 +++++++++- tests/doc.go | 1 + tests/model_eval_context_test.go | 22 ++++++ 49 files changed, 370 insertions(+), 97 deletions(-) create mode 100644 docs/Health.md create mode 100644 model_health.go create mode 100644 tests/doc.go create mode 100644 tests/model_eval_context_test.go diff --git a/.circleci/config.yml b/.circleci/config.yml index 81ab807..b2405fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,4 +7,5 @@ jobs: steps: - checkout - run: go get -v -t -d ./... - - run: go build -v ./... + - run: make build + - run: make test diff --git a/.swagger-codegen/VERSION b/.swagger-codegen/VERSION index ab6d278..a6c4b4a 100644 --- a/.swagger-codegen/VERSION +++ b/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.4 \ No newline at end of file +2.4.10 \ No newline at end of file diff --git a/Makefile b/Makefile index 0165788..980569a 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,15 @@ gen: rm -rf docs rm -rf api rm README.md - docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli:2.4.4 generate \ + docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli:2.4.10 generate \ -i /local/swagger.yaml \ -l go \ -o /local/ -c /local/swagger_go.json go get golang.org/x/tools/cmd/goimports goimports -w . + +test: + go test -race -covermode=atomic ./tests/... + +build: + go build -v ./... diff --git a/README.md b/README.md index 1a1b922..c0796df 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Flagr is a feature flagging, A/B testing and dynamic configuration microservice. ## Overview 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. -- API version: 1.1.0 +- API version: 1.1.4 - Package version: 1.1.1 - Build package: io.swagger.codegen.languages.GoClientCodegen @@ -29,7 +29,8 @@ Class | Method | HTTP request | Description *DistributionApi* | [**PutDistributions**](docs/DistributionApi.md#putdistributions) | **Put** /flags/{flagID}/segments/{segmentID}/distributions | *EvaluationApi* | [**PostEvaluation**](docs/EvaluationApi.md#postevaluation) | **Post** /evaluation | *EvaluationApi* | [**PostEvaluationBatch**](docs/EvaluationApi.md#postevaluationbatch) | **Post** /evaluation/batch | -*ExportApi* | [**GetExportSQLite**](docs/ExportApi.md#getexportsqlite) | **Get** /export/sqlite | +*ExportApi* | [**GetExportEvalCacheJSON**](docs/ExportApi.md#getexportevalcachejson) | **Get** /export/eval_cache/json | +*ExportApi* | [**GetExportSqlite**](docs/ExportApi.md#getexportsqlite) | **Get** /export/sqlite | *FlagApi* | [**CreateFlag**](docs/FlagApi.md#createflag) | **Post** /flags | *FlagApi* | [**DeleteFlag**](docs/FlagApi.md#deleteflag) | **Delete** /flags/{flagID} | *FlagApi* | [**FindFlags**](docs/FlagApi.md#findflags) | **Get** /flags | @@ -66,6 +67,7 @@ Class | Method | HTTP request | Description - [EvaluationEntity](docs/EvaluationEntity.md) - [Flag](docs/Flag.md) - [FlagSnapshot](docs/FlagSnapshot.md) + - [Health](docs/Health.md) - [ModelError](docs/ModelError.md) - [PutDistributionsRequest](docs/PutDistributionsRequest.md) - [PutFlagRequest](docs/PutFlagRequest.md) @@ -81,4 +83,8 @@ Class | Method | HTTP request | Description ## Documentation For Authorization Endpoints do not require authorization. + ## Author + + + diff --git a/api/swagger.yaml b/api/swagger.yaml index 3d7d4ab..110156b 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -3,7 +3,7 @@ swagger: "2.0" info: description: "Flagr is a feature flagging, A/B testing and dynamic configuration\ \ microservice. The base path for all the APIs is \"/api/v1\".\n" - version: "1.1.0" + version: "1.1.4" title: "Flagr" basePath: "/api/v1" tags: @@ -87,7 +87,7 @@ paths: x-exportParamName: "Preload" x-optionalDataType: "Bool" responses: - 200: + "200": description: "list all the flags" schema: type: "array" @@ -110,7 +110,7 @@ paths: $ref: "#/definitions/createFlagRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "returns the created flag" schema: $ref: "#/definitions/flag" @@ -133,7 +133,7 @@ paths: format: "int64" x-exportParamName: "FlagID" responses: - 200: + "200": description: "returns the flag" schema: $ref: "#/definitions/flag" @@ -162,7 +162,7 @@ paths: $ref: "#/definitions/putFlagRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "returns the flag" schema: $ref: "#/definitions/flag" @@ -184,7 +184,7 @@ paths: format: "int64" x-exportParamName: "FlagID" responses: - 200: + "200": description: "OK deleted" default: description: "generic error response" @@ -212,7 +212,7 @@ paths: $ref: "#/definitions/setFlagEnabledRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "returns the flag" schema: $ref: "#/definitions/flag" @@ -235,7 +235,7 @@ paths: format: "int64" x-exportParamName: "FlagID" responses: - 200: + "200": description: "variant ordered by variantID" schema: type: "array" @@ -266,7 +266,7 @@ paths: $ref: "#/definitions/createVariantRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "variant just created" schema: $ref: "#/definitions/variant" @@ -304,7 +304,7 @@ paths: $ref: "#/definitions/putVariantRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "variant just updated" schema: $ref: "#/definitions/variant" @@ -334,7 +334,7 @@ paths: format: "int64" x-exportParamName: "VariantID" responses: - 200: + "200": description: "deleted" default: description: "generic error response" @@ -355,7 +355,7 @@ paths: format: "int64" x-exportParamName: "FlagID" responses: - 200: + "200": description: "segments ordered by rank of the flag" schema: type: "array" @@ -386,7 +386,7 @@ paths: $ref: "#/definitions/createSegmentRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "segment created" schema: $ref: "#/definitions/segment" @@ -416,7 +416,7 @@ paths: $ref: "#/definitions/putSegmentReorderRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "segments reordered" default: description: "generic error response" @@ -452,7 +452,7 @@ paths: $ref: "#/definitions/putSegmentRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "segment updated" schema: $ref: "#/definitions/segment" @@ -482,7 +482,7 @@ paths: format: "int64" x-exportParamName: "SegmentID" responses: - 200: + "200": description: "deleted" default: description: "generic error response" @@ -511,7 +511,7 @@ paths: format: "int64" x-exportParamName: "SegmentID" responses: - 200: + "200": description: "constraints under the segment" schema: type: "array" @@ -550,7 +550,7 @@ paths: $ref: "#/definitions/createConstraintRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "the constraint created" schema: $ref: "#/definitions/constraint" @@ -596,7 +596,7 @@ paths: $ref: "#/definitions/createConstraintRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "constraint just updated" schema: $ref: "#/definitions/constraint" @@ -634,7 +634,7 @@ paths: format: "int64" x-exportParamName: "ConstraintID" responses: - 200: + "200": description: "deleted" default: description: "generic error response" @@ -663,7 +663,7 @@ paths: format: "int64" x-exportParamName: "SegmentID" responses: - 200: + "200": description: "distribution under the segment" schema: type: "array" @@ -703,7 +703,7 @@ paths: $ref: "#/definitions/putDistributionsRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "distribution under the segment" schema: type: "array" @@ -728,7 +728,7 @@ paths: format: "int64" x-exportParamName: "FlagID" responses: - 200: + "200": description: "returns the flag snapshots" schema: type: "array" @@ -745,7 +745,7 @@ paths: operationId: "getFlagEntityTypes" parameters: [] responses: - 200: + "200": description: "returns all the FlagEntityTypes" schema: type: "array" @@ -770,7 +770,7 @@ paths: $ref: "#/definitions/evalContext" x-exportParamName: "Body" responses: - 200: + "200": description: "evaluation result" schema: $ref: "#/definitions/evalResult" @@ -792,7 +792,7 @@ paths: $ref: "#/definitions/evaluationBatchRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "evaluation batch result" schema: $ref: "#/definitions/evaluationBatchResponse" @@ -808,8 +808,10 @@ paths: operationId: "getHealth" parameters: [] responses: - 200: - description: "OK" + "200": + description: "status of health check" + schema: + $ref: "#/definitions/health" default: description: "generic error response" schema: @@ -820,12 +822,12 @@ paths: - "export" description: "Export sqlite3 format of the db dump, which is converted from\ \ the main database." - operationId: "getExportSQLite" + operationId: "getExportSqlite" produces: - "application/octet-stream" parameters: [] responses: - 200: + "200": description: "OK" schema: type: "file" @@ -833,6 +835,24 @@ paths: description: "generic error response" schema: $ref: "#/definitions/error" + /export/eval_cache/json: + get: + tags: + - "export" + description: "Export JSON format of the eval cache dump" + operationId: "getExportEvalCacheJSON" + produces: + - "application/json" + parameters: [] + responses: + "200": + description: "OK" + schema: + type: "object" + default: + description: "generic error response" + schema: + $ref: "#/definitions/error" definitions: flag: type: "object" @@ -871,6 +891,9 @@ definitions: type: "string" description: "it will override the entityType in the evaluation logs if it's\ \ not empty" + notes: + type: "string" + description: "flag usage details in markdown format" createdBy: type: "string" updatedBy: @@ -879,6 +902,7 @@ definitions: type: "string" format: "date-time" example: + notes: "notes" updatedBy: "updatedBy" dataRecordsEnabled: true createdBy: "createdBy" @@ -974,6 +998,9 @@ definitions: key: type: "string" x-nullable: true + notes: + type: "string" + x-nullable: true setFlagEnabledRequest: type: "object" required: @@ -1002,6 +1029,7 @@ definitions: example: updatedBy: "updatedBy" flag: + notes: "notes" updatedBy: "updatedBy" dataRecordsEnabled: true createdBy: "createdBy" @@ -1497,6 +1525,13 @@ definitions: variantKey: "variantKey" flagKey: "flagKey" timestamp: "timestamp" + health: + type: "object" + properties: + status: + type: "string" + example: + status: "status" error: type: "object" required: diff --git a/api_constraint.go b/api_constraint.go index bc24be5..b7f39e9 100644 --- a/api_constraint.go +++ b/api_constraint.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/api_distribution.go b/api_distribution.go index 10c9a11..6e650d4 100644 --- a/api_distribution.go +++ b/api_distribution.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/api_evaluation.go b/api_evaluation.go index 5de111c..186c97e 100644 --- a/api_evaluation.go +++ b/api_evaluation.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/api_export.go b/api_export.go index 1dc0f40..a43d0b3 100644 --- a/api_export.go +++ b/api_export.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ @@ -25,6 +25,104 @@ var ( type ExportApiService service +/* +ExportApiService +Export JSON format of the eval cache dump + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return interface{} +*/ +func (a *ExportApiService) GetExportEvalCacheJSON(ctx context.Context) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/export/eval_cache/json" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 0 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + /* ExportApiService Export sqlite3 format of the db dump, which is converted from the main database. @@ -32,7 +130,7 @@ Export sqlite3 format of the db dump, which is converted from the main database. @return *os.File */ -func (a *ExportApiService) GetExportSQLite(ctx context.Context) (*os.File, *http.Response, error) { +func (a *ExportApiService) GetExportSqlite(ctx context.Context) (*os.File, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} diff --git a/api_flag.go b/api_flag.go index 4dcd080..385051f 100644 --- a/api_flag.go +++ b/api_flag.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/api_health.go b/api_health.go index 3b958af..38c9fa9 100644 --- a/api_health.go +++ b/api_health.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ @@ -29,14 +29,15 @@ HealthApiService Check if Flagr is healthy * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - +@return Health */ -func (a *HealthApiService) GetHealth(ctx context.Context) (*http.Response, error) { +func (a *HealthApiService) GetHealth(ctx context.Context) (Health, *http.Response, error) { var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Health ) // create path and map variables @@ -65,18 +66,26 @@ func (a *HealthApiService) GetHealth(ctx context.Context) (*http.Response, error } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { - return localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } if localVarHttpResponse.StatusCode >= 300 { @@ -85,19 +94,30 @@ func (a *HealthApiService) GetHealth(ctx context.Context) (*http.Response, error error: localVarHttpResponse.Status, } + if localVarHttpResponse.StatusCode == 200 { + var v Health + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + if localVarHttpResponse.StatusCode == 0 { var v ModelError err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) if err != nil { newErr.error = err.Error() - return localVarHttpResponse, newErr + return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v - return localVarHttpResponse, newErr + return localVarReturnValue, localVarHttpResponse, newErr } - return localVarHttpResponse, newErr + return localVarReturnValue, localVarHttpResponse, newErr } - return localVarHttpResponse, nil + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/api_segment.go b/api_segment.go index 009d42d..eb43eec 100644 --- a/api_segment.go +++ b/api_segment.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/api_variant.go b/api_variant.go index d54eebb..cedf41d 100644 --- a/api_variant.go +++ b/api_variant.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/client.go b/client.go index 4ee560a..08a5825 100644 --- a/client.go +++ b/client.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ @@ -37,7 +37,7 @@ var ( xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) -// APIClient manages communication with the Flagr API v1.1.0 +// APIClient manages communication with the Flagr API v1.1.4 // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration diff --git a/configuration.go b/configuration.go index 9f7f278..2511926 100644 --- a/configuration.go +++ b/configuration.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/docs/ExportApi.md b/docs/ExportApi.md index 1de16be..2413fb4 100644 --- a/docs/ExportApi.md +++ b/docs/ExportApi.md @@ -4,11 +4,36 @@ All URIs are relative to *http://localhost/api/v1* Method | HTTP request | Description ------------- | ------------- | ------------- -[**GetExportSQLite**](ExportApi.md#GetExportSQLite) | **Get** /export/sqlite | +[**GetExportEvalCacheJSON**](ExportApi.md#GetExportEvalCacheJSON) | **Get** /export/eval_cache/json | +[**GetExportSqlite**](ExportApi.md#GetExportSqlite) | **Get** /export/sqlite | -# **GetExportSQLite** -> *os.File GetExportSQLite(ctx, ) +# **GetExportEvalCacheJSON** +> interface{} GetExportEvalCacheJSON(ctx, ) + + +Export JSON format of the eval cache dump + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**interface{}**](interface{}.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[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) + +# **GetExportSqlite** +> *os.File GetExportSqlite(ctx, ) Export sqlite3 format of the db dump, which is converted from the main database. diff --git a/docs/Flag.md b/docs/Flag.md index 4ee7d01..65ebe94 100644 --- a/docs/Flag.md +++ b/docs/Flag.md @@ -11,6 +11,7 @@ Name | Type | Description | Notes **Variants** | [**[]Variant**](variant.md) | | [optional] [default to null] **DataRecordsEnabled** | **bool** | enabled data records will get data logging in the metrics pipeline, for example, kafka. | [default to null] **EntityType** | **string** | it will override the entityType in the evaluation logs if it's not empty | [optional] [default to null] +**Notes** | **string** | flag usage details in markdown format | [optional] [default to null] **CreatedBy** | **string** | | [optional] [default to null] **UpdatedBy** | **string** | | [optional] [default to null] **UpdatedAt** | [**time.Time**](time.Time.md) | | [optional] [default to null] diff --git a/docs/Health.md b/docs/Health.md new file mode 100644 index 0000000..4a841f5 --- /dev/null +++ b/docs/Health.md @@ -0,0 +1,10 @@ +# Health + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Status** | **string** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/HealthApi.md b/docs/HealthApi.md index fba022b..45e8a38 100644 --- a/docs/HealthApi.md +++ b/docs/HealthApi.md @@ -8,7 +8,7 @@ Method | HTTP request | Description # **GetHealth** -> GetHealth(ctx, ) +> Health GetHealth(ctx, ) Check if Flagr is healthy @@ -18,7 +18,7 @@ This endpoint does not need any parameter. ### Return type - (empty response body) +[**Health**](health.md) ### Authorization diff --git a/docs/PutFlagRequest.md b/docs/PutFlagRequest.md index 1375749..f028cb8 100644 --- a/docs/PutFlagRequest.md +++ b/docs/PutFlagRequest.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **EntityType** | **string** | it will overwrite entityType into evaluation logs if it's not empty | [optional] [default to null] **Enabled** | **bool** | | [optional] [default to null] **Key** | **string** | | [optional] [default to null] +**Notes** | **string** | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/model_constraint.go b/model_constraint.go index 478f28d..269766d 100644 --- a/model_constraint.go +++ b/model_constraint.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_create_constraint_request.go b/model_create_constraint_request.go index 621024e..8c83ac5 100644 --- a/model_create_constraint_request.go +++ b/model_create_constraint_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_create_flag_request.go b/model_create_flag_request.go index 3012d5b..1a7e0a0 100644 --- a/model_create_flag_request.go +++ b/model_create_flag_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_create_segment_request.go b/model_create_segment_request.go index edaa910..70e4603 100644 --- a/model_create_segment_request.go +++ b/model_create_segment_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_create_variant_request.go b/model_create_variant_request.go index 6a7fc62..676f0d2 100644 --- a/model_create_variant_request.go +++ b/model_create_variant_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_distribution.go b/model_distribution.go index b843881..fe65bab 100644 --- a/model_distribution.go +++ b/model_distribution.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_error.go b/model_error.go index 09fbff3..9be738b 100644 --- a/model_error.go +++ b/model_error.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_eval_context.go b/model_eval_context.go index 2d78223..857c631 100644 --- a/model_eval_context.go +++ b/model_eval_context.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_eval_debug_log.go b/model_eval_debug_log.go index e8904d5..5677566 100644 --- a/model_eval_debug_log.go +++ b/model_eval_debug_log.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_eval_result.go b/model_eval_result.go index 082ac13..c9b29e5 100644 --- a/model_eval_result.go +++ b/model_eval_result.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_evaluation_batch_request.go b/model_evaluation_batch_request.go index 8d99ee4..3461b58 100644 --- a/model_evaluation_batch_request.go +++ b/model_evaluation_batch_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_evaluation_batch_response.go b/model_evaluation_batch_response.go index c9e617d..f2be301 100644 --- a/model_evaluation_batch_response.go +++ b/model_evaluation_batch_response.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_evaluation_entity.go b/model_evaluation_entity.go index f0d9f31..5b49453 100644 --- a/model_evaluation_entity.go +++ b/model_evaluation_entity.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_flag.go b/model_flag.go index 9526ac2..02bc660 100644 --- a/model_flag.go +++ b/model_flag.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ @@ -24,8 +24,10 @@ type Flag struct { // enabled data records will get data logging in the metrics pipeline, for example, kafka. DataRecordsEnabled bool `json:"dataRecordsEnabled"` // it will override the entityType in the evaluation logs if it's not empty - EntityType string `json:"entityType,omitempty"` - CreatedBy string `json:"createdBy,omitempty"` - UpdatedBy string `json:"updatedBy,omitempty"` - UpdatedAt time.Time `json:"updatedAt,omitempty"` + EntityType string `json:"entityType,omitempty"` + // flag usage details in markdown format + Notes string `json:"notes,omitempty"` + CreatedBy string `json:"createdBy,omitempty"` + UpdatedBy string `json:"updatedBy,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty"` } diff --git a/model_flag_snapshot.go b/model_flag_snapshot.go index 64c62b8..46a911b 100644 --- a/model_flag_snapshot.go +++ b/model_flag_snapshot.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_health.go b/model_health.go new file mode 100644 index 0000000..2545d4e --- /dev/null +++ b/model_health.go @@ -0,0 +1,14 @@ +/* + * Flagr + * + * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". + * + * API version: 1.1.4 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package goflagr + +type Health struct { + Status string `json:"status,omitempty"` +} diff --git a/model_put_distributions_request.go b/model_put_distributions_request.go index 37639f1..deffc41 100644 --- a/model_put_distributions_request.go +++ b/model_put_distributions_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_put_flag_request.go b/model_put_flag_request.go index 8d989a4..6e86a41 100644 --- a/model_put_flag_request.go +++ b/model_put_flag_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ @@ -17,4 +17,5 @@ type PutFlagRequest struct { EntityType string `json:"entityType,omitempty"` Enabled bool `json:"enabled,omitempty"` Key string `json:"key,omitempty"` + Notes string `json:"notes,omitempty"` } diff --git a/model_put_segment_reorder_request.go b/model_put_segment_reorder_request.go index 752e788..63da1e1 100644 --- a/model_put_segment_reorder_request.go +++ b/model_put_segment_reorder_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_put_segment_request.go b/model_put_segment_request.go index 458bbe6..1cec812 100644 --- a/model_put_segment_request.go +++ b/model_put_segment_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_put_variant_request.go b/model_put_variant_request.go index f2804ad..b1921bf 100644 --- a/model_put_variant_request.go +++ b/model_put_variant_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_segment.go b/model_segment.go index 45a5088..bfb23ba 100644 --- a/model_segment.go +++ b/model_segment.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_segment_debug_log.go b/model_segment_debug_log.go index 287e9a4..6f109fa 100644 --- a/model_segment_debug_log.go +++ b/model_segment_debug_log.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_set_flag_enabled_request.go b/model_set_flag_enabled_request.go index d49803f..3c8cac7 100644 --- a/model_set_flag_enabled_request.go +++ b/model_set_flag_enabled_request.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/model_variant.go b/model_variant.go index d313b88..6dedcc2 100644 --- a/model_variant.go +++ b/model_variant.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/response.go b/response.go index c0c5d7b..fdc7a82 100644 --- a/response.go +++ b/response.go @@ -3,7 +3,7 @@ * * Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is \"/api/v1\". * - * API version: 1.1.0 + * API version: 1.1.4 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ diff --git a/swagger.yaml b/swagger.yaml index 7827f9c..da6dcb3 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -4,7 +4,7 @@ info: Flagr is a feature flagging, A/B testing and dynamic configuration microservice. The base path for all the APIs is "/api/v1". title: Flagr - version: 1.1.0 + version: 1.1.4 tags: - name: flag description: Everything about the flag @@ -759,7 +759,9 @@ paths: description: Check if Flagr is healthy responses: '200': - description: OK + description: status of health check + schema: + $ref: '#/definitions/health' default: description: generic error response schema: @@ -768,7 +770,7 @@ paths: get: tags: - export - operationId: getExportSQLite + operationId: getExportSqlite description: >- Export sqlite3 format of the db dump, which is converted from the main database. @@ -783,6 +785,23 @@ paths: description: generic error response schema: $ref: '#/definitions/error' + /export/eval_cache/json: + get: + tags: + - export + operationId: getExportEvalCacheJSON + description: Export JSON format of the eval cache dump + produces: + - application/json + responses: + '200': + description: OK + schema: + type: object + default: + description: generic error response + schema: + $ref: '#/definitions/error' definitions: flag: type: object @@ -823,6 +842,9 @@ definitions: it will override the entityType in the evaluation logs if it's not empty type: string + notes: + description: flag usage details in markdown format + type: string createdBy: type: string updatedBy: @@ -864,6 +886,9 @@ definitions: key: type: string x-nullable: true + notes: + type: string + x-nullable: true setFlagEnabledRequest: type: object required: @@ -1195,6 +1220,11 @@ definitions: type: array items: $ref: '#/definitions/evalResult' + health: + type: object + properties: + status: + type: string error: type: object required: diff --git a/tests/doc.go b/tests/doc.go new file mode 100644 index 0000000..56e5404 --- /dev/null +++ b/tests/doc.go @@ -0,0 +1 @@ +package test diff --git a/tests/model_eval_context_test.go b/tests/model_eval_context_test.go new file mode 100644 index 0000000..6388d43 --- /dev/null +++ b/tests/model_eval_context_test.go @@ -0,0 +1,22 @@ +package test + +import ( + "testing" + + "github.com/checkr/goflagr" +) + +func TestEvalContext(t *testing.T) { + entityContext := interface{}(map[string]string{ + "foo": "bar", + }) + ctx := goflagr.EvalContext{ + EntityID: "123", + EntityType: "type1", + EntityContext: &entityContext, + FlagID: 1, + } + if ctx.EntityContext == nil { + t.Error("empty EvalContext") + } +}