entities

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

Table Storage Entities SDK for API version 2020-08-04

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

Supported Authorizers

  • SharedKeyLite (Table)

Example Usage

package main

import (
	"context"
	"fmt"
	"time"
	
	"github.com/Azure/go-autorest/autorest"
	"github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities"
)

func Example() error {
	accountName := "storageaccount1"
    storageAccountKey := "ABC123...."
    tableName := "mytable"
    
    storageAuth := autorest.NewSharedKeyLiteTableAuthorizer(accountName, storageAccountKey)
    entitiesClient := entities.New()
    entitiesClient.Client.Authorizer = storageAuth
    
    ctx := context.TODO()
    input := entities.InsertEntityInput{
    	PartitionKey: "abc",
    	RowKey: "123",
    	MetaDataLevel: entities.NoMetaData,
    	Entity: map[string]interface{}{
    	    "title": "Don't Kill My Vibe",
    	    "artist": "Sigrid",
    	},
    }
    if _, err := entitiesClient.Insert(ctx, accountName, tableName, input); err != nil {
        return fmt.Errorf("Error creating Entity: %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 Table 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) Delete

func (client Client) Delete(ctx context.Context, accountName, tableName string, input DeleteEntityInput) (result autorest.Response, err error)

Delete deletes an existing entity in a table.

func (Client) DeletePreparer

func (client Client) DeletePreparer(ctx context.Context, accountName, tableName string, input DeleteEntityInput) (*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, tableName string, input GetEntityInput) (result GetEntityResult, err error)

Get queries entities in a table and includes the $filter and $select options.

func (Client) GetPreparer

func (client Client) GetPreparer(ctx context.Context, accountName, tableName string, input GetEntityInput) (*http.Request, error)

GetPreparer prepares the Get request.

func (Client) GetResourceID

func (client Client) GetResourceID(accountName, tableName, partitionKey, rowKey string) string

GetResourceID returns the Resource ID for the given Entity 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 GetEntityResult, 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) Insert

func (client Client) Insert(ctx context.Context, accountName, tableName string, input InsertEntityInput) (result autorest.Response, err error)

Insert inserts a new entity into a table.

func (Client) InsertOrMerge

func (client Client) InsertOrMerge(ctx context.Context, accountName, tableName string, input InsertOrMergeEntityInput) (result autorest.Response, err error)

InsertOrMerge updates an existing entity or inserts a new entity if it does not exist in the table. Because this operation can insert or update an entity, it is also known as an upsert operation.

func (Client) InsertOrMergePreparer

func (client Client) InsertOrMergePreparer(ctx context.Context, accountName, tableName string, input InsertOrMergeEntityInput) (*http.Request, error)

InsertOrMergePreparer prepares the InsertOrMerge request.

func (Client) InsertOrMergeResponder

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

InsertOrMergeResponder handles the response to the InsertOrMerge request. The method always closes the http.Response Body.

func (Client) InsertOrMergeSender

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

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

func (Client) InsertOrReplace

func (client Client) InsertOrReplace(ctx context.Context, accountName, tableName string, input InsertOrReplaceEntityInput) (result autorest.Response, err error)

InsertOrReplace replaces an existing entity or inserts a new entity if it does not exist in the table. Because this operation can insert or update an entity, it is also known as an upsert operation.

func (Client) InsertOrReplacePreparer

func (client Client) InsertOrReplacePreparer(ctx context.Context, accountName, tableName string, input InsertOrReplaceEntityInput) (*http.Request, error)

InsertOrReplacePreparer prepares the InsertOrReplace request.

func (Client) InsertOrReplaceResponder

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

InsertOrReplaceResponder handles the response to the InsertOrReplace request. The method always closes the http.Response Body.

func (Client) InsertOrReplaceSender

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

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

func (Client) InsertPreparer

func (client Client) InsertPreparer(ctx context.Context, accountName, tableName string, input InsertEntityInput) (*http.Request, error)

InsertPreparer prepares the Insert request.

func (Client) InsertResponder

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

InsertResponder handles the response to the Insert request. The method always closes the http.Response Body.

func (Client) InsertSender

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

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

func (Client) Query

func (client Client) Query(ctx context.Context, accountName, tableName string, input QueryEntitiesInput) (result QueryEntitiesResult, err error)

Query queries entities in a table and includes the $filter and $select options.

func (Client) QueryPreparer

func (client Client) QueryPreparer(ctx context.Context, accountName, tableName string, input QueryEntitiesInput) (*http.Request, error)

QueryPreparer prepares the Query request.

func (Client) QueryResponder

func (client Client) QueryResponder(resp *http.Response) (result QueryEntitiesResult, err error)

QueryResponder handles the response to the Query request. The method always closes the http.Response Body.

func (Client) QuerySender

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

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

type DeleteEntityInput

type DeleteEntityInput struct {
	// When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties.
	// Together, these properties form the primary key and must be unique within the table.
	// Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size.
	// If you are using an integer value for the key value, you should convert the integer to a fixed-width string,
	// because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting.
	RowKey       string
	PartitionKey string
}

type GetEntityInput

type GetEntityInput struct {
	PartitionKey string
	RowKey       string

	// The Level of MetaData which should be returned
	MetaDataLevel MetaDataLevel
}

type GetEntityResult

type GetEntityResult struct {
	autorest.Response

	Entity map[string]interface{}
}

type InsertEntityInput

type InsertEntityInput struct {
	// The level of MetaData provided for this Entity
	MetaDataLevel MetaDataLevel

	// The Entity which should be inserted, by default all values are strings
	// To explicitly type a property, specify the appropriate OData data type by setting
	// the m:type attribute within the property definition
	Entity map[string]interface{}

	// When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties.
	// Together, these properties form the primary key and must be unique within the table.
	// Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size.
	// If you are using an integer value for the key value, you should convert the integer to a fixed-width string,
	// because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting.
	RowKey       string
	PartitionKey string
}

type InsertOrMergeEntityInput

type InsertOrMergeEntityInput struct {
	// The Entity which should be inserted, by default all values are strings
	// To explicitly type a property, specify the appropriate OData data type by setting
	// the m:type attribute within the property definition
	Entity map[string]interface{}

	// When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties.
	// Together, these properties form the primary key and must be unique within the table.
	// Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size.
	// If you are using an integer value for the key value, you should convert the integer to a fixed-width string,
	// because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting.
	RowKey       string
	PartitionKey string
}

type InsertOrReplaceEntityInput

type InsertOrReplaceEntityInput struct {
	// The Entity which should be inserted, by default all values are strings
	// To explicitly type a property, specify the appropriate OData data type by setting
	// the m:type attribute within the property definition
	Entity map[string]interface{}

	// When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties.
	// Together, these properties form the primary key and must be unique within the table.
	// Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size.
	// If you are using an integer value for the key value, you should convert the integer to a fixed-width string,
	// because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting.
	RowKey       string
	PartitionKey string
}

type MetaDataLevel

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

type QueryEntitiesInput

type QueryEntitiesInput struct {
	// An optional OData filter
	Filter *string

	// An optional comma-separated
	PropertyNamesToSelect *[]string

	// An optional OData top
	Top *int

	PartitionKey string
	RowKey       string

	// The Level of MetaData which should be returned
	MetaDataLevel MetaDataLevel

	// The Next Partition Key used to load data from a previous point
	NextPartitionKey *string

	// The Next Row Key used to load data from a previous point
	NextRowKey *string
}

type QueryEntitiesResult

type QueryEntitiesResult struct {
	autorest.Response

	NextPartitionKey string
	NextRowKey       string

	MetaData string                   `json:"odata.metadata,omitempty"`
	Entities []map[string]interface{} `json:"value"`
}

type ResourceID

type ResourceID struct {
	AccountName  string
	TableName    string
	PartitionKey string
	RowKey       string
}

func ParseResourceID

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

ParseResourceID parses the specified Resource ID and returns an object which can be used to look up the specified Entity within the specified Table

type StorageTableEntity

type StorageTableEntity interface {
	Delete(ctx context.Context, accountName, tableName string, input DeleteEntityInput) (result autorest.Response, err error)
	Insert(ctx context.Context, accountName, tableName string, input InsertEntityInput) (result autorest.Response, err error)
	InsertOrReplace(ctx context.Context, accountName, tableName string, input InsertOrReplaceEntityInput) (result autorest.Response, err error)
	InsertOrMerge(ctx context.Context, accountName, tableName string, input InsertOrMergeEntityInput) (result autorest.Response, err error)
	Query(ctx context.Context, accountName, tableName string, input QueryEntitiesInput) (result QueryEntitiesResult, err error)
	Get(ctx context.Context, accountName, tableName string, input GetEntityInput) (result GetEntityResult, err error)
	GetResourceID(accountName, tableName, partitionKey, rowKey string) string
}

Jump to

Keyboard shortcuts

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