apic

package
v1.1.53 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 41 Imported by: 22

Documentation

Index

Constants

View Source
const (
	Apikey      = "verify-api-key"
	Passthrough = "pass-through"
	Oauth       = "verify-oauth-token"
	Basic       = "http-basic"
)

constants for auth policy types

View Source
const (
	API           = "API"
	Wsdl          = "wsdl"
	SwaggerV2     = "swaggerv2"
	Oas2          = "oas2"
	Oas3          = "oas3"
	Protobuf      = "protobuf"
	AsyncAPI      = "asyncapi"
	Unstructured  = "unstructured"
	Specification = "specification"
	Swagger       = "swagger"

	SubscriptionSchemaNameSuffix      = ".authsubscription"
	DefaultSubscriptionWebhookName    = "subscriptionwebhook"
	DefaultSubscriptionWebhookAuthKey = "webhookAuthKey"

	FieldsKey = "fields"
	QueryKey  = "query"

	CreateTimestampQueryKey = "metadata.audit.createTimestamp"

	DefaultTeamKey = "DefaultTeam"
)

Various consts for use

View Source
const (
	UnpublishedState     = "UNPUBLISHED"
	PublishedState       = "PUBLISHED"
	ApprovalPendingState = "PENDING"
)

consts for state

View Source
const (
	DeprecatedStatus          = "DEPRECATED"
	PublishedStatus           = "PUBLISHED"
	UnpublishedStatus         = "UNPUBLISHED"
	UnidentifiedInboundPolicy = "UNIDENTIFIED INBOUND POLICY"
)

consts for status

View Source
const (
	MajorChange = "MAJOR"
	MinorChange = "MINOR"
)

consts for update serverity

View Source
const (
	SubscriptionApproved              = SubscriptionState("APPROVED")
	SubscriptionRequested             = SubscriptionState("REQUESTED")
	SubscriptionRejected              = SubscriptionState("REJECTED")
	SubscriptionActive                = SubscriptionState("ACTIVE")
	SubscriptionUnsubscribed          = SubscriptionState("UNSUBSCRIBED")
	SubscriptionUnsubscribeInitiated  = SubscriptionState("UNSUBSCRIBE_INITIATED")
	SubscriptionFailedToSubscribe     = SubscriptionState("FAILED_TO_SUBSCRIBE")
	SubscriptionFailedToUnsubscribe   = SubscriptionState("FAILED_TO_UNSUBSCRIBE")
	SubscriptionChangeRequested       = SubscriptionState("CHANGE_REQUESTED")
	AccessRequestProvisioning         = SubscriptionState("provisioning")
	AccessRequestProvisioned          = SubscriptionState("provisioned")
	AccessRequestFailedProvisioning   = SubscriptionState("failedProvisioning")
	AccessRequestDeprovisioning       = SubscriptionState("deprovisioning")
	AccessRequestDeprovisioned        = SubscriptionState("deprovisioned")
	AccessRequestFailedDeprovisioning = SubscriptionState("failedDeprovisioning")
)

SubscriptionState

View Source
const (
	DataTypeString  = "string"
	DataTypeNumber  = "number"
	DataTypeInteger = "integer"
	DataTypeArray   = "array"
	DataTypeObject  = "object"
)

TODO - this file should be able to be removed once Unified Catalog support has been removed Supported data types

View Source
const (
	TeamMapKey = "TeamMap"
)

other consts

Variables

View Source
var (
	ErrCentralConfig      = errors.New(1100, "configuration error for Amplify Central")
	ErrEnvironmentQuery   = errors.New(1101, "error sending request to Amplify Central. Check configuration for CENTRAL_ENVIRONMENT")
	ErrTeamNotFound       = errors.Newf(1102, "could not find team (%s) in Amplify Central. Check configuration for CENTRAL_TEAM")
	ErrNetwork            = errors.New(1110, "error connecting to Amplify Central. Check docs.axway.com for more info on this error code")
	ErrRequestQuery       = errors.New(1120, "error making a request to Amplify")
	ErrAuthenticationCall = errors.New(1130, "error getting authentication token. Check Amplify Central auth configuration (CENTRAL_AUTH_*) and network configuration for agent on docs.axway.com")
	ErrAuthentication     = errors.New(1131, "authentication token was not valid. Check Amplify Central auth configuration (CENTRAL_AUTH_*)")
)

Errors hit when validating Amplify Central connectivity

View Source
var (
	ErrNoAddressFound = errors.Newf(1139, "could not find the subscriber (%s) email address")
	// Subscription APIs
	ErrSubscriptionQuery        = errors.New(1140, "error connecting to Amplify Central for subscriptions")
	ErrSubscriptionResp         = errors.Newf(1141, "unexpected response code (%d) from Amplify Central for subscription")
	ErrSubscriptionSchemaCreate = errors.New(1142, "error creating/updating subscription schema in Amplify Central")
	ErrSubscriptionSchemaResp   = errors.Newf(1143, "unexpected response code (%d) when creating a subscription schema in Amplify Central")
	// APIs related to webhooks
	ErrCreateWebhook                       = errors.New(1144, "unable to create webhook")
	ErrCreateSecret                        = errors.New(1145, "unable to create secret")
	ErrAccessRequestSubscriptionSchemaResp = errors.Newf(1146, "unexpected response code (%d) when creating an access request subscription schema in Amplify Central")

	ErrGetSubscriptionDefProperties       = errors.New(1155, "error getting subscription definition properties in Amplify Central")
	ErrUpdateSubscriptionDefProperties    = errors.New(1156, "error updating subscription definition properties in Amplify Central")
	ErrGetCatalogItemServerInfoProperties = errors.New(1157, "error getting catalog item API server info properties")
	ErrSubscriptionManagerDown            = errors.New(1158, "subscription manager is not running")

	// Service body builder
	ErrSetSpecEndPoints = errors.New(1160, "error getting endpoints for the API specification")

	// Category
	ErrCategoryCreate = errors.Newf(1164, "error creating category %s")
)

