directories

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: 17 Imported by: 0

README

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

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

Supported Authorizers

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

Limitations

  • At this time the headers x-ms-file-permission and x-ms-file-attributes are hard-coded (to inherit and None, respectively).

Example Usage

package main

import (
	"context"
	"fmt"

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

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

	auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
	if err != nil {
		return fmt.Errorf("building SharedKey authorizer: %+v", err)
	}
	
    directoriesClient, err := directories.NewWithBaseUri(fmt.Sprintf("https://%s.dfs.%s", accountName, domainSuffix))
	if err != nil {
		return fmt.Errorf("building client for environment: %+v", err)
	}
    directoriesClient.Client.SetAuthorizer(auth)
    
    ctx := context.TODO()
    metadata := map[string]string{
    	"hello": "world",
    }
	
	input := directories.CreateDirectoryInput{
		MetaData: metadata,
    }
    if _, err := directoriesClient.Create(ctx, shareName, directoryName, input); err != nil {
        return fmt.Errorf("Error creating Directory: %s", err)
    }
    
    return nil 
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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, path string, input CreateDirectoryInput) (result CreateDirectoryResponse, err error)

Create creates a new directory under the specified share or parent directory.

func (Client) Delete

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

Delete removes the specified empty directory Note that the directory must be empty before it can be deleted.

func (Client) Get

func (c Client) Get(ctx context.Context, shareName, path string) (result GetResponse, err error)

Get returns all system properties for the specified directory, and can also be used to check the existence of a directory.

func (Client) GetMetaData

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

GetMetaData returns all user-defined metadata for the specified directory

func (Client) SetMetaData

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

SetMetaData updates user defined metadata for the specified directory

type CreateDirectoryInput

type CreateDirectoryInput struct {
	// The time at which this file was created at - if omitted, this'll be set to "now"
	// This maps to the `x-ms-file-creation-time` field.
	// ... Yes I know it says File not Directory, I didn't design the API.
	CreatedAt *time.Time

	// The time at which this file was last modified - if omitted, this'll be set to "now"
	// This maps to the `x-ms-file-last-write-time` field.
	// ... Yes I know it says File not Directory, I didn't design the API.
	LastModified *time.Time

	// MetaData is a mapping of key value pairs which should be assigned to this directory
	MetaData map[string]string
}

type CreateDirectoryResponse

type CreateDirectoryResponse struct {
	HttpResponse *http.Response
}

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 DeleteResponse

type DeleteResponse struct {
	HttpResponse *http.Response
}

type DirectoryId added in v0.22.0

type DirectoryId struct {
	// AccountId specifies the ID of the Storage Account where this Directory exists.
	AccountId accounts.AccountId

	// ShareName specifies the name of the File Share containing this Directory.
	ShareName string

	// DirectoryPath specifies the path representing this Directory.
	DirectoryPath string
}

func NewDirectoryID added in v0.22.0

func NewDirectoryID(accountId accounts.AccountId, shareName, directoryPath string) DirectoryId

func ParseDirectoryID added in v0.22.0

func ParseDirectoryID(input, domainSuffix string) (*DirectoryId, error)

ParseDirectoryID parses `input` into a Directory ID using a known `domainSuffix`

func (DirectoryId) ID added in v0.22.0

func (b DirectoryId) ID() string

func (DirectoryId) String added in v0.22.0

func (b DirectoryId) String() string

type ErrorResponse added in v0.25.4

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

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 GetResponse

type GetResponse struct {
	HttpResponse *http.Response

	// A set of name-value pairs that contain metadata for the directory.
	MetaData map[string]string

	// The value of this header is set to true if the directory metadata is completely
	// encrypted using the specified algorithm. Otherwise, the value is set to false.
	DirectoryMetaDataEncrypted bool
}

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 StorageDirectory

type StorageDirectory interface {
	Delete(ctx context.Context, shareName, path string) (resp DeleteResponse, err error)
	GetMetaData(ctx context.Context, shareName, path string) (resp GetMetaDataResponse, err error)
	SetMetaData(ctx context.Context, shareName, path string, input SetMetaDataInput) (resp SetMetaDataResponse, err error)
	Create(ctx context.Context, shareName, path string, input CreateDirectoryInput) (resp CreateDirectoryResponse, err error)
	Get(ctx context.Context, shareName, path string) (resp GetResponse, err error)
}

Jump to

Keyboard shortcuts

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