Skip to content

Commit

Permalink
chore: add deletebackup mutation support (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon authored May 20, 2024
1 parent 94f79c0 commit 5370c3e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/lagoon/client/_lgraphql/environments/deleteBackup.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mutation ($backupId: String!) {
deleteBackup(input: {
backupId: $backupId
})
}
18 changes: 18 additions & 0 deletions api/lagoon/client/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
7 changes: 7 additions & 0 deletions api/lagoon/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
5 changes: 5 additions & 0 deletions api/schema/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit 5370c3e

Please sign in to comment.