anypoint

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 18 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 (
	HealthCheckEndpoint = "mulesoft"
)

Variables

View Source
var (
	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")
)

Functions

func ToPointer added in v1.1.47

func ToPointer[K comparable](val K) *K

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"`
	Endpoint                  *Endpoint `json:"endpoint,omitempty"`
	EnvironmentID             string    `json:"environmentId"`
	GroupID                   string    `json:"groupId"`
	ID                        int       `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 APIMonitoringMetric added in v1.2.5

type APIMonitoringMetric struct {
	Time   time.Time
	Events []APISummaryMetricEvent
}

Monitoring Archive API metrics data definitions

type APISummaryMetricEvent added in v1.2.5

type APISummaryMetricEvent struct {
	APIName            string `json:"api_name"`
	APIVersion         string `json:"api_version"`
	APIVersionID       string `json:"api_version_id"`
	ClientID           string `json:"client_id"`
	Method             string `json:"method"`
	StatusCode         string `json:"status_code"`
	ResponseSizeCount  int    `json:"response_size.count"`
	ResponseSizeMax    int    `json:"response_size.max"`
	ResponseSizeMin    int    `json:"response_size.min"`
	ResponseSizeSos    int    `json:"response_size.sos"`
	ResponseSizeSum    int    `json:"response_size.sum"`
	ResponseTimeCount  int    `json:"response_time.count"`
	ResponseTimeMax    int    `json:"response_time.max"`
	ResponseTimeMin    int    `json:"response_time.min"`
	ResponseTimeSos    int    `json:"response_time.sos"`
	ResponseTimeSum    int    `json:"response_time.sum"`
	RequestSizeCount   int    `json:"request_size.count"`
	RequestSizeMax     int    `json:"request_size.max"`
	RequestSizeMin     int    `json:"request_size.min"`
	RequestSizeSos     int    `json:"request_size.sos"`
	RequestSizeSum     int    `json:"request_size.sum"`
	RequestDisposition string `json:"request_disposition"`
}

type AnalyticsClient

type AnalyticsClient interface {
	GetMonitoringBootstrap() (*MonitoringBootInfo, error)
	GetMonitoringMetrics(dataSourceName string, dataSourceID int, apiID, apiVersionID string, startDate, endTime time.Time) ([]APIMonitoringMetric, error)
	GetMonitoringArchive(apiID string, startDate time.Time) ([]APIMonitoringMetric, error)
	OnConfigChange(mulesoftConfig *config.MulesoftConfig)
	GetClientApplication(appID string) (*Application, error)
	GetAPI(apiID string) (*API, error)
}

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(apiID string, app *AppRequestBody) (*Application, error)

func (*AnypointClient) CreateContract

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

func (*AnypointClient) CreateSLATier added in v1.1.47

func (c *AnypointClient) CreateSLATier(apiID string) (int, error)

func (*AnypointClient) DeleteClientApplication

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

func (*AnypointClient) DeleteContract added in v1.1.5

func (c *AnypointClient) DeleteContract(apiID, contractID string) error

func (*AnypointClient) GetAPI added in v1.1.5

func (c *AnypointClient) GetAPI(apiID string) (*API, error)

GetAPI gets a single api by id

func (*AnypointClient) GetAccessToken

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

GetAccessToken retrieves a token

func (*AnypointClient) GetClientApplication

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

func (*AnypointClient) GetContract added in v1.1.5

func (c *AnypointClient) GetContract(apiID, contractID string) (*Contract, 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, useOriginalRaml bool) ([]byte, bool, error)

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

func (*AnypointClient) GetMonitoringArchive added in v1.2.5

func (c *AnypointClient) GetMonitoringArchive(apiID string, startDate time.Time) ([]APIMonitoringMetric, error)

GetMonitoringArchive returns archived monitoring data Mulesoft: https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/anypoint-monitoring-archive-api/minor/1.0/pages/home/

func (*AnypointClient) GetMonitoringBootstrap added in v1.2.5

func (c *AnypointClient) GetMonitoringBootstrap() (*MonitoringBootInfo, error)

func (*AnypointClient) GetMonitoringMetrics added in v1.2.5

func (c *AnypointClient) GetMonitoringMetrics(dataSourceName string, dataSourceID int, apiID, apiVersionID string, startDate, endTime time.Time) ([]APIMonitoringMetric, error)

GetMonitoringMetrics returns monitoring data from InfluxDb

func (*AnypointClient) GetPolicies

func (c *AnypointClient) GetPolicies(apiID string) ([]Policy, error)

GetPolicies lists the API policies.

func (*AnypointClient) GetSLATiers

func (c *AnypointClient) GetSLATiers(apiID string, tierName string) (*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)

func (*AnypointClient) ResetAppSecret added in v1.1.9

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

func (*AnypointClient) RevokeContract added in v1.1.5

func (c *AnypointClient) RevokeContract(apiID, contractID string) error

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           int    `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 {
	CreateClientApplication(apiID string, app *AppRequestBody) (*Application, error)
	CreateContract(appID string, contract *Contract) (*Contract, error)
	DeleteClientApplication(appID string) error
	GetAccessToken() (string, *User, time.Duration, error)
	GetAPI(apiID string) (*API, error)
	GetClientApplication(appID string) (*Application, error)
	GetEnvironmentByName(name string) (*Environment, error)
	GetExchangeAsset(groupID, assetID, assetVersion string) (*ExchangeAsset, error)
	GetExchangeAssetIcon(icon string) (string, string, error)
	GetExchangeFileContent(link, packaging, mainFile string, useOriginalRaml bool) ([]byte, bool, error)
	GetPolicies(apiID string) ([]Policy, error)
	GetSLATiers(apiID string, tierName string) (*Tiers, error)
	CreateSLATier(apiID string) (int, error)
	ListAssets(page *Page) ([]Asset, error)
	OnConfigChange(mulesoftConfig *config.MulesoftConfig)
	DeleteContract(apiID, contractID string) error
	RevokeContract(apiID, contractID string) error
	ResetAppSecret(appID string) (*Application, 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"`
	ID              int    `json:"id"`
	OrganizationID  string `json:"organizationId"`
	RequestedTierID int    `json:"requestedTierId,omitempty"`
	Status          string `json:"status"`
	Version         string `json:"version"`
	VersionGroup    string `json:"versionGroup"`
}

type CurrentUser

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

CurrentUser -

type DataFile added in v1.2.5

type DataFile struct {
	ID   string    `json:"id"`
	Time time.Time `json:"time"`
	Size int       `json:"size"`
}

type DataFileResources added in v1.2.5

type DataFileResources struct {
	Resources []DataFile `json:"resources"`
}

type Endpoint added in v1.1.47

type Endpoint struct {
	ProxyURI string `json:"proxyUri"`
}

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 InfluxDB added in v1.2.5

type InfluxDB struct {
	ID       int    `json:"id"`
	Database string `json:"database"`
}

type Limits

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

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 MetricData added in v1.2.5

type MetricData struct {
	Format   string                 `json:"format"`
	Time     int64                  `json:"time"`
	Type     string                 `json:"type"`
	Metadata map[string]interface{} `json:"metadata"`
	Commons  map[string]interface{} `json:"commons"`
	Events   []APISummaryMetricEvent
}

type MetricResponse added in v1.2.5

type MetricResponse struct {
	Results []*MetricResult `json:"results"`
}

type MetricResult added in v1.2.5

type MetricResult struct {
	StatementID int             `json:"statement_id"`
	Series      []*MetricSeries `json:"series"`
}

type MetricSeries added in v1.2.5

type MetricSeries struct {
	Name        string      `json:"name"`
	Tags        *MetricTag  `json:"tags"`
	Columns     []string    `json:"columns"`
	Values      [][]float64 `json:"values"`
	Time        time.Time   `json:"-"`
	Count       int64       `json:"-"`
	ResponseMax int64       `json:"-"`
	ResponseMin int64       `json:"-"`
}

func (*MetricSeries) UnmarshalJSON added in v1.2.5

func (ms *MetricSeries) UnmarshalJSON(data []byte) error

type MetricTag added in v1.2.5

type MetricTag struct {
	ClientID   string `json:"client_id"`
	StatusCode string `json:"status_code"`
}

type MockAnypointClient

type MockAnypointClient struct {
	mock.Mock
}

func (*MockAnypointClient) CreateClientApplication

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

func (*MockAnypointClient) CreateContract

func (m *MockAnypointClient) CreateContract(appID string, contract *Contract) (*Contract, error)

func (*MockAnypointClient) CreateSLATier added in v1.1.47

func (m *MockAnypointClient) CreateSLATier(apiID string) (int, error)

func (*MockAnypointClient) DeleteClientApplication

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

func (*MockAnypointClient) DeleteContract added in v1.1.5

func (m *MockAnypointClient) DeleteContract(apiID, contractID string) error

func (*MockAnypointClient) GetAPI added in v1.1.5

func (m *MockAnypointClient) GetAPI(apiID string) (*API, error)

func (*MockAnypointClient) GetAccessToken

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

func (*MockAnypointClient) GetClientApplication added in v1.1.5

func (m *MockAnypointClient) GetClientApplication(appID string) (*Application, 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, shouldConvert bool) ([]byte, bool, error)

func (*MockAnypointClient) GetMonitoringArchive added in v1.2.5

func (m *MockAnypointClient) GetMonitoringArchive(apiID string, startDate time.Time) ([]APIMonitoringMetric, error)

func (*MockAnypointClient) GetPolicies

func (m *MockAnypointClient) GetPolicies(string) ([]Policy, error)

func (*MockAnypointClient) GetSLATiers

func (m *MockAnypointClient) GetSLATiers(apiID, tierName string) (*Tiers, error)

func (*MockAnypointClient) ListAssets

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

func (*MockAnypointClient) OnConfigChange

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

func (*MockAnypointClient) ResetAppSecret added in v1.1.9

func (m *MockAnypointClient) ResetAppSecret(appID string) (*Application, error)

func (*MockAnypointClient) RevokeContract added in v1.1.5

func (m *MockAnypointClient) RevokeContract(apiID, contractID string) error

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 MonitoringBootInfo added in v1.2.5

type MonitoringBootInfo struct {
	Settings MonitoringBootSetting `json:"Settings"`
}

Influx DB based metric data definitions

type MonitoringBootSetting added in v1.2.5

type MonitoringBootSetting struct {
	DataSource MonitoringDataSource `json:"datasources"`
}

type MonitoringDataSource added in v1.2.5

type MonitoringDataSource struct {
	InfluxDB InfluxDB `json:"influxdb"`
}

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 {
	Configuration     interface{} `json:"configuration,omitempty"`
	ConfigurationData interface{} `json:"configurationData,omitempty"`
	PolicyTemplateID  string      `json:"policyTemplateId,omitempty"`
}

Policy -

type SLATier

type SLATier struct {
	Audit                *Audit   `json:"audit,omitempty"`
	MasterOrganizationID *string  `json:"masterOrganizationId,omitempty"`
	OrganizationID       *string  `json:"organizationId,omitempty"`
	Description          *string  `json:"description,omitempty"`
	ID                   *int     `json:"id,omitempty"`
	Limits               []Limits `json:"limits"`
	Name                 string   `json:"name"`
	Status               string   `json:"status"`
	AutoApprove          bool     `json:"autoApprove"`
	ApplicationCount     *int     `json:"applicationCount,omitempty"`
}

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