v1

package
v0.0.0-...-91c4cd1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MPL-2.0 Imports: 14 Imported by: 1

README

Overview

This package contains 2 high level elements of note.

  • openapi.yaml - This is the OpenAPI specification file generated by the generator package in this repository. From this specification, clients and servers can be generated for the Nomad HTTP API. This file is generated and should never be edited by hand.
  • This directory contains hand-written go code and associated tests that provide a higher level of abstraction over the generated client. For example, the jobs.go file contains methods that expose all the jobs related endpoints, and jobs_tests.go contains code showing how a calling client might consume those methods. The api.go file contains framework level code related to creating a client instance, generating contexts for query and write operations, as well as helper methods for applying query and write options to requests.

Note: This package is experimental and is likely to change. There is no guarantee of backward compatability, at this time. Method names, signatures, and type names may change as we iterate.

Quick start

Import this package to your project.

go get https://github.com/hashicorp/nomad-openapi

Add an import for the package to your code.

import (
	"github.com/hashicorp/nomad-openapi/v1"
)

Create a client instance.

client, err := NewClient()

All operations are modeled as either queries or writes. Queries require QueryOpts and writes require WriteOpts.

var queryOpts = &QueryOpts{}

queryOpts := queryOpts().
    WithRegion("global")
    WithNamespace("default").
    WithAllowStale(true).
    WithWaitIndex(1000).
    WithWaitTime(100000 * time.Millisecond) // WaitTime is expected to always be defined in milliseconds
    // See QueryOpts struct for all possible QueryOpts.

These options can then be converted to a context, and passed to each API endpoint as the first argument.

result, meta, err := client.Jobs().GetJobs(queryOpts.Ctx())
if err != nil {
	// do error handling
}
  • Most endpoint functions returns a result, a meta struct, and an error
  • All endpoint functions return an error
  • If the error is not nil, both result and meta should be nil and no further evaluation is necessary
  • The result will usually be a model from the generated client package, but may also be a golang primitive type like string or int
  • The meta struct contains metadata about the state of the server at the time of the response as callers may wish to track things like the last index at the time of the operation
  • See the QueryMeta and WriteMeta structs for a full explanation of the metadata returned for query and write operations respectively

Goals

This package has several goals which are listed below.

  • Create an opinionated, consistent API DX across all endpoints of the Nomad HTTP API
  • Provide a high-level abstraction over the generated client
  • Provide an example of how to consume a generated OpenAPI client
  • Experiment with context as a first-class citizen of the Nomad API
  • Experiment with API versioning and uplift mechanisms
  • Experiment with a unified OpenAPI/AsyncAPI client

Documentation

Index

Constants

