wireformat

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

wireformat package contains wireformat structs intended for plan management API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorization

type Authorization struct {
	AuthorizationID string    `json:"authorization-id"` // TODO(cmars): rename to AuthUUID & auth-uuid
	User            string    `json:"user"`
	PlanURL         string    `json:"plan"`
	EnvironmentUUID string    `json:"env-uuid"`
	CharmURL        string    `json:"charm-url"`
	ServiceName     string    `json:"service-name"`
	CreatedOn       time.Time `json:"created-on"`
	CredentialsID   string    `json:"credentials-id"`
	PlanDefinition  string    `json:"plan-definition,omitempty"`
	PlanID          string    `json:"plan-id,omitempty"`
}

Authorization defines the struct containing information on an issued request for a plan authorization macaroon.

func (*Authorization) UnmarshalJSON

func (a *Authorization) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a transitional json.Unmarshaler to allow forward-compatible processing of fields renamed in Juju 2.0.

type AuthorizationQuery

type AuthorizationQuery struct {
	AuthorizationID string `json:"authorization-id"` // TODO(cmars): rename to AuthUUID & auth-uuid
	User            string `json:"user"`
	PlanURL         string `json:"plan"`
	EnvironmentUUID string `json:"env-uuid"`
	CharmURL        string `json:"charm-url"`
	ServiceName     string `json:"service-name"`
	IncludePlan     bool   `json:"include-plan"`
	StatementPeriod string `json:"statement-period"`
}

AuthorizationQuery defines the struct used to query authorization records.

func (*AuthorizationQuery) UnmarshalJSON

func (a *AuthorizationQuery) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a transitional json.Unmarshaler to allow forward-compatible processing of fields renamed in Juju 2.0.

type AuthorizationRequest

type AuthorizationRequest struct {
	EnvironmentUUID string `json:"env-uuid"`
	CharmURL        string `json:"charm-url"`
	ServiceName     string `json:"service-name"`
	PlanURL         string `json:"plan-url"`
}

AuthorizationRequest defines the struct used to request a plan authorization.

func (*AuthorizationRequest) UnmarshalJSON

