api

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

This package provides a high-level interface to the NetApp GCP Cloud Volumes NFS REST API.

Index

Constants

View Source
const (
	VolumeCreateTimeout = 10 * time.Second
	DefaultTimeout      = 120 * time.Second

	MaxLabelLength = 255
)
View Source
const (
	StateCreating  = "creating"
	StateAvailable = "available"
	StateUpdating  = "updating"
	StateDisabled  = "disabled"
	StateDeleting  = "deleting"
	StateDeleted   = "deleted"
	StateError     = "error"
	StateRestoring = "restoring"

	ProtocolTypeNFSv3 = "NFSv3"
	ProtocolTypeNFSv4 = "NFSv4"
	ProtocolTypeCIFS  = "CIFS"

	APIServiceLevel1 = "basic"    // "low"
	APIServiceLevel2 = "standard" // "medium"
	APIServiceLevel3 = "extreme"  // "high"

	UserServiceLevel1 = "standard"
	UserServiceLevel2 = "premium"
	UserServiceLevel3 = "extreme"

	AccessReadOnly  = "ReadOnly"
	AccessReadWrite = "ReadWrite"

	StorageClassHardware = "hardware"
	StorageClassSoftware = "software"
)

Variables

This section is empty.

Functions

func GCPAPIServiceLevelFromUserServiceLevel

func GCPAPIServiceLevelFromUserServiceLevel(userServiceLevel string) string

func IsTransitionalState

func IsTransitionalState(volumeState string) bool

func IsValidUserServiceLevel

func IsValidUserServiceLevel(userServiceLevel string) bool

func UserServiceLevelFromAPIServiceLevel

func UserServiceLevelFromAPIServiceLevel(apiServiceLevel string) string

Types

type Backup

type Backup struct {
	Created               time.Time `json:"created"`
	VolumeID              string    `json:"volumeId"`
	LifeCycleState        string    `json:"lifeCycleState"`
	LifeCycleStateDetails string    `json:"lifeCycleStateDetails"`
	Name                  string    `json:"name"`
	OwnerID               string    `json:"ownerId"`
	Region                string    `json:"region"`
	BackupID              string    `json:"backupId"`
	LogicalSize           int64     `json:"logicalSize"`
	BytesTransferred      int64     `json:"bytesTransferred"`
	ProgressPercentage    int       `json:"progressPercentage"`
}

type BackupCreateRequest

type BackupCreateRequest struct {
	VolumeID string `json:"volumeId"`
	Name     string `json:"name"`
}

type BackupPolicy

type BackupPolicy struct {
	DailyBackupsToKeep   int  `json:"dailyBackupsToKeep"`
	DeleteAllBackups     bool `json:"deleteAllBackups"`
	Enabled              bool `json:"enabled"`
	MonthlyBackupsToKeep int  `json:"monthlyBackupsToKeep"`
	WeeklyBackupsToKeep  int  `json:"weeklyBackupsToKeep"`
}

type CallResponseError

type CallResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

CallResponseError is used for errors on RESTful calls to return what went wrong

type Checked

type Checked struct {
	Checked bool `json:"checked"`
}

type Client

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

func NewDriver

func NewDriver(config ClientConfig) *Client

NewDriver is a factory method for creating a new instance.

func (*Client) ChangeVolumeUnixPermissions

func (d *Client) ChangeVolumeUnixPermissions(ctx context.Context, volume *Volume, newUnixPermissions string) (*Volume,
	error,
)

func (*Client) CreateBackup

func (d *Client) CreateBackup(ctx context.Context, request *BackupCreateRequest) error

func (*Client) CreateSnapshot

func (d *Client) CreateSnapshot(ctx context.Context, request *SnapshotCreateRequest) error

func (*Client) CreateVolume

func (d *Client) CreateVolume(ctx context.Context, request *VolumeCreateRequest) error

func (*Client) DeleteBackup

