Skip to content

Commit

Permalink
create types for endpoint config
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavio Stutz committed Jan 18, 2024
1 parent 07ca13a commit a92d4aa
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
48 changes: 47 additions & 1 deletion src/wso2/wso2-api/v1/types-swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,12 @@ export type API = {
* }
* }
*/
endpointConfig?: { [key: string]: unknown };
endpointConfig?:
| ({ endpoint_type: 'http' } & EndpointHttp)
| ({ endpoint_type: 'load_balance' } & EndpointLoadBalance)
| ({ endpoint_type: 'failover' } & EndpointFailover)
| ({ endpoint_type: 'default' } & EndpointHttp);

/**
* @default ENDPOINT
* @example INLINE
Expand Down Expand Up @@ -544,3 +549,44 @@ export type MediationPolicy = {
/** @example true */
shared?: boolean;
};

export type EndpointTarget = {
endpoint_type?: string;
template_not_supported?: boolean;
url: string;
};

export type EndpointHttp = {
endpoint_type: 'http';
sandbox_endpoints: {
url: string;
};
production_endpoints: {
url: string;
};
};

export type EndpointFailover = {
endpoint_type: 'failover';
sandbox_endpoints: {
url: string;
};
production_endpoints: {
url: string;
};
production_failovers: [EndpointTarget];
sandbox_failovers: [EndpointTarget];
};

export type EndpointLoadBalance = {
endpoint_type: 'load_balance';
algoCombo: 'org.apache.synapse.endpoints.algorithms.RoundRobin';
sessionManagement: 'None' | 'Transport' | 'SOAP' | 'ClientID';
sandbox_endpoints: [EndpointTarget];
production_endpoints: [EndpointTarget];
/**
* Session timeout in milliseconds
*/
sessionTimeOut: number;
algoClassName: 'org.apache.synapse.endpoints.algorithms.RoundRobin';
};
3 changes: 0 additions & 3 deletions src/wso2/wso2-api/wso2-api-defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ export const validateWso2ApiDefs = (apiDef: Wso2ApiDefinition): void => {
if (!apiDef.endpointConfig) {
throw new Error('endpointConfig is required');
}
if (!apiDef.gatewayEnvironments || apiDef.gatewayEnvironments.length === 0) {
throw new Error('gatewayEnvironments is required');
}

validateVisibility(apiDef);
};
Expand Down

0 comments on commit a92d4aa

Please sign in to comment.