Errors hit when calling different Amplify APIs

View Source
var MockTokenGetter = &mockTokenGetter{}

MockTokenGetter - global var for use in unit tests to return a fake token

View Source
var ValidPolicies = []string{Apikey, Passthrough, Oauth, Basic}

ValidPolicies - list of valid auth policies supported by Central. Add to this list as more policies are supported.

Functions

func GetTestServiceClientCentralConfiguration

func GetTestServiceClientCentralConfiguration(client *ServiceClient) *corecfg.CentralConfiguration

GetTestServiceClientCentralConfiguration - cast and return the CentralConfiguration

Types

type APIError

type APIError struct {
	Status int    `json:"status,omitempty"`
	Title  string `json:"title,omitempty"`
	Detail string `json:"detail,omitempty"`
}

APIError - api response error

type APIKeyInfo

type APIKeyInfo struct {
	Name     string
	Location string
}

APIKeyInfo -

type APIServerInfo

type APIServerInfo struct {
	ConsumerInstance APIServerInfoProperty `json:"consumerInstance,omitempty"`
	Environment      APIServerInfoProperty `json:"environment,omitempty"`
}

APIServerInfo -

type APIServerInfoProperty

type APIServerInfoProperty struct {
	Name string `json:"name,omitempty"`
	ID   string `json:"id,omitempty"`
}

APIServerInfoProperty -

type APIServiceRevisionTitle

type APIServiceRevisionTitle struct {
	APIServiceName string
	Date           string
	Revision       string
	StageLabel     string
	Stage          string
}

APIServiceRevisionTitle - apiservicerevision template for title

type AnyOfSubscriptionSchemaPropertyDefinitions

type AnyOfSubscriptionSchemaPropertyDefinitions struct {
	AnyOf []SubscriptionSchemaPropertyDefinition `json:"anyOf,omitempty"`
}

AnyOfSubscriptionSchemaPropertyDefinitions - used for items of SubscriptionSchemaPropertyDefinition

type ArrayPropertyBuilder

type ArrayPropertyBuilder interface {
	// AddItem - Add a item property in the array property
	AddItem(item PropertyBuilder) ArrayPropertyBuilder
	// SetMinItems - Set the minimum number of items in the array property
	SetMinItems(min uint) ArrayPropertyBuilder
	// SetMaxItems - Set the maximum number of items in the array property
	SetMaxItems(max uint) ArrayPropertyBuilder
	PropertyBuilder
}

ArrayPropertyBuilder - specific methods related to the Array property builders

type CentralSubscription

type CentralSubscription struct {
	Subscription
	CatalogItemSubscription *uc.CatalogItemSubscription `json:"catalogItemSubscription"`
	ApicID                  string                      `json:"-"`
	RemoteAPIID             string                      `json:"-"`
	RemoteAPIStage          string                      `json:"-"`

	RemoteAPIAttributes map[string]string
	// contains filtered or unexported fields
}

CentralSubscription -

func (*CentralSubscription) GetApicID

func (s *CentralSubscription) GetApicID() string

GetApicID - Returns ID of the Catalog Item or API Service instance

func (*CentralSubscription) GetCatalogItemID

func (s *CentralSubscription) GetCatalogItemID() string

GetCatalogItemID - Returns ID of the Catalog Item

func (*CentralSubscription) GetCreatedUserID

func (s *CentralSubscription) GetCreatedUserID() string

GetCreatedUserID - Returns ID of the user that created the subscription

func (*CentralSubscription) GetID

func (s *CentralSubscription) GetID() string

GetID - Returns ID of the subscription

func (*CentralSubscription) GetName

func (s *CentralSubscription) GetName() string

GetName - Returns Name of the subscription

func (*CentralSubscription) GetPropertyValue

func (s *CentralSubscription) GetPropertyValue(propertyKey string) string

GetPropertyValue - Returns subscription Property value based on the key

func (*CentralSubscription) GetPropertyValues

func (s *CentralSubscription) GetPropertyValues(propertyKey string) []interface{}

GetPropertyValues - Returns subscription Property value based on the key

func (*CentralSubscription) GetRemoteAPIAttributes

func (s *CentralSubscription) GetRemoteAPIAttributes() map[string]string

GetRemoteAPIAttributes - Returns the attributes from the API that the subscription is tied to.

func (*CentralSubscription) GetRemoteAPIID

func (s *CentralSubscription) GetRemoteAPIID() string

GetRemoteAPIID - Returns ID of the API on remote gateway

func (*CentralSubscription) GetRemoteAPIStage

func (s *CentralSubscription) GetRemoteAPIStage() string

GetRemoteAPIStage - Returns the stage name of the API on remote gateway

func (*CentralSubscription) GetState

func (s *CentralSubscription) GetState() SubscriptionState

GetState - Returns subscription state

func (*CentralSubscription) UpdateEnumProperty

func (s *CentralSubscription) UpdateEnumProperty(key, newValue, dataType string) error

UpdateEnumProperty -

func (*CentralSubscription) UpdateProperties

func (s *CentralSubscription) UpdateProperties(appName string) error

UpdateProperties -

func (*CentralSubscription) UpdatePropertyValues

func (s *CentralSubscription) UpdatePropertyValues(values map[string]interface{}) error

UpdatePropertyValues - Updates the property values of the subscription

func (*CentralSubscription) UpdateState

func (s *CentralSubscription) UpdateState(newState SubscriptionState, description string) error

UpdateState - Updates the state of subscription

func (*CentralSubscription) UpdateStateWithProperties

func (s *CentralSubscription) UpdateStateWithProperties(newState SubscriptionState, description string, properties map[string]interface{}) error

UpdateStateWithProperties - Updates the state of subscription

type Client