func (d *Client) DeleteBackup(ctx context.Context, volume *Volume, backup *Backup) error

func (*Client) DeleteSnapshot

func (d *Client) DeleteSnapshot(ctx context.Context, volume *Volume, snapshot *Snapshot) error

func (*Client) DeleteVolume

func (d *Client) DeleteVolume(ctx context.Context, volume *Volume) error

func (*Client) GetBackupByID

func (d *Client) GetBackupByID(ctx context.Context, backupId string) (*Backup, error)

func (*Client) GetBackupForVolume

func (d *Client) GetBackupForVolume(ctx context.Context, volume *Volume, backupName string) (*Backup, error)

func (*Client) GetBackupsForVolume

func (d *Client) GetBackupsForVolume(ctx context.Context, volume *Volume) (*[]Backup, error)

func (*Client) GetServiceLevels

func (d *Client) GetServiceLevels(ctx context.Context) (map[string]string, error)

func (*Client) GetSnapshotByID

func (d *Client) GetSnapshotByID(ctx context.Context, snapshotId string) (*Snapshot, error)

func (*Client) GetSnapshotForVolume

func (d *Client) GetSnapshotForVolume(ctx context.Context, volume *Volume, snapshotName string) (*Snapshot, error)

func (*Client) GetSnapshotsForVolume

func (d *Client) GetSnapshotsForVolume(ctx context.Context, volume *Volume) (*[]Snapshot, error)

func (*Client) GetVersion

func (d *Client) GetVersion(ctx context.Context) (*utils.Version, *utils.Version, error)

func (*Client) GetVolumeByCreationToken

func (d *Client) GetVolumeByCreationToken(ctx context.Context, creationToken string) (*Volume, error)

func (*Client) GetVolumeByID

func (d *Client) GetVolumeByID(ctx context.Context, volumeId string) (*Volume, error)

func (*Client) GetVolumeByName

func (d *Client) GetVolumeByName(ctx context.Context, name string) (*Volume, error)

func (*Client) GetVolumes

func (d *Client) GetVolumes(ctx context.Context) (*[]Volume, error)

func (*Client) InvokeAPI

func (d *Client) InvokeAPI(
	ctx context.Context, requestBody []byte, method, gcpURL string,
) (*http.Response, []byte, error)

InvokeAPI makes a REST call to the cloud volumes REST service. The body must be a marshaled JSON byte array (or nil). The method is the HTTP verb (i.e. GET, POST, ...).

func (*Client) RelabelVolume

func (d *Client) RelabelVolume(ctx context.Context, volume *Volume, labels []string) (*Volume, error)

func (*Client) RenameRelabelVolume

func (d *Client) RenameRelabelVolume(
	ctx context.Context, volume *Volume, newName string, labels []string,
) (*Volume, error)

func (*Client) RenameVolume

func (d *Client) RenameVolume(ctx context.Context, volume *Volume, newName string) (*Volume, error)

func (*Client) ResizeVolume

func (d *Client) ResizeVolume(ctx context.Context, volume *Volume, newSizeBytes int64) (*Volume, error)

func (*Client) RestoreSnapshot

func (d *Client) RestoreSnapshot(ctx context.Context, volume *Volume, snapshot *Snapshot) error

func (*Client) VolumeExistsByCreationToken

func (d *Client) VolumeExistsByCreationToken(ctx context.Context, creationToken string) (bool, *Volume, error)

func (*Client) WaitForBackupStates

func (d *Client) WaitForBackupStates(
	ctx context.Context, backup *Backup, desiredStates, abortStates []string, maxElapsedTime time.Duration,
) error

func (*Client) WaitForSnapshotState

func (d *Client) WaitForSnapshotState(
	ctx context.Context, snapshot *Snapshot, desiredState string, abortStates []string, maxElapsedTime time.Duration,
) error

func (*Client) WaitForVolumeStates

func (d *Client) WaitForVolumeStates(
	ctx context.Context, volume *Volume, desiredStates, abortStates []string, maxElapsedTime time.Duration,
) (string, error)

