Documentation ¶
Overview ¶
Package model contains the implementation of DTOs to convert OpenAPI/Swagger files and create a common model which can represent both types.
Package model contains the implementation of DTOs to convert OpenAPI/Swagger files and create a common model which can represent both types.
Index ¶
- func GenerateInterceptorIncludes(includes []string) *interceptor.RequestInclusions
- func GetXWso2Label(vendorExtensions openapi3.ExtensionProps) []string
- func ResolveAmznResourceName(vendorExtensions map[string]interface{}) string
- func ResolveDisableSecurity(vendorExtensions map[string]interface{}) bool
- func ResolveThrottlingTier(vendorExtensions map[string]interface{}) string
- type APIData
- type APIEndpointSecurity
- type APIYaml
- type AsyncAPI
- type Certificate
- type CertificateDetails
- type ChannelItem
- type CircuitBreakers
- type ClientCertificate
- type ClientCertificatesDetails
- type CorsConfig
- type Deployment
- type DeploymentEnvironments
- type Endpoint
- type EndpointCertificate
- type EndpointCertificatesDetails
- type EndpointCluster
- type EndpointConfig
- type EndpointInfo
- type EndpointSecurity
- type GraphQLComplexityYaml
- type InterceptEndpoint
- type MgwSwagger
- func (swagger *MgwSwagger) GetAPIType() string
- func (swagger *MgwSwagger) GetClientCerts() []Certificate
- func (swagger *MgwSwagger) GetCorsConfig() *CorsConfig
- func (swagger *MgwSwagger) GetDescription() string
- func (swagger *MgwSwagger) GetDisableSecurity() bool
- func (swagger *MgwSwagger) GetEndpointType() string
- func (swagger *MgwSwagger) GetID() string
- func (swagger *MgwSwagger) GetInterceptor(vendorExtensions map[string]interface{}, extensionName string, level string) InterceptEndpoint
- func (swagger *MgwSwagger) GetMgwSwagger(apiContent []byte) error
- func (swagger *MgwSwagger) GetOperationInterceptors(apiInterceptor InterceptEndpoint, resourceInterceptor InterceptEndpoint, ...) map[string]InterceptEndpoint
- func (swagger *MgwSwagger) GetProdEndpoints() *EndpointCluster
- func (swagger *MgwSwagger) GetResources() []*Resource
- func (swagger *MgwSwagger) GetSandEndpoints() *EndpointCluster
- func (swagger *MgwSwagger) GetSecurity() []map[string][]string
- func (swagger *MgwSwagger) GetSecurityScheme() []SecurityScheme
- func (swagger *MgwSwagger) GetTitle() string
- func (swagger *MgwSwagger) GetVendorExtensions() map[string]interface{}
- func (swagger *MgwSwagger) GetVersion() string
- func (swagger *MgwSwagger) GetXWSO2ApplicationSecurity() bool
- func (swagger *MgwSwagger) GetXWSO2AuthHeader() string
- func (swagger *MgwSwagger) GetXWSO2MutualSSL() string
- func (swagger *MgwSwagger) GetXWso2Basepath() string
- func (swagger *MgwSwagger) GetXWso2Endpoints() map[string]*EndpointCluster
- func (swagger *MgwSwagger) GetXWso2HTTP2BackendEnabled() bool
- func (swagger *MgwSwagger) GetXWso2RequestBodyPass() bool
- func (swagger *MgwSwagger) GetXWso2ThrottlingTier() string
- func (swagger *MgwSwagger) PopulateFromAPIYaml(apiYaml APIYaml) error
- func (swagger *MgwSwagger) SanitizeAPISecurity(isYamlAPIKey bool, isYamlOauth bool, isYamlMutualssl bool, ...)
- func (swagger *MgwSwagger) SetClientCerts(certs []Certificate)
- func (swagger *MgwSwagger) SetEnvLabelProperties(envProps synchronizer.APIEnvProps)
- func (swagger *MgwSwagger) SetEnvVariables(apiHashValue string)
- func (swagger *MgwSwagger) SetID(id string)
- func (swagger *MgwSwagger) SetInfoAsyncAPI(asyncAPI AsyncAPI) error
- func (swagger *MgwSwagger) SetInfoGraphQLAPI(apiYaml APIYaml) error
- func (swagger *MgwSwagger) SetInfoOpenAPI(swagger3 openapi3.Swagger) error
- func (swagger *MgwSwagger) SetInfoSwagger(swagger2 spec.Swagger) error
- func (swagger *MgwSwagger) SetName(name string)
- func (swagger *MgwSwagger) SetOperationPolicies(apiProject ProjectAPI) (err error)
- func (swagger *MgwSwagger) SetProductionEndpoints(productionEndpoints []Endpoint)
- func (swagger *MgwSwagger) SetSandboxEndpoints(sandboxEndpoints []Endpoint)
- func (swagger *MgwSwagger) SetSecurity(security []map[string][]string)
- func (swagger *MgwSwagger) SetSecurityScheme(securityScheme []SecurityScheme)
- func (swagger *MgwSwagger) SetVersion(version string)
- func (swagger *MgwSwagger) SetXWSO2ApplicationSecurity(applicationSecurity bool)
- func (swagger *MgwSwagger) SetXWSO2MutualSSL(mutualSSl string)
- func (swagger *MgwSwagger) SetXWso2AuthHeader(authHeader string)
- func (swagger *MgwSwagger) SetXWso2Extensions() error
- func (swagger *MgwSwagger) Validate() error
- type Operation
- func (operation *Operation) GetCallInterceptorService(isIn bool) InterceptEndpoint
- func (operation *Operation) GetDisableSecurity() bool
- func (operation *Operation) GetID() string
- func (operation *Operation) GetMethod() string
- func (operation *Operation) GetMockedAPIConfig() *api.MockedApiConfig
- func (operation *Operation) GetPolicies() *OperationPolicies
- func (operation *Operation) GetSecurity() []map[string][]string
- func (operation *Operation) GetTier() string
- func (operation *Operation) GetVendorExtensions() map[string]interface{}
- func (operation *Operation) SetMockedAPIConfigOAS2(openAPIOperation *spec.Operation)
- func (operation *Operation) SetMockedAPIConfigOAS3(openAPIOperation *openapi3.Operation)
- func (operation *Operation) SetSecurity(security []map[string][]string)
- type OperationAsync
- type OperationPolicies
- type OperationYaml
- type Policy
- type PolicyContainer
- type PolicyContainerMap
- type PolicyDefinition
- type PolicyFlow
- type PolicyList
- type PolicySpecification
- type ProjectAPI
- type Resource
- func (resource *Resource) GetAmznResourceName() string
- func (resource *Resource) GetID() string
- func (resource *Resource) GetMethod() []*Operation
- func (resource *Resource) GetMethodList() []string
- func (resource *Resource) GetOperations() []*Operation
- func (resource *Resource) GetPath() string
- func (resource *Resource) GetProdEndpoints() *EndpointCluster
- func (resource *Resource) GetSandEndpoints() *EndpointCluster
- func (resource *Resource) GetVendorExtensions() map[string]interface{}
- func (resource *Resource) HasPolicies() bool
- func (resource *Resource) SetAmznResourceName(amznResourceName string)
- type RetryConfig
- type SecurityScheme
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateInterceptorIncludes ¶
func GenerateInterceptorIncludes(includes []string) *interceptor.RequestInclusions
GenerateInterceptorIncludes generate includes
func GetXWso2Label ¶
func GetXWso2Label(vendorExtensions openapi3.ExtensionProps) []string
GetXWso2Label extracts the vendor-extension (openapi v3) property.
Default value is 'default'
func ResolveAmznResourceName ¶
ResolveAmznResourceName extracts the value of x-amzn-resource-name extension. If the property is not availble, an empty string is returned.
func ResolveDisableSecurity ¶
ResolveDisableSecurity extracts the value of x-auth-type extension. if the property is not available, false is returned. If the API definition is fed from API manager, then API definition contains x-auth-type as "None" for non secured APIs. Then the return value would be true. If the API definition is fed through apictl, the users can use either x-wso2-disable-security : true/false to enable and disable security.
func ResolveThrottlingTier ¶
ResolveThrottlingTier extracts the value of x-wso2-throttling-tier and x-throttling-tier extension. if x-wso2-throttling-tier is available it will be prioritized. if both the properties are not available, an empty string is returned.
Types ¶
type APIData ¶
type APIData struct { ProviderName string `json:"providerName"` APIName string `json:"apiName"` Version string `json:"version"` UUID string `json:"uuid"` ID uint32 `json:"id"` }
APIData represents API information of relevant API of the certificate
type APIEndpointSecurity ¶
type APIEndpointSecurity struct { Production EndpointSecurity `json:"production,omitempty"` Sandbox EndpointSecurity `json:"sandbox,omitempty"` }
APIEndpointSecurity represents the structure of endpoint_security param in api.yaml
type APIYaml ¶
type APIYaml struct { Type string `yaml:"type" json:"type"` Version string `yaml:"version" json:"version"` Data struct { ID string `json:"Id,omitempty"` Name string `json:"name,omitempty"` Context string `json:"context,omitempty"` Version string `json:"version,omitempty"` RevisionID int `json:"revisionId,omitempty"` APIType string `json:"type,omitempty"` LifeCycleStatus string `json:"lifeCycleStatus,omitempty"` EndpointImplementationType string `json:"endpointImplementationType,omitempty"` AuthorizationHeader string `json:"authorizationHeader,omitempty"` SecurityScheme []string `json:"securityScheme,omitempty"` OrganizationID string `json:"organizationId,omitempty"` APIThrottlingPolicy string `json:"apiThrottlingPolicy,omitempty"` IsDefaultVersion bool `json:"isDefaultVersion,omitempty"` CorsConfiguration struct { CorsConfigurationEnabled bool `json:"corsConfigurationEnabled,omitempty"` AccessControlAllowOrigins []string `json:"accessControlAllowOrigins,omitempty"` AccessControlAllowCredentials bool `json:"accessControlAllowCredentials,omitempty"` AccessControlAllowHeaders []string `json:"accessControlAllowHeaders,omitempty"` AccessControlAllowMethods []string `json:"accessControlAllowMethods,omitempty"` } `json:"corsConfiguration,omitempty"` EndpointConfig struct { EndpointType string `json:"endpoint_type,omitempty"` AccessMethod string `json:"access_method,omitempty"` AmazonRegion string `json:"amznRegion"` LoadBalanceAlgo string `json:"algoCombo,omitempty"` LoadBalanceSessionManagement string `json:"sessionManagement,omitempty"` LoadBalanceSessionTimeOut string `json:"sessionTimeOut,omitempty"` APIEndpointSecurity APIEndpointSecurity `json:"endpoint_security,omitempty"` RawProdEndpoints interface{} `json:"production_endpoints,omitempty"` ProductionEndpoints []EndpointInfo ProductionFailoverEndpoints []EndpointInfo `json:"production_failovers,omitempty"` RawSandboxEndpoints interface{} `json:"sandbox_endpoints,omitempty"` SandBoxEndpoints []EndpointInfo SandboxFailoverEndpoints []EndpointInfo `json:"sandbox_failovers,omitempty"` ImplementationStatus string `json:"implementation_status,omitempty"` } `json:"endpointConfig,omitempty"` Operations []OperationYaml `json:"Operations,omitempty"` } `json:"data"` }
APIYaml contains everything necessary to extract api.json/api.yaml file To support both api.json and api.yaml we convert yaml to json and then use json.Unmarshal() Therefore, the params are defined to support json.Unmarshal()
func NewAPIYaml ¶
NewAPIYaml returns an APIYaml struct after reading and validating api.yaml or api.json
func (*APIYaml) FormatAndUpdateInfo ¶
func (apiYaml *APIYaml) FormatAndUpdateInfo()
FormatAndUpdateInfo formats necessary parameters and update from config if null
func (*APIYaml) PopulateEndpointsInfo ¶
func (apiYaml *APIYaml) PopulateEndpointsInfo()
PopulateEndpointsInfo this will map sandbox and prod endpoint This is done to fix the issue https://github.com/wso2/product-microgateway/issues/2288
func (APIYaml) ValidateAPIType ¶
ValidateAPIType checks if the apiProject is properly assigned with the type.
func (*APIYaml) ValidateMandatoryFields ¶
ValidateMandatoryFields check and populates the mandatory fields if null
type AsyncAPI ¶
type AsyncAPI struct { SpecVersion string `json:"asyncapi,omitempty"` ID string `json:"id,omitempty"` Info struct { Title string `json:"title,omitempty"` Version string `json:"version,omitempty"` } `json:"info,omitempty"` Servers struct { Production Server `json:"production,omitempty"` Sandbox Server `json:"sandbox,omitempty"` } `json:"servers,omitempty"` Channels map[string]ChannelItem `json:"channels,omitempty"` Components struct { Schemas map[string]interface{} `json:"schemas,omitempty"` Messages map[string]interface{} `json:"messages,omitempty"` SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"` } `json:"components,omitempty"` VendorExtensions map[string]interface{} `json:"-"` }
AsyncAPI is the struct for the AsyncAPI 2.0.0 definition
type Certificate ¶
Certificate contains information of a client certificate
type CertificateDetails ¶
CertificateDetails represents certificates information that needed to passed to the enforcer
type ChannelItem ¶
type ChannelItem struct { Ref string `json:"$ref,omitempty"` Subscribe interface{} `json:"subscribe,omitempty"` // TODO: (suksw) OperationAsync or $ref Publish interface{} `json:"publish,omitempty"` // TODO: (suksw) OperationAsync or $ref Parameters map[string]interface{} `json:"parameters,omitempty"` Bindings map[string]interface{} `json:"bindings,omitempty"` XAuthType string `json:"x-auth-type,omitempty"` XWso2DisableSecurity bool `json:"x-wso2-disable-security,omitempty"` }
ChannelItem in AsyncAPI channels
type CircuitBreakers ¶
type CircuitBreakers struct { MaxConnections int32 `mapstructure:"maxConnections"` MaxRequests int32 `mapstructure:"maxRequests"` MaxPendingRequests int32 `mapstructure:"maxPendingRequests"` MaxRetries int32 `mapstructure:"maxRetries"` MaxConnectionPools int32 `mapstructure:"maxConnectionPools"` }
CircuitBreakers holds the parameters for retries done by cc to the EndpointCluster
type ClientCertificate ¶
type ClientCertificate struct { Alias string `json:"alias"` Certificate string `json:"certificate"` TierName string `json:"tierName"` APIIdentifier APIData `json:"apiIdentifier"` }
ClientCertificate represents certificate information of an API_CTL project
type ClientCertificatesDetails ¶
type ClientCertificatesDetails struct { Type string `yaml:"type" json:"type"` Version string `yaml:"version" json:"version"` Data []ClientCertificate `json:"data"` }
ClientCertificatesDetails represents content of client_certificates.yaml file of an API_CTL Project
type CorsConfig ¶
type CorsConfig struct { Enabled bool `mapstructure:"corsConfigurationEnabled"` AccessControlAllowCredentials bool `mapstructure:"accessControlAllowCredentials,omitempty"` AccessControlAllowHeaders []string `mapstructure:"accessControlAllowHeaders"` AccessControlAllowMethods []string `mapstructure:"accessControlAllowMethods"` AccessControlAllowOrigins []string `mapstructure:"accessControlAllowOrigins"` AccessControlExposeHeaders []string `mapstructure:"accessControlExposeHeaders"` }
CorsConfig represents the API level Cors Configuration
type Deployment ¶
type Deployment struct { DisplayOnDevportal bool `yaml:"displayOnDevportal"` DeploymentVhost string `yaml:"deploymentVhost"` DeploymentEnvironment string `yaml:"deploymentEnvironment"` }
Deployment represents deployment information of an API_CTL project
type DeploymentEnvironments ¶
type DeploymentEnvironments struct { Type string `yaml:"type" json:"type"` Version string `yaml:"version" json:"version"` Data []Deployment `yaml:"data"` }
DeploymentEnvironments represents content of deployment_environments.yaml file of an API_CTL Project
type Endpoint ¶
type Endpoint struct { // Host name Host string // BasePath (which would be added as prefix to the path mentioned in openapi definition) // In openAPI v2, it is determined from the basePath property // In openAPi v3, it is determined from the server object's suffix Basepath string // https, http, ws, wss // In openAPI v2, it is fetched from the schemes entry // In openAPI v3, it is extracted from the server property under servers object // only https and http are supported at the moment. URLType string // Port of the endpoint. // If the port is not specified, 80 is assigned if URLType is http // 443 is assigned if URLType is https Port uint32 //ServiceDiscoveryQuery consul query for service discovery ServiceDiscoveryString string RawURL string }
Endpoint represents the structure of an endpoint.
func (*Endpoint) GetAuthorityHeader ¶
GetAuthorityHeader creates the authority header using Host and Port in the form of Host [ ":" Port ]
type EndpointCertificate ¶
type EndpointCertificate struct { Alias string `json:"alias"` Endpoint string `json:"endpoint"` Certificate string `json:"certificate"` }
EndpointCertificate represents certificate information of an API_CTL project
type EndpointCertificatesDetails ¶
type EndpointCertificatesDetails struct { Type string `yaml:"type" json:"type"` Version string `yaml:"version" json:"version"` Data []EndpointCertificate `json:"data"` }
EndpointCertificatesDetails represents content of endpoint_certificates.yaml file of an API_CTL Project
type EndpointCluster ¶
type EndpointCluster struct { EndpointPrefix string Endpoints []Endpoint // EndpointType enum {failover, loadbalance}. if any other value provided, consider as the default value; which is loadbalance EndpointType string Config *EndpointConfig SecurityConfig EndpointSecurity // Is http2 protocol enabled HTTP2BackendEnabled bool }
EndpointCluster represent an upstream cluster
func (*EndpointCluster) SetEndpointsConfig ¶
func (endpointCluster *EndpointCluster) SetEndpointsConfig(endpointInfos []EndpointInfo) error
SetEndpointsConfig set configs for Endpoints sent by api.yaml
type EndpointConfig ¶
type EndpointConfig struct { RetryConfig *RetryConfig `mapstructure:"retryConfig"` TimeoutInMillis uint32 `mapstructure:"timeoutInMillis"` CircuitBreakers *CircuitBreakers `mapstructure:"circuitBreakers"` }
EndpointConfig holds the configs such as timeout, retry, etc. for the EndpointCluster
type EndpointInfo ¶
type EndpointInfo struct { Endpoint string `json:"url,omitempty"` Config struct { ActionDuration string `json:"actionDuration,omitempty"` RetryTimeOut string `json:"retryTimeOut,omitempty"` } `json:"config,omitempty"` }
EndpointInfo holds config values regards to the endpoint
type EndpointSecurity ¶
type EndpointSecurity struct { Password string `json:"password,omitempty" mapstructure:"password"` Type string `json:"type,omitempty" mapstructure:"type"` Enabled bool `json:"enabled,omitempty" mapstructure:"enabled"` Username string `json:"username,omitempty" mapstructure:"username"` CustomParameters map[string]string `json:"customparameters,omitempty" mapstructure:"customparameters"` }
EndpointSecurity contains parameters of endpoint security at api.json
func RetrieveEndpointBasicAuthCredentialsFromEnv ¶
func RetrieveEndpointBasicAuthCredentialsFromEnv(apiHashValue string, keyType string, endpointSecurity EndpointSecurity) EndpointSecurity
RetrieveEndpointBasicAuthCredentialsFromEnv retrieve endpoint security credentials from env variables
type GraphQLComplexityYaml ¶
type GraphQLComplexityYaml struct { Data struct { List []*api.GraphqlComplexity } }
GraphQLComplexityYaml contains complexity values relevant to the fields included in the GraphQL schema.
type InterceptEndpoint ¶
type InterceptEndpoint struct { Enable bool EndpointCluster EndpointCluster ClusterName string ClusterTimeout time.Duration RequestTimeout time.Duration // Level this is an enum allowing only values {api, resource, operation} // to indicate from which level interceptor is added Level string // Includes this is an enum allowing only values in // {"request_headers", "request_body", "request_trailer", "response_headers", "response_body", "response_trailer", //"invocation_context" } Includes *interceptor.RequestInclusions }
InterceptEndpoint contains the parameters of endpoint security
type MgwSwagger ¶
type MgwSwagger struct { UUID string OrganizationID string IsPrototyped bool EndpointType string EndpointImplementationType string LifecycleStatus string IsDefaultVersion bool GraphQLSchema string GraphQLComplexities GraphQLComplexityYaml // contains filtered or unexported fields }
MgwSwagger represents the object structure holding the information related to the openAPI object. The values are populated from the extensions/properties mentioned at the root level of the openAPI definition. The pathItem level information is represented by the resources array which contains the MgwResource entries.
func CreateDummyMgwSwaggerForAWSLambdaTests ¶
func CreateDummyMgwSwaggerForAWSLambdaTests(resources []*Resource) *MgwSwagger
CreateDummyMgwSwaggerForAWSLambdaTests creates a dummy MgwSwagger struct to be used for aws lambda unit tests
func (*MgwSwagger) GetAPIType ¶
func (swagger *MgwSwagger) GetAPIType() string
GetAPIType returns the openapi version
func (*MgwSwagger) GetClientCerts ¶
func (swagger *MgwSwagger) GetClientCerts() []Certificate
GetClientCerts returns the client certificates of the API
func (*MgwSwagger) GetCorsConfig ¶
func (swagger *MgwSwagger) GetCorsConfig() *CorsConfig
GetCorsConfig returns the CorsConfiguration Object.
func (*MgwSwagger) GetDescription ¶
func (swagger *MgwSwagger) GetDescription() string
GetDescription returns the description of the openapi
func (*MgwSwagger) GetDisableSecurity ¶
func (swagger *MgwSwagger) GetDisableSecurity() bool
GetDisableSecurity returns the authType via the vendor extension.
func (*MgwSwagger) GetEndpointType ¶
func (swagger *MgwSwagger) GetEndpointType() string
GetEndpointType returns the EndpointType of the API
func (*MgwSwagger) GetID ¶
func (swagger *MgwSwagger) GetID() string
GetID returns the Id of the API
func (*MgwSwagger) GetInterceptor ¶
func (swagger *MgwSwagger) GetInterceptor(vendorExtensions map[string]interface{}, extensionName string, level string) InterceptEndpoint
GetInterceptor returns interceptors
func (*MgwSwagger) GetMgwSwagger ¶
func (swagger *MgwSwagger) GetMgwSwagger(apiContent []byte) error
GetMgwSwagger converts/handles the openAPI v3, v2, asyncAPI and GraphQL content To MgwSwagger objects
func (*MgwSwagger) GetOperationInterceptors ¶
func (swagger *MgwSwagger) GetOperationInterceptors(apiInterceptor InterceptEndpoint, resourceInterceptor InterceptEndpoint, operations []*Operation, isIn bool) map[string]InterceptEndpoint
GetOperationInterceptors returns operation interceptors
func (*MgwSwagger) GetProdEndpoints ¶
func (swagger *MgwSwagger) GetProdEndpoints() *EndpointCluster
GetProdEndpoints returns the array of production endpoints.
func (*MgwSwagger) GetResources ¶
func (swagger *MgwSwagger) GetResources() []*Resource
GetResources returns the array of resources (openAPI path level info)
func (*MgwSwagger) GetSandEndpoints ¶
func (swagger *MgwSwagger) GetSandEndpoints() *EndpointCluster
GetSandEndpoints returns the array of sandbox endpoints.
func (*MgwSwagger) GetSecurity ¶
func (swagger *MgwSwagger) GetSecurity() []map[string][]string
GetSecurity returns the API level security of the API
func (*MgwSwagger) GetSecurityScheme ¶
func (swagger *MgwSwagger) GetSecurityScheme() []SecurityScheme
GetSecurityScheme returns the securitySchemes of the API
func (*MgwSwagger) GetTitle ¶
func (swagger *MgwSwagger) GetTitle() string
GetTitle returns the API Title
func (*MgwSwagger) GetVendorExtensions ¶
func (swagger *MgwSwagger) GetVendorExtensions() map[string]interface{}
GetVendorExtensions returns the map of vendor extensions which are defined at openAPI's root level.
func (*MgwSwagger) GetVersion ¶
func (swagger *MgwSwagger) GetVersion() string
GetVersion returns the API version
func (*MgwSwagger) GetXWSO2ApplicationSecurity ¶
func (swagger *MgwSwagger) GetXWSO2ApplicationSecurity() bool
GetXWSO2ApplicationSecurity returns the optional or mandatory application security
func (*MgwSwagger) GetXWSO2AuthHeader ¶
func (swagger *MgwSwagger) GetXWSO2AuthHeader() string
GetXWSO2AuthHeader returns the auth header set via the vendor extension.
func (*MgwSwagger) GetXWSO2MutualSSL ¶
func (swagger *MgwSwagger) GetXWSO2MutualSSL() string
GetXWSO2MutualSSL returns the optional or mandatory mTLS
func (*MgwSwagger) GetXWso2Basepath ¶
func (swagger *MgwSwagger) GetXWso2Basepath() string
GetXWso2Basepath returns the basepath set via the vendor extension.
func (*MgwSwagger) GetXWso2Endpoints ¶
func (swagger *MgwSwagger) GetXWso2Endpoints() map[string]*EndpointCluster
GetXWso2Endpoints returns the array of x wso2 endpoints.
func (*MgwSwagger) GetXWso2HTTP2BackendEnabled ¶
func (swagger *MgwSwagger) GetXWso2HTTP2BackendEnabled() bool
GetXWso2HTTP2BackendEnabled returns the http2 backend enabled set via the vendor extension.
func (*MgwSwagger) GetXWso2RequestBodyPass ¶
func (swagger *MgwSwagger) GetXWso2RequestBodyPass() bool
GetXWso2RequestBodyPass returns boolean value to indicate whether it is allowed to pass request body to the enforcer or not.
func (*MgwSwagger) GetXWso2ThrottlingTier ¶
func (swagger *MgwSwagger) GetXWso2ThrottlingTier() string
GetXWso2ThrottlingTier returns the Throttling tier via the vendor extension.
func (*MgwSwagger) PopulateFromAPIYaml ¶
func (swagger *MgwSwagger) PopulateFromAPIYaml(apiYaml APIYaml) error
PopulateFromAPIYaml populates the mgwSwagger object for APIs using API.yaml TODO - (VirajSalaka) read cors config and populate mgwSwagger feild
func (*MgwSwagger) SanitizeAPISecurity ¶
func (swagger *MgwSwagger) SanitizeAPISecurity(isYamlAPIKey bool, isYamlOauth bool, isYamlMutualssl bool, isYamlMutualsslMandatory bool, isYamlOauthBasicAuthAPIKeyMandatory bool)
SanitizeAPISecurity this will validate api level and operation level swagger security if apiyaml security is provided swagger security will be removed accordingly
func (*MgwSwagger) SetClientCerts ¶
func (swagger *MgwSwagger) SetClientCerts(certs []Certificate)
SetClientCerts set the client certificates of the API
func (*MgwSwagger) SetEnvLabelProperties ¶
func (swagger *MgwSwagger) SetEnvLabelProperties(envProps synchronizer.APIEnvProps)
SetEnvLabelProperties sets environment specific values
func (*MgwSwagger) SetEnvVariables ¶
func (swagger *MgwSwagger) SetEnvVariables(apiHashValue string)
SetEnvVariables sets environment specific values to the mgwswagger
func (*MgwSwagger) SetInfoAsyncAPI ¶
func (swagger *MgwSwagger) SetInfoAsyncAPI(asyncAPI AsyncAPI) error
SetInfoAsyncAPI populates the MgwSwagger object with information in asyncapi.yaml.
func (*MgwSwagger) SetInfoGraphQLAPI ¶
func (swagger *MgwSwagger) SetInfoGraphQLAPI(apiYaml APIYaml) error
SetInfoGraphQLAPI populates the MgwSwagger object with information in api.yaml.
func (*MgwSwagger) SetInfoOpenAPI ¶
func (swagger *MgwSwagger) SetInfoOpenAPI(swagger3 openapi3.Swagger) error
SetInfoOpenAPI populates the MgwSwagger object with the properties within the openAPI v3 definition. The title, version, description, vendor extension map, endpoints based on servers property, and pathItem level information are populated here.
For each pathItem; vendor extensions, endpoints (based on servers object), available http Methods, are populated. Each resource corresponding to a pathItem, has the property called ID, which is a UUID.
No operation specific information is extracted.
func (*MgwSwagger) SetInfoSwagger ¶
func (swagger *MgwSwagger) SetInfoSwagger(swagger2 spec.Swagger) error
SetInfoSwagger populates the MgwSwagger object with the properties within the openAPI v2 (swagger) definition. The title, version, description, vendor extension map, endpoints based on host and schemes properties, and pathItem level information are populated here.
for each pathItem; vendor extensions, available http Methods, are populated. Each resource corresponding to a pathItem, has the property called iD, which is a UUID.
No operation specific information is extracted.
func (*MgwSwagger) SetName ¶
func (swagger *MgwSwagger) SetName(name string)
SetName sets the name of the API
func (*MgwSwagger) SetOperationPolicies ¶
func (swagger *MgwSwagger) SetOperationPolicies(apiProject ProjectAPI) (err error)
SetOperationPolicies this will merge operation level policies provided in api yaml
func (*MgwSwagger) SetProductionEndpoints ¶
func (swagger *MgwSwagger) SetProductionEndpoints(productionEndpoints []Endpoint)
SetProductionEndpoints set the MgwSwagger object with the productionEndpoint when it is not populated by SetXWso2Extensions
func (*MgwSwagger) SetSandboxEndpoints ¶
func (swagger *MgwSwagger) SetSandboxEndpoints(sandboxEndpoints []Endpoint)
SetSandboxEndpoints set the MgwSwagger object with the SandboxEndpoint when it is not populated by SetXWso2Extensions
func (*MgwSwagger) SetSecurity ¶
func (swagger *MgwSwagger) SetSecurity(security []map[string][]string)
SetSecurity sets the API level security of the API. These refer to the security schemes defined for the same API and would have the structure given below,
security:
- PetstoreAuth:
- 'write:pets'
- 'read:pets'
- ApiKeyAuth: []
func (*MgwSwagger) SetSecurityScheme ¶
func (swagger *MgwSwagger) SetSecurityScheme(securityScheme []SecurityScheme)
SetSecurityScheme sets the securityschemes of the API
func (*MgwSwagger) SetVersion ¶
func (swagger *MgwSwagger) SetVersion(version string)
SetVersion sets the version of the API
func (*MgwSwagger) SetXWSO2ApplicationSecurity ¶
func (swagger *MgwSwagger) SetXWSO2ApplicationSecurity(applicationSecurity bool)
SetXWSO2ApplicationSecurity sets the optional or mandatory application security
func (*MgwSwagger) SetXWSO2MutualSSL ¶
func (swagger *MgwSwagger) SetXWSO2MutualSSL(mutualSSl string)
SetXWSO2MutualSSL sets the optional or mandatory mTLS
func (*MgwSwagger) SetXWso2AuthHeader ¶
func (swagger *MgwSwagger) SetXWso2AuthHeader(authHeader string)
SetXWso2AuthHeader sets the authHeader of the API
func (*MgwSwagger) SetXWso2Extensions ¶
func (swagger *MgwSwagger) SetXWso2Extensions() error
SetXWso2Extensions set the MgwSwagger object with the properties extracted from vendor extensions. xWso2Basepath, xWso2ProductionEndpoints, and xWso2SandboxEndpoints are assigned based on the vendor extensions.
Resource level properties (xwso2ProductionEndpoints and xWso2SandboxEndpoints are also populated at the same time).
func (*MgwSwagger) Validate ¶
func (swagger *MgwSwagger) Validate() error
Validate method confirms that the mgwSwagger has all required fields in the required format. This needs to be checked prior to generate router/enforcer related resources.
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation type object holds data about each http method in the REST API.
func NewOperation ¶
func NewOperation(method string, security []map[string][]string, extensions map[string]interface{}) *Operation
NewOperation Creates and returns operation type object
func (*Operation) GetCallInterceptorService ¶
func (operation *Operation) GetCallInterceptorService(isIn bool) InterceptEndpoint
GetCallInterceptorService returns the interceptor configs for a given operation.
func (*Operation) GetDisableSecurity ¶
GetDisableSecurity returns if the resouce is secured.
func (*Operation) GetID ¶
GetID returns the id of a given resource. This is a randomly generated UUID
func (*Operation) GetMockedAPIConfig ¶
func (operation *Operation) GetMockedAPIConfig() *api.MockedApiConfig
GetMockedAPIConfig returns the operation level mocked API implementation configs
func (*Operation) GetPolicies ¶
func (operation *Operation) GetPolicies() *OperationPolicies
GetPolicies returns if the resouce is secured.
func (*Operation) GetSecurity ¶
GetSecurity returns the security schemas defined for the http opeartion
func (*Operation) GetVendorExtensions ¶
GetVendorExtensions returns vendor extensions which are explicitly defined under a given resource.
func (*Operation) SetMockedAPIConfigOAS2 ¶
SetMockedAPIConfigOAS2 generate mock impl endpoint configurations
func (*Operation) SetMockedAPIConfigOAS3 ¶
SetMockedAPIConfigOAS3 generate mock impl endpoint configurations
func (*Operation) SetSecurity ¶
SetSecurity sets the security schemas for the http opeartion
type OperationAsync ¶
type OperationAsync struct { OperationID string `json:"operationId,omitempty"` Message struct { Headers string `json:"headers,omitempty"` Payload string `json:"payload,omitempty"` CorrelationID string `json:"correlationId,omitempty"` SchemaFormat string `json:"schemaFormat,omitempty"` ContentType string `json:"contentType,omitempty"` Name string `json:"name,omitempty"` Title string `json:"title,omitempty"` } }
OperationAsync is the Operation object that includes the message object
type OperationPolicies ¶
type OperationPolicies struct { Request PolicyList `json:"request,omitempty"` Response PolicyList `json:"response,omitempty"` Fault PolicyList `json:"fault,omitempty"` }
OperationPolicies holds policies of the APIM operations
type OperationYaml ¶
type OperationYaml struct { ID string `json:"id,omitempty"` Target string `json:"target,omitempty"` Verb string `json:"verb,omitempty"` AuthType string `json:"authType,omitempty"` ThrottlingPolicy string `json:"throttlingPolicy,omitempty"` Scopes []string `json:"scopes,omitempty"` OperationPolicies OperationPolicies `json:"operationPolicies,omitempty"` }
OperationYaml holds attributes of APIM operations
type Policy ¶
type Policy struct { PolicyName string `json:"policyName,omitempty"` PolicyVersion string `json:"policyVersion,omitempty"` Action string `json:"-"` // This is a meta value used in CC, not included in API YAML IsPassToEnforcer bool `json:"-"` // This is a meta value used in CC, not included in API YAML Parameters interface{} `json:"parameters,omitempty"` }
Policy holds APIM policies
func (*Policy) GetFullName ¶
GetFullName returns the fully qualified name of the policy This should be equal to the policy spec/def file name
type PolicyContainer ¶
type PolicyContainer struct { Specification PolicySpecification Definition PolicyDefinition }
PolicyContainer holds the definition and specification of policy
type PolicyContainerMap ¶
type PolicyContainerMap map[string]PolicyContainer
PolicyContainerMap maps PolicyName -> PolicyContainer
func (PolicyContainerMap) GetFormattedOperationalPolicies ¶
func (p PolicyContainerMap) GetFormattedOperationalPolicies(policies OperationPolicies, swagger *MgwSwagger) (OperationPolicies, error)
GetFormattedOperationalPolicies returns formatted, Choreo Connect policy from a user templated policy here, the struct swagger is only used for logging purpose, in case if we introduce logger context to get org ID, API ID, we can remove it from here
type PolicyDefinition ¶
type PolicyDefinition struct { Definition struct { Action string `yaml:"action"` Parameters map[string]interface{} `yaml:"parameters"` } `yaml:"definition"` RawData []byte `yaml:"-"` }
PolicyDefinition holds the content of policy definition which is rendered from ./Policy/<policy>.gotmpl files
type PolicyFlow ¶
type PolicyFlow string
PolicyFlow holds list of Policies in a operation (in one flow: In, Out or Fault)
type PolicySpecification ¶
type PolicySpecification struct { Type string `yaml:"type" json:"type"` Version string `yaml:"version" json:"version"` Data struct { Name string `yaml:"name"` Version string `yaml:"version"` ApplicableFlows []string `yaml:"applicableFlows"` SupportedGateways []string `yaml:"supportedGateways"` SupportedAPITypes []string `yaml:"supportedApiTypes"` MultipleAllowed bool `yaml:"multipleAllowed"` PolicyAttributes []struct { Name string `yaml:"name"` ValidationRegex string `yaml:"validationRegex,omitempty"` Type string `yaml:"type"` DefaultValue string `yaml:"defaultValue"` Required bool `yaml:"required,omitempty"` } `yaml:"policyAttributes"` } }
PolicySpecification holds policy specification from ./Policy/<policy>.yaml files
type ProjectAPI ¶
type ProjectAPI struct { APIYaml APIYaml APIEnvProps map[string]synchronizer.APIEnvProps Deployments []Deployment APIDefinition []byte InterceptorCerts []byte UpstreamCerts map[string][]byte // cert filename -> cert bytes EndpointCerts map[string]string // url -> cert filename Policies PolicyContainerMap // read from policy dir, policyName -> {policy spec, policy definition} DownstreamCerts map[string][]byte // cert filename -> cert bytes ClientCerts []CertificateDetails GraphQLComplexities GraphQLComplexityYaml }
ProjectAPI contains the extracted from an API project zip
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource represents the object structure holding the information related to the pathItem object in OpenAPI definition. This is the most granular level in which the information can be stored as envoy architecture does not support having an operation level granularity out of the box.
Each resource can contain the path, the http methods that support, security schemas, production endpoints, and sandbox endpoints. These values are populated from extensions/properties mentioned under pathItem.
func CreateDummyResourceForAwsLambdaTests ¶
CreateDummyResourceForAwsLambdaTests create a resource object with amazon resource name(arn) which could be used for unit tests.
func CreateMinimalDummyResourceForTests ¶
func CreateMinimalDummyResourceForTests(path string, methods []*Operation, id string, productionUrls, sandboxUrls []Endpoint) Resource
CreateMinimalDummyResourceForTests create a resource object with minimal required set of values which could be used for unit tests.
func SortResources ¶
SortResources Sort the list of resources provided based on the resource path.
func (*Resource) GetAmznResourceName ¶
GetAmznResourceName returns the amazon resourse name related to aws lambda endpoint of given resource.
func (*Resource) GetID ¶
GetID returns the id of a given resource. This is a randomly generated UUID
func (*Resource) GetMethod ¶
GetMethod returns an array of http method operations which are explicitly defined under a given resource.
func (*Resource) GetMethodList ¶
GetMethodList returns a list of http Methods as strings which are explicitly defined under a given resource.
func (*Resource) GetOperations ¶
GetOperations returns the array of operations of the resource.
func (*Resource) GetPath ¶
GetPath returns the pathItem name (of openAPI definition) corresponding to a given resource
func (*Resource) GetProdEndpoints ¶
func (resource *Resource) GetProdEndpoints() *EndpointCluster
GetProdEndpoints returns the production endpoints object of a given resource.
func (*Resource) GetSandEndpoints ¶
func (resource *Resource) GetSandEndpoints() *EndpointCluster
GetSandEndpoints returns the sandbox endpoints object of a given resource.
func (*Resource) GetVendorExtensions ¶
GetVendorExtensions returns vendor extensions which are explicitly defined under a given resource.
func (*Resource) HasPolicies ¶
HasPolicies returns whether the resource has operations that includes policies.
func (*Resource) SetAmznResourceName ¶
SetAmznResourceName sets the amazon resource name.
type RetryConfig ¶
type RetryConfig struct { Count int32 `mapstructure:"count"` StatusCodes []uint32 `mapstructure:"statusCodes"` }
RetryConfig holds the parameters for retries done by cc to the EndpointCluster
type SecurityScheme ¶
type SecurityScheme struct { DefinitionName string // Arbitrary name used to define the security scheme. ex: default, myApikey Type string // Type of the security scheme. Valid: apiKey, api_key, oauth2 Name string // Used for API key. Name of header or query. ex: x-api-key, apikey In string // Where the api key found in. Valid: query, header }
SecurityScheme represents the structure of an security scheme.
type Server ¶
type Server struct { URL string `json:"url,omitempty"` Protocol string `json:"protocol,omitempty"` ProtocolVersion string `json:"protocolVersion,omitempty"` Variables map[string]interface{} `json:"variables,omitempty"` Security []map[string][]string `json:"security,omitempty"` Bindings map[string]interface{} `json:"bindings,omitempty"` }
Server object in AsyncAPI