anypointclient

package
v0.0.0-...-cda2449 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BearerAuthenticationType       AuthenticationType = "bearer"
	UserAuthenticationType                            = "user"
	ConnectedAppAuthenticationType                    = "connectedapp"
)
View Source
const EURegionBaseURL = "https://eu1.anypoint.mulesoft.com"
View Source
const USRegionBaseURL = "https://anypoint.mulesoft.com"

Variables

This section is empty.

Functions

func ResolveBaseURLFromRegion

func ResolveBaseURLFromRegion(region string) (string, error)

Types

type AnypointClient

type AnypointClient struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

AnypointClient represents the

func NewAnypointClientWithConnectedApp

func NewAnypointClientWithConnectedApp(clientId string, clientSecret string, baseURL string) *AnypointClient

NewAnypointClientWithCredentials creates a new Anypoint Client using the given client id and client secret to acquire a token

func NewAnypointClientWithCredentials

func NewAnypointClientWithCredentials(username string, password string, baseURL string) *AnypointClient

NewAnypointClientWithCredentials creates a new Anypoint Client using the given username and password to acquire a token

func NewAnypointClientWithToken

func NewAnypointClientWithToken(bearer string, baseURL string) *AnypointClient

NewAnypointClientWithToken creates a new Anypoint Client using the given token

func (*AnypointClient) CreateApplication

func (client *AnypointClient) CreateApplication(environment Environment, application CloudhubApplicationRequest) error

func (*AnypointClient) GetApiInstancePolicies

func (client *AnypointClient) GetApiInstancePolicies(orgId string, envId string, apiInstanceID int) (*[]ApiPolicy, error)

func (*AnypointClient) GetApis

func (client *AnypointClient) GetApis(orgId string, envId string, offset int, limit int) (*ApiListResponse, error)

func (*AnypointClient) GetApplication

func (client *AnypointClient) GetApplication(environment Environment, applicationname string) (CloudhubApplicationResponse, error)

func (*AnypointClient) GetApplications

func (client *AnypointClient) GetApplications(environment Environment) ([]CloudhubApplicationResponse, error)

func (*AnypointClient) GetExchangeAssets

func (client *AnypointClient) GetExchangeAssets(orgId string, offset int, limit int) (*[]ExchangeAsset, error)

GetExchangeAssets retrieves assets from exchange

func (*AnypointClient) GetExchangeAssetsDetails

func (client *AnypointClient) GetExchangeAssetsDetails(orgId string, assetId string) (*ExchangeAsset, error)

curl 'https://anypoint.mulesoft.com/exchange/api/v2/assets/xxxx/api' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0' -H 'Accept: application/json' -H 'Accept-Language: en,en-US;q=0.7,sv;q=0.3' --compressed

func (*AnypointClient) Login

func (client *AnypointClient) Login() error

func (*AnypointClient) ResolveEnvironment

func (client *AnypointClient) ResolveEnvironment(organization Organization, environmentName string) (Environment, error)

ResolveEnvironment will resolve, in the given organization, an Environment by name.

func (*AnypointClient) ResolveOrganization

func (client *AnypointClient) ResolveOrganization(organizationPath string) (Organization, error)

func (*AnypointClient) UpdateApiInstancePolicies

func (client *AnypointClient) UpdateApiInstancePolicies(orgId string, envId string, apiInstanceID int,
	configData string, policyID int, newPolicyTemplateID int) error

func (*AnypointClient) UpdateApplication

func (client *AnypointClient) UpdateApplication(environment Environment, application CloudhubApplicationRequest) error

func (*AnypointClient) UpdateExchangeApiManagedInstanceUrl

func (client *AnypointClient) UpdateExchangeApiManagedInstanceUrl(orgId string, assetId string, versionGroup string, instanceId string, newURL string) error

Update curl 'https://anypoint.mulesoft.com/exchange/api/v2/assets/xxxxxxxxxxxx/api/versionGroups/v1/instances/managed/1122344' -X PATCH -H 'authorization: bearer xxxxxxxx' -H 'content-type: application/json' --data-raw '{"name":"v1:25252525","endpointUri":"https://api.example.com/api/v2/","isPublic":false}'

type ApiListResponse

