api

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package API provides functionality for interacting with the Optimizely REST API. Current functionality includes reading projects, environments, and datafiles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PerPage

func PerPage(i int) func(*client)

PerPage sets the requested number of items to return on each request to the optimizely API as an option when building a new Client. If this option is not provided to NewClient, the default value is 25 items per page.

func Token

func Token(t string) func(*client)

Token provides the Optimizely API token as an option when building a new Client.

Types

type Client

type Client interface {
	// GetDatafile returns the raw contents of the datafile for a given environment and project. This method will
	// return an error if the project cannot be found, the environment cannot be found in the project, or if there
	// is an error retrieving the datafile.
	GetDatafile(environmentName string, projectID int) ([]byte, error)
	// GetEnvironment returns a single environment with a given name within a Project with a given ID.
	// This method can return an error if the given project ID is not found or the environment with the specified name
	// is not found.
	GetEnvironmentByProjectID(name string, projectID int) (Environment, error)
	// GetEnvironmentByProjectName returns the a single environment with a given name within a Project with a given name.
	// This method can return an error if the given project is not found or the environment with the specified name
	// is not found.
	GetEnvironmentByProjectName(key, projectName string) (Environment, error)
	// GetEnvironmentsByProjectID returns a list of environments located in the project with the given ID.
	GetEnvironmentsByProjectID(projectID int) ([]Environment, error)
	// GetEnvironmentsByProjectName returns a list of environments located in the project with the given name.
	// If there is no project with the given name, an error is returned.
	GetEnvironmentsByProjectName(projectName string) ([]Environment, error)
	// GetProjects returns all Optimizely Projects within the Optimizely account that the client has access to.
	GetProjects() ([]Project, error)
	// ReportEvents sends serialized events to the Optimizely events API.
	ReportEvents(events []byte) error
}

Client is the interface for interacting with the Optimizely API. NewClient returns a real implementation of this interface and the mocks package contains a version of this interface for testing purposes.

func NewClient

func NewClient(options ...func(*client)) Client

NewClient constructs a new Optimizely API client from optional provided options.

type Datafile

type Datafile struct {
	ID             int      `json:"id"`
	LatestFileSize int      `json:"latest_file_size"`
	OtherURLs      []string `json:"other_urls"`
	Revision       int      `json:"revision"`
	SDKKey         string   `json:"sdk_key"`
	URL            string   `json:"url"`
}

Datafile is the API representation of a datafile for an environment

type Environment

type Environment struct {
	ID                       int       `json:"id"`
	Key                      string    `json:"key"`
	Name                     string    `json:"name"`
	ProjectID                int       `json:"project_id"`
	Archived                 bool      `json:"archived"`
	Description              string    `json:"description"`
	HasRestrictedPermissions bool      `json:"has_restricted_permissions"`
	Created                  time.Time `json:"created"`
	LastModified             time.Time `json:"last_modified"`
	Datafile                 Datafile  `json:"datafile"`
	IsPrimary                bool      `json:"is_primary"`
}

Environment is the API representation of an Optimizely environment with a project

type Project

type Project struct {
	ID           int       `json:"id"`
	Name         string    `json:"name"`
	Description  string    `json:"description"`
	Status       string    `json:"status"`
	AccountID    int       `json:"account_id"`
	Created      time.Time `json:"created"`
	LastModified time.Time `json:"last_modified"`
}

Project is the API representation of an Optimizely project

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL