azure-docs-sdk-java/docs-ref-autogen/com.azure.cosmos.models.Cos...

158 строки
17 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.cosmos.models.CosmosPatchOperations"
fullName: "com.azure.cosmos.models.CosmosPatchOperations"
name: "CosmosPatchOperations"
nameWithType: "CosmosPatchOperations"
summary: "Grammar is a super set of this RFC: https://tools.<wbr>ietf.<wbr>org/html/rfc6902\\#section-4.1 Contains a list of Patch operations to be applied on an item."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public final class **CosmosPatchOperations**"
methods:
- uid: "com.azure.cosmos.models.CosmosPatchOperations.<T>add(java.lang.String,T)"
fullName: "com.azure.cosmos.models.CosmosPatchOperations.add(String path, T value)"
name: "add(String path, T value)"
nameWithType: "CosmosPatchOperations.add(String path, T value)"
summary: "This performs one of the following functions, depending upon what the target location references: 1."
parameters:
- description: "the operation path."
name: "path"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the value which will be added."
name: "value"
type: "<xref href=\"T?alt=T&text=T\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosPatchOperations <T>add(String path, T value)"
desc: "This performs one of the following functions, depending upon what the target location references: 1. Target location specifies an array index, a new value is inserted into the array at the specified index. 2. Target location specifies an object member that does not already exist, a new member is added to the object. 3. Target location specifies an object member that does exist, that member's value is replaced. For the above JSON, we can have something like this: `CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create(); cosmosPatch.add(\"/b/e\", 15); // will add a value to the array, so /b/e array will become [0, 1, 2, 3, 15] cosmosPatch.add(\"/a\", \"new value\"); // will replace the value cosmosPatch.add(\"/b/e/1\", 10); // will change value of the /b/e array to [0, 10, 2, 3]` This operation is not idempotent for scenario 1 and 2. For 3rd it is as the final value will be the value provided here."
returns:
description: "same instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref>"
type: "<xref href=\"com.azure.cosmos.models.CosmosPatchOperations?alt=com.azure.cosmos.models.CosmosPatchOperations&text=CosmosPatchOperations\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.models.CosmosPatchOperations.<T>replace(java.lang.String,T)"
fullName: "com.azure.cosmos.models.CosmosPatchOperations.replace(String path, T value)"
name: "replace(String path, T value)"
nameWithType: "CosmosPatchOperations.replace(String path, T value)"
summary: "This replaces the value at the target location with a new value."
parameters:
- description: "the operation path."
name: "path"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the value which will be replaced."
name: "value"
type: "<xref href=\"T?alt=T&text=T\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosPatchOperations <T>replace(String path, T value)"
desc: "This replaces the value at the target location with a new value. For the above JSON, we can have something like this: `CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create(); cosmosPatch.replace(\"/a\", \"new value\"); // will replace \"xyz\" to \"new value\" cosmosPatch.replace(\"/b/e/1\", 2); // will replace 2nd element of /b/e array to 2` This operation is idempotent as multiple call execution replace to the same value."
returns:
description: "same instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref>"
type: "<xref href=\"com.azure.cosmos.models.CosmosPatchOperations?alt=com.azure.cosmos.models.CosmosPatchOperations&text=CosmosPatchOperations\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.models.CosmosPatchOperations.<T>set(java.lang.String,T)"
fullName: "com.azure.cosmos.models.CosmosPatchOperations.set(String path, T value)"
name: "set(String path, T value)"
nameWithType: "CosmosPatchOperations.set(String path, T value)"
summary: "This sets the value at the target location with a new value."
parameters:
- description: "the operation path."
name: "path"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the value which will be set."
name: "value"
type: "<xref href=\"T?alt=T&text=T\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosPatchOperations <T>set(String path, T value)"
desc: "This sets the value at the target location with a new value. For the above JSON, we can have something like this: `CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create(); cosmosPatch.set(\"/f\", \"new value\"); // will add a new path \"/f\" and set it's value as \"new value\". cosmosPatch.set(\"/b/e\", \"bar\"); // will set \"/b/e\" path to be \"bar\".` This operation is idempotent as multiple execution will set the same value. If a new path is added, next time same value will be set."
returns:
description: "same instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref>"
type: "<xref href=\"com.azure.cosmos.models.CosmosPatchOperations?alt=com.azure.cosmos.models.CosmosPatchOperations&text=CosmosPatchOperations\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.models.CosmosPatchOperations.create()"
fullName: "com.azure.cosmos.models.CosmosPatchOperations.create()"
name: "create()"
nameWithType: "CosmosPatchOperations.create()"
summary: "Initializes a new instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref> that will contain operations to be performed on a item atomically."
modifiers:
- "static"
syntax: "public static CosmosPatchOperations create()"
desc: "Initializes a new instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref> that will contain operations to be performed on a item atomically."
returns:
description: "A new instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref>."
type: "<xref href=\"com.azure.cosmos.models.CosmosPatchOperations?alt=com.azure.cosmos.models.CosmosPatchOperations&text=CosmosPatchOperations\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.models.CosmosPatchOperations.increment(java.lang.String,double)"
fullName: "com.azure.cosmos.models.CosmosPatchOperations.increment(String path, double value)"
name: "increment(String path, double value)"
nameWithType: "CosmosPatchOperations.increment(String path, double value)"
summary: "This increment the value at the target location."
parameters:
- description: "the operation path."
name: "path"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the value which will be incremented."
name: "value"
type: "<xref href=\"double?alt=double&text=double\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosPatchOperations increment(String path, double value)"
desc: "This increment the value at the target location. For the above JSON, we can have something like this: `CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create(); cosmosPatch.increment(\"/b/d\", 3.5); // will add 3.5 to \"/b/d\" resulting in 7.5.` This is not idempotent as multiple execution will increase the value by the given increment. For multi-region we do support concurrent increment on different regions and the final value is a merged value combining all increments values. However if multiple increments are on the same region, it can lead to concurrency issue which can be retried."
returns:
description: "same instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref>"
type: "<xref href=\"com.azure.cosmos.models.CosmosPatchOperations?alt=com.azure.cosmos.models.CosmosPatchOperations&text=CosmosPatchOperations\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.models.CosmosPatchOperations.increment(java.lang.String,long)"
fullName: "com.azure.cosmos.models.CosmosPatchOperations.increment(String path, long value)"
name: "increment(String path, long value)"
nameWithType: "CosmosPatchOperations.increment(String path, long value)"
summary: "This increment the value at the target location."
parameters:
- description: "the operation path."
name: "path"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the value which will be incremented."
name: "value"
type: "<xref href=\"long?alt=long&text=long\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosPatchOperations increment(String path, long value)"
desc: "This increment the value at the target location. It's a CRDT operator and won't cause any conflict. For the above JSON, we can have something like this: `CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create(); cosmosPatch.increment(\"/b/d\", 1); // will add 1 to \"/b/d\" resulting in 5.` This is not idempotent as multiple execution will increase the value by the given increment. For multi-region we do support concurrent increment on different regions and the final value is a merged value combining all increments value. However if multiple increments are on the same region, it can lead to concurrency issue which can be retried."
returns:
description: "same instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref>"
type: "<xref href=\"com.azure.cosmos.models.CosmosPatchOperations?alt=com.azure.cosmos.models.CosmosPatchOperations&text=CosmosPatchOperations\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.models.CosmosPatchOperations.move(java.lang.String,java.lang.String)"
fullName: "com.azure.cosmos.models.CosmosPatchOperations.move(String fromPath, String toPath)"
name: "move(String fromPath, String toPath)"
nameWithType: "CosmosPatchOperations.move(String fromPath, String toPath)"
summary: "This moves the value of an object from the source to a destination."
parameters:
- description: "the source path for the operation."
name: "fromPath"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the destination path for the operation."
name: "toPath"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosPatchOperations move(String fromPath, String toPath)"
desc: "This moves the value of an object from the source to a destination. This performs the following based on different cases: 1. Source location points to an object as value, moves the entire object to the target location. 2. Target location specifies an object member that does not already exist, a new member is added to the object. Its value is set to the value of the source location. For the above JSON, we can have something like this: `CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create(); cosmosPatch.move(\"/a\", \"/c/d\"); // will move the value of \"/a\" to \"/c/d\" cosmosPatch.move(\"/b/e/1\", \"/d\"); // will move the object at the 2nd element of the array and set it as the value of \"/d\". cosmosPatch.move(\"/b\", \"/c\"); //It can also be used as a rename operation since now all values of \"/b\" will set as values of \"/c\".`"
returns:
description: "same instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref>"
type: "<xref href=\"com.azure.cosmos.models.CosmosPatchOperations?alt=com.azure.cosmos.models.CosmosPatchOperations&text=CosmosPatchOperations\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.models.CosmosPatchOperations.remove(java.lang.String)"
fullName: "com.azure.cosmos.models.CosmosPatchOperations.remove(String path)"
name: "remove(String path)"
nameWithType: "CosmosPatchOperations.remove(String path)"
summary: "This removes the value at the target location."
parameters:
- description: "the operation path."
name: "path"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosPatchOperations remove(String path)"
desc: "This removes the value at the target location. For the above JSON, we can have something like this: `CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create(); cosmosPatch.remove(\"/a\"); cosmosPatch.remove(\"/b/e/3\"); // will remove 4th element of /b/e array` This operation is not idempotent. Since once applied, next time it will return bad request due to path not found."
returns:
description: "same instance of <xref uid=\"com.azure.cosmos.models.CosmosPatchOperations\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosPatchOperations\"></xref>"
type: "<xref href=\"com.azure.cosmos.models.CosmosPatchOperations?alt=com.azure.cosmos.models.CosmosPatchOperations&text=CosmosPatchOperations\" data-throw-if-not-resolved=\"False\" />"
type: "class"
desc: "Grammar is a super set of this RFC: https://tools.ietf.org/html/rfc6902\\#section-4.1 Contains a list of Patch operations to be applied on an item. It is applied in an atomic manner and we support all the operation in above RFC and more. This can be executed in 3 ways: 1. Passing this to container in container.patchItem() which requires the id of the item to be patched, partition key, the CosmosPatchOperations instance, any CosmosItemRequestOptions and the class type for which response will be parsed. 2. Add CosmosPatchOperations instance in TransactionalBatch using batch.patchItemOperation() which requires the id of the item to be patched, cosmos patch instance and TransactionalBatchItemRequestOptions(if-any) and follow remaining steps for batch for it's execution. 3. Create a bulk item using <xref uid=\"com.azure.cosmos.models.CosmosBulkOperations.getPatchItemOperation(java.lang.String,com.azure.cosmos.models.PartitionKey,com.azure.cosmos.models.CosmosPatchOperations)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosBulkOperations#getPatchItemOperation(String, PartitionKey, CosmosPatchOperations)\"></xref> which requires the id of the item to be patched, cosmos patch instance, partition key and <xref uid=\"com.azure.cosmos.models.CosmosBulkItemRequestOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosBulkItemRequestOptions\"></xref>(if-any) and follow remaining steps to execute bulk operations. Let's assume this is the JSON for which we want to run patch operation. `{ a : \"xyz\" b : { c : \"efg: d : 4 e : [0, 1, 2 , 3] } }`"
metadata: {}
package: "com.azure.cosmos.models"
artifact: com.azure:azure-cosmos:4.63.4