From 54b35ed6399351894affe13e50a4a7c20fccb392 Mon Sep 17 00:00:00 2001 From: Phineas Date: Sat, 4 Feb 2023 10:05:05 +0000 Subject: [PATCH] patch deployment metadata --- src/rest/types/ignite.ts | 9 +++++ src/sdks/ignite.ts | 81 ++++++++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/rest/types/ignite.ts b/src/rest/types/ignite.ts index 562689c0..484c45e1 100644 --- a/src/rest/types/ignite.ts +++ b/src/rest/types/ignite.ts @@ -276,6 +276,9 @@ export interface BuildSettings { export interface DeploymentMetaData { container_port_mappings: Record, string[]>; + ignored_boarding?: boolean; + created_from_preset?: string; + created_first_gateway?: boolean; } export interface BuildMetaData { @@ -906,6 +909,12 @@ export type IgniteEndpoints = {deployment: Deployment}, DeploymentConfig > + | Endpoint< + 'PATCH', + '/v1/ignite/deployments/:deployment_id/metadata', + {deployment: Deployment}, + Partial + > | Endpoint< 'POST', '/v1/ignite/deployments/:deployment_id/rollouts', diff --git a/src/sdks/ignite.ts b/src/sdks/ignite.ts index 4b68eb3e..0cad2553 100644 --- a/src/sdks/ignite.ts +++ b/src/sdks/ignite.ts @@ -3,6 +3,7 @@ import {API, assertId, Id} from '../rest/index.js'; import { Deployment, DeploymentConfig, + DeploymentMetaData, Gateway, GatewayType, RuntimeType, @@ -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); }, @@ -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', @@ -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 */