backup

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeginFullBackupOptions

type BeginFullBackupOptions struct {
	// Resumes the LRO from the provided token.
	ResumeToken string
}

BeginFullBackupOptions contains the optional parameters for the Client.BeginFullBackup method.

type BeginFullRestoreOptions

type BeginFullRestoreOptions struct {
	// Resumes the LRO from the provided token.
	ResumeToken string
}

BeginFullRestoreOptions contains the optional parameters for the Client.BeginFullRestore method.

type BeginSelectiveKeyRestoreOptions

type BeginSelectiveKeyRestoreOptions struct {
	// Resumes the LRO from the provided token.
	ResumeToken string
}

BeginSelectiveKeyRestoreOptions contains the optional parameters for the Client.BeginSelectiveKeyRestore method.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client contains the methods for the Client group. Don't use this type directly, use a constructor function instead.

func NewClient

func NewClient(vaultURL string, credential azcore.TokenCredential, options *ClientOptions) (*Client, error)

NewClient creates a client that performs backup and restore operations for a Managed HSM. You should validate that vaultURL references a valid Managed HSM. See https://aka.ms/azsdk/blog/vault-uri for details.

Example
package main

import (
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin/backup"
)

func main() {
	vaultURL := "https://<TODO: your vault name>.managedhsm.azure.net/"
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		// TODO: handle error
	}

	client, err := backup.NewClient(vaultURL, cred, nil)
	if err != nil {
		// TODO: handle error
	}

	_ = client
}
Output:

func (*Client) BeginFullBackup

func (client *Client) BeginFullBackup(ctx context.Context, azureStorageBlobContainerURI SASTokenParameters, options *BeginFullBackupOptions) (*runtime.Poller[FullBackupResponse], error)

BeginFullBackup - Creates a full backup using a user-provided SAS token to an Azure blob storage container. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 7.5

  • azureStorageBlobContainerURI - Azure blob shared access signature token pointing to a valid Azure blob container where full backup needs to be stored. This token needs to be valid for at least next 24 hours from the time of making this call
  • options - BeginFullBackupOptions contains the optional parameters for the Client.BeginFullBackup method.
Example
package main

import (
	"context"
	"fmt"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin/backup"
)

var client *backup.Client

func main() {
	storageParameters := backup.SASTokenParameters{
		StorageResourceURI: to.Ptr("https://<storage-account>.blob.core.windows.net/<container>"),
		Token:              to.Ptr("<your SAS token>"),
	}
	backupPoller, err := client.BeginFullBackup(context.Background(), storageParameters, nil)
	if err != nil {
		// TODO: handle error
	}
	backupResults, err := backupPoller.PollUntilDone(context.Background(), nil)
	if err != nil {
		// TODO: handle error
	}
	fmt.Printf("Status of backup: %s", *backupResults.Status)
}
Output:

func (*Client) BeginFullRestore

func (client *Client) BeginFullRestore(ctx context.Context, restoreBlobDetails RestoreOperationParameters, options *BeginFullRestoreOptions) (*runtime.Poller[FullRestoreResponse], error)

BeginFullRestore - Restores all key materials using the SAS token pointing to a previously stored Azure Blob storage backup folder If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 7.5

  • restoreBlobDetails - The Azure blob SAS token pointing to a folder where the previous successful full backup was stored
  • options - BeginFullRestoreOptions contains the optional parameters for the Client.BeginFullRestore method.
Example
package main

import (
	"context"
	"fmt"
	"strings"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin/backup"
)

var client *backup.Client

func main() {
	// first, backup the managed HSM to a blob storage container
	storageParameters := backup.SASTokenParameters{
		StorageResourceURI: to.Ptr("https://<storage-account>.blob.core.windows.net/<container>"),
		Token:              to.Ptr("<your SAS token>"),
	}
	backupPoller, err := client.BeginFullBackup(context.Background(), storageParameters, nil)
	if err != nil {
		// TODO: handle error
	}
	backupResults, err := backupPoller.PollUntilDone(context.Background(), nil)
	if err != nil {
		// TODO: handle error
	}

	// FolderToRestore is the folder in the blob container your managed HSM was uploaded to
	// FolderToRestore can be extracted from the returned backupResults.AzureStorageBlobContainerURI
	s := *backupResults.AzureStorageBlobContainerURI
	folderName := s[strings.LastIndex(s, "/")+1:]

	// begin the restore operation
	restoreOperationParameters := backup.RestoreOperationParameters{
		FolderToRestore: to.Ptr(folderName),
		SASTokenParameters: &backup.SASTokenParameters{
			StorageResourceURI: to.Ptr("https://<storage-account>.blob.core.windows.net/<container>"),
			Token:              to.Ptr("<your SAS token>"),
		},
	}
	restorePoller, err := client.BeginFullRestore(context.Background(), restoreOperationParameters, nil)
	if err != nil {
		// TODO: handle error
	}

	// Poll for the results
	restoreResults, err := restorePoller.PollUntilDone(context.Background(), nil)
	if err != nil {
		// TODO: handle error
	}

	fmt.Printf("Status of restore: %s", *restoreResults.Status)
}
Output:

