Documentation
¶
Index ¶
- Variables
- func IsErrorStatusCode(err error, statusCode int) bool
- func RetryOnHttpStatusOrError(f func() error, statusCode int, errorString ...string) (err error)
- func RetryOnPreconditionFailed(f func() error) (err error)
- type Authorizer
- type Collection
- type CollectionClient
- type CollectionIterator
- type Collections
- type CompositeIndex
- type ConflictResolutionPolicy
- type ConflictResolutionPolicyMode
- type Database
- type DatabaseClient
- type DatabaseIterator
- type Databases
- type Error
- type ExcludedPath
- type FakePersonClient
- func (c *FakePersonClient) ChangeFeed(*Options) PersonIterator
- func (c *FakePersonClient) Create(ctx context.Context, partitionkey string, person *pkg.Person, options *Options) (*pkg.Person, error)
- func (c *FakePersonClient) Delete(ctx context.Context, partitionKey string, person *pkg.Person, options *Options) error
- func (c *FakePersonClient) ExecuteStoredProcedure(ctx context.Context, sprocsid string, partitionkey string, parameters []string, ...) (err error)
- func (c *FakePersonClient) Get(ctx context.Context, partitionkey string, id string, options *Options) (*pkg.Person, error)
- func (c *FakePersonClient) List(*Options) PersonIterator
- func (c *FakePersonClient) ListAll(ctx context.Context, options *Options) (*pkg.People, error)
- func (c *FakePersonClient) Query(name string, query *Query, options *Options) PersonRawIterator
- func (c *FakePersonClient) QueryAll(ctx context.Context, partitionkey string, query *Query, options *Options) (*pkg.People, error)
- func (c *FakePersonClient) Replace(ctx context.Context, partitionkey string, person *pkg.Person, options *Options) (*pkg.Person, error)
- func (c *FakePersonClient) SetConflictChecker(conflictChecker func(*pkg.Person, *pkg.Person) bool)
- func (c *FakePersonClient) SetError(err error)
- func (c *FakePersonClient) SetQueryHandler(queryName string, query fakePersonQueryHandler)
- func (c *FakePersonClient) SetSorter(sorter func([]*pkg.Person))
- func (c *FakePersonClient) SetTriggerHandler(triggerName string, trigger fakePersonTriggerHandler)
- type GeospatialConfig
- type GeospatialConfigType
- type IncludedPath
- type Index
- type IndexDataType
- type IndexKind
- type IndexingPolicy
- type IndexingPolicyMode
- type MissingFields
- type Options
- type Order
- type Parameter
- type PartitionKey
- type PartitionKeyKind
- type PartitionKeyRange
- type PartitionKeyRangeStatus
- type PartitionKeyRanges
- type Permission
- type PermissionClient
- type PermissionIterator
- type PermissionMode
- type Permissions
- type PersonClient
- type PersonIterator
- type PersonRawIterator
- type Query
- type StoredProcedure
- type StoredProcedureClient
- type StoredProcedureIterator
- type StoredProcedures
- type Trigger
- type TriggerClient
- type TriggerIterator
- type TriggerOperation
- type TriggerType
- type Triggers
- type UniqueKey
- type UniqueKeyPolicy
- type User
- type UserClient
- type UserIterator
- type Users
Constants ¶
This section is empty.
Variables ¶
var ErrETagRequired = fmt.Errorf("ETag is required")
ErrETagRequired is the error returned if the ETag field is not populate on a PUT or DELETE operation
var ErrNotImplemented = fmt.Errorf("not implemented")
ErrNotImplemented is the error returned if a fake function is not implemented
Functions ¶
func IsErrorStatusCode ¶
IsErrorStatusCode returns true if err is of type Error and its StatusCode matches statusCode
func RetryOnHttpStatusOrError ¶
RetryOnHttpStatus retries a function based on Http status code or if the error message contains any of the errorString
func RetryOnPreconditionFailed ¶
RetryOnPreconditionFailed retries a function if it fails due to PreconditionFailed
Types ¶
type Authorizer ¶
func NewMasterKeyAuthorizer ¶
func NewMasterKeyAuthorizer(masterKey string) (Authorizer, error)
func NewOauthMsalAADAuthorizer ¶
func NewOauthMsalAADAuthorizer(token azcore.TokenCredential, cosmosDBInstanceURI string) Authorizer
func NewTokenAuthorizer ¶
func NewTokenAuthorizer(token string) Authorizer
type Collection ¶
type Collection struct {
ID string `json:"id,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Timestamp int `json:"_ts,omitempty"`
Self string `json:"_self,omitempty"`
ETag string `json:"_etag,omitempty"`
Documents string `json:"_docs,omitempty"`
StoredProcedures string `json:"_sprocs,omitempty"`
Triggers string `json:"_triggers,omitempty"`
UserDefinedFunctions string `json:"_udfs,omitempty"`
Conflicts string `json:"_conflicts,omitempty"`
IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"`
PartitionKey *PartitionKey `json:"partitionKey,omitempty"`
UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"`
ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"`
AllowMaterializedViews bool `json:"allowMaterializedViews,omitempty"`
GeospatialConfig *GeospatialConfig `json:"geospatialConfig,omitempty"`
}
Collection represents a collection
type CollectionClient ¶
type CollectionClient interface {
Create(context.Context, *Collection) (*Collection, error)
List() CollectionIterator
ListAll(context.Context) (*Collections, error)
Get(context.Context, string) (*Collection, error)
Delete(context.Context, *Collection) error
Replace(context.Context, *Collection) (*Collection, error)
PartitionKeyRanges(context.Context, string) (*PartitionKeyRanges, error)
}
CollectionClient is a collection client
func NewCollectionClient ¶
func NewCollectionClient(c DatabaseClient, dbid string) CollectionClient
NewCollectionClient returns a new collection client
type CollectionIterator ¶
type CollectionIterator interface {
Next(context.Context) (*Collections, error)
}
CollectionIterator is a collection iterator
type Collections ¶
type Collections struct {
Count int `json:"_count,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Collections []*Collection `json:"DocumentCollections,omitempty"`
}
Collections represents collections
type CompositeIndex ¶
type CompositeIndex []struct {
Path string `json:"path,omitempty"`
Order Order `json:"order,omitempty"`
}
CompositeIndex represents a composite index
type ConflictResolutionPolicy ¶
type ConflictResolutionPolicy struct {
Mode ConflictResolutionPolicyMode `json:"mode,omitempty"`
ConflictResolutionPath string `json:"conflictResolutionPath,omitempty"`
ConflictResolutionProcedure string `json:"conflictResolutionProcedure,omitempty"`
}
ConflictResolutionPolicy represents a conflict resolution policy
type ConflictResolutionPolicyMode ¶
type ConflictResolutionPolicyMode string
ConflictResolutionPolicyMode represents a conflict resolution policy mode
const ( ConflictResolutionPolicyModeLastWriterWins ConflictResolutionPolicyMode = "LastWriterWins" ConflictResolutionPolicyModeCustom ConflictResolutionPolicyMode = "Custom" )
ConflictResolutionPolicyMode constants
type Database ¶
type Database struct {
ID string `json:"id,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Timestamp int `json:"_ts,omitempty"`
Self string `json:"_self,omitempty"`
ETag string `json:"_etag,omitempty"`
Collections string `json:"_colls,omitempty"`
Users string `json:"_users,omitempty"`
}
Database represents a database
type DatabaseClient ¶
type DatabaseClient interface {
SetAuthorizer(Authorizer)
Create(context.Context, *Database) (*Database, error)
List() DatabaseIterator
ListAll(context.Context) (*Databases, error)
Get(context.Context, string) (*Database, error)
Delete(context.Context, *Database) error
}
DatabaseClient is a database client
func NewDatabaseClient ¶
func NewDatabaseClient(log *logrus.Entry, hc *http.Client, jsonHandle *codec.JsonHandle, databaseHostname string, authorizer Authorizer) DatabaseClient
NewDatabaseClient returns a new database client
type DatabaseIterator ¶
DatabaseIterator is a database iterator
type Databases ¶
type Databases struct {
Count int `json:"_count,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Databases []*Database `json:"Databases,omitempty"`
}
Databases represents databases
type ExcludedPath ¶
type ExcludedPath struct {
Path string `json:"path,omitempty"`
}
ExcludedPath represents an excluded path
type FakePersonClient ¶
type FakePersonClient struct {
// contains filtered or unexported fields
}
FakePersonClient is a FakePersonClient
func NewFakePersonClient ¶
func NewFakePersonClient(h *codec.JsonHandle) *FakePersonClient
NewFakePersonClient returns a FakePersonClient
func (*FakePersonClient) ChangeFeed ¶
func (c *FakePersonClient) ChangeFeed(*Options) PersonIterator
ChangeFeed is unimplemented
func (*FakePersonClient) Create ¶
func (c *FakePersonClient) Create(ctx context.Context, partitionkey string, person *pkg.Person, options *Options) (*pkg.Person, error)
Create creates a Person in the database
func (*FakePersonClient) Delete ¶
func (c *FakePersonClient) Delete(ctx context.Context, partitionKey string, person *pkg.Person, options *Options) error
Delete deletes a Person from the database
func (*FakePersonClient) ExecuteStoredProcedure ¶
func (c *FakePersonClient) ExecuteStoredProcedure(ctx context.Context, sprocsid string, partitionkey string, parameters []string, response interface{}) (err error)
ExecuteStoredProcedure executes a stored procedure in the database
func (*FakePersonClient) Get ¶
func (c *FakePersonClient) Get(ctx context.Context, partitionkey string, id string, options *Options) (*pkg.Person, error)
Get gets a Person from the database
func (*FakePersonClient) List ¶
func (c *FakePersonClient) List(*Options) PersonIterator
List returns a PersonIterator to list all People in the database
func (*FakePersonClient) Query ¶
func (c *FakePersonClient) Query(name string, query *Query, options *Options) PersonRawIterator
Query calls a query handler to implement database querying
func (*FakePersonClient) QueryAll ¶
func (c *FakePersonClient) QueryAll(ctx context.Context, partitionkey string, query *Query, options *Options) (*pkg.People, error)
QueryAll calls a query handler to implement database querying
func (*FakePersonClient) Replace ¶
func (c *FakePersonClient) Replace(ctx context.Context, partitionkey string, person *pkg.Person, options *Options) (*pkg.Person, error)
Replace replaces a Person in the database
func (*FakePersonClient) SetConflictChecker ¶
SetConflictChecker sets or unsets a function which can be used to validate additional unique keys in a Person
func (*FakePersonClient) SetError ¶
func (c *FakePersonClient) SetError(err error)
SetError sets or unsets an error that will be returned on any FakePersonClient method invocation
func (*FakePersonClient) SetQueryHandler ¶
func (c *FakePersonClient) SetQueryHandler(queryName string, query fakePersonQueryHandler)
SetQueryHandler sets or unsets a query handler
func (*FakePersonClient) SetSorter ¶
func (c *FakePersonClient) SetSorter(sorter func([]*pkg.Person))
SetSorter sets or unsets a sorter function which will be used to sort values returned by List() for test stability
func (*FakePersonClient) SetTriggerHandler ¶
func (c *FakePersonClient) SetTriggerHandler(triggerName string, trigger fakePersonTriggerHandler)
SetTriggerHandler sets or unsets a trigger handler
type GeospatialConfig ¶
type GeospatialConfig struct {
Type GeospatialConfigType `json:"type,omitempty"`
}
GeospatialConfig represents a geospatial config
type GeospatialConfigType ¶
type GeospatialConfigType string
GeospatialConfigType represents geospatial config types
const (
GeospatialConfigTypeGeography GeospatialConfigType = "Geography"
)
GeospatialConfigType constants
type IncludedPath ¶
type IncludedPath struct {
Path string `json:"path,omitempty"`
Indexes []Index `json:"indexes,omitempty"`
}
IncludedPath represents an included path
type Index ¶
type Index struct {
DataType IndexDataType `json:"dataType,omitempty"`
Kind IndexKind `json:"kind,omitempty"`
Precision int `json:"precision,omitempty"`
}
Index represents an index
type IndexDataType ¶
type IndexDataType string
IndexDataType represents an index data type
const ( IndexDataTypeString IndexDataType = "String" IndexDataTypeNumber IndexDataType = "Number" IndexDataTypePoint IndexDataType = "Point" IndexDataTypePolygon IndexDataType = "Polygon" IndexDataTypeLineString IndexDataType = "LineString" )
IndexDataType constants
type IndexingPolicy ¶
type IndexingPolicy struct {
Automatic bool `json:"automatic,omitempty"`
IndexingMode IndexingPolicyMode `json:"indexingMode,omitempty"`
IncludedPaths []IncludedPath `json:"includedPaths,omitempty"`
ExcludedPaths []IncludedPath `json:"excludedPaths,omitempty"`
CompositeIndexes []CompositeIndex `json:"compositeIndexes,omitempty"`
}
IndexingPolicy represents an indexing policy
type IndexingPolicyMode ¶
type IndexingPolicyMode string
IndexingPolicyMode represents an indexing policy mode
const ( IndexingPolicyModeConsistent IndexingPolicyMode = "Consistent" IndexingPolicyModeLazy IndexingPolicyMode = "Lazy" )
IndexingPolicyMode constants
type MissingFields ¶
type MissingFields struct {
// contains filtered or unexported fields
}
MissingFields retains values that do not map to struct fields during JSON marshalling/unmarshalling. MissingFields implements https://github.com/ugorji/go/issues/355
func (*MissingFields) CodecMissingField ¶
func (mf *MissingFields) CodecMissingField(field []byte, value interface{}) bool
CodecMissingField is called to set a missing field and value pair
func (*MissingFields) CodecMissingFields ¶
func (mf *MissingFields) CodecMissingFields() map[string]interface{}
CodecMissingFields returns the set of fields which are not struct fields
type Options ¶
type Options struct {
NoETag bool
PreTriggers []string
PostTriggers []string
PartitionKeyRangeID string
Continuation string
}
Options represents API options
type PartitionKey ¶
type PartitionKey struct {
Paths []string `json:"paths,omitempty"`
Kind PartitionKeyKind `json:"kind,omitempty"`
Version int `json:"version,omitempty"`
}
PartitionKey represents a partition key
type PartitionKeyKind ¶
type PartitionKeyKind string
PartitionKeyKind represents a partition key kind
const (
PartitionKeyKindHash PartitionKeyKind = "Hash"
)
PartitionKeyKind constants
type PartitionKeyRange ¶
type PartitionKeyRange struct {
ID string `json:"id,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Timestamp int `json:"_ts,omitempty"`
Self string `json:"_self,omitempty"`
ETag string `json:"_etag,omitempty"`
MaxExclusive string `json:"maxExclusive,omitempty"`
MinInclusive string `json:"minInclusive,omitempty"`
ResourceIDPrefix int `json:"ridPrefix,omitempty"`
ThroughputFraction float64 `json:"throughputFraction,omitempty"`
Status PartitionKeyRangeStatus `json:"status,omitempty"`
Parents []string `json:"parents,omitempty"`
LSN int `json:"lsn,omitempty"`
MissingFields
}
PartitionKeyRange represents a partition key range
type PartitionKeyRangeStatus ¶
type PartitionKeyRangeStatus string
PartitionKeyRangeStatus represents a partition key range status
const (
PartitionKeyRangeStatusOnline PartitionKeyRangeStatus = "online"
)
PartitionKeyRangeStatus constants
type PartitionKeyRanges ¶
type PartitionKeyRanges struct {
Count int `json:"_count,omitempty"`
ResourceID string `json:"_rid,omitempty"`
PartitionKeyRanges []PartitionKeyRange `json:"PartitionKeyRanges,omitempty"`
}
PartitionKeyRanges represents partition key ranges
type Permission ¶
type Permission struct {
ID string `json:"id,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Timestamp int `json:"_ts,omitempty"`
Self string `json:"_self,omitempty"`
ETag string `json:"_etag,omitempty"`
Token string `json:"_token,omitempty"`
PermissionMode PermissionMode `json:"permissionMode,omitempty"`
Resource string `json:"resource,omitempty"`
}
Permission represents a permission
type PermissionClient ¶
type PermissionClient interface {
Create(context.Context, *Permission) (*Permission, error)
List() PermissionIterator
ListAll(context.Context) (*Permissions, error)
Get(context.Context, string) (*Permission, error)
Delete(context.Context, *Permission) error
Replace(context.Context, *Permission) (*Permission, error)
}
PermissionClient is a permission client
func NewPermissionClient ¶
func NewPermissionClient(userc UserClient, userid string) PermissionClient
NewPermissionClient returns a new permission client
type PermissionIterator ¶
type PermissionIterator interface {
Next(context.Context) (*Permissions, error)
}
PermissionIterator is a permission iterator
type PermissionMode ¶
type PermissionMode string
PermissionMode represents a permission mode
const ( PermissionModeAll PermissionMode = "All" PermissionModeRead PermissionMode = "Read" )
PermissionMode constants
type Permissions ¶
type Permissions struct {
Count int `json:"_count,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Permissions []*Permission `json:"Permissions,omitempty"`
}
Permissions represents permissions
type PersonClient ¶
type PersonClient interface {
Create(context.Context, string, *pkg.Person, *Options) (*pkg.Person, error)
List(*Options) PersonIterator
ListAll(context.Context, *Options) (*pkg.People, error)
Get(context.Context, string, string, *Options) (*pkg.Person, error)
Replace(context.Context, string, *pkg.Person, *Options) (*pkg.Person, error)
Delete(context.Context, string, *pkg.Person, *Options) error
Query(string, *Query, *Options) PersonRawIterator
QueryAll(context.Context, string, *Query, *Options) (*pkg.People, error)
ChangeFeed(*Options) PersonIterator
ExecuteStoredProcedure(context.Context, string, string, []string, interface{}) error
}
PersonClient is a person client
func NewPersonClient ¶
func NewPersonClient(collc CollectionClient, collid string) PersonClient
NewPersonClient returns a new person client
type PersonIterator ¶
type PersonIterator interface {
Next(context.Context, int) (*pkg.People, error)
Continuation() string
}
PersonIterator is a person iterator
type PersonRawIterator ¶
type PersonRawIterator interface {
PersonIterator
NextRaw(context.Context, int, interface{}) error
}
PersonRawIterator is a person raw iterator
func NewFakePersonErroringRawIterator ¶
func NewFakePersonErroringRawIterator(err error) PersonRawIterator
NewFakePersonErroringRawIterator returns a PersonRawIterator which whose methods return the given error
func NewFakePersonIterator ¶
func NewFakePersonIterator(people []*pkg.Person, continuation int) PersonRawIterator
type Query ¶
type Query struct {
Query string `json:"query,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
}
Query represents a query
type StoredProcedure ¶
type StoredProcedure struct {
// ID is the user generated unique name for the stored procedure. No two stored procedures can have the same IDs.
ID string `json:"id,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Timestamp int `json:"_ts,omitempty"`
Self string `json:"_self,omitempty"`
ETag string `json:"_etag,omitempty"`
// Body of the stored procedure.
Body string `json:"body,omitempty"`
}
StoredProcedure represents a stored procedure
type StoredProcedureClient ¶
type StoredProcedureClient interface {
Create(context.Context, *StoredProcedure) (*StoredProcedure, error)
List() StoredProcedureIterator
ListAll(context.Context) (*StoredProcedures, error)
Get(context.Context, string) (*StoredProcedure, error)
Delete(context.Context, *StoredProcedure) error
Replace(context.Context, *StoredProcedure) (*StoredProcedure, error)
}
StoredProcedureClient is a stored procedure client
func NewStoredProcedureClient ¶
func NewStoredProcedureClient(collc CollectionClient, collid string) StoredProcedureClient
NewStoredProcedureClient returns a new stored procedure client
type StoredProcedureIterator ¶
type StoredProcedureIterator interface {
Next(context.Context) (*StoredProcedures, error)
}
StoredProcedureIterator is a stored procedure iterator
type StoredProcedures ¶
type StoredProcedures struct {
Count int `json:"_count,omitempty"`
ResourceID string `json:"_rid,omitempty"`
StoredProcedures []*StoredProcedure `json:"StoredProcedures,omitempty"`
}
StoredProcedures represents stored procedures
type Trigger ¶
type Trigger struct {
ID string `json:"id,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Timestamp int `json:"_ts,omitempty"`
Self string `json:"_self,omitempty"`
ETag string `json:"_etag,omitempty"`
Body string `json:"body,omitempty"`
TriggerOperation TriggerOperation `json:"triggerOperation,omitempty"`
TriggerType TriggerType `json:"triggerType,omitempty"`
}
Trigger represents a trigger
type TriggerClient ¶
type TriggerClient interface {
Create(context.Context, *Trigger) (*Trigger, error)
List() TriggerIterator
ListAll(context.Context) (*Triggers, error)
Get(context.Context, string) (*Trigger, error)
Delete(context.Context, *Trigger) error
Replace(context.Context, *Trigger) (*Trigger, error)
}
TriggerClient is a trigger client
func NewTriggerClient ¶
func NewTriggerClient(collc CollectionClient, collid string) TriggerClient
NewTriggerClient returns a new trigger client
type TriggerIterator ¶
TriggerIterator is a trigger iterator
type TriggerOperation ¶
type TriggerOperation string
TriggerOperation represents a trigger operation
const ( TriggerOperationAll TriggerOperation = "All" TriggerOperationCreate TriggerOperation = "Create" TriggerOperationReplace TriggerOperation = "Replace" TriggerOperationDelete TriggerOperation = "Delete" )
TriggerOperation constants
type TriggerType ¶
type TriggerType string
TriggerType represents a trigger type
const ( TriggerTypePre TriggerType = "Pre" TriggerTypePost TriggerType = "Post" )
TriggerType constants
type Triggers ¶
type Triggers struct {
Count int `json:"_count,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Triggers []*Trigger `json:"Triggers,omitempty"`
}
Triggers represents triggers
type UniqueKey ¶
type UniqueKey struct {
Paths []string `json:"paths,omitempty"`
}
UniqueKey represents a unique key
type UniqueKeyPolicy ¶
type UniqueKeyPolicy struct {
UniqueKeys []UniqueKey `json:"uniqueKeys,omitempty"`
}
UniqueKeyPolicy represents a unique key policy
type User ¶
type User struct {
ID string `json:"id,omitempty"`
ResourceID string `json:"_rid,omitempty"`
Timestamp int `json:"_ts,omitempty"`
Self string `json:"_self,omitempty"`
ETag string `json:"_etag,omitempty"`
Permissions string `json:"_permissions,omitempty"`
}
User represents a user
type UserClient ¶
type UserClient interface {
Create(context.Context, *User) (*User, error)
List() UserIterator
ListAll(context.Context) (*Users, error)
Get(context.Context, string) (*User, error)
Delete(context.Context, *User) error
Replace(context.Context, *User) (*User, error)
}
UserClient is a user client
func NewUserClient ¶
func NewUserClient(c DatabaseClient, dbid string) UserClient
NewUserClient returns a new user client
type UserIterator ¶
UserIterator is a user iterator