edge

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

package edge provides a client for administering Apigee Edge.

Index

Constants

This section is empty.

Variables

View Source
var OAuthURL = "https://login.apigee.com/oauth/token"

OAuthURL is the oauth token endpoint

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.

func SetOAuthURL

func SetOAuthURL(url string)

SetOAuthURL sets the OAuth url

func StreamToString

func StreamToString(stream io.Reader) string

StreamToString converts a reader to a string

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type ApiProduct

type ApiProduct struct {
	APIResources   []string    `json:"apiResources"`
	ApprovalType   string      `json:"approvalType"`
	CreatedAt      Timestamp   `json:"createdAt,omitempty"`
	CreatedBy      string      `json:"createdBy,omitempty"`
	Description    string      `json:"description"`
	DisplayName    string      `json:"displayName"`
	Environments   []string    `json:"environments"`
	LastModifiedAt Timestamp   `json:"lastModifiedAt,omitempty"`
	LastModifiedBy string      `json:"lastModifiedBy,omitempty"`
	Name           string      `json:"name"`
	Proxies        []string    `json:"proxies"`
	Scopes         []string    `json:"scopes"`
	Attributes     []Attribute `json:"attributes"`
}

type Attribute

type Attribute struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type DeletedProxyInfo

type DeletedProxyInfo struct {
	Name string `json:"name,omitempty"`
}

DeletedProxyInfo contains the name of the deleted proxy

type DeploymentConfiguration

type DeploymentConfiguration struct {
	BasePath string      `json:"basePath,omitempty"`
	Steps    interface{} `json:"steps,omitempty"`
}

type DeploymentEnvironment

type DeploymentEnvironment struct {
	Name       string            `json:"name,omitempty"`
	APIProxies []DeploymentProxy `json:"aPIProxy,omitempty"`
}

type DeploymentProxy

type DeploymentProxy struct {
	Name      string               `json:"name,omitempty"`
	Revisions []DeploymentRevision `json:"revision,omitempty"`
}

type DeploymentRevision

type DeploymentRevision struct {
	// Configuration interface{} `json:"configuration,omitempty"` // includeApiConfig = false, so this is not included
	Name string `json:"name,omitempty"`
	// Servers       []DeploymentServer `json:"server,omitempty"` // includeServerStatus = false, so this is not include
	State string `json:"state,omitempty"`
}

type DeploymentServer

type DeploymentServer struct {
	Pod    Pod      `json:"pod,omitempty"`
	Status string   `json:"status,omitempty"`
	Types  []string `json:"type,omitempty"`
	UUID   string   `json:"uUID,omitempty"`
}

type DeploymentsService

type DeploymentsService interface {
	OrganizationDeployments() (*OrganizationDeployments, *Response, error)
}

DeploymentsService is an interface for interfacing with the Apigee Edge Admin API dealing with apiproxies.

type DeploymentsServiceOp

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

DeploymentsServiceOp represents deployments

func (*DeploymentsServiceOp) OrganizationDeployments

func (s *DeploymentsServiceOp) OrganizationDeployments() (*OrganizationDeployments, *Response, error)

type EdgeAuth

type EdgeAuth struct {
	// Optional. The path to the .netrc file that holds credentials for the Edge Management server.
	// By default, this is ${HOME}/.netrc .  If you specify a Password, this option is ignored.
	NetrcPath string

	// Optional. The username to use when authenticating to the Edge Management server.
	// Ignored if you specify a NetrcPath.
	Username string

	// Optional. Used if you explicitly specify a Password.
	Password string

	// Optional. Required if MFA (multi-factor authorization) is enabled.
	MFAToken string

	// if set to true, no auth will be set
	SkipAuth bool

	// BearerToken token for OAuth or SAML
	BearerToken string
}

EdgeAuth holds information about how to authenticate to the Edge Management server.

func (*EdgeAuth) ApplyTo

