anypoint

package
v1.1.46 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

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

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)
	GetAPI(id string) (*API, 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"`
	AssetVersion       string    `json:"AssetVersion"`
}

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) DeleteContract added in v1.1.5

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

func (*AnypointClient) GetAPI added in v1.1.5

func (c *AnypointClient) GetAPI(id 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) 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) GetContract added in v1.1.5

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

func (c *AnypointClient) GetPolicies(apiID int64) ([]Policy, 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)

func (*AnypointClient) ResetAppSecret added in v1.1.9

func (c *AnypointClient) ResetAppSecret(appID int64) (*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           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 {
	CreateClientApplication(apiInstanceID string, app *AppRequestBody) (*Application, error)
	CreateContract(int64, *Contract) (*Contract, error)
	DeleteClientApplication(appID int64) error
	GetAccessToken() (string, *User, time.Duration, error)
	GetAPI(id 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 int64) ([]Policy, error)
	GetSLATiers(int642 int64) (*Tiers, error)
	ListAssets(page *Page) ([]Asset, error)
	OnConfigChange(mulesoftConfig *config.MulesoftConfig)
	DeleteContract(apiID string, contractID string) error
	RevokeContract(apiID, contractID string) error
	ResetAppSecret(appID int64) (*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              int64  `json:"id"`
	OrganizationID  string `json:"organizationId"`
	RequestedTierID int64  `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 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
}

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) DeleteContract added in v1.1.5

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

func (*MockAnypointClient) GetAPI added in v1.1.5

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

func (*MockAnypointClient) GetAccessToken

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

func (*MockAnypointClient) GetAnalyticsWindow

func (m *MockAnypointClient) GetAnalyticsWindow() ([]AnalyticsEvent, 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) GetPolicies

func (m *MockAnypointClient) GetPolicies(int64) ([]Policy, 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)

func (*MockAnypointClient) ResetAppSecret added in v1.1.9

func (m *MockAnypointClient) ResetAppSecret(appID int64) (*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 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,omitempty"`
	// Audit                Audit       `json:"audit,omitempty"`
	Configuration     interface{} `json:"configuration,omitempty"`
	ConfigurationData interface{} `json:"configurationData,omitempty"`
	// ID                   int64       `json:"id,omitempty"`
	// MasterOrganizationID string      `json:"masterOrganizationId,omitempty"`
	// Order                int         `json:"order,omitempty"`
	// OrganizationID       string      `json:"organizationId,omitempty"`
	// PointCutData         interface{} `json:"pointCutData,omitempty"`
	// PolicyID             int         `json:"policyId,omitempty"`
	PolicyTemplateID string `json:"policyTemplateId,omitempty"`
}

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 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