diff --git a/api/lagoon/client/_lgraphql/environments/deleteBackup.graphql b/api/lagoon/client/_lgraphql/environments/deleteBackup.graphql new file mode 100644 index 0000000..4b0e297 --- /dev/null +++ b/api/lagoon/client/_lgraphql/environments/deleteBackup.graphql @@ -0,0 +1,5 @@ +mutation ($backupId: String!) { + deleteBackup(input: { + backupId: $backupId + }) +} \ No newline at end of file diff --git a/api/lagoon/client/environments.go b/api/lagoon/client/environments.go index e505cd5..344639f 100644 --- a/api/lagoon/client/environments.go +++ b/api/lagoon/client/environments.go @@ -285,3 +285,21 @@ func (c *Client) DeleteEnvironmentService( Response: result, }) } + +// DeleteBackup deletes an environment backup. +func (c *Client) DeleteBackup(ctx context.Context, + backupID string, result *schema.DeleteBackup) error { + req, err := c.newRequest("_lgraphql/environments/deleteBackup.graphql", + map[string]interface{}{ + "backupId": backupID, + }) + if err != nil { + return err + } + + return c.client.Run(ctx, req, &struct { + Response *schema.DeleteBackup `json:"deleteBackup"` + }{ + Response: result, + }) +} diff --git a/api/lagoon/environments.go b/api/lagoon/environments.go index 4e3be6d..8e59e9b 100644 --- a/api/lagoon/environments.go +++ b/api/lagoon/environments.go @@ -24,6 +24,7 @@ type Environments interface { SSHEndpointByNamespace(ctx context.Context, namespace string, result *schema.Environment) error AddOrUpdateEnvironmentService(ctx context.Context, service schema.AddEnvironmentServiceInput, result *schema.EnvironmentService) error DeleteEnvironmentService(ctx context.Context, service schema.DeleteEnvironmentServiceInput, result *schema.DeleteEnvironmentService) error + DeleteBackup(context.Context, string, *schema.DeleteBackup) error } // GetBackupsForEnvironmentByName gets backup info in lagoon for specific environment. @@ -109,3 +110,9 @@ func DeleteEnvironmentService(ctx context.Context, service schema.DeleteEnvironm result := schema.DeleteEnvironmentService{} return &result, e.DeleteEnvironmentService(ctx, service, &result) } + +// DeleteBackup deletes an environment backup. +func DeleteBackup(ctx context.Context, backupID string, e Environments) (*schema.DeleteBackup, error) { + result := schema.DeleteBackup{} + return &result, e.DeleteBackup(ctx, backupID, &result) +} diff --git a/api/schema/backups.go b/api/schema/backups.go index bb2c6c8..a3d5eec 100644 --- a/api/schema/backups.go +++ b/api/schema/backups.go @@ -29,3 +29,8 @@ type AddRestoreInput struct { RestoreLocation string `json:"restoreLocation"` Execute bool `json:"execute"` } + +// DeleteBackup is the response. +type DeleteBackup struct { + DeleteBackup string `json:"deleteBackup"` +}