func (auth *EdgeAuth) ApplyTo(req *http.Request)

ApplyTo applies the auth info onto a request

type EdgeClient

type EdgeClient struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// Base URL for API requests.
	BaseURLEnv *url.URL

	// User agent for client
	UserAgent string

	// Services used for communicating with the API
	Proxies      ProxiesService
	Deployments  DeploymentsService
	Environments EnvironmentsService
	Products     ProductsService
	Metrics      MetricsService

	IsGCPManaged bool
	// contains filtered or unexported fields
}

EdgeClient manages communication with Apigee Edge V1 Admin API.

func NewEdgeClient

func NewEdgeClient(o *EdgeClientOptions) (*EdgeClient, error)

NewEdgeClient returns a new EdgeClient.

func (*EdgeClient) Do

func (c *EdgeClient) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.

func (*EdgeClient) NewRequest

func (c *EdgeClient) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body. The current environment path element will be included in the URL.

func (*EdgeClient) NewRequestNoEnv

func (c *EdgeClient) NewRequestNoEnv(method, urlStr string, body interface{}) (*http.Request, error)

NewRequestNoEnv creates an API request as NewRequest, but does not include the environment path element.

func (*EdgeClient) OnRequestCompleted

func (c *EdgeClient) OnRequestCompleted(rc RequestCompletionCallback)

OnRequestCompleted sets the request completion callback for the API

type EdgeClientOptions

type EdgeClientOptions struct {

	// MgmtURL is the Admin base URL. Optional. For example, if using OPDK this might be
	// http://192.168.10.56:8080. It defaults to https://api.enterprise.apigee.com.
	MgmtURL string

	// Specify the Edge organization name.
	Org string

	// Specify the Edge environment name.
	Env string

	// Required. Authentication information for the Edge Management server.
	Auth *EdgeAuth

	// Optional. Warning: if set to true, HTTP Basic Auth base64 blobs will appear in output.
	Debug bool

	// Optional. For hybrid and NG must be true.
	GCPManaged bool

	// Optional. Skip cert verification.
	InsecureSkipVerify bool

	// Root CAs for mTLS connection
	RootCAs *x509.CertPool

	// TLS Certificates for mTLS connection
	Certificates []tls.Certificate
}

EdgeClientOptions sets options for accessing edge APIs

type EdgeServer

type EdgeServer struct {
	Status string   `json:"status,omitempty"`
	UUID   string   `json:"uUID,omitempty"`
	Type   []string `json:"type,omitempty"`
}

EdgeServer is the deployment status for the edge server. When inquiring the deployment status of an API Proxy revision, even implicitly as when performing a Deploy or Undeploy, the response includes the deployment status for each particular Edge Server in the environment. This struct deserializes that information. It will normally not be useful at all. In rare cases, it may be useful in helping to diagnose problems. For example, if there is a problem with a deployment change, as when a Message Processor is experiencing a problem and cannot undeploy, or more commonly, cannot deploy an API Proxy, this struct will hold relevant information.

type Environment

type Environment struct {
	Name           string    `json:"name,omitempty"`
	CreatedBy      string    `json:"createdBy,omitempty"`
	CreatedAt      Timestamp `json:"createdAt,omitempty"`
	LastModifiedBy string    `json:"lastModifiedBy,omitempty"`
	LastModifiedAt Timestamp `json:"lastModifiedAt,omitempty"`
	APIProxies     []Proxy   `json:"aPIProxy,omitempty"`
}

Environment contains information about an environment within an Edge organization.

type EnvironmentDeployment

type EnvironmentDeployment struct {
	Name     string               `json:"name,omitempty"`
	Revision []RevisionDeployment `json:"revision,omitempty"`
}

EnvironmentDeployment is the deployment state of an environment

type EnvironmentsService

