Skip to content

Commit

Permalink
patch deployment metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Phineas committed Feb 4, 2023
1 parent e560002 commit 54b35ed
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 29 deletions.
9 changes: 9 additions & 0 deletions src/rest/types/ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ export interface BuildSettings {

export interface DeploymentMetaData {
container_port_mappings: Record<Id<'container'>, string[]>;
ignored_boarding?: boolean;
created_from_preset?: string;
created_first_gateway?: boolean;
}

export interface BuildMetaData {
Expand Down Expand Up @@ -906,6 +909,12 @@ export type IgniteEndpoints =
{deployment: Deployment},
DeploymentConfig
>
| Endpoint<
'PATCH',
'/v1/ignite/deployments/:deployment_id/metadata',
{deployment: Deployment},
Partial<DeploymentMetaData>
>
| Endpoint<
'POST',
'/v1/ignite/deployments/:deployment_id/rollouts',
Expand Down
81 changes: 52 additions & 29 deletions src/sdks/ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {API, assertId, Id} from '../rest/index.js';
import {
Deployment,
DeploymentConfig,
DeploymentMetaData,
Gateway,
GatewayType,
RuntimeType,
Expand Down Expand Up @@ -42,18 +43,22 @@ export const ignite = sdk(client => {
return igniteSDK.containers.create(this.id);
},

createGateway(config: {
type: API.Ignite.GatewayType.EXTERNAL;
protocol: API.Ignite.Gateway['protocol'];
name: string;
targetPort: number;
} | {
type: API.Ignite.GatewayType.INTERNAL;
protocol: API.Ignite.Gateway['protocol'];
name: string;
targetPort: number;
internalDomain: string;
}) {
createGateway(
config:
| {
type: API.Ignite.GatewayType.EXTERNAL;
protocol: API.Ignite.Gateway['protocol'];
name: string;
targetPort: number;
}
| {
type: API.Ignite.GatewayType.INTERNAL;
protocol: API.Ignite.Gateway['protocol'];
name: string;
targetPort: number;
internalDomain: string;
},
) {
return igniteSDK.gateways.create(this.id, config);
},

Expand Down Expand Up @@ -222,27 +227,32 @@ export const ignite = sdk(client => {
*/
async create(
deployment: Deployment | Deployment['id'],
config: {
type: GatewayType.EXTERNAL;
protocol: Gateway['protocol'];
targetPort: number;
name: string;
} | {
type: GatewayType.INTERNAL;
protocol: Gateway['protocol'];
targetPort: number;
name: string;
internalDomain: string;
},
config:
| {
type: GatewayType.EXTERNAL;
protocol: Gateway['protocol'];
targetPort: number;
name: string;
}
| {
type: GatewayType.INTERNAL;
protocol: Gateway['protocol'];
targetPort: number;
name: string;
internalDomain: string;
},
) {
const deploymentId =
typeof deployment === 'object' ? deployment.id : deployment;

const body = config.type === GatewayType.EXTERNAL ? (
{...config, target_port: config.targetPort}
) : (
{...config, target_port: config.targetPort, internal_domain: config.internalDomain}
);
const body =
config.type === GatewayType.EXTERNAL
? {...config, target_port: config.targetPort}
: {
...config,
target_port: config.targetPort,
internal_domain: config.internalDomain,
};

const {gateway} = await client.post(
'/v1/ignite/deployments/:deployment_id/gateways',
Expand Down Expand Up @@ -413,6 +423,19 @@ export const ignite = sdk(client => {
);
},

async patchMetadata(
deploymentId: Id<'deployment'>,
metadata: DeploymentMetaData,
) {
const {deployment} = await client.patch(
'/v1/ignite/deployments/:deployment_id/metadata',
metadata,
{deployment_id: deploymentId},
);

return deployment;
},

/**
* @deprecated This property has moved — use hop.ignite.gateways instead
*/
Expand Down

0 comments on commit 54b35ed

Please sign in to comment.