-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding APIM Project to APK Conf tranformer module
- Loading branch information
Showing
12 changed files
with
976 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package transformer | ||
|
||
// EndpointDetails represents the details of an endpoint, containing its URL. | ||
type EndpointDetails struct { | ||
URL string `json:"url"` | ||
} | ||
|
||
// EndpointConfig represents the configuration of an endpoint, including its type, sandbox, and production details. | ||
type EndpointConfig struct { | ||
EndpointType string `json:"endpoint_type"` | ||
SandboxEndpoints EndpointDetails `json:"sandbox_endpoints"` | ||
ProductionEndpoints EndpointDetails `json:"production_endpoints"` | ||
} | ||
|
||
// CORSConfiguration represents the CORS (Cross-Origin Resource Sharing) configuration for an API. | ||
type CORSConfiguration struct { | ||
CORSConfigurationEnabled bool `yaml:"corsConfigurationEnabled"` | ||
AccessControlAllowOrigins []string `yaml:"accessControlAllowOrigins"` | ||
AccessControlAllowCredentials bool `yaml:"accessControlAllowCredentials"` | ||
AccessControlAllowHeaders []string `yaml:"accessControlAllowHeaders"` | ||
AccessControlAllowMethods []string `yaml:"accessControlAllowMethods"` | ||
} | ||
|
||
// AdditionalPropertiesMap represents additional properties for an API in the form of a map. | ||
type AdditionalPropertiesMap struct{} | ||
|
||
// InterceptorService holds configuration details for configuring interceptor | ||
// for a aperticular API requests or responses. | ||
type InterceptorService struct { | ||
BackendURL string `yaml:"backendUrl,omitempty"` | ||
HeadersEnabled bool `yaml:"headersEnabled,omitempty"` | ||
BodyEnabled bool `yaml:"bodyEnabled,omitempty"` | ||
TrailersEnabled bool `yaml:"trailersEnabled,omitempty"` | ||
ContextEnabled bool `yaml:"contextEnabled,omitempty"` | ||
TLSSecretName string `yaml:"tlsSecretName,omitempty"` | ||
TLSSecretKey string `yaml:"tlsSecretKey,omitempty"` | ||
} | ||
|
||
// OperationPolicy defines policies, including interceptor parameters, for API operations. | ||
type OperationPolicy struct { | ||
PolicyName string `yaml:"policyName,omitempty"` | ||
PolicyVersion string `yaml:"policyVersion,omitempty"` | ||
PolicyID string `yaml:"policyId,omitempty"` | ||
Parameters *InterceptorService `yaml:"parameters,omitempty"` | ||
} | ||
|
||
// APIMOperationPolicies organizes request, response, and fault policies for an API operation. | ||
type APIMOperationPolicies struct { | ||
Request []OperationPolicy `yaml:"request"` | ||
Response []OperationPolicy `yaml:"response"` | ||
Fault []OperationPolicy `yaml:"fault"` | ||
} | ||
|
||
// APIMOperation represents an API operation with its target, verb, scopes, and associated policies. | ||
type APIMOperation struct { | ||
Target string `yaml:"target"` | ||
Verb string `yaml:"verb"` | ||
Scopes []string `yaml:"scopes"` | ||
OperationPolicies *APIMOperationPolicies `yaml:"operationPolicies"` | ||
} | ||
|
||
// APIMApi represents an API along with it's all basic information and the operations. | ||
type APIMApi struct { | ||
ID string `yaml:"id"` | ||
Name string `yaml:"name"` | ||
Version string `yaml:"version"` | ||
Context string `yaml:"context"` | ||
DefaultVersion bool `yaml:"isDefaultVersion"` | ||
Type string `yaml:"type"` | ||
AuthorizationHeader string `yaml:"authorizationHeader"` | ||
SecuritySchemes []string `json:"securityScheme"` | ||
AdditionalProperties []string `yaml:"additionalProperties"` | ||
AdditionalPropertiesMap AdditionalPropertiesMap `yaml:"additionalPropertiesMap"` | ||
CORSConfiguration CORSConfiguration `yaml:"corsConfiguration"` | ||
EndpointConfig EndpointConfig `yaml:"endpointConfig"` | ||
Operations []APIMOperation `yaml:"operations"` | ||
OrganizationID string `yaml:"organizationId"` | ||
RevisionID uint32 `yaml:"revisionId"` | ||
} | ||
|
||
// APIYaml is a wrapper struct for YAML representation of an API. | ||
type APIYaml struct { | ||
Data APIMApi `json:"data"` | ||
} | ||
|
||
// APIArtifact represents the artifact details of an API, including api details, environment configuration, | ||
// Swagger definition, deployment descriptor, and revision ID extracted from the API Project Zip. | ||
type APIArtifact struct { | ||
APIJson string `json:"apiJson"` | ||
EnvConfig string `json:"envConfig"` | ||
Swagger string `json:"swagger"` | ||
DeploymentDescriptor string `json:"deploymentDescriptor"` | ||
RevisionID uint32 `json:"revisionId"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package transformer | ||
|
||
// AuthConfiguration represents the security configurations made for the API security | ||
type AuthConfiguration struct { | ||
AuthType string `yaml:"authType,omitempty"` | ||
HeaderName string `yaml:"headerName,omitempty"` | ||
SendTokenUpStream bool `yaml:"sendTokenToUpstream,omitempty"` | ||
} | ||
|
||
// Endpoint represents an API endpoint. | ||
type Endpoint struct { | ||
Endpoint string `yaml:"endpoint,omitempty"` | ||
} | ||
|
||
// EndpointConfiguration holds production and sandbox endpoints. | ||
type EndpointConfiguration struct { | ||
Production *Endpoint `yaml:"production,omitempty"` | ||
Sandbox *Endpoint `yaml:"sandbox,omitempty"` | ||
} | ||
|
||
// OperationPolicies organizes request and response policies for an API operation. | ||
type OperationPolicies struct { | ||
Request []OperationPolicy `yaml:"request,omitempty"` | ||
Response []OperationPolicy `yaml:"response,omitempty"` | ||
} | ||
|
||
// Operation represents an API operation with target, verb, scopes, security, and associated policies. | ||
type Operation struct { | ||
Target string `yaml:"target,omitempty"` | ||
Verb string `yaml:"verb,omitempty"` | ||
Scopes []string `yaml:"scopes"` | ||
Secured bool `yaml:"secured,omitempty"` | ||
OperationPolicies *OperationPolicies `yaml:"operationPolicies,omitempty"` | ||
// Ratelimit *Ratelimit `yaml:"ratelimit,omitempty"` | ||
} | ||
|
||
// Ratelimit is a placeholder for future rate-limiting configuration. | ||
type Ratelimit struct { | ||
} | ||
|
||
// VHost defines virtual hosts for production and sandbox environments. | ||
type VHost struct { | ||
Production []string `yaml:"production,omitempty"` | ||
Sandbox []string `yaml:"sandbox,omitempty"` | ||
} | ||
|
||
// API represents an main API type definition | ||
type API struct { | ||
Name string `yaml:"name,omitempty"` | ||
ID string `yaml:"id,omitempty"` | ||
Version string `yaml:"version,omitempty"` | ||
Context string `yaml:"basePath,omitempty"` | ||
Type string `yaml:"type,omitempty"` | ||
DefaultVersion bool `yaml:"defaultVersion"` | ||
EndpointConfigurations *EndpointConfiguration `yaml:"endpointConfigurations,omitempty"` | ||
Operations *[]Operation `yaml:"operations,omitempty"` | ||
Authentication []AuthConfiguration `yaml:"authentication,omitempty"` | ||
CorsConfig *CORSConfiguration `yaml:"corsConfiguration,omitempty"` | ||
} |
Oops, something went wrong.