type EnvironmentsService interface {
	ListNames() ([]string, *Response, error)
	Get(env string) (*Environment, *Response, error)
	ListVirtualHosts(env string) ([]string, *Response, error)
	GetVirtualHost(env, name string) (*VirtualHost, *Response, error)
}

EnvironmentsService is an interface for interfacing with the Apigee Edge Admin API querying Edge environments.

type EnvironmentsServiceOp

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

func (*EnvironmentsServiceOp) Get

Get retrieves the information about an Environment in an organization, information including the properties, and the created and last modified details.

func (*EnvironmentsServiceOp) GetVirtualHost

func (s *EnvironmentsServiceOp) GetVirtualHost(env, name string) (*VirtualHost, *Response, error)

func (*EnvironmentsServiceOp) ListNames

func (s *EnvironmentsServiceOp) ListNames() ([]string, *Response, error)

List retrieves the list of environment names for the organization referred by the ApigeeClient.

func (*EnvironmentsServiceOp) ListVirtualHosts

func (s *EnvironmentsServiceOp) ListVirtualHosts(env string) ([]string, *Response, error)

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response

	// Error message - maybe the json for this is "fault"
	Message ResponseErrorMessage `json:"error"`
}

An ErrorResponse reports the error caused by an API request

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type GCPDeployment

type GCPDeployment struct {
	Environment     string `json:"environment,omitempty"`
	Name            string `json:"apiProxy,omitempty"`
	Revision        string `json:"revision,omitempty"`
	DeployStartTime string `json:"deployStartTime,omitempty"`
	BasePath        string `json:"basePath,omitempty"`
}

GCPDeployment contains information about a deployment in GCP.

type GCPDeployments

type GCPDeployments struct {
	Deployments []GCPDeployment `json:"deployments,omitempty"`
}

GCPDeployments holds an array of GCPDeployment objects.

type ListOptions

type ListOptions struct {
	// to ask for expanded results
	Expand bool `url:"expand"`
}

ListOptions holds optional parameters to various List methods

type MetricsService added in v0.2.5

type MetricsService interface {
	Metrics(ctx context.Context, env string, dimensions []string,
		metrics []string, start time.Time, end time.Time) (*apigee.GoogleCloudApigeeV1Stats, *Response, error)
}

MetricsService is an interface for interfacing with the Apigee Edge Admin API dealing with Metrics.

type MetricsServiceOp added in v0.2.5

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

MetricsServiceOp represents metrics

func (*MetricsServiceOp) Metrics added in v0.2.5

func (s *MetricsServiceOp) Metrics(ctx context.Context, env string, dimensions []string,
	metrics []string, start time.Time, end time.Time) (*apigee.GoogleCloudApigeeV1Stats, *Response, error)

type OAuthResponse

type OAuthResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    uint32 `json:"expires_in,omitempty"`
	Scope        string `json:"scope,omitempty"`
	JTI          string `json:"jti,omitempty"`
}

OAuthResponse represents the response from the token request

type OrganizationDeployments

type OrganizationDeployments struct {
	Environments []DeploymentEnvironment `json:"environment"`
	Name         string                  `json:"name"`
}

https://apidocs.apigee.com/docs/deployments/1/routes/organizations/%7Borg_name%7D/deployments/get

type Pod

type Pod struct {
	Name   string `json:"name,omitempty"`
	Region string `json:"region,omitempty"`
}

type ProductsService

type ProductsService interface {
	ListNames() ([]string, *Response, error)
	Get(name string) (*ApiProduct, *Response, error)
}

ProductsService is an interface for interfacing with the Apigee Edge Admin API dealing with APIProducts.

type ProductsServiceOp

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

ProductsServiceOp represents deployments

func (*ProductsServiceOp) Get

func (s *ProductsServiceOp) Get(name string) (*ApiProduct, *Response, error)

func (*ProductsServiceOp) ListNames

func (s *ProductsServiceOp) ListNames() ([]string, *Response, error)

type ProxiesService