type ApiListResponse struct {
	Total     int `json:"total"`
	Instances []struct {
		Audit struct {
			Created struct {
				Date time.Time `json:"date"`
			} `json:"created"`
			Updated struct {
				Date time.Time `json:"date"`
			} `json:"updated"`
		} `json:"audit"`
		MasterOrganizationID string        `json:"masterOrganizationId"`
		OrganizationID       string        `json:"organizationId"`
		ID                   int           `json:"id"`
		InstanceLabel        string        `json:"instanceLabel"`
		GroupID              string        `json:"groupId"`
		AssetID              string        `json:"assetId"`
		AssetVersion         string        `json:"assetVersion"`
		ProductVersion       string        `json:"productVersion"`
		Description          interface{}   `json:"description"`
		Tags                 []interface{} `json:"tags"`
		Order                int           `json:"order"`
		ProviderID           interface{}   `json:"providerId"`
		Deprecated           bool          `json:"deprecated"`
		LastActiveDate       time.Time     `json:"lastActiveDate"`
		EndpointURI          string        `json:"endpointUri"`
		EnvironmentID        string        `json:"environmentId"`
		IsPublic             bool          `json:"isPublic"`
		Stage                string        `json:"stage"`
		Technology           string        `json:"technology"`
		LastActiveDelta      int           `json:"lastActiveDelta,omitempty"`
		Pinned               bool          `json:"pinned"`
		ActiveContractsCount int           `json:"activeContractsCount"`
		Asset                struct {
			Name              string `json:"name"`
			ExchangeAssetName string `json:"exchangeAssetName"`
			GroupID           string `json:"groupId"`
			AssetID           string `json:"assetId"`
		} `json:"asset"`
		AutodiscoveryInstanceName string `json:"autodiscoveryInstanceName"`
	} `json:"instances"`
}

type ApiPolicy

type ApiPolicy struct {
	Audit struct {
		Created struct {
			Date time.Time `json:"date"`
		} `json:"created"`
		Updated struct {
			Date time.Time `json:"date"`
		} `json:"updated"`
	} `json:"audit"`
	MasterOrganizationID string            `json:"masterOrganizationId"`
	OrganizationID       string            `json:"organizationId"`
	ID                   int               `json:"id"`
	PolicyTemplateID     string            `json:"policyTemplateId"`
	ConfigurationData    ConfigurationData `json:"configurationData,omitempty"`
	Order                int               `json:"order"`
	Disabled             bool              `json:"disabled"`
	PointcutData         interface{}       `json:"pointcutData"`
	GroupID              interface{}       `json:"groupId"`
	AssetID              interface{}       `json:"assetId"`
	AssetVersion         interface{}       `json:"assetVersion"`
	Template             string            `json:"template"`
	Standalone           bool              `json:"standalone"`
	APIID                int               `json:"apiId"`
}

type AuthenticationType

type AuthenticationType string

type CloudhubApplicationRequest

type CloudhubApplicationRequest struct {
	ApplicationInfo struct {
		FileName    string `json:"fileName,omitempty"`
		MuleVersion struct {
			Version string `json:"version,omitempty"`
		} `json:"muleVersion,omitempty"`
		Properties       map[string]string `json:"properties,omitempty"`
		LogLevels        []interface{}     `json:"logLevels,omitempty"`
		TrackingSettings struct {
			TrackingLevel string `json:"trackingLevel,omitempty"`
		} `json:"trackingSettings,omitempty"`
		DeploymentGroup           interface{} `json:"deploymentGroup,omitempty"`
		MonitoringEnabled         bool        `json:"monitoringEnabled,omitempty"`
		MonitoringAutoRestart     bool        `json:"monitoringAutoRestart,omitempty"`
		PersistentQueues          bool        `json:"persistentQueues,omitempty"`
		PersistentQueuesEncrypted bool        `json:"persistentQueuesEncrypted,omitempty"`
		Workers                   struct {
			Amount int `json:"amount,omitempty"`
			Type   struct {
				Name   string  `json:"name,omitempty"`
				Weight float64 `json:"weight,omitempty"`
				CPU    string  `json:"cpu,omitempty"`
				Memory string  `json:"memory,omitempty"`
			} `json:"type,omitempty"`
		} `json:"workers,omitempty"`
		ObjectStoreV1             bool   `json:"objectStoreV1,omitempty"`
		LoggingNgEnabled          bool   `json:"loggingNgEnabled,omitempty"`
		LoggingCustomLog4JEnabled bool   `json:"loggingCustomLog4JEnabled,omitempty"`
		StaticIPsEnabled          bool   `json:"staticIPsEnabled,omitempty"`
		Domain                    string `json:"domain,omitempty"`
	} `json:"applicationInfo,omitempty"`
	ApplicationSource struct {
		Source         string `json:"source,omitempty"`
		GroupID        string `json:"groupId,omitempty"`
		ArtifactID     string `json:"artifactId,omitempty"`
		Version        string `json:"version,omitempty"`
		OrganizationID string `json:"organizationId,omitempty"`
	} `json:"applicationSource,omitempty"`
	AutoStart bool `json:"autoStart,omitempty"`
}

