From 43a4f46d482e22653e91fd7f79454ab6d9bde6d1 Mon Sep 17 00:00:00 2001 From: Sivaanand Murugesan Date: Tue, 19 Nov 2024 20:48:16 +0530 Subject: [PATCH] PLT-1443: Added minio, gcp and azure bsl support in sdk. (#143) * PLT-1443: Added Minio, gcp and azure bsl support in sdk. * Added backup storage validation functions * fix --- client/backup_storage_location.go | 114 ++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/client/backup_storage_location.go b/client/backup_storage_location.go index 88ca8875..87c46673 100644 --- a/client/backup_storage_location.go +++ b/client/backup_storage_location.go @@ -41,6 +41,60 @@ func (h *V1Client) GetS3BackupStorageLocation(uid string) (*models.V1UserAssetsL return resp.Payload, nil } +// GetMinioBackupStorageLocation retrieves an existing Minio backup storage location. +func (h *V1Client) GetMinioBackupStorageLocation(uid string) (*models.V1UserAssetsLocationS3, error) { + params := clientv1.NewV1UsersAssetsLocationMinioGetParamsWithContext(h.ctx). + WithUID(uid) + resp, err := h.Client.V1UsersAssetsLocationMinioGet(params) + if err != nil { + return nil, err + } + return resp.Payload, nil +} + +// GetGCPBackupStorageLocation retrieves an existing GCP backup storage location. +func (h *V1Client) GetGCPBackupStorageLocation(uid string) (*models.V1UserAssetsLocationGcp, error) { + params := clientv1.NewV1UsersAssetsLocationGcpGetParamsWithContext(h.ctx). + WithUID(uid) + resp, err := h.Client.V1UsersAssetsLocationGcpGet(params) + if err != nil { + return nil, err + } + return resp.Payload, nil +} + +// GetAzureBackupStorageLocation retrieves an existing Azure backup storage location. +func (h *V1Client) GetAzureBackupStorageLocation(uid string) (*models.V1UserAssetsLocationAzure, error) { + params := clientv1.NewV1UsersAssetsLocationAzureGetParamsWithContext(h.ctx). + WithUID(uid) + resp, err := h.Client.V1UsersAssetsLocationAzureGet(params) + if err != nil { + return nil, err + } + return resp.Payload, nil +} + +// ValidateS3BackupStorageLocation validate a S3 credential for backup storage location. +func (h *V1Client) ValidateS3BackupStorageLocation(awsCred *models.V1AwsS3BucketCredentials) error { + params := clientv1.NewV1AwsS3ValidateParamsWithContext(h.ctx).WithAwsS3Credential(awsCred) + _, err := h.Client.V1AwsS3Validate(params) + return err +} + +// ValidateGcpBackupStorageLocation validate a gcp credential for backup storage location. +func (h *V1Client) ValidateGcpBackupStorageLocation(gcpCred *models.V1GcpAccountNameValidateSpec) error { + params := clientv1.NewV1GcpBucketNameValidateParamsWithContext(h.ctx).WithBody(gcpCred) + _, err := h.Client.V1GcpBucketNameValidate(params) + return err +} + +// ValidateAzureBackupStorageLocation validate an azure credential for backup storage location. +func (h *V1Client) ValidateAzureBackupStorageLocation(azureCred *models.V1AzureCloudAccount) error { + params := clientv1.NewV1AzureAccountValidateParamsWithContext(h.ctx).WithAzureCloudAccount(azureCred) + _, err := h.Client.V1AzureAccountValidate(params) + return err +} + // CreateS3BackupStorageLocation creates a new S3 backup storage location. func (h *V1Client) CreateS3BackupStorageLocation(bsl *models.V1UserAssetsLocationS3) (string, error) { params := clientv1.NewV1UsersAssetsLocationS3CreateParamsWithContext(h.ctx). @@ -52,6 +106,39 @@ func (h *V1Client) CreateS3BackupStorageLocation(bsl *models.V1UserAssetsLocatio return *resp.Payload.UID, nil } +// CreateMinioBackupStorageLocation creates a new Minio backup storage location. +func (h *V1Client) CreateMinioBackupStorageLocation(bsl *models.V1UserAssetsLocationS3) (string, error) { + params := clientv1.NewV1UsersAssetsLocationMinioCreateParamsWithContext(h.ctx). + WithBody(bsl) + resp, err := h.Client.V1UsersAssetsLocationMinioCreate(params) + if err != nil { + return "", err + } + return *resp.Payload.UID, nil +} + +// CreateGcpBackupStorageLocation creates a new GCP backup storage location. +func (h *V1Client) CreateGcpBackupStorageLocation(bsl *models.V1UserAssetsLocationGcp) (string, error) { + params := clientv1.NewV1UsersAssetsLocationGcpCreateParamsWithContext(h.ctx). + WithBody(bsl) + resp, err := h.Client.V1UsersAssetsLocationGcpCreate(params) + if err != nil { + return "", err + } + return *resp.Payload.UID, nil +} + +// CreateAzureBackupStorageLocation creates a new Azure backup storage location. +func (h *V1Client) CreateAzureBackupStorageLocation(bsl *models.V1UserAssetsLocationAzure) (string, error) { + params := clientv1.NewV1UsersAssetsLocationAzureCreateParamsWithContext(h.ctx). + WithBody(bsl) + resp, err := h.Client.V1UsersAssetsLocationAzureCreate(params) + if err != nil { + return "", err + } + return *resp.Payload.UID, nil +} + // UpdateS3BackupStorageLocation updates an existing S3 backup storage location. func (h *V1Client) UpdateS3BackupStorageLocation(uid string, bsl *models.V1UserAssetsLocationS3) error { params := clientv1.NewV1UsersAssetsLocationS3UpdateParamsWithContext(h.ctx). @@ -61,6 +148,33 @@ func (h *V1Client) UpdateS3BackupStorageLocation(uid string, bsl *models.V1UserA return err } +// UpdateMinioBackupStorageLocation updates an existing Minio backup storage location. +func (h *V1Client) UpdateMinioBackupStorageLocation(uid string, bsl *models.V1UserAssetsLocationS3) error { + params := clientv1.NewV1UsersAssetsLocationMinioUpdateParamsWithContext(h.ctx). + WithUID(uid). + WithBody(bsl) + _, err := h.Client.V1UsersAssetsLocationMinioUpdate(params) + return err +} + +// UpdateGcpBackupStorageLocation updates an existing Gcp backup storage location. +func (h *V1Client) UpdateGcpBackupStorageLocation(uid string, bsl *models.V1UserAssetsLocationGcp) error { + params := clientv1.NewV1UsersAssetsLocationGcpUpdateParamsWithContext(h.ctx). + WithUID(uid). + WithBody(bsl) + _, err := h.Client.V1UsersAssetsLocationGcpUpdate(params) + return err +} + +// UpdateAzureBackupStorageLocation updates an existing Azure backup storage location. +func (h *V1Client) UpdateAzureBackupStorageLocation(uid string, bsl *models.V1UserAssetsLocationAzure) error { + params := clientv1.NewV1UsersAssetsLocationAzureUpdateParamsWithContext(h.ctx). + WithUID(uid). + WithBody(bsl) + _, err := h.Client.V1UsersAssetsLocationAzureUpdate(params) + return err +} + // DeleteS3BackupStorageLocation deletes an existing S3 backup storage location. func (h *V1Client) DeleteS3BackupStorageLocation(uid string) error { params := clientv1.NewV1UsersAssetsLocationS3DeleteParamsWithContext(h.ctx).