func (*Client) BeginSelectiveKeyRestore

func (client *Client) BeginSelectiveKeyRestore(ctx context.Context, keyName string, restoreBlobDetails SelectiveKeyRestoreOperationParameters, options *BeginSelectiveKeyRestoreOptions) (*runtime.Poller[SelectiveKeyRestoreResponse], error)

BeginSelectiveKeyRestore - Restores all key versions of a given key using user supplied SAS token pointing to a previously stored Azure Blob storage backup folder If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 7.5

  • keyName - The name of the key to be restored from the user supplied backup
  • restoreBlobDetails - The Azure blob SAS token pointing to a folder where the previous successful full backup was stored
  • options - BeginSelectiveKeyRestoreOptions contains the optional parameters for the Client.BeginSelectiveKeyRestore method.
Example
package main

import (
	"context"
	"fmt"
	"strings"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin/backup"
	"github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys"
)

var client *backup.Client
var keyClient *azkeys.Client

func main() {
	// first, create a key to backup
	params := azkeys.CreateKeyParameters{
		KeySize: to.Ptr(int32(2048)),
		Kty:     to.Ptr(azkeys.KeyTypeRSA),
	}
	_, err := keyClient.CreateKey(context.TODO(), "<key-name>", params, nil)
	if err != nil {
		// TODO: handle error
	}

	// backup the vault
	storageParameters := backup.SASTokenParameters{
		StorageResourceURI: to.Ptr("https://<storage-account>.blob.core.windows.net/<container>"),
		Token:              to.Ptr("<your SAS token>"),
	}
	backupPoller, err := client.BeginFullBackup(context.Background(), storageParameters, nil)
	if err != nil {
		// TODO: handle error
	}
	backupResults, err := backupPoller.PollUntilDone(context.Background(), nil)
	if err != nil {
		// TODO: handle error
	}

	// extract the folder name where the vault was backed up
	s := *backupResults.AzureStorageBlobContainerURI
	folderName := s[strings.LastIndex(s, "/")+1:]

	// restore the key
	restoreOperationParameters := backup.SelectiveKeyRestoreOperationParameters{
		Folder: to.Ptr(folderName),
		SASTokenParameters: &backup.SASTokenParameters{
			StorageResourceURI: to.Ptr("https://<storage-account>.blob.core.windows.net/<container>"),
			Token:              to.Ptr("<your SAS token>"),
		},
	}
	selectivePoller, err := client.BeginSelectiveKeyRestore(context.Background(), "<key-name>", restoreOperationParameters, nil)
	if err != nil {
		// TODO: handle error
	}
	selectiveResults, err := selectivePoller.PollUntilDone(context.Background(), nil)
	if err != nil {
		// TODO: handle error
	}
	fmt.Printf("Status of the selective restore: %s", *selectiveResults.Status)
}
Output:

type ClientOptions

type ClientOptions struct {
	azcore.ClientOptions

	// DisableChallengeResourceVerification controls whether the policy requires the
	// authentication challenge resource to match the Key Vault or Managed HSM domain.
	// See https://aka.ms/azsdk/blog/vault-uri for more information.
	DisableChallengeResourceVerification bool
}

ClientOptions contains optional settings for Client.

type ErrorInfo added in v0.2.0

type ErrorInfo struct {
	// REQUIRED; A machine readable error code.
	Code string
	// contains filtered or unexported fields
}

ErrorInfo - Internal error from Azure Key Vault server.

func (*ErrorInfo) Error added in v0.2.0

func (e *ErrorInfo) Error() string

Error implements a custom error for type ServerError. Returns full error message

func (*ErrorInfo) UnmarshalJSON added in v0.2.0

