From 41bc9ae987e76c11cb53dae745a54f8997576a01 Mon Sep 17 00:00:00 2001 From: genos1998 Date: Wed, 18 Sep 2024 23:47:56 +0530 Subject: [PATCH] add: runhistory status update --- july2024august2024/august2024/queries.graphql | 6 +++ .../august2024/schema-generated.go | 49 +++++++++++++++++++ july2024august2024/updateRunhistoryStatus.go | 20 ++++++++ july2024august2024/upgradeSteps.go | 4 ++ 4 files changed, 79 insertions(+) create mode 100644 july2024august2024/updateRunhistoryStatus.go diff --git a/july2024august2024/august2024/queries.graphql b/july2024august2024/august2024/queries.graphql index 005dad2..c63525b 100644 --- a/july2024august2024/august2024/queries.graphql +++ b/july2024august2024/august2024/queries.graphql @@ -3,3 +3,9 @@ mutation AttachJiraToRunHistory($jira: [AddJiraInput!]!) { numUids } } + +mutation UpdateRunHistory { + updateRunHistory(input: { set: { Status: "active" }, filter: {} }) { + numUids + } +} diff --git a/july2024august2024/august2024/schema-generated.go b/july2024august2024/august2024/schema-generated.go index ba8b243..7d76535 100644 --- a/july2024august2024/august2024/schema-generated.go +++ b/july2024august2024/august2024/schema-generated.go @@ -1457,6 +1457,24 @@ func (v *ToolsUsedRef) GetSbom() string { return v.Sbom } // GetMisc returns ToolsUsedRef.Misc, and is useful for accessing the field via an interface. func (v *ToolsUsedRef) GetMisc() []string { return v.Misc } +// UpdateRunHistoryResponse is returned by UpdateRunHistory on success. +type UpdateRunHistoryResponse struct { + UpdateRunHistory *UpdateRunHistoryUpdateRunHistoryUpdateRunHistoryPayload `json:"updateRunHistory"` +} + +// GetUpdateRunHistory returns UpdateRunHistoryResponse.UpdateRunHistory, and is useful for accessing the field via an interface. +func (v *UpdateRunHistoryResponse) GetUpdateRunHistory() *UpdateRunHistoryUpdateRunHistoryUpdateRunHistoryPayload { + return v.UpdateRunHistory +} + +// UpdateRunHistoryUpdateRunHistoryUpdateRunHistoryPayload includes the requested fields of the GraphQL type UpdateRunHistoryPayload. +type UpdateRunHistoryUpdateRunHistoryUpdateRunHistoryPayload struct { + NumUids *int `json:"numUids"` +} + +// GetNumUids returns UpdateRunHistoryUpdateRunHistoryUpdateRunHistoryPayload.NumUids, and is useful for accessing the field via an interface. +func (v *UpdateRunHistoryUpdateRunHistoryUpdateRunHistoryPayload) GetNumUids() *int { return v.NumUids } + type VulnerabilityRef struct { Id string `json:"id"` Parent string `json:"parent"` @@ -1562,3 +1580,34 @@ func AttachJiraToRunHistory( return &data_, err_ } + +// The query or mutation executed by UpdateRunHistory. +const UpdateRunHistory_Operation = ` +mutation UpdateRunHistory { + updateRunHistory(input: {set:{Status:"active"},filter:{}}) { + numUids + } +} +` + +func UpdateRunHistory( + ctx_ context.Context, + client_ graphql.Client, +) (*UpdateRunHistoryResponse, error) { + req_ := &graphql.Request{ + OpName: "UpdateRunHistory", + Query: UpdateRunHistory_Operation, + } + var err_ error + + var data_ UpdateRunHistoryResponse + resp_ := &graphql.Response{Data: &data_} + + err_ = client_.MakeRequest( + ctx_, + req_, + resp_, + ) + + return &data_, err_ +} diff --git a/july2024august2024/updateRunhistoryStatus.go b/july2024august2024/updateRunhistoryStatus.go new file mode 100644 index 0000000..fd74950 --- /dev/null +++ b/july2024august2024/updateRunhistoryStatus.go @@ -0,0 +1,20 @@ +package july2024august2024 + +import ( + "context" + "fmt" + "upgradationScript/july2024august2024/august2024" + + "github.com/Khan/genqlient/graphql" +) + +func performStatusUpdate(expDgraphClient graphql.Client) error { + ctx := context.Background() + + if _, err := august2024.UpdateRunHistory(ctx, expDgraphClient); err != nil { + return fmt.Errorf("error while updating runhistory status to active") + } + + return nil + +} diff --git a/july2024august2024/upgradeSteps.go b/july2024august2024/upgradeSteps.go index 6db7ee0..6ad4d83 100644 --- a/july2024august2024/upgradeSteps.go +++ b/july2024august2024/upgradeSteps.go @@ -17,6 +17,10 @@ func UpgradeToAugust2024(prodGraphUrl, prodToken, expDgraphUrl, restoreServiceUr return fmt.Errorf("UpgradeToAugust2024: performJiraDetailsTransition: %s", err.Error()) } + if err := performStatusUpdate(expDgraphClient); err != nil { + return fmt.Errorf("UpgradeToAugust2024: performStatusUpdate: %s", err.Error()) + } + if err := graphqlfunc.BackupAndRestoreDgraph(expDgraphUrl, restoreServiceUrl); err != nil { return fmt.Errorf("UpgradeToAugust2024: BackupAndRestoreDgraph: %s", err.Error()) }