entities

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

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

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

Supported Authorizers

  • SharedKeyLite (Table)

Example Usage

package main

import (
	"context"
	"fmt"

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

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)
	}
	
    entitiesClient, err := entities.NewWithBaseUri(fmt.Sprintf("https://%s.table.%s", accountName, domainSuffix))
	if err != nil {
		return fmt.Errorf("building client for environment: %+v", err)
	}
	entitiesClient.Client.SetAuthorizer(auth)
    
    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, tableName, input); err != nil {
        return fmt.Errorf("Error creating Entity: %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 Table Storage Shares.

func NewWithBaseUri

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

func (Client) Delete

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

Delete deletes an existing entity in a table.

func (Client) Get

func (c Client) Get(ctx context.Context, tableName string, input GetEntityInput) (result GetEntityResponse, err error)

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

func (Client) Insert

func (c Client) Insert(ctx context.Context, tableName string, input InsertEntityInput) (result InsertResponse, err error)

Insert inserts a new entity into a table.

func (Client) InsertOrMerge

func (c Client) InsertOrMerge(ctx context.Context, tableName string, input InsertOrMergeEntityInput) (result InsertOrMergeResponse, 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) InsertOrReplace

func (c Client) InsertOrReplace(ctx context.Context, tableName string, input InsertOrReplaceEntityInput) (result InsertOrReplaceResponse, 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) Query

func (c Client) Query(ctx context.Context, tableName string, input QueryEntitiesInput) (result QueryEntitiesResponse, err error)

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

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 DeleteEntityResponse

type DeleteEntityResponse struct {
	HttpResponse *http.Response
}

type EntityId

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

	// TableName specifies the name of the Table where this Entity exists.
	TableName string

	// PartitionKey specifies the Partition Key for this Entity.
	PartitionKey string

	// RowKey specifies the Row Key for this Entity.
	RowKey string
}

func NewEntityID

func NewEntityID(accountId accounts.AccountId, tableName, partitionKey, rowKey string) EntityId

func ParseEntityID

func ParseEntityID(input, domainSuffix string) (*EntityId, error)

ParseEntityID parses `input` into a Entity ID using a known `domainSuffix`

func (EntityId) ID

func (b EntityId) ID() string

func (EntityId) String

func (b EntityId) String() string

type GetEntityInput

type GetEntityInput struct {
	PartitionKey string
	RowKey       string

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

type GetEntityResponse

type GetEntityResponse struct {
	HttpResponse *http.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 InsertOrMergeResponse

type InsertOrMergeResponse struct {
	HttpResponse *http.Response
}

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 InsertOrReplaceResponse

type InsertOrReplaceResponse struct {
	HttpResponse *http.Response
}

type InsertResponse

type InsertResponse struct {
	HttpResponse *http.Response
}

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 QueryEntitiesResponse

type QueryEntitiesResponse struct {
	HttpResponse *http.Response

	NextPartitionKey string
	NextRowKey       string

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

type StorageTableEntity

type StorageTableEntity interface {
	Delete(ctx context.Context, tableName string, input DeleteEntityInput) (resp DeleteEntityResponse, err error)
	Insert(ctx context.Context, tableName string, input InsertEntityInput) (resp InsertResponse, err error)
	InsertOrReplace(ctx context.Context, tableName string, input InsertOrReplaceEntityInput) (resp InsertOrReplaceResponse, err error)
	InsertOrMerge(ctx context.Context, tableName string, input InsertOrMergeEntityInput) (resp InsertOrMergeResponse, err error)
	Query(ctx context.Context, tableName string, input QueryEntitiesInput) (resp QueryEntitiesResponse, err error)
	Get(ctx context.Context, tableName string, input GetEntityInput) (resp GetEntityResponse, err error)
}

Jump to

Keyboard shortcuts

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