gateway

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBackend

func DefaultBackend() manifold.Backend

DefaultBackend returns an instance of the default Backend configuration.

Types

type APIClient

type APIClient struct {
	ID        *IDClient
	Product   *ProductClient
	Products  *ProductsClient
	Resource  *ResourceClient
	Resources *ResourcesClient
	// contains filtered or unexported fields
}

APIClient is an API client for all endpoints.

func NewAPI

func NewAPI() *APIClient

NewAPI returns a new APIClient with the default configuration.

type CatalogFeatureType

type CatalogFeatureType struct {
	Label        string `json:"label"`
	Name         string `json:"name"`
	Type         string `json:"type"`
	Customizable *bool  `json:"customizable"` // This sets whether or not the feature can be customized by a consumer.

	// This sets whether or not the feature can be upgraded by the consumer after the
	// resource has provisioned. Upgrading means setting a higher value or selecting a
	// higher element in the list.
	Upgradable *bool `json:"upgradable"`

	// This sets whether or not the feature can be downgraded by the consumer after the
	// resource has provisioned. Downgrading means setting a lower value or selecting a
	// lower element in the list.
	Downgradable *bool `json:"downgradable"`

	// Sets if this feature’s value is trackable from the provider,
	// this only really affects numeric constraints.
	Measurable *bool                         `json:"measurable"`
	Values     *[]CatalogFeatureValueDetails `json:"values"` // Optional
}

CatalogFeatureType is a data type for API communication. A feature type represents the different aspects of a product that are offered, these features can manifest differently depending on the plan.

type CatalogFeatureValueDetails

type CatalogFeatureValueDetails struct {
	Label string `json:"label"`
	Name  string `json:"name"`

	// The cost that will be added to the monthly plan cost when this value
	// is selected or is default for the plan.
	// Cost is deprecated in favor of the `price.cost` field.
	Cost *int `json:"cost"`

	// Price describes the cost of a feature. It should be preferred over
	// the `cost` property.
	Price *struct {
		// Cost is the price in cents that will be added to plan's base cost
		// when this value is selected or is default for the plan.
		// Number features should use the cost range instead.
		Cost *int `json:"cost"`

		// When a feature is used to multiply the cost of the plan or of
		// another feature, multiply factor is used for calculation.
		// A feature cannot have both a cost and a multiply factor.
		MultiplyFactor *float64 `json:"multiply_factor"`
		Formula        *string  `json:"formula"`     // Optional
		Description    *string  `json:"description"` // Description explains how a feature is calculated to the user.
	} `json:"price"`

	NumericDetails *struct {
		// Sets the increment at which numbers can be selected if customizable, by
		// default this is 1; for example, setting this to 8 would only allow integers
		// in increments of 8 ( 0, 8, 16, ... ). This property is not used if the
		// feature is measurable; except if it is set to 0, setting the increment to 0
		// means this numeric details has no scale, and will not be or customizable.
		// Some plans may not have a measureable or customizable feature.
		Increment *int `json:"increment"`
		Min       *int `json:"min"` // Minimum value that can be set by a user if customizable
		Max       *int `json:"max"` // Maximum value that can be set by a user if customizable

		// Applied to the end of the number for display, for example the ‘GB’ in ‘20 GB’.
		Suffix *string `json:"suffix"`

		CostRanges *[]struct {
			// Defines the end of the range ( inclusive ), from the previous, or 0;
			// where the cost_multiple starts taking effect. If set to -1 this defines the
			// range to infinity, or the maximum integer the system can handle
			// ( whichever comes first ).
			Limit *int `json:"limit"`

			// An integer in 10,000,000ths of cents, will be multiplied by the
			// numeric value set in the feature to determine the cost.
			CostMultiple *int `json:"cost_multiple"`
		} `json:"cost_ranges"` // Optional
	} `json:"numeric_details"` // Optional
}

CatalogFeatureValueDetails is a data type for API communication.

type Client

