anypoint

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AccessCode          = "accessCode"
	APIKey              = "apiKey"
	AppName             = "appName"
	Authorization       = "authorization"
	ClientID            = "client-id-enforcement"
	ClientIDProp        = "client_id"
	ClientSecretProp    = "client_secret"
	CredOrigin          = "credentialsOriginHasHttpBasicAuthenticationHeader"
	DescClienCred       = "Provided as: client_id:<INSERT_VALID_CLIENTID_HERE> \n\n client_secret:<INSERT_VALID_SECRET_HERE>\n\n"
	DescOauth2          = "This API supports OAuth 2.0 for authenticating all API requests"
	Description         = "description"
	ErrAuthNotSupported = "only Oauth and ClientID enforcement(ApiKey) security policies are supported"
	ErrSpecNotSupported = "Invalid Spec Type, Only OAS specs are supported"
	ExternalOauth       = "external-oauth2-access-token-enforcement"
	Header              = "header"
	Oauth2              = "oauth2"
	Scopes              = "scopes"
	SLAAuth             = "sla-based"
	TierLabel           = "SLA Tier"
	TokenURL            = "tokenUrl"
)

TODO move the errors to the SDK

View Source
const HealthCheckEndpoint = "mulesoft"

Variables

View Source
var (
	// request and response errors 3001-3099
	ErrUnexpectedResponse       = errors.Newf(3001, "unexpected HTTP response code %v, when communicating with Mulesoft")
	ErrUnexpectedResponsePath   = errors.Newf(3002, "unexpected HTTP response code %v, when communicating with Mulesoft. URL: %s.")
	ErrAPICodeMessage           = errors.Newf(3003, "unexpected Mulesoft response code %s-%s")
	ErrParsingResponse          = errors.New(3004, "could not parse the body of the response from Mulesoft")
	ErrCommunicatingWithGateway = errors.New(3005, "could not make request to Mulesoft")
	ErrMarshallingBody          = errors.New(3006, "could not create the body of the request to Mulesoft")
	ErrAuthentication           = errors.New(3401, "authentication failed")
)

Errors hit communicating with and setting up resources on Mulesoft

Functions

This section is empty.

Types

type API

type API struct {
	ActiveContractsCount      int      `json:"activeContractsCount"`
	AssetID                   string   `json:"assetId"`
	AssetVersion              string   `json:"assetVersion"`
	Audit                     Audit    `json:"audit"`
	AutodiscoveryInstanceName string   `json:"autodiscoveryInstanceName"`
	Deprecated                bool     `json:"deprecated"`
	Description               string   `json:"description"`
	EndpointURI               string   `json:"endpointUri"`
	EnvironmentID             string   `json:"environmentId"`
	GroupID                   string   `json:"groupId"`
	ID                        int64    `json:"id"`
	InstanceLabel             string   `json:"instanceLabel"`
	IsPublic                  bool     `json:"isPublic"`
	MasterOrganizationID      string   `json:"masterOrganizationId"`
	Order                     int      `json:"order"`
	OrganizationID            string   `json:"organizationId"`
	Pinned                    bool     `json:"pinned"`
	ProductVersion            string   `json:"productVersion"`
	Tags                      []string `json:"tags"`
}

API -

type AnalyticsClient

type AnalyticsClient interface {
	GetAnalyticsWindow(string, string) ([]AnalyticsEvent, error)
	OnConfigChange(mulesoftConfig *config.MulesoftConfig)
	GetClientApplication(appId string) (*Application, error)
}

type AnalyticsEvent