func (ar *AuthorizationRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a transitional json.Unmarshaler to allow forward-compatible processing of fields renamed in Juju 2.0.

func (AuthorizationRequest) Validate

func (s AuthorizationRequest) Validate() error

Validate checks the AuthorizationRequest for errors.

type CharmPlanDetail

type CharmPlanDetail struct {
	CharmURL       string     `json:"charm"`
	Attached       Event      `json:"attached"`
	EffectiveSince *time.Time `json:"effective-since,omitempty"`
	Default        bool       `json:"default"`
	Events         []Event    `json:"events"`
}

type Event

type Event struct {
	User string    `json:"user"` // user who triggered the event
	Type string    `json:"type"` // type of the event
	Time time.Time `json:"time"` // timestamp
}

Event defines the wireformat for a backend.event

type Plan

type Plan struct {
	Id              string      `json:"id"`         // Full id of the plan format
	URL             string      `json:"url"`        // Name of the rating plan
	Definition      string      `json:"plan"`       // The rating plan source
	CreatedOn       string      `json:"created-on"` // When the plan was created - RFC3339 encoded timestamp
	PlanDescription string      `json:"description"`
	PlanPrice       string      `json:"price"`
	Released        bool        `json:"released"`
	EffectiveTime   *time.Time  `json:"effective-time,omitempty"`
	Model           interface{} `json:"model,omitempty"` // The rating plan model
}

Plan structure is used as a wire format to store information on ISV-created rating plan and charm URLs for which the plan is valid.

func (Plan) Validate

func (p Plan) Validate() error

Validate validates the plan and returns any errors if the contents are invalid.

type PlanActive

type PlanActive struct {
	*Plan
	Active bool `json:"active"`
}

PlanActive structure adds an active field to the plan wireformat.

type PlanDetails

type PlanDetails struct {
	Plan     Plan              `json:"plan"`
	Created  Event             `json:"created-event"`
	Released *Event            `json:"released-event,omitempty"`
	Charms   []CharmPlanDetail `json:"charms,omitempty"`
}

PlanDetails defines the wireformat for a plan with details abouts historical lifecycle.

type PlanID

type PlanID struct {
	PlanURL
	Revision int
}

PlanID identifies a plan revision.

func ParsePlanID

func ParsePlanID(id string) (*PlanID, error)

ParsePlanID parses the string representation of a plan ID. Canonical string format is: owner/name/revision

func ParsePlanIDWithOptionalRevision

func ParsePlanIDWithOptionalRevision(id string) (*PlanID, error)

ParsePlanIDWithOptionalRevision parses the string representation of a plan ID. If revision is not specified, it will be set to 0. Canonical string format is: owner/name/revision

func (PlanID) String

func (p PlanID) String() string

String returns the plan id in canonical string format.

func (PlanID) Validate

func (p PlanID) Validate() error

Validate returns an error if one of the components of the PlanID is not in acceptable format.

type PlanURL

type PlanURL struct {
	Owner string
	Name  string
}

PlanURL holds the components of a plan url.

func ParsePlanURL

func ParsePlanURL(url string) (*PlanURL, error)

ParsePlanURL converts a plan url in canonical string format into a PlanURL. Canonical string format is: owner/name

func (PlanURL) Revision

func (p PlanURL) Revision(rev int) PlanID

Revision generates a PlanID based on the PlanURL and provided revision number.

func (PlanURL) String

func (p PlanURL) String() string

String returns the plan url in canonical string format.

func (PlanURL) Validate

func (p PlanURL) Validate() error

Validate returns an error if one of the components of the PlanURL is not in acceptable format.

type ResellerAuthorization

type ResellerAuthorization struct {
	AuthUUID         string    `json:"auth-uuid"`
	Plan             string    `json:"plan"`
	CharmURL         string    `json:"charm-url"`
	Application      string    `json:"application"`
	ApplicationOwner string    `json:"owner"`
	ApplicationUser  string    `json:"user"`
	Credentials      []byte    `json:"credentials"`
	CreatedOn        time.Time `json:"created-on"`
	PlanDefinition   string    `json:"plan-definition,omitempty"`
	PlanID           string    `json:"plan-id,omitempty"`
}

ResellerAuthorization defines the struct containing information on an issued reseller plan authorization.

type ResellerAuthorizationQuery

type ResellerAuthorizationQuery struct {
	AuthUUID        string `json:"auth-uuid"`
	Application     string `json:"application"`
	Reseller        string `json:"reseller"`
	User            string `json:"user"`
	IncludePlan     bool   `json:"include-plan"`
	StatementPeriod string `json:"statement-period"`
}

ResellerAuthorizationQuery defines the struct used to query reseller authorization records.

func (ResellerAuthorizationQuery) Validate

func (q ResellerAuthorizationQuery) Validate() error

Validate validates the ResellerAuthorizationQuery.

type ResellerAuthorizationRequest

type ResellerAuthorizationRequest struct {
	Application string `json:"application"`
	// The reseller of the application.
	ApplicationOwner string `json:"application-owner"`
	// User consuming resources provided by the application.
	ApplicationUser string `json:"application-user"`
	Plan            string `json:"plan"`
	CharmURL        string `json:"charm-url"`
}

ResellerAuthorizationRequest defines the struct resellers use to obtain authorization credentials.

func (ResellerAuthorizationRequest) Validate

func (r ResellerAuthorizationRequest) Validate() error

Validate checks the ResellerAuthorizationRequest for errors.

type ServicePlanResponse

type ServicePlanResponse struct {
	CurrentPlan    string          `json:"current-plan"`
	AvailablePlans map[string]Plan `json:"available-plans"`
}

ServicePlanResponse defines the response for getServicePlan.

type UUIDResponse

type UUIDResponse struct {
	UUID string `json:"uuid"`
}

UUIDResponse defines a response that just contains a uuid.

Jump to

Keyboard shortcuts

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