blob: 7de54b339948e6d3df63f5a587196d5c50b97a24 [file] [log] [blame]
Scott Seaboltd51cafc2017-09-20 10:33:30 -04001.. _appc_client_library:
Scott Seabolt59153e92017-09-08 15:08:33 -04002
Scott Seaboltd51cafc2017-09-20 10:33:30 -04003==================================================
4Application Controller (APPC) Client Library Guide
5==================================================
6
7
8Revision History
9----------------
Scott Seabolt59153e92017-09-08 15:08:33 -040010
11+--------------+------------+---------------+--------------------------------------------------+
12| Date | Revision | Author | Changes |
13+--------------+------------+---------------+--------------------------------------------------+
Scott Seaboltd51cafc2017-09-20 10:33:30 -040014| 2017-08-22 | 1.0.0 | Paul Miller | First draft |
Scott Seabolt59153e92017-09-08 15:08:33 -040015+--------------+------------+---------------+--------------------------------------------------+
16+--------------+------------+---------------+--------------------------------------------------+
17
Scott Seaboltd51cafc2017-09-20 10:33:30 -040018Introduction
19============
Scott Seabolt59153e92017-09-08 15:08:33 -040020
Scott Seaboltd51cafc2017-09-20 10:33:30 -040021Target Audience
22---------------
Scott Seabolt59153e92017-09-08 15:08:33 -040023
Scott Seaboltd51cafc2017-09-20 10:33:30 -040024This document is for an advanced technical audience, which includes engineers and technicians. Document revisions occur with the release of new software versions.
Scott Seabolt59153e92017-09-08 15:08:33 -040025
26Related Documentation
27---------------------
28
Scott Seaboltd51cafc2017-09-20 10:33:30 -040029For additional information, see the ONAP Application Controller (APPC) API Guide.
Scott Seabolt59153e92017-09-08 15:08:33 -040030
Scott Seabolt59153e92017-09-08 15:08:33 -040031
32Client Library Background
Scott Seaboltd51cafc2017-09-20 10:33:30 -040033=========================
Scott Seabolt59153e92017-09-08 15:08:33 -040034
Scott Seaboltd51cafc2017-09-20 10:33:30 -040035This guide discusses the Application Controller (APPC) Client Library and how to use it.
Scott Seabolt59153e92017-09-08 15:08:33 -040036
37About the Client Library
38------------------------
39
Scott Seaboltd51cafc2017-09-20 10:33:30 -040040The 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.
Scott Seabolt59153e92017-09-08 15:08:33 -040041
42Consumer Logic
43--------------
44
Scott Seaboltd51cafc2017-09-20 10:33:30 -040045The client application that consumes APPCs 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.
Scott Seabolt59153e92017-09-08 15:08:33 -040046
47VNF Lifecycle Management API
48----------------------------
49
Scott Seaboltd51cafc2017-09-20 10:33:30 -040050The 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 applicationThe original YANG schema used by the APPC component and the underlying MD-SAL layer on the server-side generates these artifacts.
Scott Seabolt59153e92017-09-08 15:08:33 -040051
52APP-C Client Library Flow
53-------------------------
54
55 |image0|
56
Scott Seaboltd51cafc2017-09-20 10:33:30 -040057**Asynchronous Flow**
Scott Seabolt59153e92017-09-08 15:08:33 -040058
Scott Seaboltd51cafc2017-09-20 10:33:30 -040059- The APPC Client Library is called using an asynchronous API using a full command object, which is mapped to a JSON representation.
60- The APPC client calls the UEB client and sends the JSON command to a configured topic.
Scott Seabolt59153e92017-09-08 15:08:33 -040061- The APPC client pulls response messages from the configured topic.
Scott Seaboltd51cafc2017-09-20 10:33:30 -040062- On receiving the response for the command, the APPC client runs the relevant callback method of the consumer ResponseHandler.
Scott Seabolt59153e92017-09-08 15:08:33 -040063
Scott Seaboltd51cafc2017-09-20 10:33:30 -040064**Synchronous Flow**
Scott Seabolt59153e92017-09-08 15:08:33 -040065
Scott Seaboltd51cafc2017-09-20 10:33:30 -040066- The APPC Client Library is called using a synchronous API using a full command object, which is mapped to a JSON representation.
67- The APPC client calls the UEB client and sends the JSON command to a configured topic.
Scott Seabolt59153e92017-09-08 15:08:33 -040068- The APPC client pulls response messages from the configured topic.
Scott Seaboltd51cafc2017-09-20 10:33:30 -040069- On receiving the **final** response for the command, the APPC client returns the response object with a final status.
Scott Seabolt59153e92017-09-08 15:08:33 -040070
Scott Seaboltd51cafc2017-09-20 10:33:30 -040071Client Library Usage
72====================
73
74Jar Files
75---------
Scott Seabolt59153e92017-09-08 15:08:33 -040076
Scott Seaboltd51cafc2017-09-20 10:33:30 -040077The Java application that runs the APPC client kit uses the following jar files:
Scott Seabolt59153e92017-09-08 15:08:33 -040078
Scott Seaboltd51cafc2017-09-20 10:33:30 -040079 - com.att.appc.client.client-kit
80 - com.att.appc.client.client-lib
Scott Seabolt59153e92017-09-08 15:08:33 -040081
Scott Seaboltd51cafc2017-09-20 10:33:30 -040082The client library JAR files are located in the repository under ``com\\att\\appc\\client``.
Scott Seabolt59153e92017-09-08 15:08:33 -040083
Scott Seaboltd51cafc2017-09-20 10:33:30 -040084Initialization
Scott Seabolt2406a972017-09-13 17:31:44 -040085--------------
Scott Seabolt59153e92017-09-08 15:08:33 -040086
Scott Seaboltd51cafc2017-09-20 10:33:30 -040087Initialize the client by calling the following method:
Scott Seabolt59153e92017-09-08 15:08:33 -040088
Scott Seaboltd51cafc2017-09-20 10:33:30 -040089``AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class).createLifeCycleManagerStateful()``
Scott Seabolt59153e92017-09-08 15:08:33 -040090
Scott Seaboltd51cafc2017-09-20 10:33:30 -040091Specify the following configuration properties as method parameters:
Scott Seabolt59153e92017-09-08 15:08:33 -040092
Scott Seaboltd51cafc2017-09-20 10:33:30 -040093 - "topic.read"
94 - "topic.read.timeout"
95 - "topic.write"
96 - "client.key"
97 - "client.secret"
98 - "client.name"
99 - "client.name.id"
100 - "poolMembers"
101 - client.response.timeout
102 - client.graceful.shutdown.timeout
Scott Seabolt59153e92017-09-08 15:08:33 -0400103
104Shutdown
Scott Seabolt2406a972017-09-13 17:31:44 -0400105--------
Scott Seabolt59153e92017-09-08 15:08:33 -0400106
107Shutdown the client by calling the following method:
108
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400109``void shutdownLifeCycleManager(boolean isForceShutdown)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400110
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400111If 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``).
Scott Seabolt59153e92017-09-08 15:08:33 -0400112
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400113If the ``isForceShutdown`` flag is set to true, the client shuts down immediately.
Scott Seabolt59153e92017-09-08 15:08:33 -0400114
115Invoking LCM Commands
Scott Seabolt2406a972017-09-13 17:31:44 -0400116---------------------
Scott Seabolt59153e92017-09-08 15:08:33 -0400117
118Invoke the LCM commands by:
119
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400120 - Creating input objects, such as AuditInput, LiveUpgradeInput, with relevant command information.
121 - Executing commands asynchronously, for example:
Scott Seabolt59153e92017-09-08 15:08:33 -0400122
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400123``void liveUpgrade(LiveUpgradeInput liveUpgradeInput, ResponseHandler<LiveUpgradeOutput> listener) throws AppcClientException;)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400124
125In this case, client should implement the ResponseHandler<T> interface.
126
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400127 - Executing commands synchronously, for example:
Scott Seabolt59153e92017-09-08 15:08:33 -0400128
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400129``LiveUpgradeOutput liveUpgrade(LiveUpgradeInput liveUpgradeInput) throws AppcClientException;)``
130
Scott Seabolt59153e92017-09-08 15:08:33 -0400131
132Client API
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400133==========
Scott Seabolt59153e92017-09-08 15:08:33 -0400134
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400135After initializing the client, a returned Object of type LifeCycleManagerStateful defines all the Life Cycle Management APIs
136 supported by APPC.
Scott Seabolt59153e92017-09-08 15:08:33 -0400137
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400138The interface contains two definitions for each RPC: one for Asynchronous call mode, and one for Synchronous.
Scott Seabolt59153e92017-09-08 15:08:33 -0400139
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400140In Asynchronous mode, client consumer should provide a callback function of type:
Scott Seabolt59153e92017-09-08 15:08:33 -0400141
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400142 ``ResponseHandler<RPC-NAMEOutput>``
Scott Seabolt59153e92017-09-08 15:08:33 -0400143
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400144where ``RPC-NAME`` is the command name, such as Audit or Snapshot.
Scott Seabolt59153e92017-09-08 15:08:33 -0400145
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400146There may be multiple calls to the ResponseHandler for each response returned by APPC. For example, first 100 accept is returned, then 400 success’.
Scott Seabolt59153e92017-09-08 15:08:33 -0400147
148LifeCycleManagerStateful Interface
149----------------------------------
150
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400151Generated from the APPC Yang model, this interface defines the services and request/response requirements for the ECOMP APPC component. For example, for LCM Command Audit, the following is defined:
Scott Seabolt59153e92017-09-08 15:08:33 -0400152
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400153``@RPC(name="audit", outputType=AuditOutput.class)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400154
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400155``AuditOutput audit(AuditInput auditInput) throws AppcClientException;``
Scott Seabolt59153e92017-09-08 15:08:33 -0400156
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400157For a Synchronous call to Audit, the consumer thread is blocked until a response is received or a timeout exception is thrown.
Scott Seabolt59153e92017-09-08 15:08:33 -0400158
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400159``@RPC(name="audit", outputType=AuditOutput.class)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400160
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400161``void audit(AuditInput auditInput, ResponseHandler<AuditOutput> listener) throws AppcClientException;``
Scott Seabolt59153e92017-09-08 15:08:33 -0400162
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400163For an Asynchronous call to Audit, a callback should be provided so that when a response is received the listener is called.
Scott Seabolt59153e92017-09-08 15:08:33 -0400164
165API documentation
166-----------------
167
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400168The API documentation is also available as a swagger page generated from files at /client-kit/target/resources.
Scott Seabolt59153e92017-09-08 15:08:33 -0400169
170appc-provider-lcm
171-----------------
172
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400173This defines the services and request/response requirements for the APPC component.
Scott Seabolt59153e92017-09-08 15:08:33 -0400174
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400175Methods
Scott Seabolt59153e92017-09-08 15:08:33 -0400176--------
177
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400178The methods should match the actions described in the LCM API Guide. For each method:
Scott Seabolt59153e92017-09-08 15:08:33 -0400179
180**Consumes**
181
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400182This API call consumes the following media types using the**Content-Type** request header:
Scott Seabolt59153e92017-09-08 15:08:33 -0400183
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400184 - ``application/json``
Scott Seabolt59153e92017-09-08 15:08:33 -0400185
186**Request body**
187
188The request body is the action name followed by Input (e.g., AuditInput)
189
190**Return type**
191
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400192The return type is the action name followed by Output (e.g., OutputInput)
Scott Seabolt59153e92017-09-08 15:08:33 -0400193
194**Produces**
195
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400196This API call produces the following media types according to the **Accept** request header; the **Content-Type** response header conveys the media type.
Scott Seabolt59153e92017-09-08 15:08:33 -0400197
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400198 - ``application/json``
Scott Seabolt59153e92017-09-08 15:08:33 -0400199
200**Responses**
201
202200 Successful operation
203
204401 Unauthorized
205
206500 Internal server error
207
208.. |image0| image:: image2.png
209 :width: 5.60495in
210 :height: 4.55272in