type Client interface {
	SetTokenGetter(tokenRequester auth.PlatformTokenGetter)
	SetConfig(cfg corecfg.CentralConfig)
	PublishService(serviceBody *ServiceBody) (*management.APIService, error)
	RegisterSubscriptionWebhook() error
	RegisterSubscriptionSchema(schema SubscriptionSchema, update bool) error
	UpdateSubscriptionSchema(schema SubscriptionSchema) error
	GetSubscriptionManager() SubscriptionManager
	GetCatalogItemIDForConsumerInstance(instanceID string) (string, error)
	DeleteAPIServiceInstance(name string) error
	DeleteConsumerInstance(name string) error
	DeleteServiceByName(name string) error
	GetConsumerInstanceByID(id string) (*management.ConsumerInstance, error)
	GetConsumerInstancesByExternalAPIID(externalAPIID string) ([]*management.ConsumerInstance, error)
	UpdateConsumerInstanceSubscriptionDefinition(externalAPIID, subscriptionDefinitionName string) error
	GetUserEmailAddress(ID string) (string, error)
	GetUserName(ID string) (string, error)
	GetSubscriptionsForCatalogItem(states []string, catalogItemID string) ([]CentralSubscription, error)
	GetSubscriptionDefinitionPropertiesForCatalogItem(catalogItemID, propertyKey string) (SubscriptionSchema, error)
	UpdateSubscriptionDefinitionPropertiesForCatalogItem(catalogItemID, propertyKey string, schema SubscriptionSchema) error
	GetCatalogItemName(ID string) (string, error)
	ExecuteAPI(method, url string, queryParam map[string]string, buffer []byte) ([]byte, error)
	Healthcheck(name string) *hc.Status
	GetAPIRevisions(query map[string]string, stage string) ([]*management.APIServiceRevision, error)
	GetAPIServiceRevisions(query map[string]string, URL, stage string) ([]*management.APIServiceRevision, error)
	GetAPIServiceInstances(query map[string]string, URL string) ([]*management.APIServiceInstance, error)
	GetAPIV1ResourceInstances(query map[string]string, URL string) ([]*apiv1.ResourceInstance, error)
	GetAPIV1ResourceInstancesWithPageSize(query map[string]string, URL string, pageSize int) ([]*apiv1.ResourceInstance, error)
	GetAPIServiceByName(name string) (*management.APIService, error)
	GetAPIServiceInstanceByName(name string) (*management.APIServiceInstance, error)
	GetAPIRevisionByName(name string) (*management.APIServiceRevision, error)
	CreateCategory(name string) (*catalog.Category, error)
	GetOrCreateCategory(category string) string
	GetEnvironment() (*management.Environment, error)
	GetCentralTeamByName(name string) (*defs.PlatformTeam, error)
	GetTeam(query map[string]string) ([]defs.PlatformTeam, error)
	GetAccessControlList(aclName string) (*management.AccessControlList, error)
	UpdateAccessControlList(acl *management.AccessControlList) (*management.AccessControlList, error)
	CreateAccessControlList(acl *management.AccessControlList) (*management.AccessControlList, error)

	CreateSubResource(rm apiv1.ResourceMeta, subs map[string]interface{}) error
	GetResource(url string) (*apiv1.ResourceInstance, error)
	UpdateResourceFinalizer(ri *apiv1.ResourceInstance, finalizer, description string, addAction bool) (*apiv1.ResourceInstance, error)
	IsMarketplaceSubsEnabled() bool

	UpdateResourceInstance(ri apiv1.Interface) (*apiv1.ResourceInstance, error)
	CreateOrUpdateResource(ri apiv1.Interface) (*apiv1.ResourceInstance, error)
	CreateResourceInstance(ri apiv1.Interface) (*apiv1.ResourceInstance, error)
	DeleteResourceInstance(ri apiv1.Interface) error
	GetResources(ri apiv1.Interface) ([]apiv1.Interface, error)

	CreateResource(url string, bts []byte) (*apiv1.ResourceInstance, error)
	UpdateResource(url string, bts []byte) (*apiv1.ResourceInstance, error)
}

Client - interface

func New

func New(cfg corecfg.CentralConfig, tokenRequester auth.PlatformTokenGetter, caches cache2.Manager) Client

New creates a new Client

type EndpointDefinition

type EndpointDefinition struct {
	Host     string
	Port     int32
	Protocol string
	BasePath string
	Details  map[string]interface{}
}

EndpointDefinition - holds the service endpoint definition

type IntegerPropertyBuilder

type IntegerPropertyBuilder interface {
	// SetMinValue - Set the minimum allowed integer value
	SetMinValue(min int64) IntegerPropertyBuilder
	// SetMaxValue - Set the maximum allowed integer value
	SetMaxValue(min int64) IntegerPropertyBuilder
	// SetDefaultValue - Define the initial value for the property
	SetDefaultValue(value int64) IntegerPropertyBuilder
	PropertyBuilder
}

IntegerPropertyBuilder - specific methods related to the Integer property builders

type MockSubscription

type MockSubscription struct {
	Subscription
	ID                           string
	Description                  string
	Name                         string
	ApicID                       string
	RemoteAPIID                  string
	RemoteAPIStage               string
	CatalogID                    string
	UserID                       string
	State                        SubscriptionState
	PropertyVals                 map[string]interface{}
	ReceivedValues               map[string]interface{}
	RemoteAPIAttributes          map[string]string
	ReceivedAppName              string
	ReceivedUpdatedEnum          string
	UpdateStateErr               error
	UpdateEnumErr                error
	UpdatePropertiesErr          error
	UpdatePropertyValErr         error
	UpdateStateWithPropertiesErr error
}

MockSubscription - use for ease of testing agents

func (*MockSubscription) GetApicID

func (s *MockSubscription) GetApicID() string

GetApicID - mocked for testing

func (*MockSubscription) GetCatalogItemID

func (s *MockSubscription) GetCatalogItemID() string

GetCatalogItemID - mocked for testing

func (*MockSubscription) GetCreatedUserID

func (s *MockSubscription) GetCreatedUserID() string

