blob: 246ba323f55e954e6f5a4a4136b42de84479e454 [file] [log] [blame]
VinodKumarS-Huaweiaf9c7a72016-08-30 19:43:39 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.yms.ych;
18
19import org.onosproject.yms.ydt.YdtBuilder;
20import org.onosproject.yms.ydt.YmsOperationType;
21
22/**
23 * Abstraction of an entity which overrides the default codec.
24 *
25 * YANG has it extension framework which allows vendor / implementation
26 * specific operation or extensions. The default CODECs will fail to handle
27 * such protocol requests. In such scenarios, the providers can register
28 * their specific CODEC's with the YANG codec utility to translate the protocol
29 * specific data to abstract YANG data tree, from which it can be translate into
30 * the YANG modelled java objects for the provider / driver to operate on the
31 * device.
32 */
33
34public interface YangDataTreeCodec {
35 /**
36 * When the YMS need to encode simple protocol operation request,
37 * it will translate the YANG objects into an abstract YANG data tree and
38 * invoke this registered encode method. Protocol CODEC implementation
39 * needs to ensure the overridden method can handle any specific
40 * extension or representation of protocol data.
41 * The operation type will be set in YANG data tree builder.
42 *
43 * @param ydtBuilder Abstract YANG data tree contains the operation
44 * request
45 * @param protocolOperation protocol operation being performed
46 * @return protocol specific string representation.
47 */
48 String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder,
49 YmsOperationType protocolOperation);
50
51 /**
52 * When the YMS need to encode composite protocol operation request, it
53 * will translate the YANG objects into an abstract YANG data
54 * tree and invoke this registered encode method. Protocol CODEC
55 * implementation needs to ensure the overridden method can handle any
56 * specific extension or representation of protocol data.
57 * The Initial chain of node in the YDT will have the operation type set
58 * to NONE to specify it is a resource identifier. The Resource
59 * information is maintained as a subtree to the resource identifier node.
60 *
61 * @param ydtBuilder Abstract YANG data tree contains the operation
62 * request
63 * @param protocolOperation protocol operation being performed
64 * @return composite response containing the requested operation
65 * information
66 */
67 YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
68 YdtBuilder ydtBuilder, YmsOperationType protocolOperation);
69
70 /**
71 * When YMS decode simple protocol operation request it uses the
72 * registered decode method to translate the protocol data into a
73 * abstract YANG data tree. Then translate the abstract YANG data
74 * tree into the YANG modeled Java objects.
75 * The CODEC implementation are unaware of the schema against which they
76 * are performing the codec operation, so YMS will send the schema
77 * registry on which the YANG data tree needs to operate, so the code
78 * implementation needs to pass this schema registry to the get a YDT
79 * builder.
80 *
81 * @param protocolData input string containing the simple
82 * protocol data which needs to be decoded
83 * @param schemaRegistryForYdt Schema registry based on which the YANG
84 * data tree will be built
85 * @param protocolOperation protocol operation being performed
86 * @return decoded operation request in YANG data tree
87 */
88 YdtBuilder decodeProtocolDataToYdt(String protocolData,
89 Object schemaRegistryForYdt,
90 YmsOperationType protocolOperation);
91
92 /**
93 * When YMS decode composite protocol operation request it uses the
94 * registered decode method to translate the protocol data into a
95 * abstract YANG data tree. Then translate the abstract YANG data
96 * tree into the YANG modeled Java objects.
97 * The CODEC implementation are unaware of the schema against which they
98 * are performing the codec operation, so YMS will send the schema
99 * registry on which the YANG data tree needs to operate, so the code
100 * implementation needs to pass this schema registry to the get a YDT
101 * builder.
102 *
103 * @param protocolData composite input string containing the
104 * protocol data which needs to be decoded
105 * @param schemaRegistryForYdt Schema registry based on which the YANG
106 * data tree will be built
107 * @param protocolOperation protocol operation being performed
108 * @return decoded operation request in YANG data tree
109 */
110 YdtBuilder decodeCompositeProtocolDataToYdt(
111 YangCompositeEncoding protocolData, Object schemaRegistryForYdt,
112 YmsOperationType protocolOperation);
113}