Change ECOMP by ONAP
[appc.git] / docs / APPC Client Library Guide / APPC Client Library Guide.rst
1 .. _appc_client_library:
2
3 ==================================================
4 Application Controller (APPC) Client Library Guide
5 ==================================================
6
7
8 Revision History
9 ================
10
11 +--------------+------------+---------------+--------------------------------------------------+
12 | Date         | Revision   | Author        | Changes                                          |
13 +--------------+------------+---------------+--------------------------------------------------+
14 | 2017-08-22   | 1.0.0      | Paul Miller   | First draft                                      |
15 +--------------+------------+---------------+--------------------------------------------------+
16
17 Introduction
18 ============
19
20 Target Audience
21 ---------------
22
23 This document is for an advanced technical audience, which includes engineers and technicians. Document revisions occur with the release of new software versions.
24
25 Related Documentation
26 ---------------------
27
28 For additional information, see
29
30         :ref:`appc_api_guide`
31
32
33 Client Library Background
34 =========================
35
36 This guide discusses the Application Controller (APPC) Client Library and how to use it.
37
38 About the Client Library
39 ------------------------
40
41 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 UEB.
42
43 Consumer Logic
44 --------------
45
46 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.
47
48 VNF Lifecycle Management API
49 ----------------------------
50
51 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.
52
53 APP-C Client Library Flow
54 -------------------------
55
56     |image0|
57
58 Asynchronous Flow
59 ^^^^^^^^^^^^^^^^^
60
61 -  The APPC Client Library is called using an asynchronous API using a full command object, which is mapped to a JSON representation.
62 -  The APPC client calls the UEB client and sends the JSON command to a configured topic.
63 -  The APPC client pulls response messages from the configured topic.
64 -  On receiving the response for the command, the APPC client runs the relevant callback method of the consumer ResponseHandler.
65
66 Synchronous Flow
67 ^^^^^^^^^^^^^^^^
68
69 -  The APPC Client Library is called using a synchronous API using a full command object, which is mapped to a JSON representation.
70 -  The APPC client calls the UEB 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 **final** response for the command, the APPC client returns the response object with a final status.
73
74 Client Library Usage
75 ====================
76
77 Jar Files
78 ---------
79
80 The Java application that runs the APPC client kit uses the following jar files:
81
82     -  com.att.appc.client.client-kit
83     -  com.att.appc.client.client-lib
84
85 The client library JAR files are located in the repository under ``com\\att\\appc\\client``.
86
87 Initialization
88 --------------
89
90 Initialize the client by calling the following method:
91
92 ``AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class).createLifeCycleManagerStateful()``
93
94 Specify the following configuration properties as method parameters:
95
96     -  "topic.read"
97     -  "topic.read.timeout"
98     -  "topic.write"
99     -  "client.key"
100     -  "client.secret"
101     -  "client.name"
102     -  "client.name.id"
103     -  "poolMembers"
104     -  “client.response.timeout”
105     -  “client.graceful.shutdown.timeout”
106
107 Shutdown
108 --------
109
110 Shutdown the client by calling the following method:
111
112 ``void shutdownLifeCycleManager(boolean isForceShutdown)``
113
114 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``).
115
116 If the ``isForceShutdown`` flag is set to true, the client shuts down immediately.
117
118 Invoking LCM Commands
119 ---------------------
120
121 Invoke the LCM commands by:
122
123     -  Creating input objects, such as AuditInput, LiveUpgradeInput, with relevant command information.
124     -  Executing commands asynchronously, for example:
125
126 ``void liveUpgrade(LiveUpgradeInput liveUpgradeInput, ResponseHandler<LiveUpgradeOutput> listener) throws AppcClientException;)``
127
128 In this case, client should implement the ResponseHandler<T> interface.
129
130     -  Executing commands synchronously, for example:
131
132 ``LiveUpgradeOutput liveUpgrade(LiveUpgradeInput liveUpgradeInput) throws AppcClientException;)``
133
134
135 Client API
136 ==========
137
138 After initializing the client, a returned Object of type LifeCycleManagerStateful defines all the Life Cycle Management APIs
139  supported by APPC.
140
141 The interface contains two definitions for each RPC: one for Asynchronous call mode, and one for Synchronous.
142
143 In Asynchronous mode, client consumer should provide a callback function of type:
144
145     ``ResponseHandler<RPC-NAMEOutput>``
146
147 where ``RPC-NAME`` is the command name, such as Audit or Snapshot.
148
149 There may be multiple calls to the ResponseHandler for each response returned by APPC. For example, first 100 ‘accept’ is returned, then 400 ‘success’.
150
151 LifeCycleManagerStateful Interface
152 ----------------------------------
153
154 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:
155
156 ``@RPC(name="audit", outputType=AuditOutput.class)``
157
158 ``AuditOutput audit(AuditInput auditInput) throws AppcClientException;``
159
160 For a Synchronous call to Audit, the consumer thread is blocked until a response is received or a timeout exception is thrown.
161
162 ``@RPC(name="audit", outputType=AuditOutput.class)``
163
164 ``void audit(AuditInput auditInput, ResponseHandler<AuditOutput> listener) throws AppcClientException;``
165
166 For an Asynchronous call to Audit, a callback should be provided so that when a response is received the listener is called.
167
168 API documentation
169 -----------------
170
171 The API documentation is also available as a swagger page generated from files at /client-kit/target/resources.
172
173 appc-provider-lcm
174 -----------------
175
176 This defines the services and request/response requirements for the APPC component.
177
178 Methods
179 -------
180
181 The methods should match the actions described in the LCM API Guide. For each method:
182
183 **Consumes**
184
185 This API call consumes the following media types using the**Content-Type** request header:
186
187     -  ``application/json``
188
189 **Request body**
190
191 The request body is the action name followed by Input (e.g., AuditInput)
192
193 **Return type**
194
195 The return type is the action name followed by Output (e.g., OutputInput)
196
197 **Produces**
198
199 This API call produces the following media types according to the **Accept** request header; the **Content-Type** response header conveys the media type.
200
201     -  ``application/json``
202
203 **Responses**
204
205 200 Successful operation
206
207 401 Unauthorized
208
209 500 Internal server error
210
211 .. |image0| image:: image2.png
212    :width: 5.60495in
213    :height: 4.55272in