Skip to content

Commit e7caf6c

Browse files
Updated documentation around match and if none match etag for request options (#43717)
* Updated documentation around match and if none match etag for request options * Fixed some missing documentation * Code review comments
1 parent 3589387 commit e7caf6c

11 files changed

+161
-1
lines changed

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosBatchItemRequestOptions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public CosmosBatchItemRequestOptions() {
2222

2323
/**
2424
* Gets the If-Match (ETag) associated with the operation in CosmosBatch.
25+
* Most commonly used with replace, upsert and delete requests.
26+
* This will be ignored if specified for create requests or for upsert requests if the item doesn't exist.
27+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
2528
*
2629
* @return ifMatchETag the ifMatchETag associated with the request.
2730
*/
@@ -31,6 +34,9 @@ public String getIfMatchETag() {
3134

3235
/**
3336
* Sets the If-Match (ETag) associated with the operation in CosmosBatch.
37+
* Most commonly used with replace, upsert and delete requests.
38+
* This will be ignored if specified for create requests or for upsert requests if the item doesn't exist.
39+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
3440
*
3541
* @param ifMatchETag the ifMatchETag associated with the request.
3642
* @return the current request options
@@ -42,6 +48,11 @@ public CosmosBatchItemRequestOptions setIfMatchETag(final String ifMatchETag) {
4248

4349
/**
4450
* Gets the If-None-Match (ETag) associated with the request in operation in CosmosBatch.
51+
* Most commonly used to detect changes to the resource via read requests.
52+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
53+
* To match any Etag use "*"
54+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
55+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
4556
*
4657
* @return the ifNoneMatchETag associated with the request.
4758
*/
@@ -51,6 +62,11 @@ public String getIfNoneMatchETag() {
5162

5263
/**
5364
* Sets the If-None-Match (ETag) associated with the request in operation in CosmosBatch.
65+
* Most commonly used to detect changes to the resource via read requests.
66+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
67+
* To match any Etag use "*"
68+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
69+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
5470
*
5571
* @param ifNoneMatchEtag the ifNoneMatchETag associated with the request.
5672
* @return the current request options

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosBatchPatchItemRequestOptions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public CosmosBatchPatchItemRequestOptions setFilterPredicate(String filterPredic
4242

4343
/**
4444
* Gets the If-Match (ETag) associated with the operation in CosmosBatch.
45+
* Most commonly used with replace, upsert and delete requests.
46+
* This will be ignored if specified for create requests or for upsert requests if the item doesn't exist.
47+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
4548
*
4649
* @return ifMatchETag the ifMatchETag associated with the request.
4750
*/
@@ -51,6 +54,9 @@ public String getIfMatchETag() {
5154

5255
/**
5356
* Sets the If-Match (ETag) associated with the operation in CosmosBatch.
57+
* Most commonly used with replace, upsert and delete requests.
58+
* This will be ignored if specified for create requests or for upsert requests if the item doesn't exist.
59+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
5460
*
5561
* @param ifMatchETag the ifMatchETag associated with the request.
5662
* @return the current request options
@@ -62,6 +68,11 @@ public CosmosBatchPatchItemRequestOptions setIfMatchETag(final String ifMatchETa
6268

6369
/**
6470
* Gets the If-None-Match (ETag) associated with the request in operation in CosmosBatch.
71+
* Most commonly used to detect changes to the resource via read requests.
72+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
73+
* To match any Etag use "*"
74+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
75+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
6576
*
6677
* @return the ifNoneMatchETag associated with the request.
6778
*/
@@ -71,6 +82,11 @@ public String getIfNoneMatchETag() {
7182

7283
/**
7384
* Sets the If-None-Match (ETag) associated with the request in operation in CosmosBatch.
85+
* Most commonly used to detect changes to the resource via read requests.
86+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
87+
* To match any Etag use "*"
88+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
89+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
7490
*
7591
* @param ifNoneMatchEtag the ifNoneMatchETag associated with the request.
7692
* @return the current request options

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosBulkItemRequestOptions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public CosmosBulkItemRequestOptions() {
2323

2424
/**
2525
* Gets the If-Match (ETag) associated with the operation in {@link CosmosItemOperation}.
26+
* Most commonly used with replace, upsert and delete requests.
27+
* This will be ignored if specified for create requests or for upsert requests if the item doesn't exist.
28+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
2629
*
2730
* @return ifMatchETag the ifMatchETag associated with the request.
2831
*/
@@ -32,6 +35,9 @@ public String getIfMatchETag() {
3235

3336
/**
3437
* Sets the If-Match (ETag) associated with the operation in {@link CosmosItemOperation}.
38+
* Most commonly used with replace, upsert and delete requests.
39+
* This will be ignored if specified for create requests or for upsert requests if the item doesn't exist.
40+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
3541
*
3642
* @param ifMatchETag the ifMatchETag associated with the request.
3743
* @return the current request options
@@ -43,6 +49,11 @@ public CosmosBulkItemRequestOptions setIfMatchETag(final String ifMatchETag) {
4349

4450
/**
4551
* Gets the If-None-Match (ETag) associated with the request in operation in {@link CosmosItemOperation}.
52+
* Most commonly used to detect changes to the resource via read requests.
53+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
54+
* To match any Etag use "*"
55+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
56+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
4657
*
4758
* @return the ifNoneMatchETag associated with the request.
4859
*/
@@ -52,6 +63,11 @@ public String getIfNoneMatchETag() {
5263

5364
/**
5465
* Sets the If-None-Match (ETag) associated with the request in operation in {@link CosmosItemOperation}.
66+
* Most commonly used to detect changes to the resource via read requests.
67+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
68+
* To match any Etag use "*"
69+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
70+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
5571
*
5672
* @param ifNoneMatchEtag the ifNoneMatchETag associated with the request.
5773
* @return the current request options.

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosBulkPatchItemRequestOptions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ public CosmosBulkPatchItemRequestOptions setContentResponseOnWriteEnabled(Boolea
8585

8686
/**
8787
* Gets the If-None-Match (ETag) associated with the request in operation in {@link CosmosItemOperation}.
88+
* Most commonly used to detect changes to the resource via read requests.
89+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
90+
* To match any Etag use "*"
91+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
92+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
8893
*
8994
* @return the ifNoneMatchETag associated with the request.
9095
*/
@@ -94,6 +99,11 @@ public String getIfNoneMatchETag() {
9499

95100
/**
96101
* Sets the If-None-Match (ETag) associated with the request in operation in {@link CosmosItemOperation}.
102+
* Most commonly used to detect changes to the resource via read requests.
103+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
104+
* To match any Etag use "*"
105+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
106+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
97107
*
98108
* @param ifNoneMatchEtag the ifNoneMatchETag associated with the request.
99109
* @return the current request options.
@@ -105,6 +115,9 @@ public CosmosBulkPatchItemRequestOptions setIfNoneMatchETag(final String ifNoneM
105115

106116
/**
107117
* Gets the If-Match (ETag) associated with the operation in {@link CosmosItemOperation}.
118+
* Most commonly used with replace, upsert and delete requests.
119+
* This will be ignored if specified for create requests or for upsert requests if the item doesn't exist.
120+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
108121
*
109122
* @return ifMatchETag the ifMatchETag associated with the request.
110123
*/
@@ -114,6 +127,9 @@ public String getIfMatchETag() {
114127

115128
/**
116129
* Sets the If-Match (ETag) associated with the operation in {@link CosmosItemOperation}.
130+
* Most commonly used with replace, upsert and delete requests.
131+
* This will be ignored if specified for create requests or for upsert requests if the item doesn't exist.
132+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
117133
*
118134
* @param ifMatchETag the ifMatchETag associated with the request.
119135
* @return the current request options

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public CosmosConflictRequestOptions(PartitionKey partitionKey) {
2828

2929
/**
3030
* Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service.
31+
* Most commonly used with replace and delete requests.
32+
* This will be ignored if specified for create requests.
33+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
3134
*
3235
* @return ifMatchETag the ifMatchETag associated with the request.
3336
*/
@@ -37,6 +40,9 @@ public String getIfMatchETag() {
3740

3841
/**
3942
* Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service.
43+
* Most commonly used with replace and delete requests.
44+
* This will be ignored if specified for create requests.
45+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
4046
*
4147
* @param ifMatchETag the ifMatchETag associated with the request.
4248
* @return the current request options
@@ -48,6 +54,11 @@ public CosmosConflictRequestOptions setIfMatchETag(String ifMatchETag) {
4854

4955
/**
5056
* Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service.
57+
* Most commonly used to detect changes to the resource via read requests.
58+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
59+
* To match any Etag use "*"
60+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
61+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
5162
*
5263
* @return the ifNoneMatchETag associated with the request.
5364
*/
@@ -57,6 +68,11 @@ public String getIfNoneMatchETag() {
5768

5869
/**
5970
* Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service.
71+
* Most commonly used to detect changes to the resource via read requests.
72+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
73+
* To match any Etag use "*"
74+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
75+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
6076
*
6177
* @param ifNoneMatchEtag the ifNoneMatchETag associated with the request.
6278
* @return the current request options

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public CosmosContainerRequestOptions setSessionToken(String sessionToken) {
8282

8383
/**
8484
* Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service.
85+
* Most commonly used with replace and delete requests.
86+
* This will be ignored if specified for create requests.
87+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
8588
*
8689
* @return the ifMatchETag associated with the request.
8790
*/
@@ -91,6 +94,9 @@ public String getIfMatchETag() {
9194

9295
/**
9396
* Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service.
97+
* Most commonly used with replace and delete requests.
98+
* This will be ignored if specified for create requests.
99+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
94100
*
95101
* @param ifMatchETag the ifMatchETag associated with the request.
96102
* @return the current request options
@@ -102,6 +108,11 @@ public CosmosContainerRequestOptions setIfMatchETag(String ifMatchETag) {
102108

103109
/**
104110
* Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service.
111+
* Most commonly used to detect changes to the resource via read requests.
112+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
113+
* To match any Etag use "*"
114+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
115+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
105116
*
106117
* @return the ifNoneMatchETag associated with the request.
107118
*/
@@ -111,6 +122,11 @@ public String getIfNoneMatchETag() {
111122

112123
/**
113124
* Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service.
125+
* Most commonly used to detect changes to the resource via read requests.
126+
* When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200.
127+
* To match any Etag use "*"
128+
* This will be ignored if specified for write requests (ex: Create, Replace, Delete).
129+
* For more details, refer to <a href="https://learn.microsoft.com/azure/cosmos-db/nosql/database-transactions-optimistic-concurrency#implementing-optimistic-concurrency-control-using-etag-and-http-headers">optimistic concurrency control documentation</a>
114130
*
115131
* @param ifNoneMatchETag the ifNoneMatchETag associated with the request.
116132
* @return the current request options

0 commit comments

Comments
 (0)