2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
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.mdsal.common.api.LogicalDatastoreType;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 * A handle to a set of operations being executed atomically on top of some backing store.
22 // FIXME: it seems the first two operations deal with lifecycle of a transaction, while others invoke various
23 // operations. This should be handled through proper allocation indirection.
25 public abstract class RestconfTransaction {
26 RestconfTransaction() {
31 * Rollback changes and unlock the datastore.
33 // FIXME: this looks synchronous, but it should not be
34 public abstract void cancel();
37 * Confirm previous operations.
39 * @return a FluentFuture containing the result of the commit information
41 public abstract FluentFuture<? extends @NonNull CommitInfo> commit();
44 * Delete data from the datastore.
46 * @param store the logical data store which should be modified
47 * @param path the data object path
49 public abstract void delete(LogicalDatastoreType store, YangInstanceIdentifier path);
52 * Remove data from the datastore.
54 * @param store the logical data store which should be modified
55 * @param path the data object path
57 public abstract void remove(LogicalDatastoreType store, YangInstanceIdentifier path);
60 * Merges a piece of data with the existing data at a specified path.
62 * @param store the logical data store which should be modified
63 * @param path the data object path
64 * @param data the data object to be merged to the specified path
66 public abstract void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data);
69 * Stores a piece of data at the specified path.
71 * @param store the logical data store which should be modified
72 * @param path the data object path
73 * @param data the data object to be merged to the specified path
74 * @param schemaContext static view of compiled yang files
76 public abstract void create(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data,
77 SchemaContext schemaContext);
80 * Replace a piece of data at the specified path.
82 * @param store the logical data store which should be modified
83 * @param path the data object path
84 * @param data the data object to be merged to the specified path
85 * @param schemaContext static view of compiled yang files
87 public abstract void replace(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data,
88 SchemaContext schemaContext);