Changed to unmaintained
[appc.git] / docs / APPC-Client-Library-Guide / APPC-Client-Library-Guide.rst
1 .. ============LICENSE_START==========================================
2 .. ===================================================================
3 .. Copyright © 2017 AT&T Intellectual Property. All rights reserved.
4 .. ===================================================================
5 .. Licensed under the Creative Commons License, Attribution 4.0 Intl.  (the "License");
6 .. you may not use this documentation except in compliance with the License.
7 .. You may obtain a copy of the License at
8 .. 
9 ..  https://creativecommons.org/licenses/by/4.0/
10 .. 
11 .. Unless required by applicable law or agreed to in writing, software
12 .. distributed under the License is distributed on an "AS IS" BASIS,
13 .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 .. See the License for the specific language governing permissions and
15 .. limitations under the License.
16 .. ============LICENSE_END============================================
17
18 .. _appc_client_library:
19
20 =========================
21 APPC Client Library Guide
22 =========================
23
24
25 Introduction
26 ============
27
28 Target Audience
29 ---------------
30
31 This document is for an advanced technical audience, which includes engineers and technicians. Document revisions occur with the release of new software versions.
32
33 Related Documentation
34 ---------------------
35
36 For additional information, see
37
38         :ref:`appc_api_guide`
39
40
41 Client Library Background
42 =========================
43
44 This guide discusses the Application Controller (APPC) Client Library and how to use it.
45
46 About the Client Library
47 ------------------------
48
49 The APPC client library provides consumers of APPC capabilities with a strongly-typed Java interface and encapsulates the actual interaction with the APPC component over an asynchronous messaging channel such as DMaaP.
50
51 Consumer Logic
52 --------------
53
54 The client application that consumes APPC’s capability for VNF lifecycle management (the APPC client library) can be implemented against the lightweight and strongly-typed Java API exposed by the APPC client library. The library does not try to impose architectural constraints upon clients, but instead provides support for different options and styles of API. It is the responsibility of the client application to select the most suitable paradigm to use; for example, a client may choose to use blocking calls as opposed to asynchronous notifications.
55
56 VNF Lifecycle Management API
57 ----------------------------
58
59 The API represents a relatively thin layer that consists mainly of business interfaces with strongly-typed APIs and a data object model created for the convenience of the consumer application. The original YANG schema used by the APPC component and the  underlying MD-SAL layer on the server-side generates these artifacts.
60
61 APP-C Client Library Flow
62 -------------------------
63
64     |image0|
65
66 Asynchronous Flow
67 ^^^^^^^^^^^^^^^^^
68
69 -  The APPC Client Library is called using an asynchronous API utilizing a full command object, which is mapped to a JSON representation.
70 -  The APPC client calls the DMaaP client and sends the JSON command to a configured topic.
71 -  The APPC client pulls response messages from the configured topic.
72 -  On receiving the response for the command, the APPC client runs the relevant callback method of the consumer ResponseHandler.
73
74 Synchronous Flow
75 ^^^^^^^^^^^^^^^^
76
77 -  The APPC Client Library is called using a synchronous API using a full command object, which is mapped to a JSON representation.
78 -  The APPC client calls the DMaaP client and sends the JSON command to a configured topic.
79 -  The APPC client pulls response messages from the configured topic.
80 -  On receiving the **final** response for the command, the APPC client returns the response object with a final status.
81
82 Client Library Usage
83 ====================
84
85 Jar Files
86 ---------
87
88 The Java application that runs the APPC client kit uses the following jar files:
89
90     -  org.onap.appc.client:client-kit
91     -  org.onap.appc.client:client-lib
92
93 The client library JAR files are located in the repository under ``com\att\appc\client``.
94
95 Initialization
96 --------------
97
98 Initialize the client by calling the following method:
99
100 ``AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class).createLifeCycleManagerStateful()``
101
102 Specify the following configuration properties as method parameters:
103
104     -  "topic.read"
105     -  "topic.read.timeout"
106     -  "topic.write"
107     -  "client.key"
108     -  "client.secret"
109     -  "client.name"
110     -  "client.name.id"
111     -  "poolMembers"
112     -  “client.response.timeout”
113     -  “client.graceful.shutdown.timeout”
114     -  “controllerType”
115
116 Shutdown
117 --------
118
119 Shutdown the client by calling the following method, first if Controller Type is not included, the second when Controller Type is included:
120
121 ``void shutdownLifeCycleManager(boolean isForceShutdown)``, or 
122 ``void shutdownLifeCycleManager(boolean isForceShutdown, String controllerType)``
123
124 If the ``isForceShutdown`` flag is set to false, the client shuts down as soon as all responses for pending requests are received, or upon configurable timeout. (``client.graceful.shutdown.timeout``).
125
126 If the ``isForceShutdown`` flag is set to true, the client shuts down immediately.
127
128 Invoking LCM Commands
129 ---------------------
130
131 Invoke the LCM commands by:
132
133     -  Creating input objects, such as AuditInput, LiveUpgradeInput, with relevant command information.
134     -  Executing commands asynchronously, for example:
135
136 ``void liveUpgrade(LiveUpgradeInput liveUpgradeInput, ResponseHandler<LiveUpgradeOutput> listener) throws AppcClientException;)``
137
138 In this case, client should implement the ResponseHandler<T> interface.
139
140     -  Executing commands synchronously, for example:
141
142 ``LiveUpgradeOutput liveUpgrade(LiveUpgradeInput liveUpgradeInput) throws AppcClientException;)``
143
144
145 Client API
146 ==========
147
148 After initializing the client, a returned Object of type LifeCycleManagerStateful defines all the Life Cycle Management APIs
149  supported by APPC.
150
151 The interface contains two definitions for each RPC: one for Asynchronous call mode, and one for Synchronous.
152
153 In Asynchronous mode, client consumer should provide a callback function of type:
154
155     ``ResponseHandler<RPC-NAMEOutput>``
156
157 where ``RPC-NAME`` is the command name, such as Audit or Snapshot.
158
159 There may be multiple calls to the ResponseHandler for each response returned by APPC. For example, first 100 ‘accept’ is returned, then 400 ‘success’.
160
161 LifeCycleManagerStateful Interface
162 ----------------------------------
163
164 Generated from the APPC Yang model, this interface defines the services and request/response requirements for the ONAP APPC component. For example, for LCM Command Audit, the following is defined:
165
166 ``@RPC(name="audit", outputType=AuditOutput.class)``
167
168 ``AuditOutput audit(AuditInput auditInput) throws AppcClientException;``
169
170 For a Synchronous call to Audit, the consumer thread is blocked until a response is received or a timeout exception is thrown.
171
172 ``@RPC(name="audit", outputType=AuditOutput.class)``
173
174 ``void audit(AuditInput auditInput, ResponseHandler<AuditOutput> listener) throws AppcClientException;``
175
176 For an Asynchronous call to Audit, a callback should be provided so that when a response is received the listener is called.
177
178 API documentation
179 -----------------
180
181 The API documentation is also available as a swagger page generated from files at /client-kit/target/resources.
182
183 appc-provider-lcm
184 -----------------
185
186 This defines the services and request/response requirements for the APPC component.
187
188 Methods
189 -------
190
191 The methods should match the actions described in the LCM API Guide. For each method:
192
193 **Consumes**
194
195 This API call consumes the following media types using the**Content-Type** request header:
196
197     -  ``application/json``
198
199 **Request body**
200
201 The request body is the action name followed by Input (e.g., AuditInput)
202
203 **Return type**
204
205 The return type is the action name followed by Output (e.g., OutputInput)
206
207 **Produces**
208
209 This API call produces the following media types according to the **Accept** request header; the **Content-Type** response header conveys the media type.
210
211     -  ``application/json``
212
213 **Responses**
214
215 200 Successful operation
216
217 401 Unauthorized
218
219 500 Internal server error
220
221 .. |image0| image:: image2.png
222    :width: 5.60495in
223    :height: 4.55272in
224