type AnalyticsEvent struct {
	APIID              string    `json:"API ID"`
	APIName            string    `json:"API Name"`
	APIVersionID       string    `json:"API Version ID"`
	APIVersionName     string    `json:"API Version Name"`
	ApplicationName    string    `json:"Application Name"`
	Application        string    `json:"Application"`
	Browser            string    `json:"Browser"`
	City               string    `json:"City"`
	ClientIP           string    `json:"Client IP"`
	Continent          string    `json:"Continent"`
	Country            string    `json:"Country"`
	HardwarePlatform   string    `json:"Hardware Platform"`
	MessageID          string    `json:"Message ID"`
	OSFamily           string    `json:"OS Family"`
	OSMajorVersion     string    `json:"OS Major Version"`
	OSMinorVersion     string    `json:"OS Minor Version"`
	OSVersion          string    `json:"OS Version"`
	PostalCode         string    `json:"Postal Code"`
	RequestOutcome     string    `json:"Request Outcome"`
	RequestSize        int       `json:"Request Size"`
	ResourcePath       string    `json:"Resource Path"`
	ResponseSize       int       `json:"Response Size"`
	ResponseTime       int       `json:"Response Time"`
	StatusCode         int       `json:"Status Code"`
	Timestamp          time.Time `json:"Timestamp"`
	Timezone           string    `json:"Timezone"`
	UserAgentName      string    `json:"User Agent Name"`
	UserAgentVersion   string    `json:"User Agent Version"`
	Verb               string    `json:"Verb"`
	ViolatedPolicyName string    `json:"Violated Policy Name"`
}

AnalyticsEvent -

type AnypointClient

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

AnypointClient is the client for interacting with Mulesoft Anypoint.

func NewClient

func NewClient(mulesoftConfig *config.MulesoftConfig, options ...ClientOptions) *AnypointClient

NewClient creates a new client for interacting with Mulesoft.

func (*AnypointClient) CreateClientApplication

func (c *AnypointClient) CreateClientApplication(apiInstanceID string, app *AppRequestBody) (*Application, error)

func (*AnypointClient) CreateContract

func (c *AnypointClient) CreateContract(appID int64, contract *Contract) (*Contract, error)

func (*AnypointClient) DeleteClientApplication

func (c *AnypointClient) DeleteClientApplication(appID int64) error

func (*AnypointClient) GetAccessToken

func (c *AnypointClient) GetAccessToken() (string, *User, time.Duration, error)

GetAccessToken gets an access token

func (*AnypointClient) GetAnalyticsWindow

func (c *AnypointClient) GetAnalyticsWindow(startDate, endDate string) ([]AnalyticsEvent, error)

GetAnalyticsWindow lists the managed assets in Mulesoft: https://docs.qax.mulesoft.com/api-manager/2.x/analytics-event-api

func (*AnypointClient) GetClientApplication

func (c *AnypointClient) GetClientApplication(appID string) (*Application, error)

func (*AnypointClient) GetEnvironmentByName

func (c *AnypointClient) GetEnvironmentByName(name string) (*Environment, error)

GetEnvironmentByName gets the Mulesoft environment with the specified name.

func (*AnypointClient) GetExchangeAsset

func (c *AnypointClient) GetExchangeAsset(groupID, assetID, assetVersion string) (*ExchangeAsset, error)

GetExchangeAsset creates the AssetDetail form the Asset API.

func (*AnypointClient) GetExchangeAssetIcon

func (c *AnypointClient) GetExchangeAssetIcon(icon string) (string, string, error)

GetExchangeAssetIcon get the icon as a base64 encoded string from the Exchange Asset files.

func (*AnypointClient) GetExchangeFileContent

func (c *AnypointClient) GetExchangeFileContent(link, packaging, mainFile string) (fileContent []byte, err error)

GetExchangeFileContent download the file from the ExternalLink reference. If the file is a zip file and thre is a MainFile set then the content of the MainFile is returned.

func (*AnypointClient) GetPolicies

func (c *AnypointClient) GetPolicies(apiID int64) (Policies, error)

GetPolicies lists the API policies.

func (*AnypointClient) GetSLATiers

func (c *AnypointClient) GetSLATiers(apiID int64) (*Tiers, error)

func (*AnypointClient) ListAssets

func (c *AnypointClient) ListAssets(page *Page) ([]Asset, error)

ListAssets lists the API Assets.

func (*AnypointClient) OnConfigChange

func (c *AnypointClient) OnConfigChange(mulesoftConfig *config.MulesoftConfig)

type AppRequestBody

type AppRequestBody struct {
	Description string `json:"description"`
	Name        string `json:"name"`
}

