use an EmptyStringAsNullAdapter in NeutronObject re. null tenant_id
[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 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
13 import org.opendaylight.yangtools.yang.common.OperationFailedException;
14
15 /**
16  * This interface defines the methods for CRUD of NB neutron objects.
17  */
18 public interface INeutronCRUD<T extends INeutronObject<T>> {
19
20     /**
21      * Applications call this interface method to determine if a particular Neutron
22      * object exists.
23      *
24      * @param uuid UUID of the Neutron object
25      * @param tx   the ReadTransaction within which to perform the check
26      * @return boolean
27      * @throws ReadFailedException if the read failed
28      */
29     boolean exists(String uuid, ReadTransaction tx) throws ReadFailedException;
30
31     /**
32      * Applications call this interface method to return if a particular
33      * Neutron object exists.
34      *
35      * @param uuid
36      *            UUID of the Neutron object
37      * @return {@link org.opendaylight.neutron.spi.INeutronObject}
38      *          OpenStack Neutron class
39      * @throws ReadFailedException if the read failed
40      */
41     T get(String uuid) throws ReadFailedException;
42
43     /**
44      * Applications call this interface method to return all Neutron objects.
45      *
46      * @return List of OpenStackNeutrons objects
47      * @throws ReadFailedRuntimeException if the read failed
48      */
49     List<T> getAll() throws ReadFailedRuntimeException;
50
51     /**
52      * Applications call this interface method to add a Neutron object to the
53      * concurrent map.
54      *
55      * @param input
56      *            OpenStackNeutron object
57      * @return result with indication on whether the object was added or not and if so why
58      * @throws OperationFailedException if the write (or a required implicit read) failed
59      */
60     Result add(T input) throws OperationFailedException;
61
62     /**
63      * Applications call this interface method to remove a Neutron object to the
64      * concurrent map.
65      *
66      * @param uuid
67      *            identifier for the neutron object
68      * @return boolean on whether the object was removed or not
69      * @throws OperationFailedException if the remove (or a required implicit read) failed
70      */
71     boolean remove(String uuid) throws OperationFailedException;
72
73     /**
74      * Applications call this interface method to edit a Neutron object.
75      *
76      * @param uuid
77      *            identifier of the neutron object
78      * @param delta
79      *            OpenStackNeutron object containing changes to apply
80      * @return boolean on whether the object was updated or not
81      * @throws OperationFailedException if the update (or a required implicit read) failed
82      */
83     Result update(String uuid, T delta) throws OperationFailedException;
84
85     enum Result { Success, AlreadyExists, DoesNotExist, DependencyMissing }
86
87 }