From 420f1f74d20722a291a3def9619045a2575035c5 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 28 Sep 2020 16:06:44 -0600 Subject: [PATCH 01/11] docs: edits for velociraptor & decide releases --- CHANGELOG.md | 16 ++++++++-------- api/openapi-spec/openapi.yaml | 18 +++++++++--------- .../010 - optimizely-agent.md | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 287aa342..1067da6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,14 +26,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - If there is a need to deploy Agent in docker, then the Host needs to be set to 0.0.0.0. This can be achieved by setting variable `OPTIMIZELY_SERVER_HOST=0.0.0.0`, or setting `server.host` to 0.0.0.0 in config file. ## [1.3.0] - July 7th, 2020 -- Upgrade to use go-sdk v1.3.0. This adds support for JSON feature variables +- Upgrade to use go-sdk v1.3.0. This adds support for JSON flag variables - Add /debug/pprof endpoints to the admin service - Run docker container as non root user - Log warnings when HTTPS and authorization are not enabled via configuration ## [1.2.0] - June 18th, 2020 - Expose event dispatch URL as a config parameter -- Return experimentKey and variationKey with feature test decisions +- Return experimentKey and variationKey with experiment decisions - Expose health endpoint for all listeners - Update API docs - Streamline CI stages @@ -85,7 +85,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Improve build tooling - Add standard metrics registry - Update documentation -- Return 404 when feature or experiment are not found +- Return 404 when flag or experiment are not found - Update event payloads to include Agent name and version ## [0.10.0] - January 9th, 2020 @@ -100,9 +100,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Add metric visibility into event dispatcher - Miscellaneous clean-up and of docs and openapi spec - Add top level config package to consolidate configuration -- Incorporate OptimizelyConfig into feature and experiment models +- Incorporate OptimizelyConfig into flag and experiment models - Add get experiment and list experiment endpoints -- Add user features endpoint for batched decision responses +- Add user flag endpoint for batched decision responses - Add windows tooling - Add credit section to README - Improve service shutdown @@ -133,8 +133,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Actually enable the impression tracking endpoint in the router ## [0.5.0] - October 24th, 2019 -- Adds GET endpoint for user-based features -- Adds impression tracking for Feature Tests +- Adds GET endpoint for user-based flag +- Adds impression tracking for Feature Tests (referred to as "A/B tests" after Nov 2020) ## [0.4.0] - October 23rd, 2019 - Adds admin endpoints for health, info and metrics @@ -152,7 +152,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.2.0] - October 3rd, 2019 - Adds Optimizely webhook support -- Adds full Feature MGMT support +- Adds full flag MGMT support - Adds NSQ for UserEvent message transport - Adds support for multiple concurrent SDK keys diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index 55683b15..b8303376 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Optimizely Agent API - description: Optimizely Agent is a stand-alone, open-source microservice that provides major benefits over using Optimizely SDKs in certain use cases. Its REST API offers consolidated and simplified endpoints for accessing all the functionality of Optimizely Full Stack SDKs. Use this API the control experiments (such as a feature tests). For more info, see https://docs.developers.optimizely.com/full-stack/docs/optimizely-agent. + description: Optimizely Agent is a stand-alone, open-source microservice that provides major benefits over using Optimizely SDKs in certain use cases. Its REST API offers consolidated and simplified endpoints for accessing all the functionality of Optimizely Full Stack SDKs. Use this API the control experiments (such as a A/B tests). For more info, see https://docs.developers.optimizely.com/full-stack/docs/optimizely-agent. termsOfService: http://optimizely.com/terms/ license: name: Apache 2.0 @@ -15,7 +15,7 @@ paths: get: summary: Return the Optimizely config for the given environment operationId: getConfig - description: Return all available experiment and features definitions for this environment. + description: Return all available flag rules and their configurations for this environment. responses: '200': description: Valid response @@ -54,9 +54,9 @@ paths: - $ref: '#/components/parameters/typeParam' - $ref: '#/components/parameters/enabledParam' post: - summary: Activate selected features and experiments for the given user. + summary: Activate selected flag rules for the given user. operationId: activate - description: Returns Optimizely's decision about which features and experiments a given user is exposed to. Optionally sends an impression event to the Optimizely analytics backend for any decision made for an experiment. This endpoint consolidates key functionality from the Full Stack SDKs into one convenient call. + description: Returns Optimizely's decision about which flag rules a given user is exposed to. Optionally sends an impression event to the Optimizely analytics backend for any decision made for an experiment. This endpoint consolidates key functionality from the Full Stack SDKs into one convenient call. responses: '200': description: Valid response @@ -161,7 +161,7 @@ components: featureKeyParam: in: query name: featureKey - description: Key for the Optimizely Feature + description: Key for the Optimizely flag schema: type: array items: @@ -170,7 +170,7 @@ components: in: query name: type required: false - description: Limit the decisions to either experiment or features + description: Limit the decisions to a type of flag rule -- either experiments or deliveries ("features") schema: type: string enum: @@ -462,8 +462,8 @@ components: body: [ { "enabled": true, - "experimentKey": "new_feature_test", - "featureKey": "new_feature", + "experimentKey": "new_ab_test", + "featureKey": "new_flag", "type": "feature", "userId": "user1", "variables": { @@ -477,7 +477,7 @@ components: { "enabled": false, "experimentKey": "flag_test_2", - "featureKey": "test_feature", + "featureKey": "test_flag", "type": "feature", "userId": "user1", "variables": { diff --git a/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md b/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md index 5bdadc3c..8fa0edc2 100644 --- a/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md +++ b/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md @@ -32,7 +32,7 @@ Now *with* Agent, instead of installing the SDK six times, you create just one O ## 2. Standardize Access Across Teams If you want to deploy Optimizely Full Stack once, then roll out the single implementation across a large number of teams, we recommend using Optimizely Agent. -By standardizing your teams' access to the Optimizely service, you can better enforce processes and implement governance around feature management and experimentation as a practice. +By standardizing your teams' access to the Optimizely service, you can better enforce processes and implement governance around flag management and experimentation as a practice. !["A diagram showing the central and standardized access to the Optimizely Agent service across an arbitrary number of teams.\n(Click to Enlarge)"](https://raw.githubusercontent.com/optimizely/agent/master/docs/images/agent-standardized-access.png) @@ -59,7 +59,7 @@ If time to provide bucketing decisions is a primary concern for you, you may wan If your app is constructed as a monolith, embedded SDKs might be easier to install and might be a more natural fit for your application and development practices. ## 3. Velocity -If you’re looking for the fastest way to get a single team up and running with deploying feature management and experimentation, embedding an SDK is the best option for you at first. You can always start using Optimizely Agent later, and it can even be used alongside Optimizely Full Stack SDKs running in another part of your stack. +If you’re looking for the fastest way to get a single team up and running with deploying flag management and experimentation, embedding an SDK is the best option for you at first. You can always start using Optimizely Agent later, and it can even be used alongside Optimizely Full Stack SDKs running in another part of your stack. # Best Practices While every implementation is different, you can review this section of best practices for tips on these commonly discussed topics. From 50d63fa11ad65d908a619f0844a2a7c55dce47e4 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 28 Sep 2020 16:13:12 -0600 Subject: [PATCH 02/11] docs: replace 'feature' with 'flag' done w 1st pass of replace 'feature' --- .../030 - use-optimizely-agent/index.md | 2 +- examples/README.md | 2 +- examples/advanced.py | 2 +- examples/notifications.py | 2 +- pkg/optimizely/optimizelytest/client.go | 2 +- pkg/optimizely/optimizelytest/config.go | 2 +- tests/acceptance/test_acceptance/test_config.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md b/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md index 49689aca..eb9a2335 100644 --- a/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md +++ b/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md @@ -11,7 +11,7 @@ updatedAt: "2020-04-08T21:26:30.308Z" Optimizely Agent provides [APIs](https://library.optimizely.com/docs/api/agent/v1/index.html) that enable experimentation and feature management. Agent provides equivalent functionality to all our SDKs. At its core is the [Optimizely Go SDK](doc:go-sdk). In some cases, however, we’ve updated our APIs to simplify key use cases. -### Manage features +### Manage flags Optimizely Agent simplifies the core feature management of our [SDK APIs](doc:sdk-reference-guides). It consolidates the following endpoints: diff --git a/examples/README.md b/examples/README.md index aad0b718..05975fcc 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,6 +1,6 @@ ## Optimizely Agent Examples -This folder provides a set of sample scripts to illustrate some of the main API features. Most of the examples below +This folder provides a set of sample scripts to illustrate some of the main API use cases. Most of the examples below require an SDK key `` as one of the arguments. The SDK key can be found in the settings of your Optimizely Full Stack or Rollouts account. diff --git a/examples/advanced.py b/examples/advanced.py index ef478ed3..fee6d22d 100644 --- a/examples/advanced.py +++ b/examples/advanced.py @@ -14,7 +14,7 @@ s = requests.Session() s.headers.update({'X-Optimizely-SDK-Key': sdk_key}) -# Making a request to /config to generically pull the set of features and experiments. +# Making a request to /config to generically pull the set of flag rules (deliveries and experiments). # In production, making this initial request to build the set of keys would not be recommended. # Instead the keys would already be known by the application, or we'd use the type= parameter illustrated below. resp = s.get('http://localhost:8080/v1/config') diff --git a/examples/notifications.py b/examples/notifications.py index 309660eb..269559d0 100644 --- a/examples/notifications.py +++ b/examples/notifications.py @@ -40,7 +40,7 @@ def print_notifications(sdk_key): } } -# Activate features and experiments - these will trigger notifications that will be sent to notification event stream +# Activate flag rules (deliveries and experiments) - these will trigger notifications that will be sent to notification event stream # subscribers for key in env['featuresMap']: diff --git a/pkg/optimizely/optimizelytest/client.go b/pkg/optimizely/optimizelytest/client.go index 6a187ae6..4a8cb676 100644 --- a/pkg/optimizely/optimizelytest/client.go +++ b/pkg/optimizely/optimizelytest/client.go @@ -60,7 +60,7 @@ func (t *TestClient) AddEvent(e entities.Event) { t.ProjectConfig.AddEvent(e) } -// AddFeature is a helper method for adding features to the ProjectConfig to facilitate testing. +// AddFeature is a helper method for adding flags to the ProjectConfig to facilitate testing. func (t TestClient) AddFeature(f entities.Feature) { t.ProjectConfig.AddFeature(f) } diff --git a/pkg/optimizely/optimizelytest/config.go b/pkg/optimizely/optimizelytest/config.go index f790cbf5..e283b6ef 100644 --- a/pkg/optimizely/optimizelytest/config.go +++ b/pkg/optimizely/optimizelytest/config.go @@ -118,7 +118,7 @@ func (c *TestProjectConfig) GetAttributeByKey(key string) (entities.Attribute, e return entities.Attribute{}, errors.New(errMessage) } -// GetFeatureList returns an array of all the features +// GetFeatureList returns an array of all the flags func (c *TestProjectConfig) GetFeatureList() (featureList []entities.Feature) { for _, feature := range c.FeatureMap { featureList = append(featureList, feature) diff --git a/tests/acceptance/test_acceptance/test_config.py b/tests/acceptance/test_acceptance/test_config.py index 874c7fe3..b20560dc 100644 --- a/tests/acceptance/test_acceptance/test_config.py +++ b/tests/acceptance/test_acceptance/test_config.py @@ -129,7 +129,7 @@ def test_config(session_obj): """ - Test validates all returned available experiment and features definitions + Test validates all returned available flag rule definitions (deliveries and experiments) for this environment. Note: Test will fail as soon as anything in the response body is modified. From 9feb1c7b235572570e86a181944e4350654345ad Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Thu, 15 Oct 2020 11:16:54 -0600 Subject: [PATCH 03/11] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1067da6d..e76a466a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,7 +134,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.5.0] - October 24th, 2019 - Adds GET endpoint for user-based flag -- Adds impression tracking for Feature Tests (referred to as "A/B tests" after Nov 2020) +- Adds impression tracking for feature tests (referred to as "A/B tests" after Nov 2020) ## [0.4.0] - October 23rd, 2019 - Adds admin endpoints for health, info and metrics From b8b4075ba266dfe7fd853b830d4e4dcd2ff351ab Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 28 Sep 2020 16:06:44 -0600 Subject: [PATCH 04/11] docs: edits for velociraptor & decide releases --- CHANGELOG.md | 16 ++++++++-------- api/openapi-spec/openapi.yaml | 18 +++++++++--------- .../010 - optimizely-agent.md | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c748402..beea79bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,14 +35,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - If there is a need to deploy Agent in docker, then the Host needs to be set to 0.0.0.0. This can be achieved by setting variable `OPTIMIZELY_SERVER_HOST=0.0.0.0`, or setting `server.host` to 0.0.0.0 in config file. ## [1.3.0] - July 7th, 2020 -- Upgrade to use go-sdk v1.3.0. This adds support for JSON feature variables +- Upgrade to use go-sdk v1.3.0. This adds support for JSON flag variables - Add /debug/pprof endpoints to the admin service - Run docker container as non root user - Log warnings when HTTPS and authorization are not enabled via configuration ## [1.2.0] - June 18th, 2020 - Expose event dispatch URL as a config parameter -- Return experimentKey and variationKey with feature test decisions +- Return experimentKey and variationKey with experiment decisions - Expose health endpoint for all listeners - Update API docs - Streamline CI stages @@ -94,7 +94,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Improve build tooling - Add standard metrics registry - Update documentation -- Return 404 when feature or experiment are not found +- Return 404 when flag or experiment are not found - Update event payloads to include Agent name and version ## [0.10.0] - January 9th, 2020 @@ -109,9 +109,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Add metric visibility into event dispatcher - Miscellaneous clean-up and of docs and openapi spec - Add top level config package to consolidate configuration -- Incorporate OptimizelyConfig into feature and experiment models +- Incorporate OptimizelyConfig into flag and experiment models - Add get experiment and list experiment endpoints -- Add user features endpoint for batched decision responses +- Add user flag endpoint for batched decision responses - Add windows tooling - Add credit section to README - Improve service shutdown @@ -142,8 +142,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Actually enable the impression tracking endpoint in the router ## [0.5.0] - October 24th, 2019 -- Adds GET endpoint for user-based features -- Adds impression tracking for Feature Tests +- Adds GET endpoint for user-based flag +- Adds impression tracking for Feature Tests (referred to as "A/B tests" after Nov 2020) ## [0.4.0] - October 23rd, 2019 - Adds admin endpoints for health, info and metrics @@ -161,7 +161,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.2.0] - October 3rd, 2019 - Adds Optimizely webhook support -- Adds full Feature MGMT support +- Adds full flag MGMT support - Adds NSQ for UserEvent message transport - Adds support for multiple concurrent SDK keys diff --git a/api/openapi-spec/openapi.yaml b/api/openapi-spec/openapi.yaml index 10daaf8e..a42fd3e1 100644 --- a/api/openapi-spec/openapi.yaml +++ b/api/openapi-spec/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Optimizely Agent API - description: Optimizely Agent is a stand-alone, open-source microservice that provides major benefits over using Optimizely SDKs in certain use cases. Its REST API offers consolidated and simplified endpoints for accessing all the functionality of Optimizely Full Stack SDKs. Use this API the control experiments (such as a feature tests). For more info, see https://docs.developers.optimizely.com/full-stack/docs/optimizely-agent. + description: Optimizely Agent is a stand-alone, open-source microservice that provides major benefits over using Optimizely SDKs in certain use cases. Its REST API offers consolidated and simplified endpoints for accessing all the functionality of Optimizely Full Stack SDKs. Use this API the control experiments (such as a A/B tests). For more info, see https://docs.developers.optimizely.com/full-stack/docs/optimizely-agent. termsOfService: http://optimizely.com/terms/ license: name: Apache 2.0 @@ -15,7 +15,7 @@ paths: get: summary: Return the Optimizely config for the given environment operationId: getConfig - description: Return all available experiment and features definitions for this environment. + description: Return all available flag rules and their configurations for this environment. responses: '200': description: Valid response @@ -54,9 +54,9 @@ paths: - $ref: '#/components/parameters/typeParam' - $ref: '#/components/parameters/enabledParam' post: - summary: Activate selected features and experiments for the given user. + summary: Activate selected flag rules for the given user. operationId: activate - description: Returns Optimizely's decision about which features and experiments a given user is exposed to. Optionally sends an impression event to the Optimizely analytics backend for any decision made for an experiment. This endpoint consolidates key functionality from the Full Stack SDKs into one convenient call. + description: Returns Optimizely's decision about which flag rules a given user is exposed to. Optionally sends an impression event to the Optimizely analytics backend for any decision made for an experiment. This endpoint consolidates key functionality from the Full Stack SDKs into one convenient call. responses: '200': description: Valid response @@ -161,7 +161,7 @@ components: featureKeyParam: in: query name: featureKey - description: Key for the Optimizely Feature + description: Key for the Optimizely flag schema: type: array items: @@ -170,7 +170,7 @@ components: in: query name: type required: false - description: Limit the decisions to either experiment or features + description: Limit the decisions to a type of flag rule -- either experiments or deliveries ("features") schema: type: string enum: @@ -466,8 +466,8 @@ components: body: [ { "enabled": true, - "experimentKey": "new_feature_test", - "featureKey": "new_feature", + "experimentKey": "new_ab_test", + "featureKey": "new_flag", "type": "feature", "userId": "user1", "variables": { @@ -481,7 +481,7 @@ components: { "enabled": false, "experimentKey": "flag_test_2", - "featureKey": "test_feature", + "featureKey": "test_flag", "type": "feature", "userId": "user1", "variables": { diff --git a/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md b/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md index 5bdadc3c..8fa0edc2 100644 --- a/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md +++ b/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md @@ -32,7 +32,7 @@ Now *with* Agent, instead of installing the SDK six times, you create just one O ## 2. Standardize Access Across Teams If you want to deploy Optimizely Full Stack once, then roll out the single implementation across a large number of teams, we recommend using Optimizely Agent. -By standardizing your teams' access to the Optimizely service, you can better enforce processes and implement governance around feature management and experimentation as a practice. +By standardizing your teams' access to the Optimizely service, you can better enforce processes and implement governance around flag management and experimentation as a practice. !["A diagram showing the central and standardized access to the Optimizely Agent service across an arbitrary number of teams.\n(Click to Enlarge)"](https://raw.githubusercontent.com/optimizely/agent/master/docs/images/agent-standardized-access.png) @@ -59,7 +59,7 @@ If time to provide bucketing decisions is a primary concern for you, you may wan If your app is constructed as a monolith, embedded SDKs might be easier to install and might be a more natural fit for your application and development practices. ## 3. Velocity -If you’re looking for the fastest way to get a single team up and running with deploying feature management and experimentation, embedding an SDK is the best option for you at first. You can always start using Optimizely Agent later, and it can even be used alongside Optimizely Full Stack SDKs running in another part of your stack. +If you’re looking for the fastest way to get a single team up and running with deploying flag management and experimentation, embedding an SDK is the best option for you at first. You can always start using Optimizely Agent later, and it can even be used alongside Optimizely Full Stack SDKs running in another part of your stack. # Best Practices While every implementation is different, you can review this section of best practices for tips on these commonly discussed topics. From bb9379942d4471dbd7f99b6c58a6616895a1b5a5 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 28 Sep 2020 16:13:12 -0600 Subject: [PATCH 05/11] docs: replace 'feature' with 'flag' done w 1st pass of replace 'feature' --- .../030 - use-optimizely-agent/index.md | 2 +- examples/README.md | 2 +- examples/advanced.py | 2 +- examples/notifications.py | 2 +- pkg/optimizely/optimizelytest/client.go | 2 +- pkg/optimizely/optimizelytest/config.go | 2 +- tests/acceptance/test_acceptance/test_config.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md b/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md index 38c06368..48eeb0ed 100644 --- a/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md +++ b/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md @@ -11,7 +11,7 @@ updatedAt: "2020-04-08T21:26:30.308Z" Optimizely Agent provides [APIs](https://library.optimizely.com/docs/api/agent/v1/index.html) that enable experimentation and feature management. Agent provides equivalent functionality to all our SDKs. At its core is the [Optimizely Go SDK](doc:go-sdk). In some cases, however, we’ve updated our APIs to simplify key use cases. -### Manage features +### Manage flags Optimizely Agent simplifies the core feature management of our [SDK APIs](doc:sdk-reference-guides). It consolidates the following endpoints: diff --git a/examples/README.md b/examples/README.md index aad0b718..05975fcc 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,6 +1,6 @@ ## Optimizely Agent Examples -This folder provides a set of sample scripts to illustrate some of the main API features. Most of the examples below +This folder provides a set of sample scripts to illustrate some of the main API use cases. Most of the examples below require an SDK key `` as one of the arguments. The SDK key can be found in the settings of your Optimizely Full Stack or Rollouts account. diff --git a/examples/advanced.py b/examples/advanced.py index ef478ed3..fee6d22d 100644 --- a/examples/advanced.py +++ b/examples/advanced.py @@ -14,7 +14,7 @@ s = requests.Session() s.headers.update({'X-Optimizely-SDK-Key': sdk_key}) -# Making a request to /config to generically pull the set of features and experiments. +# Making a request to /config to generically pull the set of flag rules (deliveries and experiments). # In production, making this initial request to build the set of keys would not be recommended. # Instead the keys would already be known by the application, or we'd use the type= parameter illustrated below. resp = s.get('http://localhost:8080/v1/config') diff --git a/examples/notifications.py b/examples/notifications.py index 309660eb..269559d0 100644 --- a/examples/notifications.py +++ b/examples/notifications.py @@ -40,7 +40,7 @@ def print_notifications(sdk_key): } } -# Activate features and experiments - these will trigger notifications that will be sent to notification event stream +# Activate flag rules (deliveries and experiments) - these will trigger notifications that will be sent to notification event stream # subscribers for key in env['featuresMap']: diff --git a/pkg/optimizely/optimizelytest/client.go b/pkg/optimizely/optimizelytest/client.go index 6a187ae6..4a8cb676 100644 --- a/pkg/optimizely/optimizelytest/client.go +++ b/pkg/optimizely/optimizelytest/client.go @@ -60,7 +60,7 @@ func (t *TestClient) AddEvent(e entities.Event) { t.ProjectConfig.AddEvent(e) } -// AddFeature is a helper method for adding features to the ProjectConfig to facilitate testing. +// AddFeature is a helper method for adding flags to the ProjectConfig to facilitate testing. func (t TestClient) AddFeature(f entities.Feature) { t.ProjectConfig.AddFeature(f) } diff --git a/pkg/optimizely/optimizelytest/config.go b/pkg/optimizely/optimizelytest/config.go index 5f3c86ba..85ec7afe 100644 --- a/pkg/optimizely/optimizelytest/config.go +++ b/pkg/optimizely/optimizelytest/config.go @@ -124,7 +124,7 @@ func (c *TestProjectConfig) GetAttributeByKey(key string) (entities.Attribute, e return entities.Attribute{}, errors.New(errMessage) } -// GetFeatureList returns an array of all the features +// GetFeatureList returns an array of all the flags func (c *TestProjectConfig) GetFeatureList() (featureList []entities.Feature) { for _, feature := range c.FeatureMap { featureList = append(featureList, feature) diff --git a/tests/acceptance/test_acceptance/test_config.py b/tests/acceptance/test_acceptance/test_config.py index 324dd63e..818fee0a 100644 --- a/tests/acceptance/test_acceptance/test_config.py +++ b/tests/acceptance/test_acceptance/test_config.py @@ -129,7 +129,7 @@ def test_config(session_obj): """ - Test validates all returned available experiment and features definitions + Test validates all returned available flag rule definitions (deliveries and experiments) for this environment. Note: Test will fail as soon as anything in the response body is modified. From f3ae1e95fa26e3722ce2355f44baecf2e0182c77 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Thu, 15 Oct 2020 11:16:54 -0600 Subject: [PATCH 06/11] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index beea79bc..d16a0489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,7 +143,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.5.0] - October 24th, 2019 - Adds GET endpoint for user-based flag -- Adds impression tracking for Feature Tests (referred to as "A/B tests" after Nov 2020) +- Adds impression tracking for feature tests (referred to as "A/B tests" after Nov 2020) ## [0.4.0] - October 23rd, 2019 - Adds admin endpoints for health, info and metrics From 5b98296e2d669f88d1490a9cfb37a269cf1dbc52 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Mon, 18 Jan 2021 13:20:44 -0700 Subject: [PATCH 07/11] adding new version for docs --- .../001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md | 0 .../010 - optimizely-agent.md | 0 .../012 - quickstart-for-agent.md | 0 .../020 - setup-optimizely-agent.md | 0 .../010 - evaluate-rest-apis.md | 0 .../020 - admin-api.md | 0 .../030 - use-optimizely-agent/index.md | 0 .../010 - authorization.md | 0 .../020 - webhooks-agent.md | 0 .../030 - docker-configurations.md | 0 .../031 - agent-notifications.md | 0 .../040 - advanced-configuration.md | 0 .../050 - agent-plugins.md | 0 .../040 - configure-optimizely-agent/index.md | 0 .../050 - api-reference.md | 0 .../060 - github-repository.md | 0 .../001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md | 10 + .../010 - optimizely-agent.md | 78 ++++++++ .../012 - quickstart-for-agent.md | 88 ++++++++ .../020 - setup-optimizely-agent.md | 75 +++++++ .../010 - evaluate-rest-apis.md | 59 ++++++ .../020 - admin-api.md | 89 +++++++++ .../030 - use-optimizely-agent/index.md | 99 +++++++++ .../010 - authorization.md | 188 ++++++++++++++++++ .../020 - webhooks-agent.md | 41 ++++ .../030 - docker-configurations.md | 9 + .../031 - agent-notifications.md | 57 ++++++ .../040 - advanced-configuration.md | 56 ++++++ .../050 - agent-plugins.md | 86 ++++++++ .../040 - configure-optimizely-agent/index.md | 56 ++++++ .../050 - api-reference.md | 11 + .../060 - github-repository.md | 11 + 32 files changed, 1013 insertions(+) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/010 - optimizely-agent.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/012 - quickstart-for-agent.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/020 - setup-optimizely-agent.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/030 - use-optimizely-agent/index.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/050 - api-reference.md (100%) rename docs/readme-sync/{ => v3.1}/deploy-as-a-microservice/060 - github-repository.md (100%) create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/010 - optimizely-agent.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/012 - quickstart-for-agent.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/020 - setup-optimizely-agent.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/index.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/050 - api-reference.md create mode 100644 docs/readme-sync/v4.0/deploy-as-a-microservice/060 - github-repository.md diff --git a/docs/readme-sync/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md diff --git a/docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/010 - optimizely-agent.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/010 - optimizely-agent.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/010 - optimizely-agent.md diff --git a/docs/readme-sync/deploy-as-a-microservice/012 - quickstart-for-agent.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/012 - quickstart-for-agent.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/012 - quickstart-for-agent.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/012 - quickstart-for-agent.md diff --git a/docs/readme-sync/deploy-as-a-microservice/020 - setup-optimizely-agent.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/020 - setup-optimizely-agent.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/020 - setup-optimizely-agent.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/020 - setup-optimizely-agent.md diff --git a/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md diff --git a/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md diff --git a/docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/030 - use-optimizely-agent/index.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/030 - use-optimizely-agent/index.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/030 - use-optimizely-agent/index.md diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md diff --git a/docs/readme-sync/deploy-as-a-microservice/050 - api-reference.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/050 - api-reference.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/050 - api-reference.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/050 - api-reference.md diff --git a/docs/readme-sync/deploy-as-a-microservice/060 - github-repository.md b/docs/readme-sync/v3.1/deploy-as-a-microservice/060 - github-repository.md similarity index 100% rename from docs/readme-sync/deploy-as-a-microservice/060 - github-repository.md rename to docs/readme-sync/v3.1/deploy-as-a-microservice/060 - github-repository.md diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md new file mode 100644 index 00000000..a17a19d0 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/001 - AUTHOR-AGENT-DOCS-IN-GITHUB.md @@ -0,0 +1,10 @@ +--- +title: "CAUTION - DON'T AUTHOR AGENT DOCS IN README" +excerpt: "" +slug: "author-agent-docs-in-github" +hidden: true +createdAt: "2020-02-21T17:44:53.019Z" +updatedAt: "2020-04-13T23:02:34.056Z" +--- + +Agent docs sync from Github. So, any changes you author here in Readme will just be overwritten. Make docs updates over in Github. For more info, see [authoring guidelines in github](https://github.com/optimizely/agent/blob/master/docs/internal%20docs%20authoring%20notes.md). diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/010 - optimizely-agent.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/010 - optimizely-agent.md new file mode 100644 index 00000000..8fa0edc2 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/010 - optimizely-agent.md @@ -0,0 +1,78 @@ +--- +title: "Optimizely Agent" +excerpt: "" +slug: "optimizely-agent" +hidden: false +metadata: + title: "Optimizely Agent microservice - Optimizely Full Stack" +createdAt: "2020-02-21T20:35:58.387Z" +updatedAt: "2020-07-14T20:51:52.458Z" +--- +Optimizely Agent is a standalone, open-source, and highly available microservice that provides major benefits over using Optimizely SDKs in certain use cases. The [Agent REST API](https://library.optimizely.com/docs/api/agent/v1/index.html) offers consolidated and simplified endpoints for accessing all the functionality of Optimizely Full Stack SDKs. + +A typical production installation of Optimizely Agent is to run two or more services behind a load balancer or proxy. The service itself can be run via a Docker container or installed from source. See [Setup Optimizely Agent](doc:setup-optimizely-agent) for instructions on how to run Optimizely Agent. + +### Example Implementation +![example implementation](https://raw.githubusercontent.com/optimizely/agent/master/docs/images/agent-example-implementation.png) +# Should I Use Optimizely Agent? + +Here are some of the top reasons to consider using Optimizely Agent: + +## 1. Service Oriented Architecture (SOA) +If you already separate some of your logic into services that might need to access the Optimizely decision APIs, we recommend using Optimizely Agent. + +The images below compare implementation styles in a service-oriented architecture, first *without* using Optimizely Agent, which shows six SDK embedded instances: + +!["A diagram showing the use of SDKs installed on each service in a service oriented architecture \n(Click to Enlarge)"](https://raw.githubusercontent.com/optimizely/agent/master/docs/images/agent-service-oriented-architecture.png) + +Now *with* Agent, instead of installing the SDK six times, you create just one Optimizely instance: an HTTP API that every service can access as needed. + +!["A diagram showing the use of Optimizely Agent in a single service \n(Click to Enlarge)"](https://raw.githubusercontent.com/optimizely/agent/master/docs/images/agent-single-service.png) + +## 2. Standardize Access Across Teams +If you want to deploy Optimizely Full Stack once, then roll out the single implementation across a large number of teams, we recommend using Optimizely Agent. + +By standardizing your teams' access to the Optimizely service, you can better enforce processes and implement governance around flag management and experimentation as a practice. + +!["A diagram showing the central and standardized access to the Optimizely Agent service across an arbitrary number of teams.\n(Click to Enlarge)"](https://raw.githubusercontent.com/optimizely/agent/master/docs/images/agent-standardized-access.png) + +## 3. Networking Centralization +You don’t want many SDK instances connecting to Optimizely's cloud service from every node in your application. Optimizely Agent centralizes your network connection. Only one cluster of agent instances connects to Optimizely for tasks like update [datafiles](doc:get-the-datafile) and dispatch [events](doc:track-events). + +## 4. Languages +You’re using a language that isn’t supported by a native SDK (i.e. Elixir, Scala, Perl). While its possible to create your own service using an Optimizely SDK of your choice, you could also customize the open-source Optimizely Agent to your needs without building the service layer on your own. + + +# Reasons to *not* use Optimizely Agent +If your use case wouldn't benefit greatly from Optimizely Agent, you should consider the below reasons to *not* use Optimizely Agent and review Optimizely's many [open-source SDKs](doc:sdk-reference-guides) instead. + +## 1. Latency +If time to provide bucketing decisions is a primary concern for you, you may want to use an embedded Full Stack SDK rather than Optimizely Agent. + + +| Implementation Option | Decision Latency | +|-----------------------|------------------| +| Embedded SDK | microseconds | +| Optimizely Agent | milliseconds | + +## 2. Monolith +If your app is constructed as a monolith, embedded SDKs might be easier to install and might be a more natural fit for your application and development practices. + +## 3. Velocity +If you’re looking for the fastest way to get a single team up and running with deploying flag management and experimentation, embedding an SDK is the best option for you at first. You can always start using Optimizely Agent later, and it can even be used alongside Optimizely Full Stack SDKs running in another part of your stack. + +# Best Practices +While every implementation is different, you can review this section of best practices for tips on these commonly discussed topics. + + +## How many Agent instances should I deploy? +Agent can scale to large decision / event tracking volumes with relatively low CPU / memory specs. For example, at Optimizely, we scaled our deployment to 740 clients with a cluster of 12 agent instances, which in total use 6 vCPUs and 12GB RAM. You will likely need to focus more on network bandwidth than compute power. + +## Using a load balancer +Any standard load balancer should let you route traffic across your agent cluster. At Optimizely, we used an AWS Elastic Load Balancer (ELB) for our internal deployment. This allows us to transparently scale our agent cluster as internal demands increase. + +## Synchronizing datafiles across Agent instances +Agent offers eventual rather than strong consistency across datafiles. +In detail, today, each agent instance maintains a dedicated, separate cache. Each agent instance persists an SDK instance for each SDK key your team uses. Agent instances automatically keep datafiles up to date for each SDK key instance so that you will have eventual consistency across the cluster. The rate of the datafile update can be [set as the configuration](doc:configure-optimizely-agent) value ```OPTIMIZELY_CLIENT_POLLINGINTERVAL``` (the default is 1 minute). +Because SDKs are generally stateless today, they shouldn’t need to share data. We plan to add a common backing data store, so we invite you to share your feedback. +If you require strong consistency across datafiles, then we recommend an active / passive deployment where all requests are made to a single vertically scaled host, with a passive, standby cluster available for high availability. diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/012 - quickstart-for-agent.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/012 - quickstart-for-agent.md new file mode 100644 index 00000000..92a8cc16 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/012 - quickstart-for-agent.md @@ -0,0 +1,88 @@ +--- +title: "Quickstart for Agent" +excerpt: "" +slug: "quickstart-for-agent" +hidden: false +metadata: + title: "Quickstart for Agent - Optimizely Full Stack" +createdAt: "2020-05-21T20:35:58.387Z" +updatedAt: "2020-08-17T20:51:52.458Z" +--- + +This brief quickstart describes how to run Agent, using two examples: + +- To get started using Docker, see [Running locally via Docker](https://docs.developers.optimizely.com/full-stack/docs/quickstart-with-docker#section-running-locally-via-docker). + +- To get started using example Node microservices, see the following video link. + + + +## Running locally via Node +| Resource | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [Implementing feature flags across microservices with Optimizely Agent](https://www.youtube.com/watch?v=kwNVdSXMGX8&t=20s) | 4-minute video on implementing Optimizely Agent with example microservices | + +## Running locally via Docker + +Follow these steps to deploy Optimizely Agent locally via Docker and access some of the common API endpoints. +If Docker is not installed then you can download it [here](https://docs.docker.com/install/). + +First pull the Docker image with: + +```bash +docker pull optimizely/agent +``` + +Then start the service in the foreground with the following command: + +```bash +docker run -p 8080:8080 --env OPTIMIZELY_LOG_PRETTY=true optimizely/agent +``` +Note that we're enabling "pretty" logs which provide colorized and human readable formatting. +The default log output format is structured JSON. + +## Evaluating REST APIs + +The rest of the getting started guide will demonstrate the APIs capabilities. For brevity, we've chosen to illustrate the API usage with Python. Note that the APIs are also defined via OpenAPI (Swagger) and can be found on localhost [here](http://localhost:8080/openapi.yaml). + +### Start an http session + +Each request made into Optimizely Agent is in the context of an Optimizely SDK Key. SDK Keys map API requests to a specific Optimizely Project and Environment. We can set up a global request header by using the `requests.Session` object. + +```python +import requests +s = requests.Session() +s.headers.update({'X-Optimizely-SDK-Key': '<>'}) +``` + +To get your SDK key, navigate to the project settings of your Optimizely account. + +Future examples will assume this session is being maintained. + +### Get current environment configuration + +The `/config` endpoint returns a manifest of the current working environment. + +```python +resp = s.get('http://localhost:8080/v1/config') +env = resp.json() + +for key in env['featuresMap']: + print(key) +``` + +### Activate Feature + +The `/activate?featureKey={key}` endpoint activates the feature for a given user. In Optimizely, activation is in the context of a given user to make the relative bucketing decision. In this case we'll provide a `userId` via the request body. The `userId` will be used to determine how the feature will be evaluated. Features can either be part of a Feature Test in which variations of feature variables are being measured against one another or a feature rollout, which progressively make the feature available to the selected audience. + +From an API standpoint the presence of a Feature Test or Rollout is abstracted away from the response and only the resulting variation or enabled feature is returned. + +```python +params = { "featureKey": "my-feature" } +payload = { "userId": "test-user" } +resp = s.post(url = 'http://localhost:8080/v1/activate', params=params, json=payload) + +print(resp.json()) +``` + +The activate API is a POST to signal to the caller that there are side-effects. Namely, activation results in a "decision" event sent to Optimizely analytics for the purpose of analyzing Feature Test results. A "decision" will NOT be sent if the feature is simply part of a rollout. diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/020 - setup-optimizely-agent.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/020 - setup-optimizely-agent.md new file mode 100644 index 00000000..23de9d44 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/020 - setup-optimizely-agent.md @@ -0,0 +1,75 @@ +--- +title: "Install Optimizely Agent" +excerpt: "" +slug: "setup-optimizely-agent" +hidden: false +metadata: + title: "Install Agent - Optimizely Full Stack" +createdAt: "2020-02-21T17:44:27.363Z" +updatedAt: "2020-03-31T23:54:17.841Z" +--- +## Running Agent from source (Linux / OSX) + +To develop and compile Optimizely Agent from source: + +1. Install [Golang](https://golang.org/dl/) version 1.13+ . +2. Clone the [Optimizely Agent repo](https://github.com/optimizely/agent). +3. From the repo directory, open a terminal and start Optimizely Agent: + +```bash +make setup +``` +Then +```bash +make run +``` + +This starts the Optimizely Agent with the default configuration in the foreground. + +## Running Agent from source (Windows) + +You can use a [helper script](https://github.com/optimizely/agent/blob/master/scripts/build.ps1) to install prerequisites (Golang, Git) and compile agent in a Windows environment. Take these steps: + +1. Clone the [Optimizely Agent repo](https://github.com/optimizely/agent) +2. From the repo directory, open a Powershell terminal and run + +```bash +Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser + +.\scripts\build.ps1 + +.\bin\optimizely.exe +``` + +## Running Agent via Docker + +If you have Docker installed, you can start Optimizely Agent as a container. Take these steps: + +1. Pull the Docker image: + +```bash +docker pull optimizely/agent +``` +By default this will pull the "latest" tag. You can also specify a specific version of Agent by providing the version as a tag to the docker command: + +```bash +docker pull optimizely/agent:X.Y.Z +``` + +2. Run the docker container with: + +```bash +docker run -p 8080:8080 optimizely/agent +``` +This will start Agent in the foreground and expose the container API port 8080 to the host. + +3. (Optional) You can alter the configuration by passing in environment variables to the preceding command, without having to create a config.yaml file. See [configure optimizely agent](doc:configure-optimizely-agent) for more options. + +Versioning: +When a new version is released, 2 images are pushed to dockerhub. They are distinguished by their tags: +- :latest (same as :X.Y.Z) +- :alpine (same as :X.Y.Z-alpine) + +The difference between latest and alpine is that latest is built `FROM scratch` while alpine is `FROM alpine`. +- [latest Dockerfile](https://github.com/optimizely/agent/blob/master/scripts/dockerfiles/Dockerfile.static) +- [alpine Dockerfile](https://github.com/optimizely/agent/blob/master/scripts/dockerfiles/Dockerfile.alpine) \ No newline at end of file diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md new file mode 100644 index 00000000..e06bd6be --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/010 - evaluate-rest-apis.md @@ -0,0 +1,59 @@ +--- +title: "Evaluate REST APIs" +excerpt: "" +slug: "evaluate-rest-apis" +hidden: false +metadata: + title: "Evaluate REST APIs - Optimizely Full Stack" +createdAt: "2020-02-21T17:44:53.019Z" +updatedAt: "2020-04-13T23:02:34.056Z" +--- +Below is an example demonstrating the APIs capabilities. For brevity, we've chosen to illustrate the API usage with Python. Note that the API documentation is defined via an OpenAPI (Swagger) spec and can be viewed [here](https://library.optimizely.com/docs/api/agent/v1/index.htm). + +## Start an http session +Each request made into Optimizely Agent is in the context of an Optimizely SDK Key. SDK Keys map API requests to a specific Optimizely Project and Environment. We can setup a global request header by using the `requests.Session` object. + + +```python +import requests + +s = requests.Session() +s.headers.update({'X-Optimizely-SDK-Key': 'YOUR-SDK-KEY'}) +``` +The following examples will assume this session is being maintained. + +## Get current environment configuration +The `/v1/config` endpoint returns a manifest of the current working environment. + +```python +resp = s.get('http://localhost:8080/v1/config') +env = resp.json() + +for key in env['featuresMap']: + print(key) +``` + +## Activate Feature +The `/v1/activate?featureKey={key}` endpoint activates the feature for a given user. In Optimizely, activation is in the context of a given user to make the relative bucketing decision. In this case we'll provide a `userId` via the request body. The `userId` will be used to determine how the feature will be evaluated. Features can either be part of a Feature Test in which variations of feature variables are being measured against one another or a feature rollout, which progressively make the feature available to the selected audience. + +From an API standpoint the presence of a Feature Test or Rollout is abstracted away from the response and only the resulting variation or enabled feature is returned. + + +```python +# single feature activate +params = { "featureKey": "my-feature" } +payload = { "userId": "test-user" } +resp = s.post(url = 'http://localhost:8080/v1/activate', params=params, json=payload) + +print(resp.json()) + + +# multiple (bulk) feature activate +params = { + "featureKey": [key for key in env['featuresMap']], + "experimentKey": [key for key in env['experimentsMap']] +} +resp2 = s.post(url = 'http://localhost:8080/v1/activate', params=params, json=payload) +print(json.dumps(resp.json(), indent=4, sort_keys=True)) +``` +The activate API is a POST to signal to the caller that there are side-effects. Namely, activation results in a "decision" event sent to Optimizely analytics for the purpose of analyzing Feature Test results. A "decision" will NOT be sent if the feature is simply part of a rollout. diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md new file mode 100644 index 00000000..9aefdfba --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/020 - admin-api.md @@ -0,0 +1,89 @@ +--- +title: "Admin API" +excerpt: "" +slug: "admin-api" +hidden: false +metadata: + title: "Admin APIs - Optimizely Full Stack" +createdAt: "2020-02-21T17:44:28.054Z" +updatedAt: "2020-02-21T23:09:19.274Z" +--- +The Admin API provides system information about the running process. This can be used to check the availability of the service, runtime information and operational metrics. By default the admin listener is configured on port 8088. + +## Info + +The `/info` endpoint provides basic information about the Optimizely Agent instance. + +Example Request: +```bash +curl localhost:8088/info +``` + +Example Response: +```json +{ + "version": "v0.10.0", + "author": "Optimizely Inc.", + "app_name": "optimizely" +} +``` + +## Health Check + +The `/health` endpoint is used to determine service availability. + +Example Request: +```bash +curl localhost:8088/health +``` + +Example Response: +```json +{ + "status": "ok" +} +``` + +Agent will return a HTTP 200 - OK response if and only if all configured listeners are open and all external dependent services can be reached. +A non-healthy service will return a HTTP 503 - Unavailable response with a descriptive message to help diagnose the issue. + +This endpoint can used when placing Agent behind a load balancer to indicate whether a particular instance can receive inbound requests. + +## Metrics + +The `/metrics` endpoint exposes telemetry data of the running Optimizely Agent. The core runtime metrics are exposed via the go expvar package. Documentation for the various statistics can be found as part of the [mstats](https://golang.org/src/runtime/mstats.go) package. + +Example Request: +```bash +curl localhost:8088/metrics +``` + +Example Response: +```json +{ + "cmdline": [ + "bin/optimizely" + ], + "memstats": { + "Alloc": 924136, + "TotalAlloc": 924136, + "Sys": 71893240, + "Lookups": 0, + "Mallocs": 4726, + "HeapAlloc": 924136, + ... + "Frees": 172 + }, + ... +} +``` +Custom metrics are also provided for the individual service endpoints and follow the pattern of: + +```bash +"timers..counts": 0, +"timers..responseTime": 0, +"timers..responseTimeHist.p50": 0, +"timers..responseTimeHist.p90": 0, +"timers..responseTimeHist.p95": 0, +"timers..responseTimeHist.p99": 0, +``` \ No newline at end of file diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/index.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/index.md new file mode 100644 index 00000000..48eeb0ed --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/030 - use-optimizely-agent/index.md @@ -0,0 +1,99 @@ +--- +title: "Use Optimizely Agent" +excerpt: "" +slug: "use-optimizely-agent" +hidden: false +metadata: + title: "How to use Optimizely Agent - Optimizely Full Stack" +createdAt: "2020-02-21T17:44:28.054Z" +updatedAt: "2020-04-08T21:26:30.308Z" +--- + +Optimizely Agent provides [APIs](https://library.optimizely.com/docs/api/agent/v1/index.html) that enable experimentation and feature management. Agent provides equivalent functionality to all our SDKs. At its core is the [Optimizely Go SDK](doc:go-sdk). In some cases, however, we’ve updated our APIs to simplify key use cases. + +### Manage flags + + Optimizely Agent simplifies the core feature management of our [SDK APIs](doc:sdk-reference-guides). It consolidates the following endpoints: + +- [isFeatureEnabled](doc:is-feature-enabled-go) +- [getFeatureVariableBoolean](doc:get-feature-variable-go#section-boolean) +- [getFeatureVariableDouble](doc:get-feature-variable-go#section-double) +- [getFeatureVariableInteger](doc:get-feature-variable-go#section-integer) +- [getFeatureVariableString](doc:get-feature-variable-go#section-string) +- [getEnabledFeatures](doc:get-enabled-features-go) + + +... into one, convenient endpoint: + +`POST /v1/activate?featureKey={featureKey}` + +This [endpoint](https://library.optimizely.com/docs/api/agent/v1/index.html#operation/activate) returns: + +- the decision for this feature for this user +- any corresponding feature variable values. + +For example: + +```json +{ + "featureKey": "feature-key-1", + "enabled": true, + "variables": { + "my-var-1": "cust-val-1", + "my-var-2": "cust-va1-2" + } +} +``` + +The response is determined by the [feature tests](doc:run-feature-tests) and [feature rollouts](doc:use-feature-flags) defined for the supplied feature key, following the same rules as any Full Stack SDK. + +Note: If the user is assigned to a feature test, this API will dispatch an impression. + +### Authentication + + +To authenticate, [pass your SDK key](https://docs.developers.optimizely.com/full-stack/docs/evaluate-rest-apis#section-start-an-http-session) as a header named ```X-Optimizely-SDK-Key``` in your API calls to Optimizely Agent. You can find your SDK key in app.optimizely.com under Settings > Environments > SDK Key. Remember you have a different SDK key for each environment. + + +### Running A/B tests + + +To activate an A/B test, use: + +`POST /v1/activate?experimentKey={experimentKey}` + +This dispatches an impression and return the user’s assigned variation: + +`POST /v1/activate?experimentKey={experimentKey}` + +This dispatches an impression and return the user’s assigned variation: +```json +{ + "experimentKey": "experiment-key-1", + "variationKey": "variation-key-1" +} +``` +### Get All Decisions +To get all Feature decisions for a visitor in a single request use: +`POST /v1/activate?type=feature` + +To receive only the enabled features for a visitor use: + +`POST /v1/activate?type=feature&enabled=true` + +To get all Experiment decisions for a visitor in a single request use: +`POST /v1/activate?type=experiment` + + + +### Tracking conversions + +To track events, use the same [tracking endpoint](https://library.optimizely.com/docs/api/agent/v1/index.html#operation/trackEvent) you use in the [SDKs' track API](doc:track-javascript): + +`POST /v1/track?eventKey={eventKey}` + +There is no response body for successful conversion event requests. + +### API reference + + For more details on Optimizely Agent’s APIs, see the [complete API Reference](https://library.optimizely.com/docs/api/agent/v1/index.html). diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md new file mode 100644 index 00000000..df731365 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/010 - authorization.md @@ -0,0 +1,188 @@ +--- +title: "Authorization" +excerpt: "" +slug: "authorization" +hidden: false +metadata: + title: "Agent Authorization - Optimizely Full Stack" +createdAt: "2020-03-11T20:58:11.777Z" +updatedAt: "2020-03-31T19:44:52.119Z" +--- +Optimizely Agent supports authorization workflows based on OAuth and JWT standards, allowing you to protect access to its API and Admin interfaces. + +There are three modes of operation: + +## 1. Issuer & Validator +Access tokens are issued by Agent itself, using a [Client Credentials grant](https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/). Access tokens are signed and validated using the HS256 algorithm with a signing secret provided in configuration. Clients request access tokens by sending a `POST` request to `/oauth/token` on the port of the desired interface (by default, `8080` for the API interface, and `8088` for the Admin interface), including a client ID and secret in the request. + + +Issuer & Validator mode is useful if you want to implement authorization, and you are not already running an authorization server that can issue JWTs. + +## 2. Validator-only +Agent validates access tokens that were issued elsewhere. Access tokens are validated with public keys fetched from a [JWKS](https://tools.ietf.org/html/rfc7517) URL provided in configuration. + +Validator-only mode is useful if you want to plug directly into an existing JWT-based workflow already being used in your system or organization. + +## 3. No authorization (default) +The interface is publicly available. + +# Configuration +- The API and Admin interfaces are each independently configured to run in one of the above-mentioned modes of operation. +- Authorization configuration is located under the `auth` key +- Each mode of operation has its own set of configuration properties, described below. + +## Issuer & Validator +The configuration properties pertaining to Issuer & Validator mode are listed below: + +|Property Name|Environment Variable|Description| +|---|---|---| +|ttl|TTL|Time-to-live of access tokens issued| +|hmacSecrets|HMACSECRETS|Array of secrets used to sign & validate access tokens, using the HMAC SHA256 algorithm. Values must be base64-format strings. The first value in the array is used to sign issued access tokens. Access tokens signed with any value in the array are considered valid.| +|clients|N/A|Array of objects, used for token issuance, consisting of `id`, `secretHash`, and `sdkKeys`. Clients provide ID and secret in their requests to `/oauth/token`. Agent validates the request credentials by checking for an exact match of ID, checking that the BCrypt hash of the request secret matches the `secretHash` from configuration, and that the SDK key provided in the `X-Optimizely-Sdk-Key` request header exists in the `sdkKeys` from configuration. `secretHash` values must be base64-format strings.| + +To make setup easier, Agent provides a command-line tool that can generate base64-encoded 32-byte random values, and their associated base64-encoded BCrypt hashes: + +```shell +// From the Agent root directory +> make generate_secret +Client Secret: i3SrdrCy/wEGqggv9OI4FgIsdHHNpOacrmIMJ6SFIkE= +Client Secret's hash: JDJhJDEyJERGNzhjRXVTNTdOQUZ3cndxTkZ6Li5XQURlazU2R21YeFZjb1pWSkN5eGZ1SXM4VXRLb0ZD +``` +Use the hash value to configure Agent, and pass the secret value as `client_secret` when making access token requests to `/oauth/token`. For details of the access token issuance endpoint, see the OpenAPI spec file. + +## Validator-only +The configuration properties pertaining to Validator-only mode are listed below: + +|Property Name|Environment Variable|Description| +|---|---|---| +|jwksURL|JWKSURL|URL from which public keys should be fetched for token validation| +|jwksUpdateInterval|JWKSUPDATEINTERVAL|Interval on which public keys should be re-fetched (example: `30m` for 30 minutes)| + +## No authorization (default) +The API & Admin interfaces run with no authorization when no `auth` configuration is given. + +## Configuration examples +Optimizely Agent uses the [Viper](https://github.com/spf13/viper) library for configuration, which allows setting values via environment variables, flags, and YAML configuration files. +### Issuer & Validator +_*WARNING*_: For security, we advise that you configure `hmacSecrets` with either an environment variable or a flag, and NOT through a config file. + +In the below example, the Admin interface is configured in Issuer & Validator mode, with `hmacSecrets` provided via environment variable, and other values provided via YAML config file. +```shell +// Comma-separated value, to set multiple hmacSecrets. +// Access tokens are signed with the first value. +// Access tokens are valid when they are signed with either of these values. +export OPTIMIZELY_ADMIN_HMACSECRETS=QPtUGP/RqaXRltZf1QE1KxlF2Iuo09J0buZ3UNKeIr0,bkZAqSsZuM5NSnwEyO9Pzb6F8gGNu1BBuX/SpPaMeyM +``` + +```yaml +admin: + auth: + # Access tokens will expire after 30 minutes + ttl: 30m + clients: + # Either of these two id/secret pairs can be exchanged for access tokens + - id: agentConsumer1 + secretHash: XgZTeTvWaZ6fLiey6EBSOxJ2QFdd6dIiUcZGDIIJ+IY + sdkKeys: + # These credentials can be exchanged for tokens granting access to these two SDK keys + - abcd1234 + - efgh5678 + - id: agentConsumer2 + secretHash: ssz0EEViKIinkFXxzqncKxz+6VygEc2d2rKf+la5rXM + sdkKeys: + # These credentials can be exchanged for tokens granting access only to this one SDK key + - ijkl9012 +``` + +### Validator-only +```yaml +# In this example, the API interface is configured in Validator-only mode +api: + auth: + # Signing keys will be fetched from this url and used when validating access tokens + jwksURL: https://YOUR_DOMAIN/.well-known/jwks.json + # Siging keys will be periodically fetched on this interval + jwksUpdateInterval: 30m +``` + +# Secret Rotation (Issuer & Validator mode) +To support secret rotation, both `hmacSecrets` and `clients` support setting multiple values. In `hmacSecrets`, the first value will be +used to sign issued tokens, but tokens signed with any of the values will be considered valid. + +# Example (Python) +Example requests demonstrating the Issuer & Validator mode: +```python +#!/usr/bin/python + +import json +import requests +import sys + +# This example demonstrates interacting with Agent running in Issuer & Validator mode. +# We obtain an access token and use it to request the current Optimizely Config +# from the API interface. + +# Fist, we need a secret value to sign access tokens. +# You can use the generate_secret tool included with Agent to generate this: + +# > make generate_secret +# Client Secret: CvzvkWm3V1D9RBxPWEjC+ud9zvwcOvnnLkWaIkzDGyA= + +# You can ignore the second line that says "Client Secret's hash". + +# Then, set an environment variable to make this secret available to Agent: +# > export OPTIMIZELY_API_AUTH_HMACSECRETS=CvzvkWm3V1D9RBxPWEjC+ud9zvwcOvnnLkWaIkzDGyA= + +# Next, we need client credentials (ID & secret), and the BCrypt hash of our secret +# Again, you can use the generate_secret tool included with Agent to generate these: +# +# > make generate_secret +# Client Secret: 0bfLVX9U3Lpr6Qe4X3DSSIWNqEkEQ4bkX1WZ5Km6spM= +# Client Secret's hash: JDJhJDEyJEdkSHpicHpRODBqOC9FQzRneGIyNXU0ZFVPMFNKcUhkdTRUQXRzWUJOdjRzRmcuVGdFUTUu +# +# Take the hash, and add it to your agent configuration file (default: config.yaml) under the "api" section, +# along with your desired client ID and SDK key: +# +# auth: +# ttl: 30m +# clients: +# - id: clientid1 +# secretHash: JDJhJDEyJEdkSHpicHpRODBqOC9FQzRneGIyNXU0ZFVPMFNKcUhkdTRUQXRzWUJOdjRzRmcuVGdFUTUu +# sdkKeys: +# - + +# +# Start Agent with the API interface running on the default port (8080). +# Then, finally, run the example, passing your SDK key, client ID and secret: +# > python auth.py clientid1 0bfLVX9U3Lpr6Qe4X3DSSIWNqEkEQ4bkX1WZ5Km6spM= +# +# For more information, see docs/auth.md + +if len(sys.argv) < 4: + sys.exit('Requires three arguments: ') + +sdk_key = sys.argv[1] +client_id = sys.argv[2] +client_secret = sys.argv[3] + +s = requests.Session() +s.headers.update({'X-Optimizely-SDK-Key': sdk_key}) + +resp = s.get('http://localhost:8080/v1/config') +print('first config request, not including access token: response status = {}'.format(resp.status_code)) + +resp = s.post('http://localhost:8080/oauth/token', data={ + 'grant_type': 'client_credentials', + 'client_id': client_id, + 'client_secret': client_secret, +}) +resp_dict = resp.json() +print('access token response: ') +print(json.dumps(resp_dict, indent=4, sort_keys=True)) + +s.headers.update({'Authorization': 'Bearer {}'.format(resp_dict['access_token'])}) + +resp = s.get('http://localhost:8080/v1/config') +print('config response after passing access token: ') +print(json.dumps(resp.json(), indent=4, sort_keys=True)) +``` \ No newline at end of file diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md new file mode 100644 index 00000000..cbd14cb3 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/020 - webhooks-agent.md @@ -0,0 +1,41 @@ +--- +title: "Webhooks" +excerpt: "" +slug: "webhooks-agent" +hidden: false +metadata: + title: "Agent microservice webhooks - Optimizely Full Stack" +createdAt: "2020-02-21T17:44:26.981Z" +updatedAt: "2020-05-05T17:03:48.045Z" +--- +Optimizely Agent implements a webhook listener used to receive inbound [Webhook](doc:configure-webhooks) requests from optimizely.com. These webhooks enable PUSH style notifications triggering immediate project configuration updates. +The webhook listener is configured on its own port (default: 8085) since it can be configured to select traffic from the internet. + +To accept webhook requests Agent must be configured by mapping an Optimizely Project Id to a set of SDK keys along +with the associated secret used for validating the inbound request. An example webhook configuration can be seen below, while the full example configuration can be found in the the provided [config.yaml](https://github.com/optimizely/agent/blob/master/config.yaml#L58). + +```yaml +## +## webhook service receives update notifications to your Optimizely project. Receipt of the webhook will +## trigger an immediate download of the datafile from the CDN +## +webhook: + ## http listener port + port: "8089" +# ## a map of Optimizely Projects to one or more SDK keys +# projects: +# ## : Optimizely project id as an integer +# : +# ## sdkKeys: a list of SDKs linked to this project +# sdkKeys: +# - +# - +# ## secret: webhook secret used the validate the notification +# secret: +# ## skipSignatureCheck: override the signature check (not recommended for production) +# skipSignatureCheck: true +``` + +## Next + +[Create Webhooks](https://docs.developers.optimizely.com/full-stack/docs/webhooks-agent) diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md new file mode 100644 index 00000000..fa5b3605 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/030 - docker-configurations.md @@ -0,0 +1,9 @@ +--- +title: "Docker Configurations" +excerpt: "" +slug: "docker-configurations" +hidden: true +createdAt: "2020-03-13T18:37:48.448Z" +updatedAt: "2020-03-13T18:37:48.448Z" +--- +Stub page for further info on how to configure docker? \ No newline at end of file diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md new file mode 100644 index 00000000..f986333b --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md @@ -0,0 +1,57 @@ +--- +title: Agent Notifications +excerpt: "" +slug: "agent-notifications" +hidden: false +metadata: + title: "Agent notifications - Optimizely Full Stack" +createdAt: "2020-05-21T20:35:58.387Z" +updatedAt: "2020-07-14T20:51:52.458Z" +--- + +Agent provides an endpoint that sends notifications to subscribers via [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This is Agent's equivalent of Notification Listeners found in Optimizely SDKs. + +For details on the notification types, what causes them to be triggered, and the data they provide, see the [Notification Listeners documentation](https://docs.developers.optimizely.com/full-stack/docs/set-up-notification-listener-go). + +## Configuration + +By default, the notifications endpoint is disabled. To enable it, change config.yaml: + +``` +# config.yaml +api: + enableNotifications: true +``` + +Or, enable it by setting an environment variable: + +``` +# set an env. variable +export OPTIMIZELY_API_ENABLENOTIFICATIONS=1 +``` + +## Usage + +Send a `GET` request to `/v1/notifications/event-stream` to subscribe: + +``` +curl -N -H "Accept:text/event-stream" -H "X-Optimizely-Sdk-Key:"\ + http://localhost:8080/v1/notifications/event-stream +``` + +This connection will remain open, and any notifications triggered by other requests received by Agent are pushed as events to this stream. Try sending requests to `/v1/activate` or `/v1/track` to see notifications being triggered. + + +### Filtering + +To subscribe only to a particular category of notifications, add a `filter` query parameter. For example, to subscribe only to Decision notifications: + +``` +# filter on decision notifications +curl -N -H "Accept:text/event-stream" -H "X-Optimizely-Sdk-Key:"\ + http://localhost:8080/v1/notifications/event-stream?filter=decision +``` + +## Example + +For a runnable Python example, see [examples/notifications.py](https://github.com/optimizely/agent/tree/master/examples). diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md new file mode 100644 index 00000000..24e30804 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md @@ -0,0 +1,56 @@ +--- +title: "Advanced configuration" +excerpt: "" +slug: "advanced-config-agent" +hidden: false +metadata: + title: "advanced config - Agent microservice - Optimizely Full Stack" +createdAt: "2020-05-21T20:35:58.387Z" +updatedAt: "2020-07-14T20:51:52.458Z" +--- + +## Setting Configuration Values + +Configuration can be provided to Agent via the following methods: + +1. Reading from environment variables +2. Reading from a YAML configuration file + +When a configuration option is specified through both methods, environment variables take precedence over the config file. + +Internally, Optimizely Agent uses the [Viper](https://github.com/spf13/viper) library's support for configuration files and environment variables. + +## Config File Location + +The default location of the config file is `config.yaml` in the root directory. If you want to specify another location, use the `OPTIMIZELY_CONFIG_FILENAME` environment variable: + +``` +OPTIMIZELY_CONFIG_FILENAME=/path/to/other_config_file.yaml make run +``` + +## Nested Configuration Options + +When setting the value of "nested" configuration options using environment variables, underscores denote deeper access. The following examples are equivalent ways of setting the client polling interval. + +Set the polling interval in YAML: + +``` +# Setting a nested value in a .yaml file: +client: + pollingInterval: 120s +``` + +Set the polling interval with a shell script: + +``` +# Set environment variable for pollingInterval, nested inside client +export OPTIMIZELY_CLIENT_POLLINGINTERVAL=120s +``` + +## Unsupported Environment Variable Options + +Some options can only be set via config file, and not environment variable (for details on these options, see the Configuration Options table in the [main README](https://github.com/optimizely/agent/blob/master/README.md): + +- `admin.auth.clients` +- `api.auth.clients` +- Options under`webhook.projects` diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md new file mode 100644 index 00000000..db908946 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/050 - agent-plugins.md @@ -0,0 +1,86 @@ +--- +title: "Agent plugins" +excerpt: "" +slug: "agent-plugins" +hidden: false +metadata: + title: "Agent plugins - Optimizely Full Stack" +createdAt: "2020-09-21T20:30:00.000Z" +updatedAt: "2020-09-21T20:30:00.000Z" +--- + +## Agent Plugins + +Optimizely Agent can be extended through the use of plugins. Plugins are distinct from the standard Agent packages that provide a namespaced environment for custom logic. Plugins must be compiled as part of the Agent distribution and are enabled through configuration. + +### Interceptor Plugins + +Interceptors can be added to Agent to customize the request and/or response by implementing the [Interceptor](https://github.com/optimizely/agent/tree/master/plugins/interceptors/registry.go) interface. +This interface defines a `Handler()` method that returns a standard net/http middleware handler based on [http.Handler](https://golang.org/pkg/net/http/#Handler). +The interceptor struct can also include a set of fields that can be configured via `config.yaml`. + +* [httplog](https://github.com/optimizely/agent/tree/master/plugins/interceptors/httplog) - Adds HTTP request logging based on [go-chi/httplog](https://github.com/go-chi/httplog). + +### Example Interceptor definition +```go +package example + +import ( + "context" + "net/http" + + "github.com/optimizely/agent/plugins/interceptors" +) + +// Example implements the Interceptor plugin interface +type Example struct { + // set of configuration fields + RequestHeader string + ResponseHeader string + ContextValue string +} + +func (i *Example) Handler() func(next http.Handler) http.Handler { + return func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + r.Header.Add("X-Example-Request", i.RequestHeader) + + // Example adding context to the request path + ctx := context.WithValue(r.Context(), "example-context", i.ContextValue) + + // Continuing with the normal serving + next.ServeHTTP(w, r.WithContext(ctx)) + + // Modify the response in some way + w.Header().Add("X-Example-Response", i.ResponseHeader) + }) + } +} + +// Register our interceptor as "example". +func init() { + interceptors.Add("example", func() interceptors.Interceptor { + return &Example{} + }) +} +``` + +To make the interceptor available to Agent, add the plugin as an anonymous import into [all.go](./interceptors/all/all.go). +```go +package all + +// Add imports here to trigger the plugin `init()` function +import ( + _ "github.com/optimizely/agent/plugins/interceptors/example" +) +``` + +Enable the example interceptor by adding to `server.interceptors` within your `config.yaml`. Note that the yaml fields should match the struct definition of your plugin. +```yaml +server: + interceptors: + example: + requestHeader: "example-request" + responseHeader: "example-response" + contextValue: "example-context" +``` diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md new file mode 100644 index 00000000..d4f936f0 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/040 - configure-optimizely-agent/index.md @@ -0,0 +1,56 @@ +--- +title: "Configure Optimizely Agent" +excerpt: "" +slug: "configure-optimizely-agent" +hidden: false +metadata: + title: "Configure Agent microservice - Optimizely Full Stack" +createdAt: "2020-02-21T17:44:27.173Z" +updatedAt: "2020-04-08T21:42:08.698Z" +--- +By default Optimizely Agent uses the configuration file in the current active directory, e.g., `./config.yaml`. You can override the [default configuration](https://github.com/optimizely/agent/blob/master/config.yaml) by providing a yaml configuration file at runtime. + +You can specify alternative configuration locations at runtime via an environment variable or command line flag: + +```bash +OPTIMIZELY_CONFIG_FILENAME=config.yaml make run +``` + + +Below is a comprehensive list of available configuration properties. + +|Property Name|Env Variable|Description| +|---|---|---| +|admin.auth.clients|N/A|Credentials for requesting access tokens. See: [Authorization Guide](doc:authorization)| +|admin.auth.jwksURL|OPTIMIZELY_ADMIN_AUTH_JWKSURL|JWKS URL for validating access tokens. See: [Authorization Guide](doc:authorization)| +|admin.auth.jwksUpdateInterval|OPTIMIZELY_ADMIN_AUTH_JWKSUPDATEINTERVAL|JWKS Update Interval for caching the keys in the background. See: [Authorization Guide](doc:authorization)| +|admin.auth.hmacSecrets|OPTIMIZELY_ADMIN_AUTH_HMACSECRETS|Signing secret for issued access tokens. See: [Authorization Guide](doc:authorization)| +|admin.auth.ttl|OPTIMIZELY_ADMIN_AUTH_TTL|Time-to-live of issued access tokens. See: [Authorization Guide](doc:authorization)| +|admin.port|OPTIMIZELY_ADMIN_PORT|Admin listener port. Default: 8088| +|api.auth.clients|N/A|Credentials for requesting access tokens. See: [Authorization Guide](doc:authorization)| +|api.auth.hmacSecrets|OPTIMIZELY_API_AUTH_HMACSECRETS|Signing secret for issued access tokens. See: [Authorization Guide](doc:authorization)| +|api.auth.jwksURL|OPTIMIZELY_API_AUTH_JWKSURL|JWKS URL for validating access tokens. See: [Authorization Guide](doc:authorization)| +|api.auth.jwksUpdateInterval|OPTIMIZELY_API_AUTH_JWKSUPDATEINTERVAL|JWKS Update Interval for caching the keys in the background. See: [Authorization Guide](doc:authorization)| +|api.auth.ttl|OPTIMIZELY_API_AUTH_TTL|Time-to-live of issued access tokens. See: [Authorization Guide](doc:authorization)| +|api.port|OPTIMIZELY_API_PORT|Api listener port. Default: 8080| +|api.maxConns|OPTIMIZLEY_API_MAXCONNS|Maximum number of concurrent requests| +|author|OPTIMIZELY_AUTHOR|Agent author. Default: Optimizely Inc.| +|certfile|OPTIMIZELY_CERTFILE|Path to a certificate file, used to run Agent with HTTPS| +|client.batchSize|OPTIMIZELY_CLIENT_BATCHSIZE|The number of events in a batch. Default: 10| +|config.filename|OPTIMIZELY_CONFIG_FILENAME|Location of the configuration YAML file. Default: ./config.yaml| +|client.flushInterval|OPTIMIZELY_CLIENT_FLUSHINTERVAL|The maximum time between events being dispatched. Default: 30s| +|client.pollingInterval|OPTIMIZELY_CLIENT_POLLINGINTERVAL|The time between successive polls for updated project configuration. Default: 1m| +|client.queueSize|OPTIMIZELY_CLIENT_QUEUESIZE|The max number of events pending dispatch. Default: 1000| +|disabledCiphers|OPTIMIZELY_DISABLEDCIPHERS|List of TLS ciphers to disable when accepting HTTPS connections| +|keyfile|OPTIMIZELY_KEYFILE|Path to a key file, used to run Agent with HTTPS| +|log.level|OPTIMIZELY_LOG_LEVEL|The log [level](https://github.com/rs/zerolog#leveled-logging) for the agent. Default: info| +|log.pretty|OPTIMIZELY_LOG_PRETTY|Flag used to set colorized console output as opposed to structured json logs. Default: false| +|name|OPTIMIZELY_NAME|Agent name. Default: optimizely| +|version|OPTIMIZELY_VERSION|Agent version. Default: `git describe --tags`| +|sdkKeys|OPTIMIZELY_SDKKEYS|List of SDK keys used to initialize on startup| +|server.readTimeout|OPTIMIZELY_SERVER_READTIMEOUT|The maximum duration for reading the entire body. Default: “5s”| +|server.writeTimeout|OPTIMIZELY_SERVER_WRITETIMEOUT|The maximum duration before timing out writes of the response. Default: “10s”| +|webhook.port|OPTIMIZELY_WEBHOOK_PORT|Webhook listener port: Default: 8085| +|webhook.projects.<*projectId*>.sdkKeys|N/A|Comma delimited list of SDK keys applicable to the respective projectId| +|webhook.projects.<*projectId*>.secret|N/A|Webhook secret used to validate webhook requests originating from the respective projectId| +|webhook.projects.<*projectId*>.skipSignatureCheck|N/A|Boolean to indicate whether the signature should be validated. TODO remove in favor of empty secret.| diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/050 - api-reference.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/050 - api-reference.md new file mode 100644 index 00000000..3649a8a6 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/050 - api-reference.md @@ -0,0 +1,11 @@ +--- +title: "API Reference" +excerpt: "" +slug: "api-reference" +hidden: false +createdAt: "2020-02-21T17:44:52.492Z" +updatedAt: "2020-02-21T17:44:52.492Z" +type: "link" +link_url: "https://optimizely.github.io/docs/api/agent/" +link_external: true +--- diff --git a/docs/readme-sync/v4.0/deploy-as-a-microservice/060 - github-repository.md b/docs/readme-sync/v4.0/deploy-as-a-microservice/060 - github-repository.md new file mode 100644 index 00000000..ae341515 --- /dev/null +++ b/docs/readme-sync/v4.0/deploy-as-a-microservice/060 - github-repository.md @@ -0,0 +1,11 @@ +--- +title: "Github Repository" +excerpt: "" +slug: "github-repository" +hidden: false +createdAt: "2020-02-21T17:44:28.559Z" +updatedAt: "2020-02-21T17:44:28.559Z" +type: "link" +link_url: "https://github.com/optimizely/agent" +link_external: true +--- From f0f9b3fa105b1191700922de4fb222c13b1ee9a6 Mon Sep 17 00:00:00 2001 From: frances elliott Date: Mon, 18 Jan 2021 13:47:52 -0700 Subject: [PATCH 08/11] adding versioned docs to staging build --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc19bc0e..16c9ae63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -240,14 +240,18 @@ jobs: # we need to be in $TRAVIS_BUILD_DIR in order to run the following git diff properly - cd $TRAVIS_BUILD_DIR - #print which docs changed in this Pull Request (and which therefore we expect to be updated by readme-sync-2 tool): + # print which docs changed in this Pull Request (and which therefore we expect to be updated by readme-sync-2 tool): - CHANGED_DOCS_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE -- docs/readme-sync)) - echo $CHANGED_DOCS_FILES - #only if changes were made in the docs/readme-sync repo, trigger this readme-sync stage and sync the docs - - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 4.0 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/) - + # only if changes were made in the docs/readme-sync repo, trigger this readme-sync stage and sync the docs + # to staging readme project at https://rollouts-sandbox-doc-test.readme.io/docs + + # build v3.1 docs + - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v3.1 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 3.1 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v3.1) + # build v4.0 docs + - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v4.0 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 4.0 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v4.0) - stage: 'Readme-sync' before_script: skip From c58eb965cf1b889dc18511efd0783c6d8c6a1b92 Mon Sep 17 00:00:00 2001 From: frances elliott Date: Mon, 18 Jan 2021 14:17:50 -0700 Subject: [PATCH 09/11] fixing versions --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 16c9ae63..d1336ac7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -248,10 +248,10 @@ jobs: # to staging readme project at https://rollouts-sandbox-doc-test.readme.io/docs - # build v3.1 docs - - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v3.1 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 3.1 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v3.1) - # build v4.0 docs - - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v4.0 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 4.0 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v4.0) + # build v3.1 docs to v 1.0 of readme staging project + - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v3.1 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 1.0 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v3.1) + # build v4.0 docs to v 1.5 of staging project + - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v4.0 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 1.5 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v4.0) - stage: 'Readme-sync' before_script: skip From 8612e720be260be0f794894957b2348c68099c8d Mon Sep 17 00:00:00 2001 From: frances elliott Date: Mon, 18 Jan 2021 14:31:09 -0700 Subject: [PATCH 10/11] putting readme 1st for test purposes --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d1336ac7..b306902a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,14 +15,15 @@ branches: - /^v\d+\.\d+(\.\d+)?(-\S*)?$/ stages: + - 'Readme-sync-preview' + - 'Readme-sync' - 'Tests' - 'Trigger FSC Tests' - 'Test Build using latest tag (no upload)' - 'Build, Upload and Publish (draft)' - 'Test github release assets' - 'Publish (real)' - - 'Readme-sync-preview' - - 'Readme-sync' + jobs: From 948db296397a0bf2a153ccd805f5c2d7d56a7260 Mon Sep 17 00:00:00 2001 From: frances elliott Date: Mon, 18 Jan 2021 14:39:57 -0700 Subject: [PATCH 11/11] adding versioning to main readme-sync docs --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b306902a..33365230 100644 --- a/.travis.yml +++ b/.travis.yml @@ -277,9 +277,11 @@ jobs: - CHANGED_DOCS_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE -- docs/readme-sync)) - echo $CHANGED_DOCS_FILES - #only if changes were made in the docs/readme-sync repo, trigger this readme-sync stage and sync the docs - - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY --version 3.1 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/) - + #only if changes were made in the docs/readme-sync repo, trigger this readme-sync stage and sync the docs + # sync v3.1 docs folder to readme project v 3.1 + - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v3.1 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY --version 3.1 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v3.1 + # sync v4.0 docs folder to readme project v 4.0 + - git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v4.0 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY --version 4.0 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v4.0 ######################################################################################### # directories/scripts for full SDK-reference-guides, to be implemented after agent docs sync #########################################################################################