type Application

type Application struct {
	APIEndpoints bool   `json:"apiEndpoints,omitempty"`
	ClientID     string `json:"clientId"`
	ClientSecret string `json:"clientSecret"`
	Description  string `json:"description"`
	ID           int64  `json:"id"`
	Name         string `json:"name"`
}

type Asset

type Asset struct {
	APIs                 []API  `json:"apis"`
	AssetID              string `json:"assetId"`
	Audit                Audit  `json:"audit"`
	AutodiscoveryAPIName string `json:"autodiscoveryApiName"`
	ExchangeAssetName    string `json:"exchangeAssetName"`
	GroupID              string `json:"groupId"`
	ID                   int64  `json:"id"`
	MasterOrganizationID string `json:"masterOrganizationId"`
	Name                 string `json:"name"`
	OrganizationID       string `json:"organizationId"`
	TotalAPIs            int    `json:"totalApis"`
}

Asset -

type AssetSearch

type AssetSearch struct {
	Assets []Asset `json:"assets"`
	Total  int     `json:"total"`
}

AssetSearch -

type Audit

type Audit struct {
	Created AuditEntry `json:"created"`
	Updated AuditEntry `json:"updated"`
}

Audit -

type AuditEntry

type AuditEntry struct {
	Date time.Time `json:"date"`
}

AuditEntry -

type Auth

type Auth interface {
	Stop()
	GetToken() string
	GetOrgID() string
}

Auth represents the authentication information.

func NewAuth

func NewAuth(client AuthClient) (Auth, error)

NewAuth creates a new authentication token

type AuthClient

type AuthClient interface {
	GetAccessToken() (string, *User, time.Duration, error)
}

type Client

type Client interface {
	OnConfigChange(mulesoftConfig *config.MulesoftConfig)
	GetAccessToken() (string, *User, time.Duration, error)
	GetEnvironmentByName(name string) (*Environment, error)
	ListAssets(page *Page) ([]Asset, error)
	GetPolicies(apiID int64) (Policies, error)
	GetExchangeAsset(groupID, assetID, assetVersion string) (*ExchangeAsset, error)
	GetExchangeAssetIcon(icon string) (string, string, error)
	GetExchangeFileContent(link, packaging, mainFile string) ([]byte, error)
	CreateClientApplication(string, *AppRequestBody) (*Application, error)
	CreateContract(int64, *Contract) (*Contract, error)
	GetSLATiers(int642 int64) (*Tiers, error)
	DeleteClientApplication(appID int64) error
}

Client interface to gateway.

type ClientOptions

type ClientOptions func(*AnypointClient)

func SetClient

func SetClient(c coreapi.Client) ClientOptions

SetClient replaces the default apiClient with anything that implements the Client interface. Can be used for writing tests.

type Contract

type Contract struct {
	AcceptedTerms   bool   `json:"acceptedTerms"`
	APIID           string `json:"apiId"`
	AssetID         string `json:"assetId"`
	EnvironmentID   string `json:"environmentId"`
	GroupID         string `json:"groupId"`
	OrganizationID  string `json:"organizationId"`
	RequestedTierID int64  `json:"requestedTierId,omitempty"`
	Version         string `json:"version"`
	VersionGroup    string `json:"versionGroup"`
}

type ContractResponse

type ContractResponse struct {
	API           API    `json:"api"`
	ApplicationID int    `json:"applicationId"`
	ClientID      string `json:"clientId"`
	ClientSecret  string `json:"clientSecret"`
	ID            int    `json:"id"`
	Status        string `json:"status"`
}

type CurrentUser

type CurrentUser struct {
	User User `json:"user"`
}

CurrentUser -

type Environment

type Environment struct {
	ClientID        string `json:"clientId"`
	EnvironmentType string `json:"type"`
	ID              string `json:"id"`
	IsProduction    bool   `json:"isProduction"`
	Name            string `json:"name"`
	OrganizationID  string `json:"organizationId"`
}

Environment -

type EnvironmentSearch

type EnvironmentSearch struct {
	Data  []Environment `json:"data"`
	Total int           `json:"total"`
}

