All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cdk8s.JsonPatch Maven / Gradle / Ivy

Go to download

This is the core library of Cloud Development Kit (CDK) for Kubernetes (cdk8s). cdk8s apps synthesize into standard Kubernetes manifests which can be applied to any Kubernetes cluster.

There is a newer version: 2.69.27
Show newest version
package org.cdk8s;

/**
 * Utility for applying RFC-6902 JSON-Patch to a document.
 * 

* Use the the JsonPatch.apply(doc, ...ops) function to apply a set of * operations to a JSON document and return the result. *

* Operations can be created using the factory methods JsonPatch.add(), * JsonPatch.remove(), etc. *

* Example: *

*

 * const output = JsonPatch.apply(input,
 *  JsonPatch.replace('/world/hi/there', 'goodbye'),
 *  JsonPatch.add('/world/foo/', 'boom'),
 *  JsonPatch.remove('/hello'));
 * 
*/ @javax.annotation.Generated(value = "jsii-pacmak/1.88.0 (build eaabd08)", date = "2023-09-04T12:16:11.498Z") @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @software.amazon.jsii.Jsii(module = org.cdk8s.$Module.class, fqn = "cdk8s.JsonPatch") public class JsonPatch extends software.amazon.jsii.JsiiObject { protected JsonPatch(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); } protected JsonPatch(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { super(initializationMode); } /** * Adds a value to an object or inserts it into an array. *

* In the case of an * array, the value is inserted before the given index. The - character can be * used instead of an index to insert at the end of an array. *

* Example: *

*

     * JsonPatch.add('/biscuits/1', { "name": "Ginger Nut" })
     * 
*

* @param path This parameter is required. * @param value This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static @org.jetbrains.annotations.NotNull org.cdk8s.JsonPatch add(final @org.jetbrains.annotations.NotNull java.lang.String path, final @org.jetbrains.annotations.NotNull java.lang.Object value) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(org.cdk8s.JsonPatch.class, "add", software.amazon.jsii.NativeType.forClass(org.cdk8s.JsonPatch.class), new Object[] { java.util.Objects.requireNonNull(path, "path is required"), value }); } /** * Applies a set of JSON-Patch (RFC-6902) operations to document and returns the result. *

* @return The result document * @param document The document to patch. This parameter is required. * @param ops The operations to apply. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static @org.jetbrains.annotations.NotNull java.lang.Object apply(final @org.jetbrains.annotations.NotNull java.lang.Object document, final @org.jetbrains.annotations.NotNull org.cdk8s.JsonPatch... ops) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(org.cdk8s.JsonPatch.class, "apply", software.amazon.jsii.NativeType.forClass(java.lang.Object.class), java.util.stream.Stream.concat(java.util.Arrays.stream(new Object[] { document }), java.util.Arrays.stream(ops)).toArray(Object[]::new)); } /** * Copies a value from one location to another within the JSON document. *

* Both * from and path are JSON Pointers. *

* Example: *

*

     * JsonPatch.copy('/biscuits/0', '/best_biscuit')
     * 
*

* @param from This parameter is required. * @param path This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static @org.jetbrains.annotations.NotNull org.cdk8s.JsonPatch copy(final @org.jetbrains.annotations.NotNull java.lang.String from, final @org.jetbrains.annotations.NotNull java.lang.String path) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(org.cdk8s.JsonPatch.class, "copy", software.amazon.jsii.NativeType.forClass(org.cdk8s.JsonPatch.class), new Object[] { java.util.Objects.requireNonNull(from, "from is required"), java.util.Objects.requireNonNull(path, "path is required") }); } /** * Moves a value from one location to the other. *

* Both from and path are JSON Pointers. *

* Example: *

*

     * JsonPatch.move('/biscuits', '/cookies')
     * 
*

* @param from This parameter is required. * @param path This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static @org.jetbrains.annotations.NotNull org.cdk8s.JsonPatch move(final @org.jetbrains.annotations.NotNull java.lang.String from, final @org.jetbrains.annotations.NotNull java.lang.String path) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(org.cdk8s.JsonPatch.class, "move", software.amazon.jsii.NativeType.forClass(org.cdk8s.JsonPatch.class), new Object[] { java.util.Objects.requireNonNull(from, "from is required"), java.util.Objects.requireNonNull(path, "path is required") }); } /** * Removes a value from an object or array. *

* Example: *

*

     * JsonPatch.remove('/biscuits/0')
     * 
*

* @param path This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static @org.jetbrains.annotations.NotNull org.cdk8s.JsonPatch remove(final @org.jetbrains.annotations.NotNull java.lang.String path) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(org.cdk8s.JsonPatch.class, "remove", software.amazon.jsii.NativeType.forClass(org.cdk8s.JsonPatch.class), new Object[] { java.util.Objects.requireNonNull(path, "path is required") }); } /** * Replaces a value. *

* Equivalent to a “remove” followed by an “add”. *

* Example: *

*

     * JsonPatch.replace('/biscuits/0/name', 'Chocolate Digestive')
     * 
*

* @param path This parameter is required. * @param value This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static @org.jetbrains.annotations.NotNull org.cdk8s.JsonPatch replace(final @org.jetbrains.annotations.NotNull java.lang.String path, final @org.jetbrains.annotations.NotNull java.lang.Object value) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(org.cdk8s.JsonPatch.class, "replace", software.amazon.jsii.NativeType.forClass(org.cdk8s.JsonPatch.class), new Object[] { java.util.Objects.requireNonNull(path, "path is required"), value }); } /** * Tests that the specified value is set in the document. *

* If the test fails, * then the patch as a whole should not apply. *

* Example: *

*

     * JsonPatch.test('/best_biscuit/name', 'Choco Leibniz')
     * 
*

* @param path This parameter is required. * @param value This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static @org.jetbrains.annotations.NotNull org.cdk8s.JsonPatch test(final @org.jetbrains.annotations.NotNull java.lang.String path, final @org.jetbrains.annotations.NotNull java.lang.Object value) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(org.cdk8s.JsonPatch.class, "test", software.amazon.jsii.NativeType.forClass(org.cdk8s.JsonPatch.class), new Object[] { java.util.Objects.requireNonNull(path, "path is required"), value }); } }