diff --git a/sdk/data/azcosmos/CHANGELOG.md b/sdk/data/azcosmos/CHANGELOG.md index 951442859e4d..f4652730f572 100644 --- a/sdk/data/azcosmos/CHANGELOG.md +++ b/sdk/data/azcosmos/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.3.5 (2023-05-09) +### Features Added +* Added support for accounts with [merge support](https://aka.ms/cosmosdbsdksupportformerge) enabled + ### Bugs Fixed * Fixed unmarshalling error when using projections in value queries diff --git a/sdk/data/azcosmos/cosmos_client.go b/sdk/data/azcosmos/cosmos_client.go index 94c455aed1e4..41807ab416e0 100644 --- a/sdk/data/azcosmos/cosmos_client.go +++ b/sdk/data/azcosmos/cosmos_client.go @@ -395,6 +395,7 @@ func (c *Client) createRequest( req.Raw().Header.Set(headerXmsDate, time.Now().UTC().Format(http.TimeFormat)) req.Raw().Header.Set(headerXmsVersion, "2020-11-05") + req.Raw().Header.Set(cosmosHeaderSDKSupportedCapabilities, supportedCapabilitiesHeaderValue) req.SetOperationValue(operationContext) diff --git a/sdk/data/azcosmos/cosmos_client_test.go b/sdk/data/azcosmos/cosmos_client_test.go index f33e730722a2..d93f4ca93d7c 100644 --- a/sdk/data/azcosmos/cosmos_client_test.go +++ b/sdk/data/azcosmos/cosmos_client_test.go @@ -258,6 +258,10 @@ func TestCreateRequest(t *testing.T) { t.Errorf("Expected %v, but got %v", "2020-11-05", req.Raw().Header.Get(headerXmsVersion)) } + if req.Raw().Header.Get(cosmosHeaderSDKSupportedCapabilities) != supportedCapabilitiesHeaderValue { + t.Errorf("Expected %v, but got %v", supportedCapabilitiesHeaderValue, req.Raw().Header.Get(cosmosHeaderSDKSupportedCapabilities)) + } + opValue := pipelineRequestOptions{} if !req.OperationValue(&opValue) { t.Error("Expected to find operation value") diff --git a/sdk/data/azcosmos/cosmos_headers.go b/sdk/data/azcosmos/cosmos_headers.go index d054bd652b93..5c8ea72c48bb 100644 --- a/sdk/data/azcosmos/cosmos_headers.go +++ b/sdk/data/azcosmos/cosmos_headers.go @@ -33,6 +33,7 @@ const ( cosmosHeaderIsBatchRequest string = "x-ms-cosmos-is-batch-request" cosmosHeaderIsBatchAtomic string = "x-ms-cosmos-batch-atomic" cosmosHeaderIsBatchOrdered string = "x-ms-cosmos-batch-ordered" + cosmosHeaderSDKSupportedCapabilities string = "x-ms-cosmos-sdk-supportedcapabilities" headerXmsDate string = "x-ms-date" headerAuthorization string = "Authorization" headerContentType string = "Content-Type" diff --git a/sdk/data/azcosmos/sdk_capabilities.go b/sdk/data/azcosmos/sdk_capabilities.go new file mode 100644 index 000000000000..71157b5fed27 --- /dev/null +++ b/sdk/data/azcosmos/sdk_capabilities.go @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azcosmos + +import "strconv" + +type supportedCapabilities uint64 + +const ( + supportedCapabilitiesNone supportedCapabilities = 0 + supportedCapabilitiesPartitionMerge supportedCapabilities = 1 << 0 +) + +var supportedCapabilitiesHeaderValue = supportedCapabilitiesAsString() + +func supportedCapabilitiesAsString() string { + supported := supportedCapabilitiesNone + supported |= supportedCapabilitiesPartitionMerge + return strconv.FormatUint(uint64(supported), 10) +}