View Source
const (
	// JobTypeService indicates a long-running processes
	JobTypeService = "service"

	// JobTypeBatch indicates a short-lived process
	JobTypeBatch = "batch"

	// JobTypeSystem indicates a system process that should run on all clients
	JobTypeSystem = "system"

	// PeriodicSpecCron is used for a cron spec.
	PeriodicSpecCron = "cron"

	// Constants for the Nomad environment variable names.
	EnvNomadAddr       = "NOMAD_ADDR"
	EnvNomadCACert     = "NOMAD_CACERT"
	EnvNomadClientCert = "NOMAD_CLIENT_CERT"
	EnvNomadClientKey  = "NOMAD_CLIENT_KEY"
	EnvNomadNamespace  = "NOMAD_NAMESPACE"
	EnvNomadRegion     = "NOMAD_REGION"
	EnvNomadToken      = "NOMAD_TOKEN"

	// DefaultAddress is the default address for a Nomad cluster. This is used
	// when no address is provided to the client.
	DefaultAddress = "http://127.0.0.1:4646"

	// DefaultNamespace is the default namespace.
	DefaultNamespace = "default"

	// GlobalRegion is a sentinel region value dor Job configuration
	// that users may specify to indicate the job should be run on
	// the region of the node that the job was submitted to.
	// For Client configuration, if no region information is given,
	// the client node will default to be part of the GlobalRegion.
	GlobalRegion = "global"

	// RegisterEnforceIndexErrPrefix is the prefix to use in errors caused by
	// enforcing the job modify index during registers.
	RegisterEnforceIndexErrPrefix = "Enforcing job modify index"

	// RegionKey can be used to prevent hard coded string key accessor errors
	RegionKey = "Region"

	// NamespaceKey can be used to prevent hard coded string key accessor errors
	NamespaceKey = "Namespace"

	// ParamsKey can be used to prevent hard coded string key accessor errors
	ParamsKey = "Params"

	// PerPageKey can be used to prevent hard coded string key accessor errors
	PerPageKey = "PerPage"

	// NextTokenKey can be used to prevent hard coded string key accessor errors
	NextTokenKey = "NextToken"

	// PrefixKey can be used to prevent hard coded string key accessor errors
	PrefixKey = "Prefix"

	// AuthTokenKey can be used to prevent hard coded string key accessor errors
	AuthTokenKey = "AuthToken"

	// AllowStaleKey can be used to prevent hard coded string key accessor errors
	AllowStaleKey = "AllowStale"

	// WaitTimeKey can be used to prevent hard coded string key accessor errors
	WaitTimeKey = "WaitTime"

	// WriteIndexKey can be used to prevent hard coded string key accessor errors
	WaitIndexKey = "WaitIndex"

	// IdempotencyTokenKey can be used to prevent hard coded string key accessor errors
	IdempotencyTokenKey = "IdempotencyToken"
)

Variables

This section is empty.

Functions

func WithAddress

func WithAddress(address string) func(*Client)

WithAddress

func WithCACert

func WithCACert(caFile string) func(*Client)

func WithClientCert

func WithClientCert(certFile, keyFile string) func(*Client)

func WithDefaultNamespace

func WithDefaultNamespace(ns string) func(*Client)

func WithDefaultRegion

func WithDefaultRegion(region string) func(*Client)

func WithTLSCerts

func WithTLSCerts(caFile, certFile, keyFile string) func(*Client)

func WithTLSServerName

func WithTLSServerName(n string) func(*Client)

func WithTLSSkipVerify

func WithTLSSkipVerify() func(*Client)

func WithToken

func WithToken(token string) func(*Client)

Types

type ACL

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

func (*ACL) ACLApi

func (a *ACL) ACLApi() *client.ACLApiService

func (*ACL) Bootstrap

func (a *ACL) Bootstrap(ctx context.Context) (*client.ACLToken, *WriteMeta, OpenAPIError)

func (*ACL) DeletePolicy

func (a *ACL) DeletePolicy(ctx context.Context, policyName string) (*WriteMeta, OpenAPIError)

pass in name, no payload can't use "Delete", because there's an ACL "Delete" for tokens as well

func (*ACL) DeleteToken

func (a *ACL) DeleteToken(ctx context.Context, tokenAccessor string) (*WriteMeta, OpenAPIError)

func (*ACL) Exchange

func (a *ACL) Exchange(ctx context.Context) (*client.ACLToken, *WriteMeta, OpenAPIError)

func (*ACL) GetPolicy

func (a *ACL) GetPolicy(ctx context.Context, policyName string) (*client.ACLPolicy, *QueryMeta, OpenAPIError)

returns objectSchema pass in policy name, no payload

func (*ACL) GetToken

func (a *ACL) GetToken(ctx context.Context, tokenAccessor string) (*client.ACLToken, *QueryMeta, OpenAPIError)

func (*ACL) OnetimeToken

func (a *ACL) OnetimeToken(ctx context.Context) (*client.OneTimeToken, *WriteMeta, OpenAPIError)

func (*ACL) Policies

returns arraySchema

func (*ACL) SavePolicy

func (a *ACL) SavePolicy(ctx context.Context, policy *client.ACLPolicy) (*WriteMeta, OpenAPIError)

returns nilSchema pass in policy name WITH payload can't use "Save", because there's an ACL "Save" for tokens as well