type ClientConfig

type ClientConfig struct {
	utils.MountPoint
	// GCP project number
	ProjectNumber string

	// GCP CVS API authentication parameters
	APIKey drivers.GCPPrivateKey

	// GCP region
	APIRegion string

	// URL for accessing the API via an HTTP/HTTPS proxy
	ProxyURL string

	// Options
	DebugTraceFlags map[string]bool

	// CVS api url
	APIURL string

	// CVS api audience url
	APIAudienceURL string
}

ClientConfig holds configuration data for the API driver object.

type DailySchedule

type DailySchedule struct {
	Hour            int `json:"hour"`
	Minute          int `json:"minute"`
	SnapshotsToKeep int `json:"snapshotsToKeep"`
}

type Error

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

func (Error) Code

func (e Error) Code() int

func (Error) Error

func (e Error) Error() string

func (Error) IsPassed

func (e Error) IsPassed() bool

func (Error) Message

func (e Error) Message() string

type ExportPolicy

type ExportPolicy struct {
	Rules []ExportRule `json:"rules"`
}

type ExportRule

type ExportRule struct {
	Access         string  `json:"access"`
	AllowedClients string  `json:"allowedClients"`
	NFSv3          Checked `json:"nfsv3,omitempty"`
	NFSv4          Checked `json:"nfsv4,omitempty"`
}

type GCPClient

type GCPClient interface {
	InvokeAPI(
		ctx context.Context, requestBody []byte, method, gcpURL string,
	) (*http.Response, []byte, error)
	GetVersion(ctx context.Context) (*utils.Version, *utils.Version, error)
	GetServiceLevels(ctx context.Context) (map[string]string, error)

	GetVolumes(ctx context.Context) (*[]Volume, error)
	GetVolumeByName(ctx context.Context, name string) (*Volume, error)
	GetVolumeByCreationToken(ctx context.Context, creationToken string) (*Volume, error)
	VolumeExistsByCreationToken(ctx context.Context, creationToken string) (bool, *Volume, error)
	GetVolumeByID(ctx context.Context, volumeId string) (*Volume, error)
	WaitForVolumeStates(
		ctx context.Context, volume *Volume, desiredStates, abortStates []string,
		maxElapsedTime time.Duration,
	) (string, error)
	CreateVolume(ctx context.Context, request *VolumeCreateRequest) error
	RenameVolume(ctx context.Context, volume *Volume, newName string) (*Volume, error)
	ChangeVolumeUnixPermissions(ctx context.Context, volume *Volume, newUnixPermissions string) (*Volume, error)
	RelabelVolume(ctx context.Context, volume *Volume, labels []string) (*Volume, error)
	RenameRelabelVolume(
		ctx context.Context, volume *Volume, newName string, labels []string,
	) (*Volume, error)
	ResizeVolume(ctx context.Context, volume *Volume, newSizeBytes int64) (*Volume, error)
	DeleteVolume(ctx context.Context, volume *Volume) error

	GetSnapshotsForVolume(ctx context.Context, volume *Volume) (*[]Snapshot, error)
	GetSnapshotForVolume(ctx context.Context, volume *Volume, snapshotName string) (*Snapshot, error)
	GetSnapshotByID(ctx context.Context, snapshotId string) (*Snapshot, error)
	WaitForSnapshotState(
		ctx context.Context, snapshot *Snapshot, desiredState string, abortStates []string,
		maxElapsedTime time.Duration,
	) error
	CreateSnapshot(ctx context.Context, request *SnapshotCreateRequest) error
	RestoreSnapshot(ctx context.Context, volume *Volume, snapshot *Snapshot) error
	DeleteSnapshot(ctx context.Context, volume *Volume, snapshot *Snapshot) error

	GetBackupsForVolume(ctx context.Context, volume *Volume) (*[]Backup, error)
	GetBackupForVolume(ctx context.Context, volume *Volume, backupName string) (*Backup, error)
	GetBackupByID(ctx context.Context, backupId string) (*Backup, error)
	WaitForBackupStates(
		ctx context.Context, backup *Backup, desiredStates, abortStates []string,
		maxElapsedTime time.Duration,
	) error
	CreateBackup(ctx context.Context, request *BackupCreateRequest) error
	DeleteBackup(ctx context.Context, volume *Volume, backup *Backup) error
}

