Documentation
¶
Overview ¶
Package apim handles the interactions with APIM.
Index ¶
- Constants
- Variables
- func CreateAPI(reqBody *APIReqBody) (string, error)
- func CreateApplication(reqBody *ApplicationCreateReq) (string, error)
- func DeleteAPI(apiID string) error
- func DeleteApplication(applicationID string) error
- func GetAppDashboardURL(appID string) string
- func Init(manager token.Manager, conf config.APIM)
- func SearchAPIByNameVersion(apiName, version string) (string, error)
- func SearchApplication(appName string) (string, error)
- func UnSubscribe(subscriptionID string) error
- func UpdateApplication(id string, reqBody *ApplicationCreateReq) error
- type APIBusinessInformation
- type APICorsConfiguration
- type APICreateResp
- type APIEndpointSecurity
- type APIMaxTps
- type APIParam
- type APIReqBody
- type APISearchInfo
- type APISearchResp
- type AppCreateReq
- type AppCreateRes
- type ApplicationCreateReq
- type ApplicationKeyGenerateRequest
- type ApplicationKeyResp
- type ApplicationMetadata
- type ApplicationParam
- type ApplicationSearchInfo
- type ApplicationSearchResp
- type Label
- type Sequence
- type SubscriptionParam
- type SubscriptionReq
- type SubscriptionResp
- type SubscriptionRespApiInfo
- type SubscriptionSpec
- type Token
Constants ¶
const ( CreateAPIContext = "create API" CreateApplicationContext = "create application" CreateMultipleSubscriptionContext = "create multiple subscriptions" UpdateApplicationContext = "update application" GenerateKeyContext = "Generate application keys" UnSubscribeContext = "unsubscribe api" ApplicationDeleteContext = "delete application" APIDeleteContext = "delete API" APISearchContext = "search API" ApplicationSearchContext = "search Application" ErrMsgAPPIDEmpty = "application id is empty" )
Variables ¶
var AppPlanBindInputParameterSchemaRaw = `{
"$schema": "http://json-schema.org/draft-04/schema#"
}`
var AppPlanInputParameterSchemaRaw = `` /* 504-byte string literal not displayed */
Functions ¶
func CreateAPI ¶
func CreateAPI(reqBody *APIReqBody) (string, error)
CreateAPI function creates an API with the provided API spec. Returns the API ID and any error encountered.
func CreateApplication ¶
func CreateApplication(reqBody *ApplicationCreateReq) (string, error)
CreateApplication creates an application with provided Application spec. Returns the Application ID and any error encountered.
func DeleteApplication ¶
DeleteApplication method deletes the given application. Returns any error encountered.
func GetAppDashboardURL ¶
GetAppDashboardURL returns DashBoard URL for the given Application.
func Init ¶
Init function initialize the API-M client. If there is an error, process exists with a panic.
func SearchAPIByNameVersion ¶
SearchAPIByNameVersion method returns API ID of the Given API. An error is returned if the number of result for the search is not equal to 1. Returns API ID and any error encountered.
func SearchApplication ¶
SearchApplication method returns Application ID of the Given Application. An error is returned if the number of result for the search is not equal to 1. Returns Application ID and any error encountered.
func UnSubscribe ¶
UnSubscribe method removes the given subscription. Returns any error encountered.
func UpdateApplication ¶
func UpdateApplication(id string, reqBody *ApplicationCreateReq) error
UpdateApplication updates an existing Application under the given ID with the provided Application spec. Returns any error encountered.
Types ¶
type APIBusinessInformation ¶
type APIBusinessInformation struct { BusinessOwner string `json:"businessOwner,omitempty"` BusinessOwnerEmail string `json:"businessOwnerEmail,omitempty"` TechnicalOwner string `json:"technicalOwner,omitempty"` TechnicalOwnerEmail string `json:"technicalOwnerEmail,omitempty"` }
APIBusinessInformation represents the API business information.
type APICorsConfiguration ¶
type APICorsConfiguration struct { CorsConfigurationEnabled bool `json:"corsConfigurationEnabled,omitempty"` AccessControlAllowOrigins []string `json:"accessControlAllowOrigins,omitempty" hash:"set"` AccessControlAllowCredentials bool `json:"accessControlAllowCredentials,omitempty"` AccessControlAllowHeaders []string `json:"accessControlAllowHeaders,omitempty" hash:"set"` AccessControlAllowMethods []string `json:"accessControlAllowMethods,omitempty" hash:"set"` }
APICorsConfiguration represents the CORS configuration for the API.
type APICreateResp ¶
type APICreateResp struct { // UUID of the api registry artifact ID string `json:"id,omitempty"` }
APICreateResp represents the response of create "API" API call.
type APIEndpointSecurity ¶
type APIEndpointSecurity struct { Type string `json:"type,omitempty"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` }
APIEndpointSecurity represents the endpoint security information.
type APIMaxTps ¶
type APIMaxTps struct { Production int64 `json:"production,omitempty"` Sandbox int64 `json:"sandbox,omitempty"` }
APIMaxTps represents the max TPS(Transactions per second) for an API.
type APIParam ¶
type APIParam struct {
APISpec APIReqBody `json:"api"`
}
APIParam represents the structure for API plan parameters.
type APIReqBody ¶
type APIReqBody struct { ID string `json:"id"` // Name of the API Name string `json:"name"` // A brief description about the API Description string `json:"description"` // A string that represents the context of the user's request Context string `json:"context"` // The version of the API Version string `json:"version"` // If the provider value is not given, the user invoking the API will be used as the provider. Provider string `json:"provider,omitempty"` // This describes in which status of the lifecycle the API is Status string `json:"status"` ThumbnailURI string `json:"thumbnailUri,omitempty"` // Swagger definition of the API which contains details about URI templates and scopes APIDefinition string `json:"apiDefinition"` // WSDL URL if the API is based on a WSDL endpoint WsdlURI string `json:"wsdlUri,omitempty"` ResponseCaching string `json:"responseCaching,omitempty"` CacheTimeout int32 `json:"cacheTimeout,omitempty"` DestinationStatsEnabled bool `json:"destinationStatsEnabled,omitempty"` IsDefaultVersion bool `json:"isDefaultVersion"` // The transport to be set. Accepted values are HTTP, WS Type string `json:"type"` // Supported transports for the API (http and/or https). Transport []string `json:"transport" hash:"set"` // Search keywords related to the API Tags []string `json:"tags,omitempty" hash:"set"` // The subscription tiers selected for the particular API Tiers []string `json:"tiers" hash:"set"` // The policy selected for the particular API APILevelPolicy string `json:"apiLevelPolicy,omitempty"` // Name of the Authorization header used for invoking the API. If it is not set, Authorization header name specified in tenant or system level will be used. AuthorizationHeader string `json:"authorizationHeader,omitempty"` MaxTps *APIMaxTps `json:"maxTps,omitempty"` // The visibility level of the API. Accepts one of the following. PUBLIC, PRIVATE, RESTRICTED OR CONTROLLED. Visibility string `json:"visibility"` // The user roles that are able to access the API VisibleRoles []string `json:"visibleRoles,omitempty" hash:"set"` VisibleTenants []string `json:"visibleTenants,omitempty" hash:"set"` EndpointConfig string `json:"endpointConfig"` EndpointSecurity *APIEndpointSecurity `json:"endpointSecurity,omitempty"` // Comma separated list of gateway environments. GatewayEnvironments string `json:"gatewayEnvironments,omitempty"` // Labels of micro-gateway environments attached to the API. Labels []Label `json:"labels,omitempty" hash:"set"` Sequences []Sequence `json:"sequences,omitempty" hash:"set"` // The subscription availability. Accepts one of the following. current_tenant, all_tenants or specific_tenants. SubscriptionAvailability string `json:"subscriptionAvailability,omitempty"` SubscriptionAvailableTenants []string `json:"subscriptionAvailableTenants,omitempty"` // Map of custom properties of API AdditionalProperties map[string]string `json:"additionalProperties,omitempty" hash:"set"` // Is the API is restricted to certain set of publishers or creators or is it visible to all the publishers and creators. If the accessControl restriction is none, this API can be modified by all the publishers and creators, if not it can only be viewable/modifiable by certain set of publishers and creators, based on the restriction. AccessControl string `json:"accessControl,omitempty"` // The user roles that are able to view/modify as API publisher or creator. AccessControlRoles []string `json:"accessControlRoles,omitempty"` BusinessInformation *APIBusinessInformation `json:"businessInformation,omitempty"` CorsConfiguration *APICorsConfiguration `json:"corsConfiguration,omitempty"` }
APIReqBody represents the request of create "API" API call.
type APISearchInfo ¶
type APISearchInfo struct { Provider string `json:"provider"` Version string `json:"version"` Description string `json:"description"` Status string `json:"status"` Name string `json:"name"` Context string `json:"context"` ID string `json:"id"` }
APISearchInfo represents the API search information.
type APISearchResp ¶
type APISearchResp struct { Previous string `json:"previous"` List []APISearchInfo `json:"list"` Count int `json:"count"` Next string `json:"next"` }
APISearchResp represents the response of search "API" by name API call.
type AppCreateReq ¶
type AppCreateReq struct { ThrottlingPolicy string `json:"throttlingPolicy"` Description string `json:"description"` Name string `json:"name"` CallbackURL string `json:"callbackUrl"` }
AppCreateReq represents the application creation request body.
type AppCreateRes ¶
type AppCreateRes struct {
ApplicationID string `json:"applicationId"`
}
AppCreateRes represents the application creation response body.
type ApplicationCreateReq ¶
type ApplicationCreateReq struct { ThrottlingPolicy string `json:"throttlingPolicy"` TokenType string `json:"tokenType"` Description string `json:"description,omitempty"` Name string `json:"name,omitempty"` }
ApplicationCreateReq represents the response of create Application API call.
type ApplicationKeyGenerateRequest ¶
type ApplicationKeyGenerateRequest struct { KeyType string `json:"keyType"` ValidityTime string `json:"validityTime"` // The grant types that are supported by the application GrantTypesToBeSupported []string `json:"grantTypesToBeSupported,omitempty"` // Callback URL CallbackURL string `json:"callbackUrl,omitempty"` // Allowed scopes for the access token Scopes []string `json:"scopes,omitempty"` // Client ID for generating access token. ClientID string `json:"clientId,omitempty"` // Client secret for generating access token. This is given together with the client ID. ClientSecret string `json:"clientSecret,omitempty"` AdditionalProperties string `json:"additionalProperties,omitempty"` }
ApplicationKeyGenerateRequest represents the application key generation request.
type ApplicationKeyResp ¶
type ApplicationKeyResp struct { // The consumer key associated with the application and identifying the client ConsumerKey string `json:"consumerKey,omitempty"` // The client secret that is used to authenticate the client with the authentication server ConsumerSecret string `json:"consumerSecret,omitempty"` // The grant types that are supported by the application SupportedGrantTypes []string `json:"supportedGrantTypes,omitempty"` // Callback URL CallbackURL string `json:"callbackUrl,omitempty"` // Describes the state of the key generation. KeyState string `json:"keyState,omitempty"` // Describes to which endpoint the key belongs KeyType string `json:"keyType,omitempty"` // ApplicationConfig group id (if any). GroupID string `json:"groupId,omitempty"` Token *Token `json:"token,omitempty"` }
ApplicationKeyResp represents the Application generate keys API call response.
func GenerateKeys ¶
func GenerateKeys(appID string) (*ApplicationKeyResp, error)
GenerateKeys generates keys for the given application. Returns generated keys and any error encountered.
type ApplicationMetadata ¶
type ApplicationMetadata struct { Name string ID string Keys *ApplicationKeyResp DashboardURL string }
ApplicationMetadata represents name, id and key of the generated application
type ApplicationParam ¶
type ApplicationParam struct {
AppSpec ApplicationCreateReq `json:"app"`
}
ApplicationParam represents the structure for Application plan parameters.
type ApplicationSearchInfo ¶
type ApplicationSearchInfo struct { GroupID string `json:"groupId"` Subscriber string `json:"subscriber"` ThrottlingTier string `json:"throttlingTier"` ApplicationID string `json:"applicationId"` Name string `json:"name"` Description string `json:"description"` Status string `json:"status"` }
ApplicationSearchInfo represents the Application search information.
type ApplicationSearchResp ¶
type ApplicationSearchResp struct { Previous string `json:"previous"` List []ApplicationSearchInfo `json:"list"` Count int `json:"count"` Next string `json:"next"` }
ApplicationSearchResp represents the response of search Application by name API call.
type Sequence ¶
type Sequence struct { Name string `json:"name"` Type string `json:"type,omitempty"` ID string `json:"id,omitempty"` }
Sequence represents a API sequence.
type SubscriptionParam ¶
type SubscriptionParam struct {
SubsSpec SubscriptionSpec `json:"subs"`
}
SubscriptionParam represents the structure for Subscription plan parameters.
type SubscriptionReq ¶
type SubscriptionReq struct { ThrottlingPolicy string `json:"throttlingPolicy"` ApiID string `json:"apiId"` ApplicationID string `json:"applicationId"` }
SubscriptionReq represents the APIM subscription create request.
type SubscriptionResp ¶
type SubscriptionResp struct { // The UUID of the subscription SubscriptionID string `json:"subscriptionId,omitempty"` // The UUID of the application ApplicationId string `json:"applicationId,omitempty"` // The UUID of the application ApiID string `json:"apiId"` // The unique identifier of the API. ApiInfo SubscriptionRespApiInfo `json:"apiInfo"` ThrottlingPolicy string `json:"throttlingPolicy"` }
SubscriptionResp represents the response of create Subscription API call.
func CreateMultipleSubscriptions ¶
func CreateMultipleSubscriptions(subs []SubscriptionReq) ([]SubscriptionResp, error)
CreateMultipleSubscriptions creates the given subscriptions. Returns list of SubscriptionResp and any error encountered.
type SubscriptionRespApiInfo ¶
type SubscriptionRespApiInfo struct { Name string `json:"name"` Version string `json:"version"` Provider string `json:"provider"` }
SubscriptionRespApiInfo represents the API info of response of create Subscription API call.
type SubscriptionSpec ¶
type SubscriptionSpec struct { APIName string `json:"apiName"` AppName string `json:"appName"` SubscriptionTier string `json:"tier"` }
SubscriptionSpec represents the parameters for a Subscription.
type Token ¶
type Token struct { // Access token AccessToken string `json:"accessToken,omitempty"` // Valid scopes for the access token TokenScopes []string `json:"tokenScopes,omitempty"` // Maximum validity time for the access token ValidityTime int64 `json:"validityTime,omitempty"` }
Token represents an Application token.