devcycle

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 20 Imported by: 0

README

DevCycle Go Server SDK.

Welcome to the the DevCycle Go SDK, initially generated via the DevCycle Bucketing API.

Installation

go get "github.com/devcyclehq/go-server-sdk"

Put the package under your project folder and add the following in import:

import "github.com/devcyclehq/go-server-sdk"

Getting Started

import (
    "github.com/devcyclehq/go-server-sdk"
    "context"
)
auth := context.WithValue(context.Background(), devcycle.ContextAPIKey, devcycle.APIKey{
    Key: "your_server_key_here",
})

client := devcycle.NewDVCClient()

Usage

To find usage documentation, visit our docs.

Documentation

Overview

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

* DevCycle Bucketing API * * Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs. * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the swagger operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type DVCClient

type DVCClient struct {
	DevcycleApi *DVCClientService
	// contains filtered or unexported fields
}

DVCClient manages communication with the DevCycle Bucketing API API v1.0.0 In most cases there should be only one, shared, DVCClient.

func NewDVCClient

func NewDVCClient() *DVCClient

NewDVCClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*DVCClient) ChangeBasePath

func (c *DVCClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

type DVCClientService

type DVCClientService service

func (*DVCClientService) AllFeatures

func (a *DVCClientService) AllFeatures(ctx context.Context, body UserData) (map[string]Feature, error)

DVCClientService Get all features by key for user data

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body

@return map[string]Feature

func (*DVCClientService) AllVariables

func (a *DVCClientService) AllVariables(ctx context.Context, body UserData) (map[string]Variable, error)

DVCClientService Get all variables by key for user data

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body

@return map[string]Variable

func (*DVCClientService) Track

func (a *DVCClientService) Track(ctx context.Context, user UserData, event Event) (InlineResponse201, error)

DVCClientService Post events to DevCycle for user

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body

@return InlineResponse201

func (*DVCClientService) Variable

func (a *DVCClientService) Variable(ctx context.Context, body UserData, key string, defaultValue interface{}) (Variable, error)

DVCClientService Get variable by key for user data

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body
  • @param key Variable key

@return Variable

type ErrorResponse

type ErrorResponse struct {
	// Error message
	Message string `json:"message"`
	// Additional error information detailing the error reasoning
	Data *interface{} `json:"data,omitempty"`
}

type Event

type Event struct {
	// Custom event type
	Type_ string `json:"type"`
	// Custom event target / subject of event. Contextual to event type
	Target string `json:"target,omitempty"`
	// Unix epoch time the event occurred according to client
	Date float64 `json:"date,omitempty"`
	// Value for numerical events. Contextual to event type
	Value float64 `json:"value,omitempty"`
	// Extra JSON metadata for event. Contextual to event type
	MetaData *interface{} `json:"metaData,omitempty"`
}

type Feature

type Feature struct {
	// unique database id
	Id string `json:"_id"`
	// Unique key by Project, can be used in the SDK / API to reference by 'key' rather than _id.
	Key string `json:"key"`
	// Feature type
	Type_ string `json:"type"`
	// Bucketed feature variation
	Variation string `json:"_variation"`
	// Bucketed feature variation key
	VariationKey string `json:"variationKey"`
	// Bucketed feature variation name
	VariationName string `json:"variationName"`
	// Evaluation reasoning
	EvalReason string `json:"evalReason,omitempty"`
}

type GenericSwaggerError

type GenericSwaggerError struct {
	// contains filtered or unexported fields
}

GenericSwaggerError Provides access to the body, error and model on returned errors.

func (GenericSwaggerError) Body

func (e GenericSwaggerError) Body() []byte

Body returns the raw bytes of the response

func (GenericSwaggerError) Error

func (e GenericSwaggerError) Error() string

Error returns non-empty string if there was an error.

func (GenericSwaggerError) Model

func (e GenericSwaggerError) Model() interface{}

Model returns the unpacked model of the error

type InlineResponse201

type InlineResponse201 struct {
	Message string `json:"message,omitempty"`
}

type UserData

type UserData struct {
	// Unique id to identify the user
	UserId string `json:"user_id"`
	// User's email used to identify the user on the dashboard / target audiences
	Email string `json:"email,omitempty"`
	// User's name used to identify the user on the dashboard / target audiences
	Name string `json:"name,omitempty"`
	// User's language in ISO 639-1 format
	Language string `json:"language,omitempty"`
	// User's country in ISO 3166 alpha-2 format
	Country string `json:"country,omitempty"`
	// App Version of the running application
	AppVersion string `json:"appVersion,omitempty"`
	// App Build number of the running application
	AppBuild string `json:"appBuild,omitempty"`
	// User's custom data to target the user with, data will be logged to DevCycle for use in dashboard.
	CustomData *interface{} `json:"customData,omitempty"`
	// User's custom data to target the user with, data will not be logged to DevCycle only used for feature bucketing.
	PrivateCustomData *interface{} `json:"privateCustomData,omitempty"`
	// Date the user was created, Unix epoch timestamp format
	CreatedDate float64 `json:"createdDate,omitempty"`
	// Date the user was created, Unix epoch timestamp format
	LastSeenDate float64 `json:"lastSeenDate,omitempty"`
	// Platform the Client SDK is running on
	Platform string `json:"platform,omitempty"`
	// Version of the platform the Client SDK is running on
	PlatformVersion string `json:"platformVersion,omitempty"`
	// User's device model
	DeviceModel string `json:"deviceModel,omitempty"`
	// DevCycle SDK type
	SdkType string `json:"sdkType,omitempty"`
	// DevCycle SDK Version
	SdkVersion string `json:"sdkVersion,omitempty"`
}

type UserDataAndEventsBody

type UserDataAndEventsBody struct {
	Events []Event   `json:"events,omitempty"`
	User   *UserData `json:"user,omitempty"`
}

type Variable

type Variable struct {
	// unique database id
	Id string `json:"_id"`
	// Unique key by Project, can be used in the SDK / API to reference by 'key' rather than _id.
	Key string `json:"key"`
	// Variable type
	Type_ string `json:"type"`
	// Variable value can be a string, number, boolean, or JSON
	Value *interface{} `json:"value"`
	// Identifies if variable was returned with the default value
	IsDefaulted bool `json:"isDefaulted,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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