func (*ACL) SaveToken

func (a *ACL) SaveToken(ctx context.Context, token *client.ACLToken) (*client.ACLToken, *WriteMeta, OpenAPIError)

func (*ACL) Self

func (*ACL) Tokens

type APIError

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

APIError Provides access to the body, error and model on returned errors. It exists to encapsulate, enhance, and extend the client.GenericOpenAPIError.

func MakeAPIError

func MakeAPIError(values []reflect.Value) *APIError

func (APIError) Body

func (e APIError) Body() []byte

Body returns the raw bytes of the response

func (APIError) Error

func (e APIError) Error() string

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

func (APIError) Model

func (e APIError) Model() interface{}

Model returns the unpacked model of the error

func (APIError) Status

func (e APIError) Status() string

Status returns the status code and status text of the HTTP error.

type Allocations

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

Jobs encapsulates and extends the generated JobsApiService with convenience methods.

func (*Allocations) AllocationsApi

func (a *Allocations) AllocationsApi() *client.AllocationsApiService

func (*Allocations) GetAllocation

func (a *Allocations) GetAllocation(ctx context.Context, allocID string) (*client.Allocation, *QueryMeta, OpenAPIError)

func (*Allocations) GetAllocationServices

func (a *Allocations) GetAllocationServices(ctx context.Context, allocID string) (*[]client.ServiceRegistration, *QueryMeta, OpenAPIError)

func (*Allocations) GetAllocations

func (*Allocations) StopAllocation

func (a *Allocations) StopAllocation(ctx context.Context, allocID string, noShutdownDelay bool) (*client.AllocStopResponse, *WriteMeta, OpenAPIError)

type Client