type ProxiesService interface {
	ListNames() ([]string, *Response, error)
	Get(string) (*Proxy, *Response, error)
	Import(proxyName string, source string) (*ProxyRevision, *Response, error)
	Deploy(string, string, Revision) (*ProxyRevisionDeployment, *Response, error)
	Undeploy(string, string, Revision) (*ProxyRevisionDeployment, *Response, error)
	GetDeployment(proxy string) (*EnvironmentDeployment, *Response, error)
	GetDeployedRevision(proxy string) (*Revision, error)
	GetGCPDeployments(proxy string) ([]GCPDeployment, *Response, error)
	GetGCPDeployedRevision(proxy string) (*Revision, error)
}

ProxiesService is an interface for interfacing with the Apigee Edge Admin API dealing with apiproxies.

type ProxiesServiceOp

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

ProxiesServiceOp represents operations against Apigee proxies

func (*ProxiesServiceOp) Deploy

func (s *ProxiesServiceOp) Deploy(proxyName, env string, rev Revision) (*ProxyRevisionDeployment, *Response, error)

Deploy a revision of an API proxy to a specific environment within an organization.

func (*ProxiesServiceOp) Get

func (s *ProxiesServiceOp) Get(proxy string) (*Proxy, *Response, error)

Get retrieves the information about an API Proxy in an organization, information including the list of available revisions, and the created and last modified dates and actors.

func (*ProxiesServiceOp) GetDeployedRevision

func (s *ProxiesServiceOp) GetDeployedRevision(proxy string) (*Revision, error)

GetDeployedRevision returns the Revision that is deployed to an environment.

func (*ProxiesServiceOp) GetDeployment

func (s *ProxiesServiceOp) GetDeployment(proxy string) (*EnvironmentDeployment, *Response, error)

GetEnvDeployment retrieves the information about the deployment of an API Proxy in an environment. DOES NOT WORK WITH GCP API!

func (*ProxiesServiceOp) GetGCPDeployedRevision

func (s *ProxiesServiceOp) GetGCPDeployedRevision(proxy string) (*Revision, error)

GetGCPDeployedRevision returns the Revision that is deployed to an environment in GCP.

func (*ProxiesServiceOp) GetGCPDeployments

func (s *ProxiesServiceOp) GetGCPDeployments(proxy string) ([]GCPDeployment, *Response, error)

GetGCPDeployments retrieves the information about deployments of an API Proxy in an GCP organization, including the environment names and revision numbers.

func (*ProxiesServiceOp) Import

func (s *ProxiesServiceOp) Import(proxyName string, source string) (*ProxyRevision, *Response, error)

Import an API proxy into an organization, creating a new API Proxy revision. The proxyName can be passed as "nil" in which case the name is derived from the source. The source can be either a filesystem directory containing an exploded apiproxy bundle, OR the path of a zip file containing an API Proxy bundle. Returns the API proxy revision information. This method does not deploy the imported proxy. See the Deploy method.

func (*ProxiesServiceOp) ListNames

func (s *ProxiesServiceOp) ListNames() ([]string, *Response, error)

func (*ProxiesServiceOp) Undeploy

func (s *ProxiesServiceOp) Undeploy(proxyName, env string, rev Revision) (*ProxyRevisionDeployment, *Response, error)

Undeploy a specific revision of an API Proxy from a particular environment within an Edge organization.

type Proxy

type Proxy struct {
	Revisions []Revision    `json:"revision,omitempty"`
	Name      string        `json:"name,omitempty"`
	MetaData  ProxyMetadata `json:"metaData,omitempty"`
}

Proxy contains information about an API Proxy within an Edge organization.

type ProxyDeployment

type ProxyDeployment struct {
	Environments []EnvironmentDeployment `json:"environment,omitempty"`
	Name         string                  `json:"name,omitempty"`
	Organization string                  `json:"organization,omitempty"`
}

ProxyDeployment holds information about the deployment state of a all revisions of an API Proxy.

