tables

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

README

Table Storage Tables SDK for API version 2023-11-03

This package allows you to interact with the Tables Table Storage API

Supported Authorizers

  • SharedKeyLite (Table)

Example Usage

package main

import (
	"context"
	"fmt"

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

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

	auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKeyTable)
	if err != nil {
		return fmt.Errorf("building SharedKey authorizer: %+v", err)
	}
    tablesClient, err := tables.NewWithBaseUri(fmt.Sprintf("https://%s.table.%s", accountName, domainSuffix))
	if err != nil {
		return fmt.Errorf("building client for environment: %+v", err)
	}
	tablesClient.Client.SetAuthorizer(auth)
    
    ctx := context.TODO()
    if _, err := tablesClient.Create(ctx, tableName); err != nil {
        return fmt.Errorf("Error creating Table: %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 Client

type Client struct {
	Client *storage.Client
}

Client is the base client for Table Storage Shares.

func NewWithBaseUri

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

func (Client) Create

func (c Client) Create(ctx context.Context, tableName string) (result CreateTableResponse, err error)

Create creates a new table in the storage account.

func (Client) Delete

func (c Client) Delete(ctx context.Context, tableName string) (result DeleteTableResponse, err error)

Delete deletes the specified table and any data it contains.

func (Client) Exists

func (c Client) Exists(ctx context.Context, tableName string) (result TableExistsResponse, err error)

Exists checks that the specified table exists

func (Client) GetACL

func (c Client) GetACL(ctx context.Context, tableName string) (result GetACLResponse, err error)

GetACL returns the Access Control List for the specified Table

func (Client) GetResourceManagerResourceID

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

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

func (Client) Query

func (c Client) Query(ctx context.Context, input QueryInput) (result GetResponse, err error)

Query returns a list of tables under the specified account.

func (Client) SetACL

func (c Client) SetACL(ctx context.Context, tableName string, acls []SignedIdentifier) (result SetACLResponse, err error)

SetACL sets the specified Access Control List for the specified Table

type CreateTableResponse

type CreateTableResponse struct {
	HttpResponse *http.Response
}

type DeleteTableResponse

type DeleteTableResponse struct {
	HttpResponse *http.Response
}

type GetACLResponse

type GetACLResponse struct {
	HttpResponse *http.Response

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

type GetResponse

type GetResponse struct {
	HttpResponse *http.Response

	MetaData string          `json:"odata.metadata,omitempty"`
	Tables   []GetResultItem `json:"value"`
}

type GetResultItem

type GetResultItem struct {
	TableName string `json:"TableName"`

	// Optional, depending on the MetaData Level
	ODataType     string `json:"odata.type,omitempty"`
	ODataID       string `json:"odata.id,omitEmpty"`
	ODataEditLink string `json:"odata.editLink,omitEmpty"`
}

type MetaDataLevel

type MetaDataLevel string
var (
	NoMetaData      MetaDataLevel = "nometadata"
	MinimalMetaData MetaDataLevel = "minimalmetadata"
	FullMetaData    MetaDataLevel = "fullmetadata"
)

type QueryInput

type QueryInput struct {
	MetaDataLevel MetaDataLevel
}

type SetACLResponse

type SetACLResponse struct {
	HttpResponse *http.Response
}

type SignedIdentifier

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

type StorageTable

type StorageTable interface {
	Delete(ctx context.Context, tableName string) (resp DeleteTableResponse, err error)
	Exists(ctx context.Context, tableName string) (resp TableExistsResponse, err error)
	GetACL(ctx context.Context, tableName string) (resp GetACLResponse, err error)
	Create(ctx context.Context, tableName string) (resp CreateTableResponse, err error)
	GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, tableName string) string
	Query(ctx context.Context, input QueryInput) (resp GetResponse, err error)
	SetACL(ctx context.Context, tableName string, acls []SignedIdentifier) (resp SetACLResponse, err error)
}

type TableExistsResponse

type TableExistsResponse struct {
	HttpResponse *http.Response
}

type TableId added in v0.22.0

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

	// TableName specifies the name of this Table.
	TableName string
}

func NewTableID added in v0.22.0

func NewTableID(accountId accounts.AccountId, tableName string) TableId

func ParseTableID added in v0.22.0

func ParseTableID(input, domainSuffix string) (*TableId, error)

ParseTableID parses `input` into a Table ID using a known `domainSuffix`

func (TableId) ID added in v0.22.0

func (b TableId) ID() string

func (TableId) String added in v0.22.0

func (b TableId) String() string

Jump to

Keyboard shortcuts

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