directories

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 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"
	"time"
	
	"github.com/Azure/go-autorest/autorest"
	"github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories"
)

func Example() error {
	accountName := "storageaccount1"
    storageAccountKey := "ABC123...."
    shareName := "myshare"
    directoryName := "myfiles"
    
    storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
    directoriesClient := directories.New()
    directoriesClient.Client.Authorizer = storageAuth
    
    ctx := context.TODO()
    metadata := map[string]string{
    	"hello": "world",
    }
    if _, err := directoriesClient.Create(ctx, accountName, shareName, directoryName, metadata); err != nil {
        return fmt.Errorf("Error creating Directory: %s", err)
    }
    
    return nil 
}

Documentation

Index

Constants

View Source
const APIVersion = "2020-08-04"

APIVersion is the version of the API used for all Storage API Operations

Variables

This section is empty.

Functions

func UserAgent

func UserAgent() string

Types

type Client

type Client struct {
	autorest.Client
	BaseURI string
}

Client is the base client for File Storage Shares.

func New

func New() Client

New creates an instance of the Client client.

func NewWithEnvironment

func NewWithEnvironment(environment azure.Environment) Client

NewWithEnvironment creates an instance of the Client client.

func (Client) Create

func (client Client) Create(ctx context.Context, accountName, shareName, path string, input CreateDirectoryInput) (result autorest.Response, err error)

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

func (Client) CreatePreparer

func (client Client) CreatePreparer(ctx context.Context, accountName, shareName, path string, input CreateDirectoryInput) (*http.Request, error)

CreatePreparer prepares the Create request.

func (Client) CreateResponder

func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error)

CreateResponder handles the response to the Create request. The method always closes the http.Response Body.

func (Client) CreateSender

func (client Client) CreateSender(req *http.Request) (*http.Response, error)

CreateSender sends the Create request. The method will close the http.Response Body if it receives an error.

func (Client) Delete

func (client Client) Delete(ctx context.Context, accountName, shareName, path string) (result autorest.Response, err error)

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

func (Client) DeletePreparer

func (client Client) DeletePreparer(ctx context.Context, accountName, shareName, path string) (*http.Request, error)

DeletePreparer prepares the Delete request.

func (Client) DeleteResponder

func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error)

DeleteResponder handles the response to the Delete request. The method always closes the http.Response Body.

func (Client) DeleteSender

func (client Client) DeleteSender(req *http.Request) (*http.Response, error)

DeleteSender sends the Delete request. The method will close the http.Response Body if it receives an error.

func (Client) Get

func (client Client) Get(ctx context.Context, accountName, shareName, path string) (result GetResult, 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 (client Client) GetMetaData(ctx context.Context, accountName, shareName, path string) (result GetMetaDataResult, err error)

GetMetaData returns all user-defined metadata for the specified directory

func (Client) GetMetaDataPreparer

func (client Client) GetMetaDataPreparer(ctx context.Context, accountName, shareName, path string) (*http.Request, error)

GetMetaDataPreparer prepares the GetMetaData request.

func (Client) GetMetaDataResponder

func (client Client) GetMetaDataResponder(resp *http.Response) (result GetMetaDataResult, err error)

GetMetaDataResponder handles the response to the GetMetaData request. The method always closes the http.Response Body.

func (Client) GetMetaDataSender

func (client Client) GetMetaDataSender(req *http.Request) (*http.Response, error)

GetMetaDataSender sends the GetMetaData request. The method will close the http.Response Body if it receives an error.

func (Client) GetPreparer

func (client Client) GetPreparer(ctx context.Context, accountName, shareName, path string) (*http.Request, error)

GetPreparer prepares the Get request.

func (Client) GetResourceID

func (client Client) GetResourceID(accountName, shareName, directoryName string) string

GetResourceID returns the Resource ID for the given Directory This can be useful when, for example, you're using this as a unique identifier

func (Client) GetResponder

func (client Client) GetResponder(resp *http.Response) (result GetResult, err error)

GetResponder handles the response to the Get request. The method always closes the http.Response Body.

func (Client) GetSender

func (client Client) GetSender(req *http.Request) (*http.Response, error)

GetSender sends the Get request. The method will close the http.Response Body if it receives an error.

func (Client) SetMetaData

func (client Client) SetMetaData(ctx context.Context, accountName, shareName, path string, metaData map[string]string) (result autorest.Response, err error)

SetMetaData updates user defined metadata for the specified directory

func (Client) SetMetaDataPreparer

func (client Client) SetMetaDataPreparer(ctx context.Context, accountName, shareName, path string, metaData map[string]string) (*http.Request, error)

SetMetaDataPreparer prepares the SetMetaData request.

func (Client) SetMetaDataResponder

func (client Client) SetMetaDataResponder(resp *http.Response) (result autorest.Response, err error)

SetMetaDataResponder handles the response to the SetMetaData request. The method always closes the http.Response Body.

func (Client) SetMetaDataSender

func (client Client) SetMetaDataSender(req *http.Request) (*http.Response, error)

SetMetaDataSender sends the SetMetaData request. The method will close the http.Response Body if it receives an error.

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 GetMetaDataResult

type GetMetaDataResult struct {
	autorest.Response

	MetaData map[string]string
}

type GetResult

type GetResult struct {
	autorest.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 ResourceID

type ResourceID struct {
	AccountName   string
	DirectoryName string
	ShareName     string
}

func ParseResourceID

func ParseResourceID(id string) (*ResourceID, error)

ParseResourceID parses the Resource ID into an Object which can be used to interact with the Directory within the File Share

type StorageDirectory

type StorageDirectory interface {
	Delete(ctx context.Context, accountName, shareName, path string) (result autorest.Response, err error)
	GetMetaData(ctx context.Context, accountName, shareName, path string) (result GetMetaDataResult, err error)
	SetMetaData(ctx context.Context, accountName, shareName, path string, metaData map[string]string) (result autorest.Response, err error)
	Create(ctx context.Context, accountName, shareName, path string, input CreateDirectoryInput) (result autorest.Response, err error)
	GetResourceID(accountName, shareName, directoryName string) string
	Get(ctx context.Context, accountName, shareName, path string) (result GetResult, err error)
}

Jump to

Keyboard shortcuts

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