blob: 0c5723438ff6b14fa19662b766702bd4a8efceb1 [file] [log] [blame]
Scott Seabolt78a683e2017-10-23 09:11:51 -04001.. ============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.. ECOMP is a trademark and service mark of AT&T Intellectual Property.
18
Scott Seaboltd51cafc2017-09-20 10:33:30 -040019.. _appc_client_library:
Scott Seabolt59153e92017-09-08 15:08:33 -040020
Hector Anapan9613c042017-10-18 21:02:18 -040021=========================
22APPC Client Library Guide
23=========================
Scott Seaboltd51cafc2017-09-20 10:33:30 -040024
25
Scott Seaboltd51cafc2017-09-20 10:33:30 -040026Introduction
27============
Scott Seabolt59153e92017-09-08 15:08:33 -040028
Scott Seaboltd51cafc2017-09-20 10:33:30 -040029Target Audience
30---------------
Scott Seabolt59153e92017-09-08 15:08:33 -040031
Scott Seaboltd51cafc2017-09-20 10:33:30 -040032This 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 -040033
34Related Documentation
35---------------------
36
Eric Debeaud057edd2017-10-19 17:09:44 +000037For additional information, see
Scott Seaboltf7824832017-10-10 11:27:11 -040038
Eric Debeaud057edd2017-10-19 17:09:44 +000039 :ref:`appc_api_guide`
Scott Seabolt59153e92017-09-08 15:08:33 -040040
Scott Seabolt59153e92017-09-08 15:08:33 -040041
42Client Library Background
Scott Seaboltd51cafc2017-09-20 10:33:30 -040043=========================
Scott Seabolt59153e92017-09-08 15:08:33 -040044
Scott Seaboltd51cafc2017-09-20 10:33:30 -040045This guide discusses the Application Controller (APPC) Client Library and how to use it.
Scott Seabolt59153e92017-09-08 15:08:33 -040046
47About the Client Library
48------------------------
49
Scott Seaboltd51cafc2017-09-20 10:33:30 -040050The 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 -040051
52Consumer Logic
53--------------
54
Scott Seaboltd51cafc2017-09-20 10:33:30 -040055The 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 -040056
57VNF Lifecycle Management API
58----------------------------
59
Scott Seaboltd51cafc2017-09-20 10:33:30 -040060The 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 -040061
62APP-C Client Library Flow
63-------------------------
64
65 |image0|
66
Scott Seaboltf7824832017-10-10 11:27:11 -040067Asynchronous Flow
68^^^^^^^^^^^^^^^^^
Scott Seabolt59153e92017-09-08 15:08:33 -040069
Takad16f5c92017-12-05 14:58:12 -050070- The APPC Client Library is called using an asynchronous API utilizing a full command object, which is mapped to a JSON representation.
Scott Seaboltd51cafc2017-09-20 10:33:30 -040071- The APPC client calls the UEB client and sends the JSON command to a configured topic.
Scott Seabolt59153e92017-09-08 15:08:33 -040072- The APPC client pulls response messages from the configured topic.
Scott Seaboltd51cafc2017-09-20 10:33:30 -040073- 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 -040074
Scott Seaboltf7824832017-10-10 11:27:11 -040075Synchronous Flow
76^^^^^^^^^^^^^^^^
Scott Seabolt59153e92017-09-08 15:08:33 -040077
Scott Seaboltd51cafc2017-09-20 10:33:30 -040078- The APPC Client Library is called using a synchronous API using a full command object, which is mapped to a JSON representation.
79- The APPC client calls the UEB client and sends the JSON command to a configured topic.
Scott Seabolt59153e92017-09-08 15:08:33 -040080- The APPC client pulls response messages from the configured topic.
Scott Seaboltd51cafc2017-09-20 10:33:30 -040081- 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 -040082
Scott Seaboltd51cafc2017-09-20 10:33:30 -040083Client Library Usage
84====================
Eric Debeaud057edd2017-10-19 17:09:44 +000085
Scott Seaboltd51cafc2017-09-20 10:33:30 -040086Jar Files
87---------
Scott Seabolt59153e92017-09-08 15:08:33 -040088
Scott Seaboltd51cafc2017-09-20 10:33:30 -040089The Java application that runs the APPC client kit uses the following jar files:
Scott Seabolt59153e92017-09-08 15:08:33 -040090
Patrick Brady07567592017-12-13 11:09:30 -080091 - org.onap.appc.client:client-kit
92 - org.onap.appc.client:client-lib
Scott Seabolt59153e92017-09-08 15:08:33 -040093
Scott Seaboltd51cafc2017-09-20 10:33:30 -040094The client library JAR files are located in the repository under ``com\\att\\appc\\client``.
Scott Seabolt59153e92017-09-08 15:08:33 -040095
Eric Debeaud057edd2017-10-19 17:09:44 +000096Initialization
Scott Seabolt2406a972017-09-13 17:31:44 -040097--------------
Scott Seabolt59153e92017-09-08 15:08:33 -040098
Scott Seaboltd51cafc2017-09-20 10:33:30 -040099Initialize the client by calling the following method:
Scott Seabolt59153e92017-09-08 15:08:33 -0400100
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400101``AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class).createLifeCycleManagerStateful()``
Scott Seabolt59153e92017-09-08 15:08:33 -0400102
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400103Specify the following configuration properties as method parameters:
Scott Seabolt59153e92017-09-08 15:08:33 -0400104
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400105 - "topic.read"
106 - "topic.read.timeout"
107 - "topic.write"
108 - "client.key"
109 - "client.secret"
110 - "client.name"
111 - "client.name.id"
112 - "poolMembers"
113 - client.response.timeout
114 - client.graceful.shutdown.timeout
Scott Seabolt59153e92017-09-08 15:08:33 -0400115
116Shutdown
Scott Seabolt2406a972017-09-13 17:31:44 -0400117--------
Scott Seabolt59153e92017-09-08 15:08:33 -0400118
119Shutdown the client by calling the following method:
120
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400121``void shutdownLifeCycleManager(boolean isForceShutdown)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400122
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400123If 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 -0400124
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400125If the ``isForceShutdown`` flag is set to true, the client shuts down immediately.
Scott Seabolt59153e92017-09-08 15:08:33 -0400126
127Invoking LCM Commands
Scott Seabolt2406a972017-09-13 17:31:44 -0400128---------------------
Scott Seabolt59153e92017-09-08 15:08:33 -0400129
130Invoke the LCM commands by:
131
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400132 - Creating input objects, such as AuditInput, LiveUpgradeInput, with relevant command information.
133 - Executing commands asynchronously, for example:
Scott Seabolt59153e92017-09-08 15:08:33 -0400134
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400135``void liveUpgrade(LiveUpgradeInput liveUpgradeInput, ResponseHandler<LiveUpgradeOutput> listener) throws AppcClientException;)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400136
137In this case, client should implement the ResponseHandler<T> interface.
138
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400139 - Executing commands synchronously, for example:
Scott Seabolt59153e92017-09-08 15:08:33 -0400140
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400141``LiveUpgradeOutput liveUpgrade(LiveUpgradeInput liveUpgradeInput) throws AppcClientException;)``
142
Scott Seabolt59153e92017-09-08 15:08:33 -0400143
144Client API
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400145==========
Scott Seabolt59153e92017-09-08 15:08:33 -0400146
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400147After initializing the client, a returned Object of type LifeCycleManagerStateful defines all the Life Cycle Management APIs
148 supported by APPC.
Scott Seabolt59153e92017-09-08 15:08:33 -0400149
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400150The interface contains two definitions for each RPC: one for Asynchronous call mode, and one for Synchronous.
Scott Seabolt59153e92017-09-08 15:08:33 -0400151
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400152In Asynchronous mode, client consumer should provide a callback function of type:
Scott Seabolt59153e92017-09-08 15:08:33 -0400153
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400154 ``ResponseHandler<RPC-NAMEOutput>``
Scott Seabolt59153e92017-09-08 15:08:33 -0400155
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400156where ``RPC-NAME`` is the command name, such as Audit or Snapshot.
Scott Seabolt59153e92017-09-08 15:08:33 -0400157
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400158There 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 -0400159
160LifeCycleManagerStateful Interface
161----------------------------------
162
Eric Debeaud057edd2017-10-19 17:09:44 +0000163Generated 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:
Scott Seabolt59153e92017-09-08 15:08:33 -0400164
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400165``@RPC(name="audit", outputType=AuditOutput.class)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400166
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400167``AuditOutput audit(AuditInput auditInput) throws AppcClientException;``
Scott Seabolt59153e92017-09-08 15:08:33 -0400168
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400169For 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 -0400170
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400171``@RPC(name="audit", outputType=AuditOutput.class)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400172
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400173``void audit(AuditInput auditInput, ResponseHandler<AuditOutput> listener) throws AppcClientException;``
Scott Seabolt59153e92017-09-08 15:08:33 -0400174
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400175For 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 -0400176
177API documentation
178-----------------
179
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400180The API documentation is also available as a swagger page generated from files at /client-kit/target/resources.
Scott Seabolt59153e92017-09-08 15:08:33 -0400181
182appc-provider-lcm
183-----------------
184
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400185This defines the services and request/response requirements for the APPC component.
Scott Seabolt59153e92017-09-08 15:08:33 -0400186
Eric Debeaud057edd2017-10-19 17:09:44 +0000187Methods
188-------
Scott Seabolt59153e92017-09-08 15:08:33 -0400189
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400190The methods should match the actions described in the LCM API Guide. For each method:
Scott Seabolt59153e92017-09-08 15:08:33 -0400191
192**Consumes**
193
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400194This API call consumes the following media types using the**Content-Type** request header:
Scott Seabolt59153e92017-09-08 15:08:33 -0400195
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400196 - ``application/json``
Scott Seabolt59153e92017-09-08 15:08:33 -0400197
198**Request body**
199
200The request body is the action name followed by Input (e.g., AuditInput)
201
202**Return type**
203
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400204The return type is the action name followed by Output (e.g., OutputInput)
Scott Seabolt59153e92017-09-08 15:08:33 -0400205
206**Produces**
207
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400208This 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 -0400209
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400210 - ``application/json``
Scott Seabolt59153e92017-09-08 15:08:33 -0400211
212**Responses**
213
214200 Successful operation
215
216401 Unauthorized
217
218500 Internal server error
219
220.. |image0| image:: image2.png
221 :width: 5.60495in
222 :height: 4.55272in