shares

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

File Storage Shares SDK for API version 2023-11-03

This package allows you to interact with the Shares File Storage API

Supported Authorizers

  • Azure Active Directory (for the Resource Endpoint https://storage.azure.com)
  • SharedKeyLite (Blob, File & Queue)

Example Usage

package main

import (
	"context"
	"fmt"

	"github.com/hashicorp/go-azure-sdk/sdk/auth"
	"github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares"
)

func Example() error {
	accountName := "storageaccount1"
    storageAccountKey := "ABC123...."
    shareName := "myshare"
	domainSuffix := "core.windows.net"

	auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
	if err != nil {
		return fmt.Errorf("building SharedKey authorizer: %+v", err)
	}
	
    sharesClient, err := shares.NewWithBaseUri(fmt.Sprintf("https://%s.file.%s", accountName, domainSuffix))
	if err != nil {
		return fmt.Errorf("building SharedKey authorizer: %+v", err)
	}
    sharesClient.Client.SetAuthorizer(auth)
    
    ctx := context.TODO()
    input := shares.CreateInput{
    	QuotaInGB: 2,
    }
    if _, err := sharesClient.Create(ctx, shareName, input); err != nil {
        return fmt.Errorf("Error creating Share: %s", err)
    }
    
    return nil 
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessPolicy

type AccessPolicy struct {
	Start      string `xml:"Start"`
	Expiry     string `xml:"Expiry"`
	Permission string `xml:"Permission"`
}

type AccessTier

type AccessTier string
const (
	TransactionOptimizedAccessTier AccessTier = "TransactionOptimized"
	HotAccessTier                  AccessTier = "Hot"
	CoolAccessTier                 AccessTier = "Cool"
	PremiumAccessTier              AccessTier = "Premium"
)

type Client

type Client struct {
	Client *storage.Client
}

Client is the base client for File Storage Shares.

func NewWithBaseUri

func NewWithBaseUri(baseUri string) (*Client, error)

func (Client) Create

func (c Client) Create(ctx context.Context, shareName string, input CreateInput) (result CreateResponse, err error)

Create creates the specified Storage Share within the specified Storage Account

func (Client) CreateSnapshot

func (c Client) CreateSnapshot(ctx context.Context, shareName string, input CreateSnapshotInput) (result CreateSnapshotResponse, err error)

CreateSnapshot creates a read-only snapshot of the share A share can support creation of 200 share snapshots. Attempting to create more than 200 share snapshots fails with 409 (Conflict). Attempting to create a share snapshot while a previous Snapshot Share operation is in progress fails with 409 (Conflict).

func (Client) Delete

func (c Client) Delete(ctx context.Context, shareName string, input DeleteInput) (result DeleteResponse, err error)

Delete deletes the specified Storage Share from within a Storage Account

func (Client) DeleteSnapshot

func (c Client) DeleteSnapshot(ctx context.Context, accountName, shareName string, shareSnapshot string) (result DeleteSnapshotResponse, err error)

DeleteSnapshot deletes the specified Snapshot of a Storage Share

func (Client) GetACL

func (c Client) GetACL(ctx context.Context, shareName string) (result GetACLResult, err error)

GetACL get the Access Control List for the specified Storage Share

func (Client) GetMetaData

func (c Client) GetMetaData(ctx context.Context, shareName string) (result GetMetaDataResponse, err error)

GetMetaData returns the MetaData associated with the specified Storage Share

func (Client) GetProperties

func (c Client) GetProperties(ctx context.Context, shareName string) (result GetPropertiesResult, err error)

GetProperties returns the properties about the specified Storage Share

func (Client) GetResourceManagerResourceID

func (c Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, shareName string) string

GetResourceManagerResourceID returns the Resource Manager specific ResourceID for a specific Storage Share

func (Client) GetSnapshot

func (c Client) GetSnapshot(ctx context.Context, shareName string, input GetSnapshotPropertiesInput) (result GetSnapshotPropertiesResponse, err error)

GetSnapshot gets information about the specified Snapshot of the specified Storage Share

func (Client) GetStats

func (c Client) GetStats(ctx context.Context, shareName string) (result GetStatsResponse, err error)

GetStats returns information about the specified Storage Share

func (Client) SetACL

func (c Client) SetACL(ctx context.Context, shareName string, input SetAclInput) (result SetAclResponse, err error)

SetACL sets the specified Access Control List on the specified Storage Share

func (Client) SetMetaData

func (c Client) SetMetaData(ctx context.Context, shareName string, input SetMetaDataInput) (result SetMetaDataResponse, err error)

SetMetaData sets the MetaData on the specified Storage Share

func (Client) SetProperties

func (c Client) SetProperties(ctx context.Context, shareName string, properties ShareProperties) (result SetPropertiesResponse, err error)

SetProperties lets you update the Quota for the specified Storage Share

type CreateInput

type CreateInput struct {
	// Specifies the maximum size of the share, in gigabytes.
	// Must be greater than 0, and less than or equal to 5TB (5120).
	QuotaInGB int

	// Specifies the enabled protocols on the share. If not specified, the default is SMB.
	EnabledProtocol ShareProtocol

	MetaData map[string]string

	// Specifies the access tier of the share.
	AccessTier *AccessTier
}

type CreateOptions

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

func (CreateOptions) ToHeaders

func (c CreateOptions) ToHeaders() *client.Headers

func (CreateOptions) ToOData

func (c CreateOptions) ToOData() *odata.Query

func (CreateOptions) ToQuery

func (c CreateOptions) ToQuery() *client.QueryParams

type CreateResponse

type CreateResponse struct {
	HttpResponse *http.Response
}

type CreateSnapshotInput

type CreateSnapshotInput struct {
	MetaData map[string]string
}

type CreateSnapshotResponse

type CreateSnapshotResponse struct {
	HttpResponse *http.Response

	// This header is a DateTime value that uniquely identifies the share snapshot.
	// The value of this header may be used in subsequent requests to access the share snapshot.
	// This value is opaque.
	SnapshotDateTime string
}

type DeleteInput

type DeleteInput struct {
	DeleteSnapshots bool
}

type DeleteOptions

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

func (DeleteOptions) ToHeaders

func (d DeleteOptions) ToHeaders() *client.Headers

func (DeleteOptions) ToOData

func (d DeleteOptions) ToOData() *odata.Query

func (DeleteOptions) ToQuery

func (d DeleteOptions) ToQuery() *client.QueryParams

type DeleteResponse

type DeleteResponse struct {
	HttpResponse *http.Response
}

type DeleteSnapshotResponse

type DeleteSnapshotResponse struct {
	HttpResponse *http.Response
}

type ErrorResponse added in v0.24.0

type ErrorResponse struct {
	XMLName xml.Name `xml:"Error"`
	Code    *string  `xml:"Code"`
	Message *string  `xml:"Message"`
}

type GetACLResult

type GetACLResult struct {
	HttpResponse *http.Response

	SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"`
}

type GetMetaDataOptions

type GetMetaDataOptions struct{}

func (GetMetaDataOptions) ToHeaders

func (g GetMetaDataOptions) ToHeaders() *client.Headers

func (GetMetaDataOptions) ToOData

func (g GetMetaDataOptions) ToOData() *odata.Query

func (GetMetaDataOptions) ToQuery

func (g GetMetaDataOptions) ToQuery() *client.QueryParams

type GetMetaDataResponse

type GetMetaDataResponse struct {
	HttpResponse *http.Response

	MetaData map[string]string
}

type GetPropertiesResult

type GetPropertiesResult struct {
	HttpResponse *http.Response

	MetaData        map[string]string
	QuotaInGB       int
	EnabledProtocol ShareProtocol
	AccessTier      *AccessTier
}

type GetSnapshotPropertiesInput

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

type GetSnapshotPropertiesResponse

type GetSnapshotPropertiesResponse struct {
	HttpResponse *http.Response

	MetaData map[string]string
}

type GetStatsResponse

type GetStatsResponse struct {
	HttpResponse *http.Response

	// The approximate size of the data stored on the share.
	// Note that this value may not include all recently created or recently resized files.
	ShareUsageBytes int64 `xml:"ShareUsageBytes"`
}

type SetAclInput

type SetAclInput struct {
	SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"`
	XMLName           xml.Name           `xml:"SignedIdentifiers"`
}

type SetAclResponse

type SetAclResponse struct {
	HttpResponse *http.Response
}

type SetMetaDataInput

type SetMetaDataInput struct {
	MetaData map[string]string
}

type SetMetaDataOptions

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

func (SetMetaDataOptions) ToHeaders

func (s SetMetaDataOptions) ToHeaders() *client.Headers

func (SetMetaDataOptions) ToOData

func (s SetMetaDataOptions) ToOData() *odata.Query

func (SetMetaDataOptions) ToQuery

func (s SetMetaDataOptions) ToQuery() *client.QueryParams

type SetMetaDataResponse

type SetMetaDataResponse struct {
	HttpResponse *http.Response
}

type SetPropertiesOptions

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

func (SetPropertiesOptions) ToHeaders

func (s SetPropertiesOptions) ToHeaders() *client.Headers

func (SetPropertiesOptions) ToOData

func (s SetPropertiesOptions) ToOData() *odata.Query

func (SetPropertiesOptions) ToQuery

type SetPropertiesResponse

type SetPropertiesResponse struct {
	HttpResponse *http.Response
}

type ShareId added in v0.22.0

type ShareId struct {
	// AccountId specifies the ID of the Storage Account where this File Share exists.
	AccountId accounts.AccountId

	// ShareName specifies the name of this File Share.
	ShareName string
}

func NewShareID added in v0.22.0

func NewShareID(accountId accounts.AccountId, shareName string) ShareId

func ParseShareID added in v0.22.0

func ParseShareID(input, domainSuffix string) (*ShareId, error)

ParseShareID parses `input` into a Share ID using a known `domainSuffix`

func (ShareId) ID added in v0.22.0

func (b ShareId) ID() string

func (ShareId) String added in v0.22.0

func (b ShareId) String() string

type ShareProperties

type ShareProperties struct {
	QuotaInGb  *int
	AccessTier *AccessTier
}

type ShareProtocol

type ShareProtocol string
const (
	// SMB indicates the share can be accessed by SMBv3.0, SMBv2.1 and REST.
	SMB ShareProtocol = "SMB"

	// NFS indicates the share can be accessed by NFSv4.1. A premium account is required for this option.
	NFS ShareProtocol = "NFS"
)

type SignedIdentifier

type SignedIdentifier struct {
	Id           string       `xml:"Id"`
	AccessPolicy AccessPolicy `xml:"AccessPolicy"`
}

type StorageShare

type StorageShare interface {
	SetACL(ctx context.Context, shareName string, input SetAclInput) (SetAclResponse, error)
	GetSnapshot(ctx context.Context, shareName string, input GetSnapshotPropertiesInput) (GetSnapshotPropertiesResponse, error)
	GetStats(ctx context.Context, shareName string) (GetStatsResponse, error)
	GetACL(ctx context.Context, shareName string) (GetACLResult, error)
	SetMetaData(ctx context.Context, shareName string, input SetMetaDataInput) (SetMetaDataResponse, error)
	GetMetaData(ctx context.Context, shareName string) (GetMetaDataResponse, error)
	SetProperties(ctx context.Context, shareName string, properties ShareProperties) (SetPropertiesResponse, error)
	DeleteSnapshot(ctx context.Context, accountName string, shareName string, shareSnapshot string) (DeleteSnapshotResponse, error)
	CreateSnapshot(ctx context.Context, shareName string, input CreateSnapshotInput) (CreateSnapshotResponse, error)
	GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, shareName string) string
	GetProperties(ctx context.Context, shareName string) (GetPropertiesResult, error)
	Delete(ctx context.Context, shareName string, input DeleteInput) (DeleteResponse, error)
	Create(ctx context.Context, shareName string, input CreateInput) (CreateResponse, error)
}

Jump to

Keyboard shortcuts

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