func (e *ErrorInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Error.

type FullBackupOperation

type FullBackupOperation struct {
	// The Azure blob storage container Uri which contains the full backup
	AzureStorageBlobContainerURI *string

	// The end time of the backup operation in UTC
	EndTime *time.Time

	// Error encountered, if any, during the full backup operation.
	Error *ErrorInfo

	// Identifier for the full backup operation.
	JobID *string

	// The start time of the backup operation in UTC
	StartTime *time.Time

	// Status of the backup operation.
	Status *string

	// The status details of backup operation.
	StatusDetails *string
}

FullBackupOperation - Full backup operation

func (FullBackupOperation) MarshalJSON

func (f FullBackupOperation) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type FullBackupOperation.

func (*FullBackupOperation) UnmarshalJSON

func (f *FullBackupOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type FullBackupOperation.

type FullBackupResponse

type FullBackupResponse struct {
	// Full backup operation
	FullBackupOperation
}

FullBackupResponse contains the response from method Client.BeginFullBackup.

type FullRestoreResponse

type FullRestoreResponse struct {
	// Restore operation
	RestoreOperation
}

FullRestoreResponse contains the response from method Client.BeginFullRestore.

type RestoreOperation

type RestoreOperation struct {
	// The end time of the restore operation
	EndTime *time.Time

	// Error encountered, if any, during the restore operation.
	Error *ErrorInfo

	// Identifier for the restore operation.
	JobID *string

	// The start time of the restore operation
	StartTime *time.Time

	// Status of the restore operation.
	Status *string

	// The status details of restore operation.
	StatusDetails *string
}

RestoreOperation - Restore operation

func (RestoreOperation) MarshalJSON

func (r RestoreOperation) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type RestoreOperation.

func (*RestoreOperation) UnmarshalJSON

func (r *RestoreOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type RestoreOperation.

type RestoreOperationParameters

type RestoreOperationParameters struct {
	// REQUIRED; The Folder name of the blob where the previous successful full backup was stored
	FolderToRestore *string

	// REQUIRED; Contains the information required to access blob storage.
	SASTokenParameters *SASTokenParameters
}

RestoreOperationParameters - Parameters for the restore operation

func (RestoreOperationParameters) MarshalJSON

func (r RestoreOperationParameters) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type RestoreOperationParameters.

func (*RestoreOperationParameters) UnmarshalJSON

func (r *RestoreOperationParameters) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type RestoreOperationParameters.

type SASTokenParameters added in v0.3.0

type SASTokenParameters struct {
	// REQUIRED; Azure Blob storage container Uri
	StorageResourceURI *string

	// The SAS token pointing to an Azure Blob storage container
	Token *string

	// Indicates which authentication method should be used. If set to true, Managed HSM will use the configured user-assigned
	// managed identity to authenticate with Azure Storage. Otherwise, a SAS token has
	// to be specified.
	UseManagedIdentity *bool
}

SASTokenParameters - Contains the information required to access blob storage.

func (SASTokenParameters) MarshalJSON added in v0.3.0

func (s SASTokenParameters) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SASTokenParameters.

func (*SASTokenParameters) UnmarshalJSON added in v0.3.0

func (s *SASTokenParameters) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SASTokenParameters.

type SelectiveKeyRestoreOperation

type SelectiveKeyRestoreOperation struct {
	// The end time of the restore operation
	EndTime *time.Time

	// Error encountered, if any, during the selective key restore operation.
	Error *ErrorInfo

	// Identifier for the selective key restore operation.
	JobID *string

	// The start time of the restore operation
	StartTime *time.Time

	// Status of the restore operation.
	Status *string

	// The status details of restore operation.
	StatusDetails *string
}

SelectiveKeyRestoreOperation - Selective Key Restore operation

func (SelectiveKeyRestoreOperation) MarshalJSON

func (s SelectiveKeyRestoreOperation) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SelectiveKeyRestoreOperation.

func (*SelectiveKeyRestoreOperation) UnmarshalJSON

func (s *SelectiveKeyRestoreOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SelectiveKeyRestoreOperation.

type SelectiveKeyRestoreOperationParameters

type SelectiveKeyRestoreOperationParameters struct {
	// REQUIRED; The Folder name of the blob where the previous successful full backup was stored
	Folder *string

	// REQUIRED; Contains the information required to access blob storage.
	SASTokenParameters *SASTokenParameters
}

SelectiveKeyRestoreOperationParameters - Parameters for the selective restore operation

func (SelectiveKeyRestoreOperationParameters) MarshalJSON

func (s SelectiveKeyRestoreOperationParameters) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SelectiveKeyRestoreOperationParameters.

func (*SelectiveKeyRestoreOperationParameters) UnmarshalJSON

func (s *SelectiveKeyRestoreOperationParameters) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SelectiveKeyRestoreOperationParameters.

type SelectiveKeyRestoreResponse

type SelectiveKeyRestoreResponse struct {
	// Selective Key Restore operation
	SelectiveKeyRestoreOperation
}

SelectiveKeyRestoreResponse contains the response from method Client.BeginSelectiveKeyRestore.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL