From 2d72cc2f2272217b2e27892d92d8aad559c03866 Mon Sep 17 00:00:00 2001 From: Frances Elliott <42477011+fscelliott@users.noreply.github.com> Date: Fri, 17 Jul 2020 12:46:46 -0600 Subject: [PATCH 1/3] fixing whitespaces in markdown --- .../031 - agent-notifications.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md b/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md index 30ca08bd..8344aa6e 100644 --- a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md +++ b/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/031 - agent-notifications.md @@ -1,5 +1,5 @@ --- -title: Agent Notifications" +title: Agent Notifications excerpt: "" slug: "agent-notifications" hidden: false @@ -9,7 +9,6 @@ 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). @@ -22,27 +21,34 @@ By default, the notifications endpoint is disabled. To enable it, change config. api: enableNotifications: true ``` + Or, enable it by setting an environment variable: + ```shell script export OPTIMIZELY_API_ENABLENOTIFICATIONS=1 ``` ## Usage + Send a `GET` request to `/v1/notifications/event-stream` to subscribe: + ```shell script 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: + ```shell script curl -N -H "Accept:text/event-stream" -H "X-Optimizely-Sdk-Key:"\ http://localhost:8080/v1/notifications/event-stream?filter=decision ``` - ## Example -A runnable Python example can be found in [`examples/notifications.py`](../examples/notifications.py). + +For a runnable Python example, see [examples/notifications.py](https://github.com/optimizely/agent/tree/master/examples). From 412053e80bb4fc4f6cdcdc26d87c31d775a72b63 Mon Sep 17 00:00:00 2001 From: Frances Elliott <42477011+fscelliott@users.noreply.github.com> Date: Fri, 17 Jul 2020 12:49:54 -0600 Subject: [PATCH 2/3] whitspace fixes --- .../040 - advanced-configuration.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md b/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md index 40b86333..e9af1d88 100644 --- a/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md +++ b/docs/readme-sync/deploy-as-a-microservice/040 - configure-optimizely-agent/040 - advanced-configuration.md @@ -12,6 +12,7 @@ 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 @@ -22,25 +23,34 @@ Internally, Optimizely Agent uses the [Viper](https://github.com/spf13/viper) li ## 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: + ```bash 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: + +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: + ```yaml # Setting a nested value in a .yaml file: client: pollingInterval: 120s ``` +Set the polling interval with a shell script: + ```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` From be5d4600a7f9a435999dfa5334768ee7bab45874 Mon Sep 17 00:00:00 2001 From: Frances Elliott <42477011+fscelliott@users.noreply.github.com> Date: Fri, 17 Jul 2020 12:58:45 -0600 Subject: [PATCH 3/3] publish a hidden page, w/ whitspace fixes --- .../012 - quickstart-with-docker.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/readme-sync/deploy-as-a-microservice/012 - quickstart-with-docker.md b/docs/readme-sync/deploy-as-a-microservice/012 - quickstart-with-docker.md index 629c0881..886c0bf1 100644 --- a/docs/readme-sync/deploy-as-a-microservice/012 - quickstart-with-docker.md +++ b/docs/readme-sync/deploy-as-a-microservice/012 - quickstart-with-docker.md @@ -2,7 +2,7 @@ title: "Quickstart with Docker" excerpt: "" slug: "quickstart-with-docker" -hidden: true +hidden: false metadata: title: "Agent Quickstart with Docker - Optimizely Full Stack" createdAt: "2020-05-21T20:35:58.387Z" @@ -13,12 +13,15 @@ This is a brief quickstart showing how to run Agent locally via Docker and how t If Docker is not installed then you can download it [here](https://docs.docker.com/install/). ## Running locally via Docker + 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 ``` @@ -26,14 +29,15 @@ Note that we're enabling "pretty" logs which provide colorized and human readabl 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 [here](http://localhost:8080/openapi.yaml). + +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 setup a global request header by using the `requests.Session` object. + +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': '<>'}) ``` @@ -43,6 +47,7 @@ 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 @@ -54,6 +59,7 @@ for key in env['featuresMap']: ``` ### 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.