type HourlySchedule

type HourlySchedule struct {
	Minute          int `json:"minute"`
	SnapshotsToKeep int `json:"snapshotsToKeep"`
}

type Job

type Job struct{}

type MonthlySchedule

type MonthlySchedule struct {
	DaysOfMonth     string `json:"daysOfMonth"`
	Hour            int    `json:"hour"`
	Minute          int    `json:"minute"`
	SnapshotsToKeep int    `json:"snapshotsToKeep"`
}

type MountPoint

type MountPoint struct {
	Export       string `json:"export"`
	ExportFull   string `json:"exportFull"`
	Instructions string `json:"instructions"`
	ProtocolType string `json:"protocolType"`
	Server       string `json:"server"`
	VlanID       int    `json:"vlanId"`
}

type ServiceLevel

type ServiceLevel struct {
	Name        string `json:"name"`
	Performance string `json:"performance"`
}

type ServiceLevelsResponse

type ServiceLevelsResponse []ServiceLevel

type Snapshot

type Snapshot struct {
	Created               time.Time `json:"created"`
	VolumeID              string    `json:"volumeId"`
	LifeCycleState        string    `json:"lifeCycleState"`
	LifeCycleStateDetails string    `json:"lifeCycleStateDetails"`
	Name                  string    `json:"name"`
	OwnerID               string    `json:"ownerId"`
	Region                string    `json:"region"`
	SnapshotID            string    `json:"snapshotId"`
	UsedBytes             int       `json:"usedBytes"`
}

type SnapshotCreateRequest

type SnapshotCreateRequest struct {
	VolumeID string `json:"volumeId"`
	Name     string `json:"name"`
}

type SnapshotPolicy

type SnapshotPolicy struct {
	DailySchedule   DailySchedule   `json:"dailySchedule"`
	Enabled         bool            `json:"enabled"`
	HourlySchedule  HourlySchedule  `json:"hourlySchedule"`
	MonthlySchedule MonthlySchedule `json:"monthlySchedule"`
	WeeklySchedule  WeeklySchedule  `json:"weeklySchedule"`
}

type SnapshotRevertRequest

type SnapshotRevertRequest struct {
	Name   string `json:"name"`
	Region string `json:"region"`
}

type TerminalStateError

type TerminalStateError struct {
	Err error
}

TerminalStateError signals that the object is in a terminal state. This is used to stop waiting on an object to change state.

func TerminalState

func TerminalState(err error) *TerminalStateError

TerminalState wraps the given err in a *TerminalStateError.

func (*TerminalStateError) Error

func (e *TerminalStateError) Error() string

type VersionResponse

type VersionResponse struct {
	APIVersion string `json:"apiVersion"`
	SdeVersion string `json:"sdeVersion"`
}

type Volume