type ProxyMetadata

type ProxyMetadata struct {
	LastModifiedBy string    `json:"lastModifiedBy,omitempty"`
	CreatedBy      string    `json:"createdBy,omitempty"`
	LastModifiedAt Timestamp `json:"lastModifiedAt,omitempty"`
	CreatedAt      Timestamp `json:"createdAt,omitempty"`
}

ProxyMetadata contains information related to the creation and last modified time and actor for an API Proxy within an organization.

type ProxyRevision

type ProxyRevision struct {
	CreatedBy       string    `json:"createdBy,omitempty"`
	CreatedAt       Timestamp `json:"createdAt,omitempty"`
	Description     string    `json:"description,omitempty"`
	ContextInfo     string    `json:"contextInfo,omitempty"`
	DisplayName     string    `json:"displayName,omitempty"`
	Name            string    `json:"name,omitempty"`
	LastModifiedBy  string    `json:"lastModifiedBy,omitempty"`
	LastModifiedAt  Timestamp `json:"lastModifiedAt,omitempty"`
	Revision        Revision  `json:"revision,omitempty"`
	TargetEndpoints []string  `json:"targetEndpoints,omitempty"`
	TargetServers   []string  `json:"targetServers,omitempty"`
	Resources       []string  `json:"resources,omitempty"`
	ProxyEndpoints  []string  `json:"proxyEndpoints,omitempty"`
	Policies        []string  `json:"policies,omitempty"`
	Type            string    `json:"type,omitempty"`
}

ProxyRevision holds information about a revision of an API Proxy.

type ProxyRevisionDeployment

type ProxyRevisionDeployment struct {
	Name         string       `json:"aPIProxy,omitempty"`
	Revision     Revision     `json:"revision,omitempty"`
	Environment  string       `json:"environment,omitempty"`
	Organization string       `json:"organization,omitempty"`
	State        string       `json:"state,omitempty"`
	Servers      []EdgeServer `json:"server,omitempty"`
}

ProxyRevisionDeployment holds information about the deployment state of a single revision of an API Proxy.

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

RequestCompletionCallback defines the type of the request callback function

type Response

type Response struct {
	*http.Response
}

Response wraps the standard http.Response returned from Apigee Edge. (why?)

type ResponseErrorMessage

type ResponseErrorMessage struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Status  string `json:"status"`
}

ResponseErrorMessage is a component of an ErrorResponse

type Revision

type Revision int

Revision represents a revision number. Edge returns rev numbers in string form. This marshals and unmarshals between that format and int.

func (Revision) String

func (r Revision) String() string

func (*Revision) UnmarshalJSON

func (r *Revision) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. It unmarshals from a string like "2" (including the quotes), into an integer 2.

type RevisionDeployment

type RevisionDeployment struct {
	Number  Revision     `json:"name,omitempty"`
	State   string       `json:"state,omitempty"`
	Servers []EdgeServer `json:"server,omitempty"`
}

RevisionDeployment is the deployment state of a revision

type RevisionSlice

type RevisionSlice []Revision

RevisionSlice is for sorting

func (RevisionSlice) Len

func (p RevisionSlice) Len() int

func (RevisionSlice) Less

func (p RevisionSlice) Less(i, j int) bool

func (RevisionSlice) Swap

func (p RevisionSlice) Swap(i, j int)

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp represents a time that can be unmarshalled from a JSON string formatted as "java time" = milliseconds-since-unix-epoch.

func (Timestamp) Equal

func (t Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON creates a JSON representation of this Timestamp

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.

type VirtualHost

type VirtualHost struct {
	Name        string   `json:"name,omitempty"`
	Port        string   `json:"port,omitempty"`
	BaseUrl     string   `json:"baseUrl,omitempty"`
	HostAliases []string `json:"hostAliases,omitempty"`
}

Jump to

Keyboard shortcuts

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