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

README

File Storage Directories SDK for API version 2020-08-04

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/2020-08-04/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 added in v0.21.0

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

func (Client) Create

func (c Client) Create(ctx context.Context, shareName, path string, input CreateDirectoryInput) (resp 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) (resp 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) (resp 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) (resp 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) (resp 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 added in v0.21.0

type CreateDirectoryResponse struct {
	HttpResponse *client.Response
}

type CreateOptions added in v0.21.0

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

func (CreateOptions) ToHeaders added in v0.21.0

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

func (CreateOptions) ToOData added in v0.21.0

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

func (CreateOptions) ToQuery added in v0.21.0

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

type DeleteResponse added in v0.21.0

type DeleteResponse struct {
	HttpResponse *client.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 GetMetaDataOptions added in v0.21.0

type GetMetaDataOptions struct{}

func (GetMetaDataOptions) ToHeaders added in v0.21.0

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

func (GetMetaDataOptions) ToOData added in v0.21.0

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

func (GetMetaDataOptions) ToQuery added in v0.21.0

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

type GetMetaDataResponse added in v0.21.0

type GetMetaDataResponse struct {
	HttpResponse *client.Response

	MetaData map[string]string
}

type GetResponse added in v0.21.0

type GetResponse struct {
	HttpResponse *client.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 added in v0.21.0

type SetMetaDataInput struct {
	MetaData map[string]string
}

type SetMetaDataOptions added in v0.21.0

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

func (SetMetaDataOptions) ToHeaders added in v0.21.0

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

func (SetMetaDataOptions) ToOData added in v0.21.0

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

func (SetMetaDataOptions) ToQuery added in v0.21.0

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

type SetMetaDataResponse added in v0.21.0

type SetMetaDataResponse struct {
	HttpResponse *client.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