Skip to content

fixing whitespaces in markdown #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -13,27 +13,31 @@ 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
```
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 [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': '<<YOUR-SDK-KEY>>'})
```
Expand All @@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Agent Notifications"
title: Agent Notifications
excerpt: ""
slug: "agent-notifications"
hidden: false
Expand All @@ -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).
Expand All @@ -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:<YOUR 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:<YOUR 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).
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`