EnvironmentSearch -

type ErrorResponse

type ErrorResponse struct {
	Code    int
	Message string
}

ErrorResponse Error response from Mulesoft

func NewErrorResponse

func NewErrorResponse(body string, code int) *ErrorResponse

NewErrorResponse returns an ErrorResponse struct

func (*ErrorResponse) String

func (er *ErrorResponse) String() string

String format the error response

type ExchangeAPIInstance

type ExchangeAPIInstance struct {
	AssetID           string    `json:"assetId"`
	AssetName         string    `json:"assetName"`
	CreatedBy         string    `json:"createdBy"`
	CreatedDate       time.Time `json:"createdDate"`
	EndpointURI       string    `json:"endpointUri"`
	EnvironmentID     string    `json:"environmentId"`
	Fullname          string    `json:"fullname"`
	GroupID           string    `json:"groupId"`
	ID                string    `json:"id"`
	InstanceType      string    `json:"type"`
	IsPublic          bool      `json:"isPublic"`
	Name              string    `json:"name"`
	ProductAPIVersion string    `json:"productApiVersion"`
	ProviderID        string    `json:"providerId"`
	UpdatedDate       time.Time `json:"updatedDate"`
	Version           string    `json:"version"`
}

ExchangeAPIInstance - https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/exchange-experience-api/minor/2.0/console/method/%231972/

type ExchangeAsset

type ExchangeAsset struct {
	AssetID      string                `json:"assetId"`
	AssetType    string                `json:"type"`
	Categories   []ExchangeCategory    `json:"categories"`
	CreatedAt    time.Time             `json:"createdAt"`
	Description  string                `json:"description"`
	Files        []ExchangeFile        `json:"files"`
	GroupID      string                `json:"groupId"`
	Icon         string                `json:"icon"`
	ID           string                `json:"id"`
	Instances    []ExchangeAPIInstance `json:"instances"`
	Labels       []string              `json:"labels"`
	MinorVersion string                `json:"minorVersion"`
	ModifiedAt   time.Time             `json:"modifiedAt"`
	Name         string                `json:"name"`
	Public       bool                  `json:"isPublic"`
	Snapshot     bool                  `json:"isSnapshot"`
	Status       string                `json:"status"`
	Version      string                `json:"version"`
	VersionGroup string                `json:"versionGroup"`
}

ExchangeAsset - https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/exchange-experience-api/minor/2.0/console/type/%231186/

type ExchangeCategory

type ExchangeCategory struct {
	DisplayName string   `json:"displayName"`
	Key         string   `json:"key"`
	Value       []string `json:"value"`
}

ExchangeCategory -

type ExchangeFile

type ExchangeFile struct {
	Classifier   string    `json:"classifier"`
	CreatedDate  time.Time `json:"createdDate"`
	DownloadURL  string    `json:"downloadURL"`
	ExternalLink string    `json:"externalLink"`
	Generated    bool      `json:"isGenerated"`
	MainFile     string    `json:"mainFile"`
	MD5          string    `json:"md5"`
	Packaging    string    `json:"packaging"`
	SHA1         string    `json:"sha1"`
}

ExchangeFile -

type Limits

type Limits struct {
	MaximumRequests          interface{} `json:"maximumRequests,omitempty"`
	TimePeriodInMilliseconds int         `json:"timePeriodInMilliseconds,omitempty"`
	Visible                  bool        `json:"visible,omitempty"`
}

type ListAssetClient

type ListAssetClient interface {
	ListAssets(page *Page) ([]Asset, error)
}

type MemberOfOrganizations

type MemberOfOrganizations struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

MemberOfOrganizations -

type MockAnypointClient

type MockAnypointClient struct {
	mock.Mock
	CreateContractAssertArgs          bool
	CreateClientApplicationAssertArgs bool
}

func (*MockAnypointClient) CreateClientApplication

func (m *MockAnypointClient) CreateClientApplication(id string, body *AppRequestBody) (*Application, error)

func (*MockAnypointClient) CreateContract

func (m *MockAnypointClient) CreateContract(id int64, contract *Contract) (*Contract, error)