type Client struct {
	Ctx context.Context
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

func (*Client) ACL

func (c *Client) ACL() *ACL

func (*Client) Allocations

func (c *Client) Allocations() *Allocations

func (*Client) Deployments

func (c *Client) Deployments() *Deployments

func (*Client) Evaluations

func (c *Client) Evaluations() *Evaluations

func (*Client) ExecNoMetaQuery

func (c *Client) ExecNoMetaQuery(ctx context.Context, request interface{}) (interface{}, error)

ExecNoMetaQuery executes a request accepts QueryOpts, but does not set index or query metadata.

func (*Client) ExecNoMetaWrite

func (c *Client) ExecNoMetaWrite(ctx context.Context, request interface{}) (interface{}, error)

ExecNoMetaWrite executes a request accepts WriteOpts, but does not set index or write metadata.

func (*Client) ExecNoResponseRequest

func (c *Client) ExecNoResponseRequest(_ context.Context, request interface{}) *APIError

ExecNoResponseRequest executes a client operation that does not return a model, query or write metadata.

func (*Client) ExecNoResponseWrite

func (c *Client) ExecNoResponseWrite(ctx context.Context, request interface{}) (*WriteMeta, *APIError)

ExecNoResponseWrite executes a request that returns write metadata, but no model.

func (*Client) ExecQuery

func (c *Client) ExecQuery(ctx context.Context, request interface{}) (interface{}, *QueryMeta, *APIError)

ExecQuery executes a request that returns query metadata.

func (*Client) ExecRequest

func (c *Client) ExecRequest(_ context.Context, request interface{}) (interface{}, *APIError)

ExecRequest executes a client operation that does not return query or write metadata.

func (*Client) ExecWrite

func (c *Client) ExecWrite(ctx context.Context, request interface{}) (interface{}, *WriteMeta, *APIError)

ExecWrite executes a request that returns write metadata.

func (*Client) Jobs

func (c *Client) Jobs() *Jobs

func (*Client) Metrics

func (c *Client) Metrics() *Metrics

func (*Client) Namespaces

func (c *Client) Namespaces() *Namespaces

func (*Client) Operator

func (c *Client) Operator() *Operator

func (*Client) Plugins

func (c *Client) Plugins() *Plugins

func (*Client) QueryOpts

func (c *Client) QueryOpts() *QueryOpts

QueryOpts creates a new QueryOpts struct with defaults populated from the current client configuration

func (*Client) Regions

func (c *Client) Regions() *Regions

func (*Client) Scaling

func (c *Client) Scaling() *Scaling

func (*Client) Status

func (c *Client) Status() *Status

func (*Client) System

func (c *Client) System() *System

func (*Client) WriteOpts

func (c *Client) WriteOpts() *WriteOpts

WriteOpts creates a new WriteOpts struct with defaults populated from the current client configuration

type ClientOption

type ClientOption func(*Client)

type Deployments

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

func (*Deployments) AllocationHealth

func (d *Deployments) AllocationHealth(ctx context.Context, deploymentID string, healthyallocs []string, unhealthyallocs []string) (*client.DeploymentUpdateResponse, OpenAPIError)

func (*Deployments) Allocations

func (d *Deployments) Allocations(ctx context.Context, deploymentID string) (*[]client.AllocationListStub, *QueryMeta, OpenAPIError)

func (*Deployments) Deployments

func (d *Deployments) Deployments(ctx context.Context) (*[]client.Deployment, *QueryMeta, OpenAPIError)

func (*Deployments) DeploymentsApi

func (d *Deployments) DeploymentsApi() *client.DeploymentsApiService

func (*Deployments) Fail

func (*Deployments) GetDeployment

func (d *Deployments) GetDeployment(ctx context.Context, deploymentID string) (*client.Deployment, *QueryMeta, OpenAPIError)

func (*Deployments) Pause

func (d *Deployments) Pause(ctx context.Context, deploymentID string, pause bool) (*client.DeploymentUpdateResponse, OpenAPIError)

func (*Deployments) Promote

func (d *Deployments) Promote(ctx context.Context, deploymentID string, all bool, groups []string) (*client.DeploymentUpdateResponse, OpenAPIError)

func (*Deployments) Unblock

func (d *Deployments) Unblock(ctx context.Context, deploymentID string) (*client.DeploymentUpdateResponse, OpenAPIError)

type Evaluations

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

func (*Evaluations) Allocations

func (e *Evaluations) Allocations(ctx context.Context, evalID string) (*[]client.AllocationListStub, *QueryMeta, OpenAPIError)

func (*Evaluations) Evaluations

func (e *Evaluations) Evaluations(ctx context.Context) (*[]client.Evaluation, *QueryMeta, OpenAPIError)

func (*Evaluations) EvaluationsApi

func (e *Evaluations) EvaluationsApi() *client.EvaluationsApiService

func (*Evaluations) GetEvaluation

func (e *Evaluations) GetEvaluation(ctx context.Context, evalID string) (*client.Evaluation, *QueryMeta, OpenAPIError)

type Jobs

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

Jobs encapsulates and extends the generated JobsApiService with convenience methods.

func (*Jobs) Allocations

func (j *Jobs) Allocations(ctx context.Context, jobName string, all bool) (*[]client.AllocationListStub, *QueryMeta, OpenAPIError)

func (*Jobs) Delete

func (j *Jobs) Delete(ctx context.Context, jobName string, purge, global bool) (*client.JobDeregisterResponse, *WriteMeta, OpenAPIError)

func (*Jobs) Deployment

func (j *Jobs) Deployment(ctx context.Context, jobName string) (*client.Deployment, *QueryMeta, OpenAPIError)

func (*Jobs) Deployments

func (j *Jobs) Deployments(ctx context.Context, jobName string) (*[]client.Deployment, *QueryMeta, OpenAPIError)

func (*Jobs) Dispatch

func (j *Jobs) Dispatch(ctx context.Context, jobName string, payload string, meta map[string]string) (*client.JobDispatchResponse, *WriteMeta, OpenAPIError)

func (*Jobs) EnforceRegister

func (j *Jobs) EnforceRegister(ctx context.Context, job *client.Job, modifyIndex uint64) (*client.JobRegisterResponse, *WriteMeta, OpenAPIError)

func (*Jobs) Evaluate

func (j *Jobs) Evaluate(ctx context.Context, jobName string, forceReschedule bool) (*client.JobRegisterResponse, *WriteMeta, OpenAPIError)

func (*Jobs) GetJob

func (j *Jobs) GetJob(ctx context.Context, jobName string) (*client.Job, *QueryMeta, OpenAPIError)

func (*Jobs) GetJobs

func (j *Jobs) GetJobs(ctx context.Context) (*[]client.JobListStub, *QueryMeta, OpenAPIError)

func (*Jobs) GetLocation

func (j *Jobs) GetLocation(job *client.Job) (*time.Location, error)

func (*Jobs) IsMultiRegion

func (j *Jobs) IsMultiRegion(job *client.Job) bool

func (*Jobs) IsParameterized

func (j *Jobs) IsParameterized(job *client.Job) bool

func (*Jobs) IsPeriodic

func (j *Jobs) IsPeriodic(job *client.Job) bool

func (*Jobs) JobsApi

func (j *Jobs) JobsApi() *client.JobsApiService

func (*Jobs) Next

func (j *Jobs) Next(p *client.PeriodicConfig, fromTime time.Time) (time.Time, error)

Next returns the closest time instant matching the spec that is after the passed time. If no matching instance exists, the zero value of time.Time is returned. The `time.Location` of the returned value matches that of the passed time.

func (*Jobs) Parse

func (j *Jobs) Parse(ctx context.Context, hcl string, canonicalize, hclV1 bool) (*client.Job, OpenAPIError)

func (*Jobs) PeriodicForce

func (j *Jobs) PeriodicForce(ctx context.Context, jobName string) (*client.PeriodicForceResponse, *WriteMeta, OpenAPIError)

func (*Jobs) Plan

func (j *Jobs) Plan(ctx context.Context, job *client.Job, diff bool) (*client.JobPlanResponse, *WriteMeta, OpenAPIError)

func (*Jobs) PlanOpts

func (j *Jobs) PlanOpts(ctx context.Context, job *client.Job, opts *PlanOpts) (*client.JobPlanResponse, *WriteMeta, OpenAPIError)

func (*Jobs) Post

func (*Jobs) Register

func (j *Jobs) Register(ctx context.Context, job *client.Job, registerOpts *RegisterOpts) (*client.JobRegisterResponse, *WriteMeta, OpenAPIError)

func (*Jobs) Revert

func (j *Jobs) Revert(ctx context.Context, jobName string, versionNumber, enforcePriorVersion int32, consulToken, vaultToken string) (*client.JobRegisterResponse, *WriteMeta, OpenAPIError)

func (*Jobs) Scale

func (j *Jobs) Scale(ctx context.Context, jobName string, count int64, msg string, target map[string]string) (*client.JobRegisterResponse, *WriteMeta, OpenAPIError)

func (*Jobs) ScaleStatus

func (j *Jobs) ScaleStatus(ctx context.Context, jobName string) (*client.JobScaleStatusResponse, *QueryMeta, OpenAPIError)

func (*Jobs) Stability

func (j *Jobs) Stability(ctx context.Context, jobName string, versionNumber int32, stable bool) (*client.JobStabilityResponse, *WriteMeta, OpenAPIError)

func (*Jobs) Summary

func (j *Jobs) Summary(ctx context.Context, jobName string) (*client.JobSummary, *QueryMeta, OpenAPIError)

func (*Jobs) Versions

func (j *Jobs) Versions(ctx context.Context, jobName string, withDiffs bool) (*client.JobVersionsResponse, *QueryMeta, OpenAPIError)

type Metrics

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

func (*Metrics) GetMetricsSummary

func (m *Metrics) GetMetricsSummary(ctx context.Context) (*client.MetricsSummary, OpenAPIError)

func (*Metrics) MetricsApi

func (m *Metrics) MetricsApi() *client.MetricsApiService

type Namespaces

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

func (*Namespaces) DeleteNamespace

func (n *Namespaces) DeleteNamespace(ctx context.Context, name string) (*WriteMeta, OpenAPIError)

func (*Namespaces) GetNamespace

func (n *Namespaces) GetNamespace(ctx context.Context, name string) (*client.Namespace, *QueryMeta, OpenAPIError)

func (*Namespaces) GetNamespaces

func (n *Namespaces) GetNamespaces(ctx context.Context) (*[]client.Namespace, *QueryMeta, OpenAPIError)

func (*Namespaces) NamespacesApi

func (n *Namespaces) NamespacesApi() *client.NamespacesApiService

func (*Namespaces) PostNamespace

func (n *Namespaces) PostNamespace(ctx context.Context, namespace *client.Namespace) (*WriteMeta, OpenAPIError)

type OpenAPIError

type OpenAPIError interface {
	Body() []byte
	Error() string
	Model() interface{}
}

OpenAPIError is the interface defined by the generated client.GenericOpenAPIError. This interface allows us to return that type natively from generated code, but also to create new instances of custom types that conform to that interface so that we can return errors from generated code and user code with a consistent interface.

type Operator

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

func (*Operator) Autopilot

func (*Operator) AutopilotHealth

func (o *Operator) AutopilotHealth(ctx context.Context) (*client.OperatorHealthReply, error)

func (*Operator) OperatorApi

func (o *Operator) OperatorApi() *client.OperatorApiService

func (*Operator) Peer

func (o *Operator) Peer(ctx context.Context) error

func (*Operator) Raft

func (*Operator) Scheduler

func (*Operator) UpdateAutopilot

func (o *Operator) UpdateAutopilot(ctx context.Context, config *client.AutopilotConfiguration) (*bool, error)

func (*Operator) UpdateScheduler

TODO: update Nomad version to pick up new fields (i.e. RejectJobRegistration)

type PlanOpts

type PlanOpts struct {
	Diff           bool
	PolicyOverride bool
}

type Plugins

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

func (*Plugins) Get

func (*Plugins) GetPlugin

func (p *Plugins) GetPlugin(ctx context.Context, pluginID string) (*[]client.CSIPlugin, *QueryMeta, OpenAPIError)

func (*Plugins) PluginsApi

func (p *Plugins) PluginsApi() *client.PluginsApiService

type QueryMeta

type QueryMeta struct {
	// LastIndex can be used as a Index to perform
	// a blocking query
	LastIndex uint64

	// LastContact is the time of last contact from the leader for the
	// server servicing the request
	LastContact time.Duration

	// KnownLeader indicates if there is a known leader
	KnownLeader bool

	// RequestTime is how long did the request took
	RequestTime time.Duration
}

QueryMeta is used to return metadata about a query

type QueryOpts

type QueryOpts struct {
	// Providing a datacenter overwrites the region provided
	// by the Config
	Region string

	// Namespace is the target namespace for the query.
	Namespace string

	// AllowStale allows any Nomad server (non-leader) to service
	// a read. This allows for lower latency and higher throughput
	AllowStale bool

	// WaitIndex is used to enable a blocking query. Waits
	// until the timeout or the next index is reached
	WaitIndex int32

	// WaitTime is used to bound the duration of a call and is set in milliseconds.
	WaitTime time.Duration

	// If set, used as prefix for resource list searches
	Prefix string

	// Set HTTP parameters on the query.
	Params map[string]string

	// AuthToken is the secret ID of an ACL token
	AuthToken string

	// PerPage is the number of entries to be returned in queries that support
	// paginated lists.
	PerPage int32

	// NextToken is the token used indicate where to start paging for queries
	// that support paginated lists.
	NextToken string
}

QueryOpts are used to parametrize a query

func DefaultQueryOpts

func DefaultQueryOpts() *QueryOpts

DefaultQueryOpts returns a QueryOpts for the default namespace and global region.

func (*QueryOpts) Ctx

func (q *QueryOpts) Ctx() context.Context

func (*QueryOpts) WithAllowStale

func (q *QueryOpts) WithAllowStale(allowStale bool) *QueryOpts

func (*QueryOpts) WithAuthToken

func (q *QueryOpts) WithAuthToken(authToken string) *QueryOpts

func (*QueryOpts) WithNamespace

func (q *QueryOpts) WithNamespace(namespace string) *QueryOpts

func (*QueryOpts) WithNextToken

func (q *QueryOpts) WithNextToken(nextToken string) *QueryOpts

func (*QueryOpts) WithPerPage

func (q *QueryOpts) WithPerPage(perPage int32) *QueryOpts

func (*QueryOpts) WithPrefix

func (q *QueryOpts) WithPrefix(prefix string) *QueryOpts

func (*QueryOpts) WithRegion

func (q *QueryOpts) WithRegion(region string) *QueryOpts

func (*QueryOpts) WithWaitIndex

func (q *QueryOpts) WithWaitIndex(waitIndex int32) *QueryOpts

func (*QueryOpts) WithWaitTime

func (q *QueryOpts) WithWaitTime(waitTime time.Duration) *QueryOpts

type Regions

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

func (*Regions) GetRegions

func (r *Regions) GetRegions(ctx context.Context) (*[]string, OpenAPIError)

func (*Regions) RegionsApi

func (r *Regions) RegionsApi() *client.RegionsApiService

type RegisterOpts

type RegisterOpts struct {
	EnforceIndex   bool
	ModifyIndex    uint64
	PolicyOverride bool
	PreserveCounts bool
}

type Scaling

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

func (*Scaling) GetPolicy

func (s *Scaling) GetPolicy(ctx context.Context, policyID string) (*client.ScalingPolicy, *QueryMeta, OpenAPIError)

func (*Scaling) Policies

func (*Scaling) ScalingApi

func (s *Scaling) ScalingApi() *client.ScalingApiService

type Status

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

func (*Status) Leader

func (s *Status) Leader(ctx context.Context) (*string, OpenAPIError)

func (*Status) Peers

func (s *Status) Peers(ctx context.Context) (*[]string, OpenAPIError)

func (*Status) StatusApi

func (s *Status) StatusApi() *client.StatusApiService

type System

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

func (*System) GarbageCollect

func (s *System) GarbageCollect(ctx context.Context) OpenAPIError

func (*System) Reconcile

func (s *System) Reconcile(ctx context.Context) OpenAPIError

func (*System) SystemApi

func (s *System) SystemApi() *client.SystemApiService

type WriteMeta

type WriteMeta struct {
	// LastIndex can be used as a Index to perform
	// a blocking query
	LastIndex uint64

	// RequestTime is how long did the request took
	RequestTime time.Duration
}

WriteMeta is used to return metadata about a write operation

type WriteOpts

type WriteOpts struct {
	// Providing a datacenter overwrites the region provided
	// by the Config
	Region string

	// Namespace is the target namespace for the operation.
	Namespace string

	// AuthToken is the secret ID of an ACL token
	AuthToken string

	// IdempotencyToken can be used to ensure the operation is idempotent.
	IdempotencyToken string
}

WriteOpts are used to parametrize a write operation

func DefaultWriteOpts

func DefaultWriteOpts() *WriteOpts

DefaultWriteOpts returns a WriteOps for the default namespace and the global region

func (*WriteOpts) Ctx

func (w *WriteOpts) Ctx() context.Context

func (*WriteOpts) WithAuthToken

func (w *WriteOpts) WithAuthToken(authToken string) *WriteOpts

func (*WriteOpts) WithIdempotencyToken

func (w *WriteOpts) WithIdempotencyToken(idempotencyToken string) *WriteOpts

func (*WriteOpts) WithNamespace

func (w *WriteOpts) WithNamespace(namespace string) *WriteOpts

func (*WriteOpts) WithRegion

func (w *WriteOpts) WithRegion(region string) *WriteOpts

Directories

Path Synopsis
client module

Jump to

Keyboard shortcuts

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