GetCreatedUserID - mocked for testing

func (*MockSubscription) GetID

func (s *MockSubscription) GetID() string

GetID - mocked for testing

func (*MockSubscription) GetName

func (s *MockSubscription) GetName() string

GetName - mocked for testing

func (*MockSubscription) GetPropertyValue

func (s *MockSubscription) GetPropertyValue(propertyKey string) string

GetPropertyValue - mocked for testing

func (*MockSubscription) GetPropertyValues

func (s *MockSubscription) GetPropertyValues(propertyKey string) []interface{}

GetPropertyValues - mocked for testing

func (*MockSubscription) GetRemoteAPIAttributes

func (s *MockSubscription) GetRemoteAPIAttributes() map[string]string

GetRemoteAPIAttributes - mocked for testing

func (*MockSubscription) GetRemoteAPIID

func (s *MockSubscription) GetRemoteAPIID() string

GetRemoteAPIID - mocked for testing

func (*MockSubscription) GetRemoteAPIStage

func (s *MockSubscription) GetRemoteAPIStage() string

GetRemoteAPIStage - mocked for testing

func (*MockSubscription) GetState

func (s *MockSubscription) GetState() SubscriptionState

GetState - mocked for testing

func (*MockSubscription) UpdateEnumProperty

func (s *MockSubscription) UpdateEnumProperty(key, value, dataType string) error

UpdateEnumProperty - mocked for testing

func (*MockSubscription) UpdateProperties

func (s *MockSubscription) UpdateProperties(appName string) error

UpdateProperties - mocked for testing

func (*MockSubscription) UpdatePropertyValues

func (s *MockSubscription) UpdatePropertyValues(values map[string]interface{}) error

UpdatePropertyValues - mocked for testing

func (*MockSubscription) UpdateState

func (s *MockSubscription) UpdateState(newState SubscriptionState, description string) error

UpdateState - mocked for testing

func (*MockSubscription) UpdateStateWithProperties

func (s *MockSubscription) UpdateStateWithProperties(newState SubscriptionState, _ string, props map[string]interface{}) error

UpdateStateWithProperties - mocked for testing

type MockSubscriptionManager

type MockSubscriptionManager struct {
	SubscriptionManager
	RegisterProcessorCalled int
	RegisterValidatorCalled int
	StartCalled             int
	StopCalled              int
}

MockSubscriptionManager - used for unit tests to bypass the normal SubscriptionManager

func NewMockSubscriptionManager

func NewMockSubscriptionManager() *MockSubscriptionManager

NewMockSubscriptionManager -

func (*MockSubscriptionManager) RegisterProcessor

func (m *MockSubscriptionManager) RegisterProcessor(state SubscriptionState, processor SubscriptionProcessor)

RegisterProcessor -

func (*MockSubscriptionManager) RegisterValidator

func (m *MockSubscriptionManager) RegisterValidator(validator SubscriptionValidator)

RegisterValidator -

func (*MockSubscriptionManager) Start

func (m *MockSubscriptionManager) Start()

Start -

func (*MockSubscriptionManager) Stop

func (m *MockSubscriptionManager) Stop()

Stop -

type NumberPropertyBuilder

type NumberPropertyBuilder interface {
	// SetMinValue - Set the minimum allowed number value
	SetMinValue(min float64) NumberPropertyBuilder
	// SetMaxValue - Set the maximum allowed number value
	SetMaxValue(min float64) NumberPropertyBuilder
	// SetDefaultValue - Define the initial value for the property
	SetDefaultValue(value float64) NumberPropertyBuilder
	PropertyBuilder
}

NumberPropertyBuilder - specific methods related to the Number property builders

type OasSpecProcessor

type OasSpecProcessor interface {
	ParseAuthInfo()
	GetAPIKeyInfo() []APIKeyInfo
	GetOAuthScopes() map[string]string
	GetAuthPolicies() []string
}

OasSpecProcessor -

type ObjectPropertyBuilder

type ObjectPropertyBuilder interface {
	// AddProperty - Add a property in the object property
	AddProperty(property PropertyBuilder) ObjectPropertyBuilder
	PropertyBuilder
}

ObjectPropertyBuilder - specific methods related to the Object property builders

type PropertyBuilder

type PropertyBuilder interface {
	// Build - builds the property, this is called automatically by the schema builder
	Build() (*SubscriptionSchemaPropertyDefinition, error)
}

PropertyBuilder - mandatory methods for all property builders

type ResponseError

type ResponseError struct {
	Errors []APIError `json:"errors,omitempty"`
}

ResponseError - api response errors

type ServiceBody

type ServiceBody struct {
	NameToPush      string
	APIName         string
	RestAPIID       string
	PrimaryKey      string
	URL             string
	Stage           string
	StageDescriptor string
	Description     string
	Version         string
	AuthPolicy      string

	SpecDefinition       []byte
	Documentation        []byte
	Tags                 map[string]interface{}
	Image                string
	ImageContentType     string
	CreatedBy            string
	ResourceType         string
	SubscriptionName     string
	APIUpdateSeverity    string
	State                string
	Status               string
	ServiceAttributes    map[string]string
	RevisionAttributes   map[string]string
	InstanceAttributes   map[string]string
	ServiceAgentDetails  map[string]interface{}
	InstanceAgentDetails map[string]interface{}
	RevisionAgentDetails map[string]interface{}

	Endpoints         []EndpointDefinition
	UnstructuredProps *UnstructuredProperties
	TeamName          string
	// contains filtered or unexported fields
}

ServiceBody - details about a service to create

func (*ServiceBody) GetAPIKeyInfo

func (s *ServiceBody) GetAPIKeyInfo() []APIKeyInfo

GetAPIKeyInfo - returns the array of locations and argument names for the api key

func (*ServiceBody) GetAccessRequestDefinition

func (s *ServiceBody) GetAccessRequestDefinition() *management.AccessRequestDefinition

GetAccessRequestDefinition -