type Client struct {
	APIClient
	// contains filtered or unexported fields
}

Client is the Manifold API client.

func New

func New(cfgs ...ConfigFunc) *Client

New returns a new API client with the default configuration

type ConfigFunc

type ConfigFunc func(*Client)

ConfigFunc is a func that configures the client during New

func ForURLPattern

func ForURLPattern(pattern string) ConfigFunc

ForURLPattern returns a configuration func to set the URL pattern for all endpoints.

func WithAPIToken

func WithAPIToken(token string) ConfigFunc

WithAPIToken returns a configuration func to set the API key to use for authentication.

func WithUserAgent

func WithUserAgent(agent string) ConfigFunc

WithUserAgent sets a specific user agent on the client. This will overwrite any 'User-Agent' header that has been set before. We will prepend the specified agent with `go-manifold-$version`.

type Error added in v0.10.9

type Error struct {
	Type    string `json:"type"`
	Code    string `json:"code"`
	Class   string `json:"class"`
	Message string `json:"message"`
}

Error represents the error returned by a handler to the requestor

func (*Error) Error added in v0.10.9

func (e *Error) Error() string

Error implements the error interface

type GetMeOpts

type GetMeOpts struct {
	ProductLabel *string `json:"product_label"` // Label of the Product to filter Resources by.
	ProjectLabel *string `json:"project_label"` // Label of the Project to filter Resources by.
}

GetMeOpts holds optional argument values

type IDClient

type IDClient endpoint

IDClient provides access to the /id APIs

func (*IDClient) CreatePlanCost

func (c *IDClient) CreatePlanCost(ctx context.Context, id gomanifold.ID, planCostRequest *PlanCostRequest) (*Price, error)

CreatePlanCost corresponds to the POST /id/plan/:id/cost endpoint.

Get plan cost Get how much a plan would cost when using a set of features

func (*IDClient) DeleteResource

func (c *IDClient) DeleteResource(ctx context.Context, id gomanifold.ID) error

DeleteResource corresponds to the DELETE /id/resource/:id endpoint.

Delete an existing resource Deletes an existing resource

func (*IDClient) GetProduct

func (c *IDClient) GetProduct(ctx context.Context, id gomanifold.ID) (*ResolvedProduct, error)

GetProduct corresponds to the GET /id/product/:id endpoint.

Get information about a product Get information about the specified product

func (*IDClient) GetResource

func (c *IDClient) GetResource(ctx context.Context, id gomanifold.ID) (*Resource, error)

GetResource corresponds to the GET /id/resource/:id endpoint.

Get information about a resource Get information about the resource and it's operational status

func (*IDClient) UpdateResource

func (c *IDClient) UpdateResource(ctx context.Context, id gomanifold.ID, resourceUpdateRequest *ResourceUpdateRequest) (*Resource, error)

UpdateResource corresponds to the PATCH /id/resource/:id endpoint.

Update an existing resource Updates an existing resource

type Owner

type Owner struct {
	ID   gomanifold.ID `json:"id"`
	Type string        `json:"type"`
	Name *string       `json:"name"` // Optional
}

Owner is a data type for API communication.

type PlanCostRequest

type PlanCostRequest struct {
	Features map[string]interface{} `json:"features"`
}

PlanCostRequest is a data type for API communication.

type Price

type Price struct {
	Cost     int    `json:"cost"`
	Currency string `json:"currency"`
}

Price is a data type for API communication.

type ProductClient

type ProductClient endpoint

ProductClient provides access to the /product APIs

func (*ProductClient) Get

func (c *ProductClient) Get(ctx context.Context, label string) (*ResolvedProduct, error)

Get corresponds to the GET /product/:label endpoint.

Get information about a product Get information about the specified product

type ProductsClient

type ProductsClient endpoint

ProductsClient provides access to the /products APIs

func (*ProductsClient) List

List corresponds to the GET /products/ endpoint.

List all available products

type ProductsListOpts