type CloudhubApplicationResponse

type CloudhubApplicationResponse struct {
	VersionID         string                    `json:"versionId,omitempty"`
	Domain            string                    `json:"domain,omitempty"`
	FullDomain        string                    `json:"fullDomain,omitempty"`
	Properties        map[string]string         `json:"properties,omitempty"`
	PropertiesOptions map[string]map[string]any `json:"propertiesOptions,omitempty"`
	Status            string                    `json:"status,omitempty"`
	Workers           struct {
		Type struct {
			Name   string  `json:"name,omitempty"`
			Weight float64 `json:"weight,omitempty"`
			CPU    string  `json:"cpu,omitempty"`
			Memory string  `json:"memory,omitempty"`
		} `json:"type"`
		Amount              int     `json:"amount,omitempty"`
		RemainingOrgWorkers float64 `json:"remainingOrgWorkers,omitempty"`
		TotalOrgWorkers     float64 `json:"totalOrgWorkers,omitempty"`
	} `json:"workers"`
	LastUpdateTime int64  `json:"lastUpdateTime,omitempty"`
	FileName       string `json:"fileName,omitempty"`
	MuleVersion    struct {
		Version          string `json:"version,omitempty"`
		UpdateID         string `json:"updateId,omitempty"`
		LatestUpdateID   string `json:"latestUpdateId,omitempty"`
		EndOfSupportDate int64  `json:"endOfSupportDate,omitempty"`
	} `json:"muleVersion"`
	Region                            string `json:"region,omitempty"`
	PersistentQueues                  bool   `json:"persistentQueues,omitempty"`
	PersistentQueuesEncryptionEnabled bool   `json:"persistentQueuesEncryptionEnabled,omitempty"`
	PersistentQueuesEncrypted         bool   `json:"persistentQueuesEncrypted,omitempty"`
	MonitoringEnabled                 bool   `json:"monitoringEnabled,omitempty"`
	MonitoringAutoRestart             bool   `json:"monitoringAutoRestart,omitempty"`
	StaticIPsEnabled                  bool   `json:"staticIPsEnabled,omitempty"`
	HasFile                           bool   `json:"hasFile,omitempty"`
	SecureDataGatewayEnabled          bool   `json:"secureDataGatewayEnabled,omitempty"`
	LoggingNgEnabled                  bool   `json:"loggingNgEnabled,omitempty"`
	LoggingCustomLog4JEnabled         bool   `json:"loggingCustomLog4JEnabled,omitempty"`
	CloudObjectStoreRegion            string `json:"cloudObjectStoreRegion,omitempty"`
	InsightsReplayDataRegion          string `json:"insightsReplayDataRegion,omitempty"`
	IsDeploymentWaiting               bool   `json:"isDeploymentWaiting,omitempty"`
	DeploymentGroup                   struct {
		ID   string `json:"id,omitempty"`
		Name string `json:"name,omitempty"`
	} `json:"deploymentGroup,omitempty"`
	UpdateRuntimeConfig bool `json:"updateRuntimeConfig,omitempty"`
	TrackingSettings    struct {
		TrackingLevel string `json:"trackingLevel,omitempty"`
	} `json:"trackingSettings,omitempty"`
	LogLevels   []interface{} `json:"logLevels,omitempty"`
	IPAddresses []interface{} `json:"ipAddresses,omitempty"`
}

type ConfigurationData

type ConfigurationData struct {
	PolicyID                   int                    `json:"policyId"`
	EndpointURI                string                 `json:"endpointUri"`
	IsRamlEndpoint             bool                   `json:"isRamlEndpoint"`
	IsWsdlEndpoint             bool                   `json:"isWsdlEndpoint"`
	IsHTTPEndpoint             bool                   `json:"isHttpEndpoint"`
	APIID                      int                    `json:"apiId"`
	Order                      int                    `json:"order"`
	AutodiscoveryAPIName       string                 `json:"autodiscoveryApiName"`
	AutodiscoveryInstanceName  string                 `json:"autodiscoveryInstanceName"`
	AdditionalPolicyProperties map[string]interface{} `json:"-"` // Rest of the fields should go here.
}

func (*ConfigurationData) UnmarshalJSON

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

type Environment

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

type EnvironmentResponse

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

type ExchangeAsset