func (*MockAnypointClient) DeleteClientApplication

func (m *MockAnypointClient) DeleteClientApplication(appID int64) error

func (*MockAnypointClient) GetAccessToken

func (m *MockAnypointClient) GetAccessToken() (string, *User, time.Duration, error)

func (*MockAnypointClient) GetAnalyticsWindow

func (m *MockAnypointClient) GetAnalyticsWindow() ([]AnalyticsEvent, error)

func (*MockAnypointClient) GetEnvironmentByName

func (m *MockAnypointClient) GetEnvironmentByName(string) (*Environment, error)

func (*MockAnypointClient) GetExchangeAsset

func (m *MockAnypointClient) GetExchangeAsset(_, _, _ string) (*ExchangeAsset, error)

func (*MockAnypointClient) GetExchangeAssetIcon

func (m *MockAnypointClient) GetExchangeAssetIcon(_ string) (string, string, error)

func (*MockAnypointClient) GetExchangeFileContent

func (m *MockAnypointClient) GetExchangeFileContent(_, _, _ string) ([]byte, error)

func (*MockAnypointClient) GetPolicies

func (m *MockAnypointClient) GetPolicies(int64) (Policies, error)

func (*MockAnypointClient) GetSLATiers

func (m *MockAnypointClient) GetSLATiers(int642 int64) (*Tiers, error)

func (*MockAnypointClient) ListAssets

func (m *MockAnypointClient) ListAssets(*Page) ([]Asset, error)

func (*MockAnypointClient) OnConfigChange

func (m *MockAnypointClient) OnConfigChange(*config.MulesoftConfig)

type MockAuth

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

func (MockAuth) GetOrgID

func (m MockAuth) GetOrgID() string

func (MockAuth) GetToken

func (m MockAuth) GetToken() string

func (MockAuth) Stop

func (m MockAuth) Stop()

type MockClientBase

type MockClientBase struct {
	Reqs map[string]*api.Response
}

func (*MockClientBase) Send

func (mc *MockClientBase) Send(request api.Request) (*api.Response, error)

type Organization

type Organization struct {
	Domain string `json:"domain"`
	ID     string `json:"id"`
	Name   string `json:"name"`
}

Organization -

type Page

type Page struct {
	Offset   int
	PageSize int
}

Page describes the page query parameter

type Policies

type Policies struct {
	Policies []Policy `json:"policies"`
}

type Policy

type Policy struct {
	APIID                int64       `json:"apiId"`
	Audit                Audit       `json:"audit"`
	Configuration        interface{} `json:"configuration"`
	ID                   int64       `json:"id"`
	MasterOrganizationID string      `json:"masterOrganizationId"`
	Order                int         `json:"order"`
	OrganizationID       string      `json:"organizationId"`
	PointCutData         interface{} `json:"pointCutData"`
	PolicyID             int         `json:"policyId"`
	PolicyTemplateID     string      `json:"policyTemplateId"`
	Template             Template    `json:"template"`
	Type                 string      `json:"type"`
	Version              int64       `json:"version"`
}

Policy -

type SLATier

type SLATier struct {
	Description interface{} `json:"description"`
	ID          int         `json:"id"`
	Limits      []Limits    `json:"limits"`
	Name        string      `json:"name"`
	Status      string      `json:"status"`
}

type Template

type Template struct {
	AssetID      string `json:"assetId"`
	AssetVersion string `json:"assetVersion"`
	GroupID      string `json:"groupId"`
}

type Tiers

type Tiers struct {
	Total int       `json:"total"`
	Tiers []SLATier `json:"tiers"`
}

type User

type User struct {
	Email                 string                  `json:"email"`
	FirstName             string                  `json:"firstName"`
	ID                    string                  `json:"id"`
	IdentityType          string                  `json:"identityType"`
	LastName              string                  `json:"lastName"`
	Organization          Organization            `json:"organization"`
	MemberOfOrganizations []MemberOfOrganizations `json:"memberOfOrganizations"`
	Username              string                  `json:"username"`
}

User -

Jump to

Keyboard shortcuts

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