From 71ceeaf44c6dfbeeabc0dd10635d0f0bcc369033 Mon Sep 17 00:00:00 2001 From: Lukasz Zajaczkowski Date: Wed, 8 May 2024 09:52:21 +0200 Subject: [PATCH] add detachServiceDeployment --- client.go | 189 +++++++++++++++++++++++++++++++++++++++ graph/deployment.graphql | 6 ++ models_gen.go | 7 +- schema/schema.graphql | 4 + 4 files changed, 205 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 2b7d280..ae455e7 100644 --- a/client.go +++ b/client.go @@ -41,6 +41,7 @@ type ConsoleClient interface { CreateServiceDeployment(ctx context.Context, clusterID string, attributes ServiceDeploymentAttributes, interceptors ...clientv2.RequestInterceptor) (*CreateServiceDeployment, error) CreateServiceDeploymentWithHandle(ctx context.Context, cluster string, attributes ServiceDeploymentAttributes, interceptors ...clientv2.RequestInterceptor) (*CreateServiceDeploymentWithHandle, error) DeleteServiceDeployment(ctx context.Context, id string, interceptors ...clientv2.RequestInterceptor) (*DeleteServiceDeployment, error) + DetachServiceDeployment(ctx context.Context, id string, interceptors ...clientv2.RequestInterceptor) (*DetachServiceDeployment, error) UpdateServiceDeployment(ctx context.Context, id string, attributes ServiceUpdateAttributes, interceptors ...clientv2.RequestInterceptor) (*UpdateServiceDeployment, error) UpdateServiceDeploymentWithHandle(ctx context.Context, cluster string, name string, attributes ServiceUpdateAttributes, interceptors ...clientv2.RequestInterceptor) (*UpdateServiceDeploymentWithHandle, error) CloneServiceDeployment(ctx context.Context, clusterID string, id string, attributes ServiceCloneAttributes, interceptors ...clientv2.RequestInterceptor) (*CloneServiceDeployment, error) @@ -6552,6 +6553,91 @@ func (t *DeleteServiceDeployment_DeleteServiceDeployment_ServiceDeploymentFragme return t.Value } +type DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" + Group *string "json:\"group,omitempty\" graphql:\"group\"" + Kind string "json:\"kind\" graphql:\"kind\"" + Namespace *string "json:\"namespace,omitempty\" graphql:\"namespace\"" + State *ComponentState "json:\"state,omitempty\" graphql:\"state\"" + Synced bool "json:\"synced\" graphql:\"synced\"" + Version *string "json:\"version,omitempty\" graphql:\"version\"" + Content *ComponentContentFragment "json:\"content,omitempty\" graphql:\"content\"" +} + +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetID() string { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.ID +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetName() string { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.Name +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetGroup() *string { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.Group +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetKind() string { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.Kind +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetNamespace() *string { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.Namespace +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetState() *ComponentState { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.State +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetSynced() bool { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.Synced +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetVersion() *string { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.Version +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components) GetContent() *ComponentContentFragment { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Components{} + } + return t.Content +} + +type DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Configuration struct { + Name string "json:\"name\" graphql:\"name\"" + Value string "json:\"value\" graphql:\"value\"" +} + +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Configuration) GetName() string { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Configuration{} + } + return t.Name +} +func (t *DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Configuration) GetValue() string { + if t == nil { + t = &DetachServiceDeployment_DetachServiceDeployment_ServiceDeploymentFragment_Configuration{} + } + return t.Value +} + type UpdateServiceDeployment_UpdateServiceDeployment_ServiceDeploymentExtended_Revision_RevisionFragment_Git struct { Ref string "json:\"ref\" graphql:\"ref\"" Folder string "json:\"folder\" graphql:\"folder\"" @@ -9745,6 +9831,17 @@ func (t *DeleteServiceDeployment) GetDeleteServiceDeployment() *ServiceDeploymen return t.DeleteServiceDeployment } +type DetachServiceDeployment struct { + DetachServiceDeployment *ServiceDeploymentFragment "json:\"detachServiceDeployment,omitempty\" graphql:\"detachServiceDeployment\"" +} + +func (t *DetachServiceDeployment) GetDetachServiceDeployment() *ServiceDeploymentFragment { + if t == nil { + t = &DetachServiceDeployment{} + } + return t.DetachServiceDeployment +} + type UpdateServiceDeployment struct { UpdateServiceDeployment *ServiceDeploymentExtended "json:\"updateServiceDeployment,omitempty\" graphql:\"updateServiceDeployment\"" } @@ -13911,6 +14008,97 @@ func (c *Client) DeleteServiceDeployment(ctx context.Context, id string, interce return &res, nil } +const DetachServiceDeploymentDocument = `mutation DetachServiceDeployment ($id: ID!) { + detachServiceDeployment(id: $id) { + ... ServiceDeploymentFragment + } +} +fragment ServiceDeploymentFragment on ServiceDeployment { + ... ServiceDeploymentBaseFragment + components { + id + name + group + kind + namespace + state + synced + version + content { + ... ComponentContentFragment + } + } + protect + deletedAt + sha + tarball + dryRun + templated + configuration { + name + value + } +} +fragment ServiceDeploymentBaseFragment on ServiceDeployment { + id + name + namespace + version + kustomize { + ... KustomizeFragment + } + git { + ... GitRefFragment + } + helm { + ... HelmSpecFragment + } + repository { + ... GitRepositoryFragment + } +} +fragment KustomizeFragment on Kustomize { + path +} +fragment GitRefFragment on GitRef { + folder + ref +} +fragment HelmSpecFragment on HelmSpec { + valuesFiles +} +fragment GitRepositoryFragment on GitRepository { + id + error + health + authMethod + url + decrypt +} +fragment ComponentContentFragment on ComponentContent { + id + live + desired +} +` + +func (c *Client) DetachServiceDeployment(ctx context.Context, id string, interceptors ...clientv2.RequestInterceptor) (*DetachServiceDeployment, error) { + vars := map[string]interface{}{ + "id": id, + } + + var res DetachServiceDeployment + if err := c.Client.Post(ctx, "DetachServiceDeployment", DetachServiceDeploymentDocument, &res, vars, interceptors...); err != nil { + if c.Client.ParseDataWhenErrors { + return &res, err + } + + return nil, err + } + + return &res, nil +} + const UpdateServiceDeploymentDocument = `mutation UpdateServiceDeployment ($id: ID!, $attributes: ServiceUpdateAttributes!) { updateServiceDeployment(id: $id, attributes: $attributes) { ... ServiceDeploymentExtended @@ -20798,6 +20986,7 @@ var DocumentOperationNames = map[string]string{ CreateServiceDeploymentDocument: "CreateServiceDeployment", CreateServiceDeploymentWithHandleDocument: "CreateServiceDeploymentWithHandle", DeleteServiceDeploymentDocument: "DeleteServiceDeployment", + DetachServiceDeploymentDocument: "DetachServiceDeployment", UpdateServiceDeploymentDocument: "UpdateServiceDeployment", UpdateServiceDeploymentWithHandleDocument: "UpdateServiceDeploymentWithHandle", CloneServiceDeploymentDocument: "CloneServiceDeployment", diff --git a/graph/deployment.graphql b/graph/deployment.graphql index baec912..0504ffb 100644 --- a/graph/deployment.graphql +++ b/graph/deployment.graphql @@ -46,6 +46,12 @@ mutation DeleteServiceDeployment($id: ID!) { } } +mutation DetachServiceDeployment($id: ID!) { + detachServiceDeployment(id: $id) { + ...ServiceDeploymentFragment + } +} + mutation UpdateServiceDeployment($id: ID!, $attributes: ServiceUpdateAttributes!) { updateServiceDeployment(id: $id, attributes: $attributes) { ...ServiceDeploymentExtended diff --git a/models_gen.go b/models_gen.go index 4515f7f..bc4a070 100644 --- a/models_gen.go +++ b/models_gen.go @@ -1771,6 +1771,9 @@ type KubernetesDatasource struct { } type KubernetesUnstructured struct { + Group *string `json:"group,omitempty"` + Version string `json:"version"` + Kind string `json:"kind"` Raw map[string]interface{} `json:"raw,omitempty"` Metadata Metadata `json:"metadata"` Events []*Event `json:"events,omitempty"` @@ -5845,17 +5848,19 @@ const ( StepStagePlan StepStage = "PLAN" StepStageVerify StepStage = "VERIFY" StepStageApply StepStage = "APPLY" + StepStageInit StepStage = "INIT" ) var AllStepStage = []StepStage{ StepStagePlan, StepStageVerify, StepStageApply, + StepStageInit, } func (e StepStage) IsValid() bool { switch e { - case StepStagePlan, StepStageVerify, StepStageApply: + case StepStagePlan, StepStageVerify, StepStageApply, StepStageInit: return true } return false diff --git a/schema/schema.graphql b/schema/schema.graphql index f02198a..a6783ef 100644 --- a/schema/schema.graphql +++ b/schema/schema.graphql @@ -941,6 +941,7 @@ enum StepStage { PLAN VERIFY APPLY + INIT } input StackAttributes { @@ -4581,6 +4582,9 @@ type ResourceSpec { } type KubernetesUnstructured { + group: String + version: String! + kind: String! raw: Map metadata: Metadata! events: [Event]