type ProductsListOpts struct {
	// Base32 encoded 18 byte identifier of the provider that these
	// products must belong to.
	ProviderID   *gomanifold.ID `json:"provider_id"`
	IncludePlans *bool          `json:"include_plans"` // Return product listings without plan information
}

ProductsListOpts holds optional argument values

type ResolvedPlan

type ResolvedPlan struct {
	Name  string `json:"name"`
	Label string `json:"label"`
	State string `json:"state"`

	Features []struct {
		Feature string `json:"feature"`
		Value   string `json:"value"`
	} `json:"features"` // Array of Feature Values
	Cost int `json:"cost"` // Dollar value in cents.

	ExpandedFeatures []struct {
		CatalogFeatureType

		// The string value set for the feature on the plan, this should only be used if the value property is null.
		ValueString string                     `json:"value_string"`
		Value       CatalogFeatureValueDetails `json:"value"`
	} `json:"expanded_features"` // An array of feature definitions for the plan, as defined on the Product.

	// A boolean flag that indicates if a plan is free or not based on it's cost and features.
	Free         bool          `json:"free"`
	DefaultCost  *int          `json:"defaultCost"`  // Plan cost using its default features plus base cost.
	Customizable *bool         `json:"customizable"` // A boolean flag that indicates if a plan has customizable features.
	ID           gomanifold.ID `json:"id"`
}

ResolvedPlan is a data type for API communication.

type ResolvedProduct

type ResolvedProduct struct {
	ProviderID gomanifold.ID `json:"provider_id"`
	Label      string        `json:"label"`
	Name       string        `json:"name"`
	State      string        `json:"state"`

	Listing struct {
		// When true, everyone can see the product when requested. When false it will
		// not be visible to anyone except those on the provider team.
		Public *bool `json:"public"`

		// When true, the product will be displayed in product listings alongside
		// other products. When false the product will be excluded from listings,
		// but can still be provisioned directly if it's label is known.
		// Any pages that display information about the product when not listed,
		// should indicate to webcrawlers that the content should not be indexed.
		Listed *bool `json:"listed"`

		// Object to hold various flags for marketing purposes only. These are values
		// that need to be stored, but should not affect decision making in code. If
		// we find ourselves in a position where we think they should, we should
		// consider refactoring our listing definition.
		Marketing *struct {
			// Indicates whether or not the product is in `Beta` and should be
			// advertised as such. This does not have any impact on who can access the
			// product, it is just used to inform consumers through our clients.
			Beta *bool `json:"beta"`

			// Indicates whether or not the product is in `New` and should be
			// advertised as such. This does not have any impact on who can access the
			// product, it is just used to inform consumers through our clients.
			New *bool `json:"new"`

			// Indicates whether or not the product is in `New` and should be
			// advertised as such. This does not have any impact on who can access the
			// product, it is just used to inform consumers through our clients.
			Featured *bool `json:"featured"`
		} `json:"marketing"`
	} `json:"listing"`

	// Logo used for Provider and Product listings.
	//
	// Must be square (same width and height) and minimum 400px. Maximum of 800px.
	LogoURL string `json:"logo_url"`
	Tagline string `json:"tagline"` // 140 character sentence positioning the product.

	ValueProps []struct {
		Header string `json:"header"` // Heading of a value proposition.
		Body   string `json:"body"`   // Body of a value proposition.
	} `json:"value_props"` // A list of value propositions of the product.
	Images           []string `json:"images"`
	SupportEmail     string   `json:"support_email"`
	DocumentationURL string   `json:"documentation_url"`

	// URL to this Product's Terms of Service. If provided is true, then
	// a url must be set. Otherwise, provided is false.
	Terms struct {
		URL      string `json:"url"`
		Provided bool   `json:"provided"`
	} `json:"terms"`
	FeatureTypes []CatalogFeatureType `json:"feature_types"`

	Billing struct {
		Type     string `json:"type"`
		Currency string `json:"currency"`
	} `json:"billing"`

	Integration struct {
		// Provider Only, implies that the product should only be provisionable by the
		//   provider; so members of the provider team, no one else should be allowed.
		// Pre-Order, should not be used yet. But in the future it should allow people to
		//   pre-provision a resource for when it does go live.
		// Public, means the resource is live and everyone should be able to provision it.
		Provisioning string  `json:"provisioning"`
		BaseURL      string  `json:"base_url"`
		SSOURL       *string `json:"sso_url"` // Optional
		Version      string  `json:"version"`

		Features struct {
			// Indicates whether or not this product supports resource transitions to
			// manifold by access_code.
			AccessCode *bool `json:"access_code"`
			SSO        *bool `json:"sso"` // Represents whether or not this product supports Single Sign On

			// Represents whether or not this product supports changing
			// the plan of a resource.
			PlanChange *bool `json:"plan_change"`

			// Describes how the region for a resource is specified, if
			// unspecified, then regions have no impact on this
			// resource.
			Region *string `json:"region"`
		} `json:"features"`
	} `json:"integration"`
	Tags *[]string     `json:"tags"` // List of tags for product categorization and search
	ID   gomanifold.ID `json:"id"`

	Provider *struct {
		ID    *gomanifold.ID `json:"id"`    // Optional
		Name  *string        `json:"name"`  // Optional
		Label *string        `json:"label"` // Optional
	} `json:"provider"` // Optional
	Plans *[]ResolvedPlan `json:"plans"` // Optional

	// An array of marketing labels for the product listing, generated from the product details.
	ListingLabels []string `json:"listing_labels"`
}

