accounts

package
v0.25.3 Latest Latest
Warning

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

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

README

Blob Storage Account SDK for API version 2023-11-03

This package allows you to interact with the Accounts Blob Storage API

Supported Authorizers

  • Azure Active Directory

Example Usage

package main

import (
	"context"
	"fmt"
	"time"
	
	"github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts"
)

func Example() error {
	accountName := "storageaccount1"
    
    // e.g. https://github.com/tombuildsstuff/giovanni/blob/76f5f686c99ecdcc3fa533a0330d0e1aacb1c327/example/azuread-auth/main.go#L54
    client, err := buildClient()
    if err != nil {
    	return fmt.Errorf("error building client: %s", err)
    }
    
    ctx := context.TODO()
    
    input := StorageServiceProperties{
        StaticWebsite: &StaticWebsite{
            Enabled:              true,
            IndexDocument:        index,
            ErrorDocument404Path: errorDocument,
        },
    }
    
    _, err = client.SetServiceProperties(ctx, accountName, input)
    if err != nil {
        return fmt.Errorf("error setting properties: %s", err)
    }
    
    time.Sleep(2 * time.Second)
    
    _, err = accountsClient.GetServiceProperties(ctx, accountName)
    if err != nil {
        return fmt.Errorf("error getting properties: %s", err)
    }
    
    return nil 
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountId added in v0.22.0

type AccountId struct {
	AccountName   string
	ZoneName      *string
	SubDomainType SubDomainType
	DomainSuffix  string
	IsEdgeZone    bool
}

func ParseAccountID added in v0.22.0

func ParseAccountID(input, domainSuffix string) (*AccountId, error)

func (AccountId) ID added in v0.22.0

func (a AccountId) ID() string

func (AccountId) String added in v0.22.0

func (a AccountId) String() string

type Client

type Client struct {
	Client *storage.Client
}

Client is the base client for Blob Storage Blobs.

func NewWithBaseUri

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

func (Client) GetServiceProperties

func (c Client) GetServiceProperties(ctx context.Context, accountName string) (result GetServicePropertiesResult, err error)

func (Client) SetServiceProperties

func (c Client) SetServiceProperties(ctx context.Context, accountName string, input StorageServiceProperties) (result SetServicePropertiesResult, err error)

type CorsRule

type CorsRule struct {
	// AllowedOrigins - Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "" to allow all domains
	AllowedOrigins []string `xml:"AllowedOrigins,omitempty"`
	// AllowedMethods - Required if CorsRule element is present. A list of HTTP methods that are allowed to be executed by the origin.
	AllowedMethods []string `xml:"AllowedMethods,omitempty"`
	// MaxAgeInSeconds - Required if CorsRule element is present. The number of seconds that the client/browser should cache a preflight response.
	MaxAgeInSeconds int32 `xml:"MaxAgeInSeconds,omitempty"`
	// ExposedHeaders - Required if CorsRule element is present. A list of response headers to expose to CORS clients.
	ExposedHeaders []string `xml:"ExposedHeaders,omitempty"`
	// AllowedHeaders - Required if CorsRule element is present. A list of headers allowed to be part of the cross-origin request.
	AllowedHeaders []string `xml:"AllowedHeaders,omitempty"`
}

CorsRule specifies a CORS rule for the Blob service.

type CorsRules

type CorsRules struct {
	// CorsRules - The List of CORS rules. You can include up to five CorsRule elements in the request.
	CorsRules []CorsRule `xml:"CorsRules,omitempty"`
}

CorsRules sets the CORS rules. You can include up to five CorsRule elements in the request.

type DeleteRetentionPolicy

type DeleteRetentionPolicy struct {
	// Enabled - Indicates whether DeleteRetentionPolicy is enabled for the Blob service.
	Enabled bool `xml:"Enabled,omitempty"`
	// Days - Indicates the number of days that the deleted blob should be retained. The minimum specified value can be 1 and the maximum value can be 365.
	Days int32 `xml:"Days,omitempty"`
}

DeleteRetentionPolicy the blob service properties for soft delete.

type GetServicePropertiesResult

type GetServicePropertiesResult struct {
	StorageServiceProperties
	HttpResponse *http.Response
}

type Logging

type Logging struct {
	Version         string                `xml:"Version"`
	Delete          bool                  `xml:"Delete"`
	Read            bool                  `xml:"Read"`
	Write           bool                  `xml:"Write"`
	RetentionPolicy DeleteRetentionPolicy `xml:"RetentionPolicy"`
}

Logging specifies the access logging options for the Blob service.

type MetricsConfig

type MetricsConfig struct {
	Version         string                `xml:"Version"`
	Enabled         bool                  `xml:"Enabled"`
	RetentionPolicy DeleteRetentionPolicy `xml:"RetentionPolicy"`
	IncludeAPIs     bool                  `xml:"IncludeAPIs"`
}

MetricsConfig specifies the hour and/or minute metrics options for the Blob service. Elements are all expected

type SetServicePropertiesResult

type SetServicePropertiesResult struct {
	HttpResponse *http.Response
}

type StaticWebsite

type StaticWebsite struct {
	// Enabled - Required. Indicates whether static website support is enabled for the given account.
	Enabled bool `xml:"Enabled"`
	// IndexDocument - Optional. The webpage that Azure Storage serves for requests to the root of a website or any subfolder. For example, index.html. The value is case-sensitive.
	IndexDocument string `xml:"IndexDocument,omitempty"`
	// ErrorDocument404Path - Optional. The absolute path to a webpage that Azure Storage serves for requests that do not correspond to an existing file. For example, error/404.html. Only a single custom 404 page is supported in each static website. The value is case-sensitive.
	ErrorDocument404Path string `xml:"ErrorDocument404Path,omitempty"`
}

StaticWebsite sets the static website support properties on the Blob service.

type StorageServiceProperties

type StorageServiceProperties struct {
	// Cors - Specifies CORS rules for the Blob service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Blob service.
	Cors *CorsRules `xml:"Cors,omitempty"`
	// DefaultServiceVersion - DefaultServiceVersion indicates the default version to use for requests to the Blob service if an incoming request’s version is not specified. Possible values include version 2008-10-27 and all more recent versions.
	DefaultServiceVersion *string `xml:"DefaultServiceVersion,omitempty"`
	// DeleteRetentionPolicy - The blob service properties for soft delete.
	DeleteRetentionPolicy *DeleteRetentionPolicy `xml:"DeleteRetentionPolicy,omitempty"`
	// Logging - The blob service properties for logging access
	Logging *Logging `xml:"Logging,omitempty"`
	// HourMetrics - The blob service properties for hour metrics
	HourMetrics *MetricsConfig `xml:"HourMetrics,omitempty"`
	// HourMetrics - The blob service properties for minute metrics
	MinuteMetrics *MetricsConfig `xml:"MinuteMetrics,omitempty"`
	// StaticWebsite - Optional
	StaticWebsite *StaticWebsite `xml:"StaticWebsite,omitempty"`
}

type SubDomainType added in v0.22.0

type SubDomainType string
const (
	BlobSubDomainType          SubDomainType = "blob"
	DataLakeStoreSubDomainType SubDomainType = "dfs"
	FileSubDomainType          SubDomainType = "file"
	QueueSubDomainType         SubDomainType = "queue"
	TableSubDomainType         SubDomainType = "table"
)

func PossibleValuesForSubDomainType added in v0.22.0

func PossibleValuesForSubDomainType() []SubDomainType

Jump to

Keyboard shortcuts

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