db67d97947675b56b46b5bc822f37332662d29d4
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / INeutronCRUD.java
1 /*
2  * Copyright (c) 2015 Intel Corporation.  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.neutron.spi;
9
10 import java.util.List;
11 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
12
13 /**
14  * This interface defines the methods for CRUD of NB neutron objects.
15  */
16 public interface INeutronCRUD<T extends INeutronObject<T>> {
17
18     /**
19      * Applications call this interface method to determine if a particular Neutron
20      * object exists.
21      *
22      * @param uuid UUID of the Neutron object
23      * @param tx   the ReadTransaction within which to perform the check
24      * @return boolean
25      */
26     boolean exists(String uuid, ReadTransaction tx);
27
28     /**
29      * Applications call this interface method to return if a particular
30      * Neutron object exists.
31      *
32      * @param uuid
33      *            UUID of the Neutron object
34      * @return {@link org.opendaylight.neutron.spi.INeutronObject}
35      *          OpenStack Neutron class
36      */
37     T get(String uuid);
38
39     /**
40      * Applications call this interface method to return all Neutron objects.
41      *
42      * @return List of OpenStackNeutrons objects
43      */
44     List<T> getAll();
45
46     /**
47      * Applications call this interface method to add a Neutron object to the
48      * concurrent map.
49      *
50      * @param input
51      *            OpenStackNeutron object
52      * @return result with indication on whether the object was added or not and if so why
53      */
54     Result add(T input);
55
56     /**
57      * Applications call this interface method to remove a Neutron object to the
58      * concurrent map.
59      *
60      * @param uuid
61      *            identifier for the neutron object
62      * @return boolean on whether the object was removed or not
63      */
64     boolean remove(String uuid);
65
66     /**
67      * Applications call this interface method to edit a Neutron object.
68      *
69      * @param uuid
70      *            identifier of the neutron object
71      * @param delta
72      *            OpenStackNeutron object containing changes to apply
73      * @return boolean on whether the object was updated or not
74      */
75     boolean update(String uuid, T delta);
76
77     // TODO The Exception Result should eventually be replaced by propagating exceptions, and removed
78     enum Result { Success, AlreadyExists, DependencyMissing, Exception }
79
80 }