Bump upstreams to SNAPSHOTs
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / transactions / RestconfTransaction.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.util.concurrent.FluentFuture;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.common.api.CommitInfo;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
17
18 /**
19  * A handle to a set of operations being executed atomically on top of some backing store.
20  */
21 // FIXME: it seems the first two operations deal with lifecycle of a transaction, while others invoke various
22 //        operations. This should be handled through proper allocation indirection.
23 @Beta
24 public abstract class RestconfTransaction {
25     RestconfTransaction() {
26         // Hidden on purpose
27     }
28
29     /**
30      * Rollback changes and unlock the datastore.
31      */
32     // FIXME: this looks synchronous, but it should not be
33     public abstract void cancel();
34
35     /**
36      * Confirm previous operations.
37      *
38      * @return a FluentFuture containing the result of the commit information
39      */
40     public abstract FluentFuture<? extends @NonNull CommitInfo> commit();
41
42     /**
43      * Delete data from the datastore.
44      *
45      * @param path the data object path
46      */
47     public abstract void delete(YangInstanceIdentifier path);
48
49     /**
50      * Remove data from the datastore.
51      *
52      * @param path  the data object path
53      */
54     public abstract void remove(YangInstanceIdentifier path);
55
56     /**
57      * Merges a piece of data with the existing data at a specified path.
58      *
59      * @param path the data object path
60      * @param data the data object to be merged to the specified path
61      */
62     public abstract void merge(YangInstanceIdentifier path, NormalizedNode data);
63
64     /**
65      * Stores a piece of data at the specified path.
66      *
67      * @param path          the data object path
68      * @param data          the data object to be merged to the specified path
69      * @param schemaContext static view of compiled yang files
70      */
71     public abstract void create(YangInstanceIdentifier path, NormalizedNode data, EffectiveModelContext schemaContext);
72
73     /**
74      * Replace a piece of data at the specified path.
75      *
76      * @param path          the data object path
77      * @param data          the data object to be merged to the specified path
78      * @param schemaContext static view of compiled yang files
79      */
80     public abstract void replace(YangInstanceIdentifier path, NormalizedNode data, EffectiveModelContext schemaContext);
81 }