func (*ServiceBody) GetAuthPolicies

func (s *ServiceBody) GetAuthPolicies() []string

GetAuthPolicies - returns the array of all auth policies in the ServiceBody

func (*ServiceBody) GetCredentialRequestDefinitions

func (s *ServiceBody) GetCredentialRequestDefinitions() []string

GetCredentialRequestDefinitions - returns the array of all credential request policies

func (*ServiceBody) GetScopes

func (s *ServiceBody) GetScopes() map[string]string

GetScopes - returns the array of scopes for this service instance

func (*ServiceBody) SetAccessRequestDefinitionName

func (s *ServiceBody) SetAccessRequestDefinitionName(ardName string, isUnique bool)

SetAccessRequestDefinitionName - set the name of the access request definition for this service body

type ServiceBuilder

type ServiceBuilder interface {
	SetID(ID string) ServiceBuilder
	SetPrimaryKey(key string) ServiceBuilder
	SetRequestDefinitionsAllowed(previouslyPublished bool) ServiceBuilder
	SetTitle(title string) ServiceBuilder
	SetAPIName(apiName string) ServiceBuilder
	SetURL(url string) ServiceBuilder
	SetStage(stage string) ServiceBuilder
	SetStageDescriptor(stageDescriptor string) ServiceBuilder
	SetDescription(description string) ServiceBuilder
	SetVersion(version string) ServiceBuilder
	SetAuthPolicy(authPolicy string) ServiceBuilder
	SetAPISpec(spec []byte) ServiceBuilder
	SetDocumentation(documentation []byte) ServiceBuilder
	SetTags(tags map[string]interface{}) ServiceBuilder
	SetImage(image string) ServiceBuilder
	SetImageContentType(imageContentType string) ServiceBuilder
	SetResourceType(resourceType string) ServiceBuilder
	SetSubscriptionName(subscriptionName string) ServiceBuilder
	SetAPIUpdateSeverity(apiUpdateSeverity string) ServiceBuilder
	SetState(state string) ServiceBuilder
	SetStatus(status string) ServiceBuilder
	SetServiceAttribute(serviceAttribute map[string]string) ServiceBuilder
	SetInstanceAttribute(instanceAttribute map[string]string) ServiceBuilder
	SetRevisionAttribute(revisionAttribute map[string]string) ServiceBuilder
	SetServiceEndpoints(endpoints []EndpointDefinition) ServiceBuilder
	AddServiceEndpoint(protocol, host string, port int32, basePath string) ServiceBuilder
	SetCredentialRequestDefinitions(credentialRequestDefNames []string) ServiceBuilder
	AddCredentialRequestDefinition(credentialRequestDefName string) ServiceBuilder
	SetAccessRequestDefinitionName(accessRequestDefName string, isUnique bool) ServiceBuilder

	SetUnstructuredType(assetType string) ServiceBuilder
	SetUnstructuredContentType(contentType string) ServiceBuilder
	SetUnstructuredLabel(label string) ServiceBuilder
	SetUnstructuredFilename(filename string) ServiceBuilder
	SetTeamName(teamName string) ServiceBuilder
	SetCategories(categories []string) ServiceBuilder
	SetServiceAgentDetails(attr map[string]interface{}) ServiceBuilder
	SetInstanceAgentDetails(attr map[string]interface{}) ServiceBuilder
	SetRevisionAgentDetails(attr map[string]interface{}) ServiceBuilder
	Build() (ServiceBody, error)
}

ServiceBuilder - Interface to build the service body

func NewServiceBodyBuilder

func NewServiceBodyBuilder() ServiceBuilder

NewServiceBodyBuilder - Creates a new service body builder

type ServiceClient

type ServiceClient struct {
	DefaultSubscriptionSchema SubscriptionSchema

	DefaultSubscriptionApprovalWebhook corecfg.WebhookConfig
	// contains filtered or unexported fields
}

ServiceClient -

func GetTestServiceClient

func GetTestServiceClient() (*ServiceClient, *api.MockHTTPClient)

GetTestServiceClient - return a true ServiceClient, but with mocks for tokengetter and the HTTPClient and dummy values for various configurations. Has enough other configuration to make the client usable. This function also returns the MockHTTPClient so the caller can use it directly if needed, as it is not available directly from ServiceClient in other packages

func (*ServiceClient) CreateAccessControlList

func (c *ServiceClient) CreateAccessControlList(acl *management.AccessControlList) (*management.AccessControlList, error)

CreateAccessControlList -

func (*ServiceClient) CreateCategory

func (c *ServiceClient) CreateCategory(title string) (*catalog.Category, error)

CreateCategory - Adds a new category

func (*ServiceClient) CreateOrUpdateResource

func (c *ServiceClient) CreateOrUpdateResource(data apiv1.Interface) (*apiv1.ResourceInstance, error)

CreateOrUpdateResource deletes a resource

func (*ServiceClient) CreateResource

func (c *ServiceClient) CreateResource(url string, bts []byte) (*apiv1.ResourceInstance, error)

CreateResource deletes a resource

func (*ServiceClient) CreateResourceInstance

func (c *ServiceClient) CreateResourceInstance(ri apiv1.Interface) (*apiv1.ResourceInstance, error)

CreateResourceInstance - creates a ResourceInstance

func (*ServiceClient) CreateSubResource

func (c *ServiceClient) CreateSubResource(rm apiv1.ResourceMeta, subs map[string]interface{}) error

CreateSubResource creates a sub resource on the provided resource.

func (*ServiceClient) DeleteAPIServiceInstance

func (c *ServiceClient) DeleteAPIServiceInstance(name string) error

DeleteAPIServiceInstance deletes an api service instance in central by name

func (*ServiceClient) DeleteConsumerInstance

func (c *ServiceClient) DeleteConsumerInstance(name string) error

DeleteConsumerInstance -

func (*ServiceClient) DeleteResourceInstance

func (c *ServiceClient) DeleteResourceInstance(ri apiv1.Interface) error