ResolvedProduct is a data type for API communication.

type ResolvedProductIter

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

ResolvedProductIter Iterates over a result set of ResolvedProducts.

func (*ResolvedProductIter) Close

func (i *ResolvedProductIter) Close()

Close closes the ResolvedProductIter and releases any associated resources. After Close, any calls to Current will return an error.

func (*ResolvedProductIter) Current

func (i *ResolvedProductIter) Current() (*ResolvedProduct, error)

Current returns the current ResolvedProduct, and an optional error. Once an error has been returned, the ResolvedProductIter is closed, or the end of iteration is reached, subsequent calls to Current will return an error.

func (*ResolvedProductIter) Next

func (i *ResolvedProductIter) Next() bool

Next advances the ResolvedProductIter and returns a boolean indicating if the end has been reached. Next must be called before the first call to Current. Calls to Current after Next returns false will return an error.

type Resource

type Resource struct {
	ResourceBodyRequired
	ResourceBodyReadFeatures
	CreatedAt string          `json:"created_at"`
	UpdatedAt string          `json:"updated_at"`
	ID        gomanifold.ID   `json:"id"`
	Product   ResolvedProduct `json:"product"`
	Plan      ResolvedPlan    `json:"plan"`

	Region *struct {
		ID   *gomanifold.ID `json:"id"`   // Optional
		Name *string        `json:"name"` // Optional
	} `json:"region"` // Optional

	Project *struct {
		ID    *gomanifold.ID `json:"id"`    // Optional
		Name  *string        `json:"name"`  // Optional
		Label *string        `json:"label"` // Optional
	} `json:"project"` // Optional
	EstimatedCost *Price                  `json:"estimated_cost"` // Optional
	Metadata      *map[string]interface{} `json:"metadata"`       // Optional
	Annotations   *map[string]interface{} `json:"annotations"`    // Optional
}

Resource is a data type for API communication.

type ResourceBodyRead

type ResourceBodyRead struct {
	Type  string  `json:"type"`
	State *string `json:"state"` // Optional

	Operation *struct {
		Status  *string `json:"status"`  // Optional
		State   *string `json:"state"`   // Optional
		Message *string `json:"message"` // Optional
	} `json:"operation"` // Optional
}

ResourceBodyRead is a data type for API communication.

type ResourceBodyReadFeatures