type Volume struct {
	Created               time.Time      `json:"created"`
	LifeCycleState        string         `json:"lifeCycleState"`
	LifeCycleStateDetails string         `json:"lifeCycleStateDetails"`
	Name                  string         `json:"name"`
	OwnerID               string         `json:"ownerId"`
	Region                string         `json:"region"`
	Zone                  string         `json:"zone,omitempty"`
	VolumeID              string         `json:"volumeId"`
	CreationToken         string         `json:"creationToken"`
	ExportPolicy          ExportPolicy   `json:"exportPolicy"`
	Jobs                  []Job          `json:"jobs"`
	Labels                []string       `json:"labels"`
	MountPoints           []MountPoint   `json:"mountPoints"`
	ProtocolTypes         []string       `json:"protocolTypes"`
	QuotaInBytes          int64          `json:"quotaInBytes"`
	SecurityStyle         string         `json:"securityStyle"`
	ServiceLevel          string         `json:"serviceLevel"`
	SnapReserve           int64          `json:"snapReserve"`
	SnapshotDirectory     bool           `json:"snapshotDirectory"`
	SnapshotPolicy        SnapshotPolicy `json:"snapshotPolicy"`
	Timezone              string         `json:"timezone,omitempty"`
	UnixPermissions       string         `json:"unixPermissions,omitempty"`
	UsedBytes             int            `json:"usedBytes"`
	StorageClass          string         `json:"storageClass"`
}

type VolumeChangeUnixPermissionsRequest

type VolumeChangeUnixPermissionsRequest struct {
	Region          string `json:"region"`
	CreationToken   string `json:"creationToken"`
	UnixPermissions string `json:"unixPermissions,omitempty"`
	QuotaInBytes    int64  `json:"quotaInBytes"`
	ServiceLevel    string `json:"serviceLevel"`
}

type VolumeCreateRequest

type VolumeCreateRequest struct {
	Name              string         `json:"name"`
	Region            string         `json:"region"`
	Zone              string         `json:"zone,omitempty"`
	BackupPolicy      *BackupPolicy  `json:"backupPolicy,omitempty"`
	CreationToken     string         `json:"creationToken"`
	ExportPolicy      ExportPolicy   `json:"exportPolicy,omitempty"`
	Jobs              []Job          `json:"jobs,omitempty"`
	Labels            []string       `json:"labels,omitempty"`
	ProtocolTypes     []string       `json:"protocolTypes"`
	QuotaInBytes      int64          `json:"quotaInBytes"`
	SecurityStyle     string         `json:"securityStyle"`
	ServiceLevel      string         `json:"serviceLevel"`
	StorageClass      string         `json:"storageClass,omitempty"`
	SnapReserve       *int64         `json:"snapReserve,omitempty"`
	SnapshotDirectory bool           `json:"snapshotDirectory"`
	SnapshotPolicy    SnapshotPolicy `json:"snapshotPolicy,omitempty"`
	Timezone          string         `json:"timezone,omitempty"`
	UnixPermissions   string         `json:"unixPermissions,omitempty"`
	VendorID          string         `json:"vendorID,omitempty"`
	BackupID          string         `json:"backupId,omitempty"`
	Network           string         `json:"network,omitempty"`
	SnapshotID        string         `json:"snapshotId,omitempty"`
}

type VolumeRenameRelabelRequest

type VolumeRenameRelabelRequest struct {
	Name          string   `json:"name,omitempty"`
	Region        string   `json:"region"`
	CreationToken string   `json:"creationToken"`
	ProtocolTypes []string `json:"protocolTypes"`
	Labels        []string `json:"labels"`
	QuotaInBytes  int64    `json:"quotaInBytes"`
}

type VolumeRenameRequest

type VolumeRenameRequest struct {
	Name          string `json:"name"`
	Region        string `json:"region"`
	CreationToken string `json:"creationToken"`
	ServiceLevel  string `json:"serviceLevel"`
	QuotaInBytes  int64  `json:"quotaInBytes"`
}

type VolumeResizeRequest

type VolumeResizeRequest struct {
	Region        string   `json:"region"`
	CreationToken string   `json:"creationToken"`
	ProtocolTypes []string `json:"protocolTypes"`
	QuotaInBytes  int64    `json:"quotaInBytes"`
	ServiceLevel  string   `json:"serviceLevel"`
}

type WeeklySchedule

type WeeklySchedule struct {
	Day             string `json:"day"`
	Hour            int    `json:"hour"`
	Minute          int    `json:"minute"`
	SnapshotsToKeep int    `json:"snapshotsToKeep"`
}

Jump to

Keyboard shortcuts

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