DeleteResourceInstance - deletes a ResourceInstance

func (*ServiceClient) DeleteServiceByName

func (c *ServiceClient) DeleteServiceByName(name string) error

DeleteServiceByName -

func (*ServiceClient) ExecuteAPI

func (c *ServiceClient) ExecuteAPI(method, url string, query map[string]string, buffer []byte) ([]byte, error)

ExecuteAPI - execute the api

func (*ServiceClient) GetAPIRevisionByName

func (c *ServiceClient) GetAPIRevisionByName(name string) (*management.APIServiceRevision, error)

GetAPIRevisionByName - Returns the API revision based on its revision name

func (*ServiceClient) GetAPIRevisions

func (c *ServiceClient) GetAPIRevisions(query map[string]string, stage string) ([]*management.APIServiceRevision, error)

GetAPIRevisions - Returns the list of API revisions for the specified filter NOTE : this function can go away. You can call GetAPIServiceRevisions directly from your function to get []*management.APIServiceRevision

func (*ServiceClient) GetAPIServiceByName

func (c *ServiceClient) GetAPIServiceByName(name string) (*management.APIService, error)

GetAPIServiceByName - Returns the API service based on its name

func (*ServiceClient) GetAPIServiceInstanceByName

func (c *ServiceClient) GetAPIServiceInstanceByName(name string) (*management.APIServiceInstance, error)

GetAPIServiceInstanceByName - Returns the API service instance for specified name

func (*ServiceClient) GetAPIServiceInstances

func (c *ServiceClient) GetAPIServiceInstances(queryParams map[string]string, URL string) ([]*management.APIServiceInstance, error)

GetAPIServiceInstances - get management.APIServiceInstance

func (*ServiceClient) GetAPIServiceRevisions

func (c *ServiceClient) GetAPIServiceRevisions(queryParams map[string]string, URL, stage string) ([]*management.APIServiceRevision, error)

GetAPIServiceRevisions - management.APIServiceRevision

func (*ServiceClient) GetAPIV1ResourceInstances

func (c *ServiceClient) GetAPIV1ResourceInstances(queryParams map[string]string, url string) ([]*apiv1.ResourceInstance, error)

GetAPIV1ResourceInstances - return apiv1 Resource instance with the default page size

func (*ServiceClient) GetAPIV1ResourceInstancesWithPageSize

func (c *ServiceClient) GetAPIV1ResourceInstancesWithPageSize(queryParams map[string]string, url string, pageSize int) ([]*apiv1.ResourceInstance, error)

GetAPIV1ResourceInstancesWithPageSize - return apiv1 Resource instance

func (*ServiceClient) GetAccessControlList

func (c *ServiceClient) GetAccessControlList(name string) (*management.AccessControlList, error)

GetAccessControlList -

func (*ServiceClient) GetCatalogItemIDForConsumerInstance

func (c *ServiceClient) GetCatalogItemIDForConsumerInstance(id string) (string, error)

GetCatalogItemIDForConsumerInstance -

func (*ServiceClient) GetCatalogItemName

func (c *ServiceClient) GetCatalogItemName(ID string) (string, error)

GetCatalogItemName -

func (*ServiceClient) GetCentralTeamByName

func (c *ServiceClient) GetCentralTeamByName(name string) (*defs.PlatformTeam, error)

GetCentralTeamByName - returns the team based on team name

func (*ServiceClient) GetConsumerInstanceByID

func (c *ServiceClient) GetConsumerInstanceByID(consumerInstanceID string) (*management.ConsumerInstance, error)

GetConsumerInstanceByID -

func (*ServiceClient) GetConsumerInstancesByExternalAPIID

func (c *ServiceClient) GetConsumerInstancesByExternalAPIID(externalAPIID string) ([]*management.ConsumerInstance, error)

GetConsumerInstancesByExternalAPIID - DEPRECATED

func (*ServiceClient) GetEnvironment

func (c *ServiceClient) GetEnvironment() (*management.Environment, error)

GetEnvironment get an environment

func (*ServiceClient) GetOrCreateCategory

func (c *ServiceClient) GetOrCreateCategory(title string) string

GetOrCreateCategory - Returns the value on published proxy

func (*ServiceClient) GetResource

func (c *ServiceClient) GetResource(url string) (*apiv1.ResourceInstance, error)

GetResource gets a single resource

func (*ServiceClient) GetResources added in v1.1.33

func (c *ServiceClient) GetResources(iface apiv1.Interface) ([]apiv1.Interface, error)

GetResource gets a single resource

func (*ServiceClient) GetSubscriptionDefinitionPropertiesForCatalogItem

func (c *ServiceClient) GetSubscriptionDefinitionPropertiesForCatalogItem(catalogItemID, propertyKey string) (SubscriptionSchema, error)

GetSubscriptionDefinitionPropertiesForCatalogItem -

func (*ServiceClient) GetSubscriptionManager

func (c *ServiceClient) GetSubscriptionManager() SubscriptionManager

GetSubscriptionManager -

func (*ServiceClient) GetSubscriptionsForCatalogItem

func (c *ServiceClient) GetSubscriptionsForCatalogItem(states []string, instanceID string) ([]CentralSubscription, error)

GetSubscriptionsForCatalogItem -

func (*ServiceClient) GetTeam

func (c *ServiceClient) GetTeam(query map[string]string) ([]defs.PlatformTeam, error)

GetTeam - returns the team ID based on filter

func (*ServiceClient) GetUserEmailAddress

func (c *ServiceClient) GetUserEmailAddress(id string) (string, error)

GetUserEmailAddress - request the user email

func (*ServiceClient) GetUserName

func (c *ServiceClient) GetUserName(id string) (string, error)

GetUserName - request the user name

func (*ServiceClient) Healthcheck

func (c *ServiceClient) Healthcheck(_ string) *hc.Status

Healthcheck - verify connection to the platform

func (*ServiceClient) IsMarketplaceSubsEnabled

func (c *ServiceClient) IsMarketplaceSubsEnabled() bool

IsMarketplaceSubsEnabled -

func (*ServiceClient) PublishService

func (c *ServiceClient) PublishService(serviceBody *ServiceBody) (*management.APIService, error)

PublishService - processes the API to create/update apiservice, revision, instance and consumer instance

func (*ServiceClient) RegisterSubscriptionSchema

func (c *ServiceClient) RegisterSubscriptionSchema(subscriptionSchema SubscriptionSchema, update bool) error

RegisterSubscriptionSchema - Adds a new subscription schema for the specified auth type. In publishToEnvironment mode creates a API Server resource for subscription definition

func (*ServiceClient) RegisterSubscriptionWebhook

func (c *ServiceClient) RegisterSubscriptionWebhook() error

RegisterSubscriptionWebhook - Adds a new Subscription webhook. There is a single webhook per environment

func (*ServiceClient) SetConfig

func (c *ServiceClient) SetConfig(cfg corecfg.CentralConfig)

SetConfig - sets the config and apiClient

func (*ServiceClient) SetSubscriptionManager

func (c *ServiceClient) SetSubscriptionManager(mgr SubscriptionManager)

SetSubscriptionManager -

func (*ServiceClient) SetTokenGetter

func (c *ServiceClient) SetTokenGetter(tokenRequester auth.PlatformTokenGetter)

SetTokenGetter - sets the token getter

func (*ServiceClient) UpdateAccessControlList

func (c *ServiceClient) UpdateAccessControlList(acl *management.AccessControlList) (*management.AccessControlList, error)

UpdateAccessControlList - removes existing then creates new AccessControlList

func (*ServiceClient) UpdateAccessRequestSubscriptionSchema

func (c *ServiceClient) UpdateAccessRequestSubscriptionSchema(subscriptionSchema SubscriptionSchema) error

UpdateAccessRequestSubscriptionSchema - Updates an access request subscription schema in Publish to environment mode creates a API Server resource for subscription definition

func (*ServiceClient) UpdateConsumerInstanceSubscriptionDefinition

func (c *ServiceClient) UpdateConsumerInstanceSubscriptionDefinition(externalAPIID, subscriptionDefinitionName string) error

UpdateConsumerInstanceSubscriptionDefinition -

func (*ServiceClient) UpdateResource

func (c *ServiceClient) UpdateResource(url string, bts []byte) (*apiv1.ResourceInstance, error)

UpdateResource updates a resource

func (*ServiceClient) UpdateResourceFinalizer

func (c *ServiceClient) UpdateResourceFinalizer(res *apiv1.ResourceInstance, finalizer, description string, addAction bool) (*apiv1.ResourceInstance, error)

UpdateResourceFinalizer - Add or remove a finalizer from a resource

func (*ServiceClient) UpdateResourceInstance

func (c *ServiceClient) UpdateResourceInstance(ri apiv1.Interface) (*apiv1.ResourceInstance, error)

UpdateResourceInstance - updates a ResourceInstance

func (*ServiceClient) UpdateSubscriptionDefinitionPropertiesForCatalogItem

func (c *ServiceClient) UpdateSubscriptionDefinitionPropertiesForCatalogItem(catalogItemID, propertyKey string, subscriptionSchema SubscriptionSchema) error

UpdateSubscriptionDefinitionPropertiesForCatalogItem -

func (*ServiceClient) UpdateSubscriptionSchema

func (c *ServiceClient) UpdateSubscriptionSchema(subscriptionSchema SubscriptionSchema) error

UpdateSubscriptionSchema - Updates a subscription schema in Publish to environment mode creates a API Server resource for subscription definition

type SpecProcessor

type SpecProcessor interface {
	GetEndpoints() ([]EndpointDefinition, error)
	// contains filtered or unexported methods
}

SpecProcessor -

type SpecResourceParser

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

SpecResourceParser -

func NewSpecResourceParser

func NewSpecResourceParser(resourceSpec []byte, resourceSpecType string) SpecResourceParser

NewSpecResourceParser -

func (*SpecResourceParser) GetSpecProcessor

func (s *SpecResourceParser) GetSpecProcessor() SpecProcessor

GetSpecProcessor -

func (*SpecResourceParser) Parse

func (s *SpecResourceParser) Parse() error

Parse -

type StringPropertyBuilder

type StringPropertyBuilder interface {
	// SetEnumValues - Set a list of valid values for the property
	SetEnumValues(values []string) StringPropertyBuilder
	// SetSortEnumValues - Sort the allowed values alphabetically in the schema
	SetSortEnumValues() StringPropertyBuilder
	// SetFirstEnumValue - Set the value that should appear first in the list
	SetFirstEnumValue(value string) StringPropertyBuilder
	// AddEnumValue - Add another value to the list of allowed values for the property
	AddEnumValue(value string) StringPropertyBuilder
	// SetDefaultValue - Define the initial value for the property
	SetDefaultValue(value string) StringPropertyBuilder
	PropertyBuilder
}

StringPropertyBuilder - specific methods related to the String property builders

type Subscription

type Subscription interface {
	GetID() string
	GetName() string
	GetApicID() string
	GetRemoteAPIAttributes() map[string]string
	GetRemoteAPIID() string
	GetRemoteAPIStage() string
	GetCatalogItemID() string
	GetCreatedUserID() string
	GetState() SubscriptionState
	GetPropertyValue(propertyKey string) string
	GetPropertyValues(propertyKey string) []interface{}
	UpdateState(newState SubscriptionState, description string) error
	UpdateStateWithProperties(newState SubscriptionState, description string, properties map[string]interface{}) error
	UpdateEnumProperty(key, value, dataType string) error
	UpdateProperties(appName string) error
	UpdatePropertyValues(values map[string]interface{}) error
	// contains filtered or unexported methods
}

Subscription -

type SubscriptionBuilder