type ResourceBodyReadFeatures struct {
	ResourceBodySource
	ResourceBodyRead

	Features []struct {
		Label    string `json:"label"`
		Name     string `json:"name"`
		Measured *bool  `json:"measured"` // Optional
		Type     string `json:"type"`

		Value struct {
			Value        *struct{} `json:"value"`        // Optional
			DisplayValue *string   `json:"displayValue"` // Optional

			// Applied to the end of the number for display, for example the ‘GB’ in ‘20 GB’.
			Suffix *string `json:"suffix"`

			Price *struct {
				Cost           *int    `json:"cost"` // Optional
				MultiplyFactor float64 `json:"multiply_factor"`
				Formula        string  `json:"formula"`
			} `json:"price"` // Optional
		} `json:"value"`
	} `json:"features"`
}

ResourceBodyReadFeatures is a data type for API communication.

type ResourceBodyRequired

type ResourceBodyRequired struct {
	Label string `json:"label"`
	Owner Owner  `json:"owner"`
}

ResourceBodyRequired is a data type for API communication.

type ResourceBodySource

type ResourceBodySource struct {
	Source string `json:"source"`
}

ResourceBodySource is a data type for API communication.

type ResourceBodyWrite

type ResourceBodyWrite struct {
	Label *string `json:"label"` // Optional
	Owner *Owner  `json:"owner"` // Optional
}

ResourceBodyWrite is a data type for API communication.

type ResourceClient

type ResourceClient endpoint

ResourceClient provides access to the /resource APIs

func (*ResourceClient) Create

func (c *ResourceClient) Create(ctx context.Context, resourceCreateRequest *ResourceCreateRequest) (*Resource, error)

Create corresponds to the POST /resource endpoint.

Create a new Resource Create a new resource, and returns the details about it

type ResourceCreateRequest

type ResourceCreateRequest struct {
	ResourceBodyWrite
	ResourceBodySource
	ProductID   *gomanifold.ID          `json:"product_id"`  // Optional
	PlanID      *gomanifold.ID          `json:"plan_id"`     // Optional
	RegionID    *gomanifold.ID          `json:"region_id"`   // Optional
	ProjectID   *gomanifold.ID          `json:"project_id"`  // Optional
	Features    *map[string]interface{} `json:"features"`    // Optional
	Annotations *map[string]interface{} `json:"annotations"` // Optional
}

ResourceCreateRequest is a data type for API communication.

type ResourceUpdateRequest

type ResourceUpdateRequest struct {
	ResourceBodyWrite
	PlanID      *gomanifold.ID          `json:"plan_id"`     // Optional
	ProjectID   *gomanifold.ID          `json:"project_id"`  // Optional
	Features    *map[string]interface{} `json:"features"`    // Optional
	Annotations *map[string]interface{} `json:"annotations"` // Optional
}

ResourceUpdateRequest is a data type for API communication.

type ResourcesClient

type ResourcesClient endpoint

ResourcesClient provides access to the /resources APIs

func (*ResourcesClient) Get

func (c *ResourcesClient) Get(ctx context.Context, teamLabel string, resourceLabel string, opts *ResourcesGetOpts) (*Resource, error)

Get corresponds to the GET /resources/:team_label/:resource_label/ endpoint.

Get information about a resource from it's label Get information about the resource and it's operational status. The resource will be fetched from the list of resources owned by the team.

func (*ResourcesClient) GetMe

func (c *ResourcesClient) GetMe(ctx context.Context, resourceLabel string, opts *GetMeOpts) (*Resource, error)

GetMe corresponds to the GET /resources/me/:resource_label/ endpoint.

Get information about a resource from it's label Get information about the resource and it's operational status. The resource will be fetched from the list of resources owned by the user.

type ResourcesGetOpts

type ResourcesGetOpts struct {
	ProductLabel *string `json:"product_label"` // Label of the Product to filter Resources by.
	ProjectLabel *string `json:"project_label"` // Label of the Project to filter Resources by.
}

ResourcesGetOpts holds optional argument values

Jump to

Keyboard shortcuts

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