apigee

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package apigee 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 APIProductRef

type APIProductRef struct {
	Name   string `json:"apiproduct"`
	Status string `json:"status,omitempty"`
}

APIProductRef holds the name and status of an APIProduct

type AppResponse

type AppResponse struct {
	Apps []Application `json:"app,omitempty"`
}

AppResponse is a collection of Applications

type Application

type Application struct {
	AppID       string          `json:"appId"`
	Attributes  interface{}     `json:"attributes,omitempty"`
	APIProducts []APIProductRef `json:"apiProducts,omitempty"`
	CallBackURL string          `json:"callbackUrl,omitempty"`
	Credentials []Credential    `json:"credentials,omitempty"`
	CompanyName string          `json:"companyName,omitempty"`
	DeveloperID string          `json:"developerId,omitempty"`
	Name        string          `json:"name"`
	Scopes      []string        `json:"scopes,omitempty"`
	Status      string          `json:"status,omitempty"`
}

Application represets an Apigee App

type Cache

type Cache struct {
	Name                              string          `json:"-,omitempty"`
	Description                       string          `json:"description,omitempty"`
	ExpirySettings                    *expirySettings `json:"expirySettings,omitempty"`
	OverflowToDisk                    *bool           `json:"overflowToDisk,omitempty"`
	SkipCacheIfElementSizeInKBExceeds *string         `json:"skipCacheIfElementSizeInKBExceeds,omitempty"`
}

Cache represents a cache definition

type CacheService

type CacheService interface {
	Get(cachename string) (*Cache, *Response, error)
	Create(cache Cache) (*Response, error)
}

CacheService is an interface for interfacing with the Apigee Edge Admin API dealing with caches.

type CacheServiceOp

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

CacheServiceOp represents a cache service operation

func (*CacheServiceOp) Create

func (s *CacheServiceOp) Create(cache Cache) (*Response, error)

Create creates a cache and returns a response

func (*CacheServiceOp) Get

func (s *CacheServiceOp) Get(cachename string) (*Cache, *Response, error)

Get returns a response given a cache name

type Credential

type Credential struct {
	APIProducts []APIProductRef `json:"apiProducts,omitempty"`
}

Credential is a collection of APIProducts

type DeletedProxyInfo

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

DeletedProxyInfo contains the name of the deleted proxy

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

	KVMService KVMService

	CacheService CacheService

	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 Entry

type Entry struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

Entry is an entry in the KVM

type EnvironmentDeployment

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

EnvironmentDeployment is the deployment state of an environment

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 KVM

type KVM struct {
	Name      string  `json:"name,omitempty"`
	Encrypted bool    `json:"encrypted,omitempty"`
	Entries   []Entry `json:"entry,omitempty"`
}

KVM represents an Apigee KVM

func (*KVM) GetValue

func (k *KVM) GetValue(name string) (v string, ok bool)

GetValue returns a value from the KVM

type KVMService

type KVMService interface {
	Get(mapname string) (*KVM, *Response, error)
	Create(kvm KVM) (*Response, error)
	UpdateEntry(kvmName string, entry Entry) (*Response, error)
	AddEntry(kvmName string, entry Entry) (*Response, error)
}

KVMService is an interface for interfacing with the Apigee Edge Admin API dealing with kvm.

type KVMServiceOp

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

KVMServiceOp represents a KVM service operation

func (*KVMServiceOp) AddEntry

func (s *KVMServiceOp) AddEntry(kvmName string, entry Entry) (*Response, error)

AddEntry add an entry to the KVM

func (*KVMServiceOp) Create

func (s *KVMServiceOp) Create(kvm KVM) (*Response, error)

Create creates a KVM and returns a response

func (*KVMServiceOp) Get

func (s *KVMServiceOp) Get(mapname string) (*KVM, *Response, error)

Get returns a response given a KVM map name

func (*KVMServiceOp) UpdateEntry

func (s *KVMServiceOp) UpdateEntry(kvmName string, entry Entry) (*Response, error)

UpdateEntry updates a KVM entry

type ListOptions

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

ListOptions holds optional parameters to various List methods

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 Organization

type Organization struct {
	Name              string      `json:"name"`
	CreatedAt         string      `json:"createdAt,omitempty"`
	LastModifiedAt    string      `json:"lastModifiedAt,omitempty"`
	RuntimeType       string      `json:"runtimeType,omitempty"`
	SubscriptionType  string      `json:"subscriptionType,omitempty"`
	CACertificate     string      `json:"caCertificate,omitempty"`
	ProjectID         string      `json:"projectId"`
	AnalyticsRegion   string      `json:"analyticsRegion,omitempty"`
	AuthorizedNetwork string      `json:"authorizedNetwork,omitempty"`
	Environments      []string    `json:"environments,omitempty"`
	Properties        interface{} `json:"properties,omitempty"`
}

Organization represents a GCP-managed Apigee organization

type ProxiesService

type ProxiesService interface {
	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)

GetDeployment 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) 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.

Jump to

Keyboard shortcuts

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