type SubscriptionBuilder interface {
	UpdateEnumProperty(key, newValue, dataType string) SubscriptionBuilder
	SetStringPropertyValue(key, value string) SubscriptionBuilder
	Process() error
}

SubscriptionBuilder -

func NewSubscriptionBuilder

func NewSubscriptionBuilder(subscription Subscription) SubscriptionBuilder

NewSubscriptionBuilder - Creates a new subscription builder to update a subscriptions property and status

type SubscriptionManager

type SubscriptionManager interface {
	RegisterProcessor(state SubscriptionState, processor SubscriptionProcessor)
	RegisterValidator(validator SubscriptionValidator)
	Start()
	Stop()

	OnConfigChange(apicClient *ServiceClient)
	// contains filtered or unexported methods
}

SubscriptionManager - Interface for subscription manager

type SubscriptionProcessor

type SubscriptionProcessor func(subscription Subscription)

SubscriptionProcessor - callback method type to process subscriptions

type SubscriptionPropertyBuilder

type SubscriptionPropertyBuilder interface {
	// SetName - sets the name of the property
	SetName(name string) SubscriptionPropertyBuilder
	// SetDescription - set the description of the property
	SetDescription(description string) SubscriptionPropertyBuilder
	// SetRequired - set the property as a required field in the schema
	SetRequired() SubscriptionPropertyBuilder
	// SetReadOnly - set the property as a read only property
	SetReadOnly() SubscriptionPropertyBuilder
	// SetHidden - set the property as a hidden property
	SetHidden() SubscriptionPropertyBuilder
	// SetAPICRefField - set the apic reference field for this property
	SetAPICRefField(field string) SubscriptionPropertyBuilder
	// IsString - Set the property to be of type string
	IsString() StringPropertyBuilder
	// IsInteger - Set the property to be of type integer
	IsInteger() IntegerPropertyBuilder
	// IsNumber - Set the property to be of type number
	IsNumber() NumberPropertyBuilder
	// IsArray - Set the property to be of type array
	IsArray() ArrayPropertyBuilder
	// IsObject - Set the property to be of type object
	IsObject() ObjectPropertyBuilder
	PropertyBuilder
}

SubscriptionPropertyBuilder - common methods related to subscription property builders

func NewSubscriptionSchemaPropertyBuilder

func NewSubscriptionSchemaPropertyBuilder() SubscriptionPropertyBuilder

NewSubscriptionSchemaPropertyBuilder - Creates a new subscription schema property builder

type SubscriptionSchema

type SubscriptionSchema interface {
	AddProperty(name, dataType, description, apicRefField string, isRequired bool, enums []string)
	GetProperty(name string) *SubscriptionSchemaPropertyDefinition
	AddUniqueKey(keyName string)
	GetSubscriptionName() string
	SetSubscriptionName(name string)

	SetJSONDraft07SchemaVersion()
	// contains filtered or unexported methods
}

SubscriptionSchema -

func NewSubscriptionSchema

func NewSubscriptionSchema(name string) SubscriptionSchema

NewSubscriptionSchema -

type SubscriptionSchemaBuilder

type SubscriptionSchemaBuilder interface {
	Update(update bool) SubscriptionSchemaBuilder
	SetName(name string) SubscriptionSchemaBuilder
	AddProperty(property PropertyBuilder) SubscriptionSchemaBuilder
	AddUniqueKey(keyName string) SubscriptionSchemaBuilder
	SetJSONDraft07SchemaVersion() SubscriptionSchemaBuilder

	Register() error
}

SubscriptionSchemaBuilder - used to build a subscription schema for API Central

func NewSubscriptionSchemaBuilder

func NewSubscriptionSchemaBuilder(apicClient Client) SubscriptionSchemaBuilder

NewSubscriptionSchemaBuilder - Creates a new subscription schema builder

type SubscriptionSchemaPropertyDefinition

type SubscriptionSchemaPropertyDefinition struct {
	Type               string                                          `json:"type"`
	Title              string                                          `json:"title,omitempty"`
	Description        string                                          `json:"description,omitempty"`
	DefaultValue       interface{}                                     `json:"default,omitempty"`
	Enum               []string                                        `json:"enum,omitempty"`
	ReadOnly           bool                                            `json:"readOnly,omitempty"`
	Format             string                                          `json:"format,omitempty"`
	Properties         map[string]SubscriptionSchemaPropertyDefinition `json:"properties,omitempty"`
	RequiredProperties []string                                        `json:"required,omitempty"`
	Items              *AnyOfSubscriptionSchemaPropertyDefinitions     `json:"items,omitempty"`    // We use a pointer to avoid generating an empty struct if not set
	MinItems           *uint                                           `json:"minItems,omitempty"` // We use a pointer to differentiate the "blank value" from a choosen 0 min value
	MaxItems           *uint                                           `json:"maxItems,omitempty"` // We use a pointer to differentiate the "blank value" from a choosen 0 min value
	Minimum            *float64                                        `json:"minimum,omitempty"`  // We use a pointer to differentiate the "blank value" from a choosen 0 min value
	Maximum            *float64                                        `json:"maximum,omitempty"`  // We use a pointer to differentiate the "blank value" from a choosen 0 max value
	APICRef            string                                          `json:"x-axway-ref-apic,omitempty"`
	Name               string                                          `json:"-"`
	Required           bool                                            `json:"-"`
}

SubscriptionSchemaPropertyDefinition -

type SubscriptionState

type SubscriptionState string

SubscriptionState - Type definition for subscription state

type SubscriptionValidator

type SubscriptionValidator func(subscription Subscription) bool

SubscriptionValidator - callback method type to validate subscription for processing

type UnstructuredProperties

type UnstructuredProperties struct {
	AssetType   string
	ContentType string
	Label       string
	Filename    string
}

UnstructuredProperties -

Directories

Path Synopsis
apiserver
Package auth implements the apic service account token management.
Package auth implements the apic service account token management.
unifiedcatalog

Jump to

Keyboard shortcuts

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