type ExchangeAsset struct {
	GroupID      string      `json:"groupId"`
	AssetID      string      `json:"assetId"`
	Version      string      `json:"version"`
	MinorVersion string      `json:"minorVersion"`
	VersionGroup string      `json:"versionGroup"`
	Description  string      `json:"description"`
	IsPublic     bool        `json:"isPublic"`
	Name         string      `json:"name"`
	ContactName  interface{} `json:"contactName"`
	ContactEmail interface{} `json:"contactEmail"`
	Type         string      `json:"type"`
	IsSnapshot   bool        `json:"isSnapshot"`
	Status       string      `json:"status"`
	ExternalFile struct {
		URL interface{} `json:"url"`
	} `json:"externalFile"`
	CreatedDate    time.Time     `json:"createdDate"`
	UpdatedDate    time.Time     `json:"updatedDate"`
	MinMuleVersion interface{}   `json:"minMuleVersion"`
	Labels         []string      `json:"labels"`
	Categories     []interface{} `json:"categories"`
	Files          []struct {
		Classifier   string    `json:"classifier"`
		Packaging    string    `json:"packaging"`
		ExternalLink string    `json:"externalLink"`
		CreatedDate  time.Time `json:"createdDate"`
		Md5          string    `json:"md5"`
		Sha1         string    `json:"sha1"`
		MainFile     string    `json:"mainFile"`
		IsGenerated  bool      `json:"isGenerated"`
	} `json:"files"`
	CustomFields  []interface{} `json:"customFields"`
	Rating        int           `json:"rating"`
	NumberOfRates int           `json:"numberOfRates"`
	CreatedBy     struct {
		ID        string `json:"id"`
		UserName  string `json:"userName"`
		FirstName string `json:"firstName"`
		LastName  string `json:"lastName"`
	} `json:"createdBy"`
	Instances []struct {
		VersionGroup                string      `json:"versionGroup"`
		OrganizationID              string      `json:"organizationId"`
		ID                          string      `json:"id"`
		GroupID                     string      `json:"groupId"`
		AssetID                     string      `json:"assetId"`
		Version                     string      `json:"version"`
		MinorVersion                string      `json:"minorVersion"`
		ProductAPIVersion           string      `json:"productAPIVersion"`
		EnvironmentID               interface{} `json:"environmentId"`
		ProviderID                  interface{} `json:"providerId"`
		EndpointURI                 string      `json:"endpointUri"`
		Name                        string      `json:"name"`
		IsPublic                    bool        `json:"isPublic"`
		Type                        string      `json:"type"`
		Deprecated                  interface{} `json:"deprecated"`
		Fullname                    string      `json:"fullname"`
		AssetName                   string      `json:"assetName"`
		EnvironmentName             string      `json:"environmentName,omitempty"`
		EnvironmentOrganizationName string      `json:"environmentOrganizationName,omitempty"`
	} `json:"instances"`
	Dependencies []struct {
		Organization struct {
			ID   string `json:"id"`
			Name string `json:"name"`
		} `json:"organization"`
		GroupID      string   `json:"groupId"`
		AssetID      string   `json:"assetId"`
		Version      string   `json:"version"`
		MinorVersion string   `json:"minorVersion"`
		VersionGroup string   `json:"versionGroup"`
		Name         string   `json:"name"`
		Type         string   `json:"type"`
		Permissions  []string `json:"permissions"`
	} `json:"dependencies"`
	Organization struct {
		ID                     string        `json:"id"`
		Name                   string        `json:"name"`
		ParentOrganizationIds  []interface{} `json:"parentOrganizationIds"`
		SubOrganizationIds     []string      `json:"subOrganizationIds"`
		TenantOrganizationIds  []interface{} `json:"tenantOrganizationIds"`
		IsMaster               bool          `json:"isMaster"`
		Domain                 string        `json:"domain"`
		IsMulesoftOrganization bool          `json:"isMulesoftOrganization"`
	} `json:"organization"`
	ID         string      `json:"id"`
	Icon       interface{} `json:"icon"`
	CreatedAt  time.Time   `json:"createdAt"`
	ModifiedAt time.Time   `json:"modifiedAt"`
}

type LoginRequest

type LoginRequest struct {
	Username string `url:"username"`
	Password string `url:"password"`
}

LoginRequest represents the form data beeing send in the Login request.

type LoginResponse

type LoginResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	RedirectURL string `url:"redirectUrl"`
}

LoginResponse represents the JSON data beeing returned by the Login request.

type Organization

type Organization struct {
	ID               string
	Name             string
	SubOrganizations []Organization
}

Jump to

Keyboard shortcuts

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