diff --git a/sdk/data/azcosmos/README.md b/sdk/data/azcosmos/README.md index 0f09b39656a5..15f7df93a51d 100644 --- a/sdk/data/azcosmos/README.md +++ b/sdk/data/azcosmos/README.md @@ -32,12 +32,12 @@ You can create an Azure Cosmos account using: #### Authenticate the client -In order to interact with the Azure CosmosDB service you'll need to create an instance of the Cosmos Client class. To make this possible you will need an URL and key of the Azure CosmosDB service. +In order to interact with the Azure CosmosDB service you'll need to create an instance of the Cosmos client class. To make this possible you will need an URL and key of the Azure CosmosDB service. ## Examples The following section provides several code snippets covering some of the most common CosmosDB SQL API tasks, including: -* [Create Cosmos Client](#create-cosmos-client "Create Cosmos Client") +* [Create Client](#create-cosmos-client "Create Cosmos client") * [Create Database](#create-database "Create Database") * [Create Container](#create-container "Create Container") * [CRUD operation on Items](#crud-operation-on-items "CRUD operation on Items") diff --git a/sdk/data/azcosmos/cosmos_client.go b/sdk/data/azcosmos/cosmos_client.go index 7b9f5800056b..3b7e49e4a48c 100644 --- a/sdk/data/azcosmos/cosmos_client.go +++ b/sdk/data/azcosmos/cosmos_client.go @@ -8,32 +8,36 @@ import ( "errors" ) -// A CosmosClient is used to interact with the Azure Cosmos DB database service. -type CosmosClient struct { - // Endpoint used to create the client. - Endpoint string +// Cosmos client is used to interact with the Azure Cosmos DB database service. +type Client struct { + endpoint string connection *cosmosClientConnection cred *SharedKeyCredential options *CosmosClientOptions } -// NewClientWithSharedKey creates a new instance of CosmosClient with the specified values. It uses the default pipeline configuration. +// Endpoint used to create the client. +func (c *Client) Endpoint() string { + return c.endpoint +} + +// NewClientWithSharedKey creates a new instance of Cosmos client with the specified values. It uses the default pipeline configuration. // endpoint - The cosmos service endpoint to use. // cred - The credential used to authenticate with the cosmos service. -// options - Optional CosmosClient options. Pass nil to accept default values. -func NewClientWithSharedKey(endpoint string, cred *SharedKeyCredential, options *CosmosClientOptions) (*CosmosClient, error) { +// options - Optional Cosmos client options. Pass nil to accept default values. +func NewClientWithSharedKey(endpoint string, cred *SharedKeyCredential, options *CosmosClientOptions) (*Client, error) { if options == nil { options = &CosmosClientOptions{} } connection := newCosmosClientConnection(endpoint, cred, options) - return &CosmosClient{Endpoint: endpoint, connection: connection, cred: cred, options: options}, nil + return &Client{endpoint: endpoint, connection: connection, cred: cred, options: options}, nil } // GetDatabase returns a Database object. // id - The id of the database. -func (c *CosmosClient) GetDatabase(id string) (*Database, error) { +func (c *Client) GetDatabase(id string) (*Database, error) { if id == "" { return nil, errors.New("id is required") } @@ -44,7 +48,7 @@ func (c *CosmosClient) GetDatabase(id string) (*Database, error) { // GetContainer returns a Container object. // databaseId - The id of the database. // containerId - The id of the container. -func (c *CosmosClient) GetContainer(databaseId string, containerId string) (*Container, error) { +func (c *Client) GetContainer(databaseId string, containerId string) (*Container, error) { if databaseId == "" { return nil, errors.New("databaseId is required") } @@ -60,7 +64,7 @@ func (c *CosmosClient) GetContainer(databaseId string, containerId string) (*Con // ctx - The context for the request. // databaseProperties - The definition of the database // o - Options for the create database operation. -func (c *CosmosClient) CreateDatabase( +func (c *Client) CreateDatabase( ctx context.Context, databaseProperties DatabaseProperties, o *CreateDatabaseOptions) (DatabaseResponse, error) { diff --git a/sdk/data/azcosmos/cosmos_client_options.go b/sdk/data/azcosmos/cosmos_client_options.go index 1177d5c9f403..938fc0d945b3 100644 --- a/sdk/data/azcosmos/cosmos_client_options.go +++ b/sdk/data/azcosmos/cosmos_client_options.go @@ -32,7 +32,7 @@ type CosmosClientOptions struct { // When EnableContentResponseOnWrite is false will cause the response to have a null resource. This reduces networking and CPU load by not sending the resource back over the network and serializing it on the client. // The default is false. EnableContentResponseOnWrite bool - // LimitToEndpoint limits the operations to the provided endpoint on the CosmosClient. See https://docs.microsoft.com/azure/cosmos-db/troubleshoot-sdk-availability + // LimitToEndpoint limits the operations to the provided endpoint on the Cosmos client. See https://docs.microsoft.com/azure/cosmos-db/troubleshoot-sdk-availability LimitToEndpoint bool // RateLimitedRetry defines the retry configuration for rate limited requests. // By default, the SDK will do 9 retries. diff --git a/sdk/data/azcosmos/cosmos_database.go b/sdk/data/azcosmos/cosmos_database.go index a6af6d4181e1..2f6ee77eef87 100644 --- a/sdk/data/azcosmos/cosmos_database.go +++ b/sdk/data/azcosmos/cosmos_database.go @@ -13,12 +13,12 @@ type Database struct { // The Id of the Cosmos database Id string // The client associated with the Cosmos database - client *CosmosClient + client *Client // The resource link link string } -func newDatabase(id string, client *CosmosClient) *Database { +func newDatabase(id string, client *Client) *Database { return &Database{ Id: id, client: client, diff --git a/sdk/data/azcosmos/emulator_tests.go b/sdk/data/azcosmos/emulator_tests.go index 1673c7a2285b..8ad92cb3c548 100644 --- a/sdk/data/azcosmos/emulator_tests.go +++ b/sdk/data/azcosmos/emulator_tests.go @@ -26,7 +26,7 @@ func newEmulatorTests(t *testing.T) *emulatorTests { } } -func (e *emulatorTests) getClient(t *testing.T) *CosmosClient { +func (e *emulatorTests) getClient(t *testing.T) *Client { cred, _ := NewSharedKeyCredential(e.key) client, err := NewClientWithSharedKey(e.host, cred, nil) if err != nil { @@ -39,7 +39,7 @@ func (e *emulatorTests) getClient(t *testing.T) *CosmosClient { func (e *emulatorTests) createDatabase( t *testing.T, ctx context.Context, - client *CosmosClient, + client *Client, dbName string) *Database { database := DatabaseProperties{Id: dbName} resp, err := client.CreateDatabase(ctx, database, nil) diff --git a/sdk/data/azcosmos/example_test.go b/sdk/data/azcosmos/example_test.go index 0b44c97f8ca7..68feb716168e 100644 --- a/sdk/data/azcosmos/example_test.go +++ b/sdk/data/azcosmos/example_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos" ) -// This example shows you how to get started using the Azure Cosmos DB SDK for Go. NewCosmosClient creates a new instance of CosmosClient with the specified values. It uses the default pipeline configuration. +// This example shows you how to get started using the Azure Cosmos DB SDK for Go. NewCosmosClient creates a new instance of Cosmos client with the specified values. It uses the default pipeline configuration. func Example() { endpoint, _ := os.LookupEnv("SOME_ENDPOINT")