blob: a819ed84ca86d9120ec77ab9e280dd0de5c5fe8c [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============================================
Scott Seabolt78a683e2017-10-23 09:11:51 -040017
Scott Seaboltd51cafc2017-09-20 10:33:30 -040018.. _appc_client_library:
Scott Seabolt59153e92017-09-08 15:08:33 -040019
Hector Anapan9613c042017-10-18 21:02:18 -040020=========================
21APPC Client Library Guide
22=========================
Scott Seaboltd51cafc2017-09-20 10:33:30 -040023
24
Scott Seaboltd51cafc2017-09-20 10:33:30 -040025Introduction
26============
Scott Seabolt59153e92017-09-08 15:08:33 -040027
Scott Seaboltd51cafc2017-09-20 10:33:30 -040028Target Audience
29---------------
Scott Seabolt59153e92017-09-08 15:08:33 -040030
Scott Seaboltd51cafc2017-09-20 10:33:30 -040031This 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 -040032
33Related Documentation
34---------------------
35
Eric Debeaud057edd2017-10-19 17:09:44 +000036For additional information, see
Scott Seaboltf7824832017-10-10 11:27:11 -040037
Eric Debeaud057edd2017-10-19 17:09:44 +000038 :ref:`appc_api_guide`
Scott Seabolt59153e92017-09-08 15:08:33 -040039
Scott Seabolt59153e92017-09-08 15:08:33 -040040
41Client Library Background
Scott Seaboltd51cafc2017-09-20 10:33:30 -040042=========================
Scott Seabolt59153e92017-09-08 15:08:33 -040043
Scott Seaboltd51cafc2017-09-20 10:33:30 -040044This guide discusses the Application Controller (APPC) Client Library and how to use it.
Scott Seabolt59153e92017-09-08 15:08:33 -040045
46About the Client Library
47------------------------
48
Scott Seaboltc449e8c2018-03-23 23:38:20 -040049The 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.
Scott Seabolt59153e92017-09-08 15:08:33 -040050
51Consumer Logic
52--------------
53
Scott Seaboltd51cafc2017-09-20 10:33:30 -040054The 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 -040055
56VNF Lifecycle Management API
57----------------------------
58
Scott Seaboltd51cafc2017-09-20 10:33:30 -040059The 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 -040060
61APP-C Client Library Flow
62-------------------------
63
64 |image0|
65
Scott Seaboltf7824832017-10-10 11:27:11 -040066Asynchronous Flow
67^^^^^^^^^^^^^^^^^
Scott Seabolt59153e92017-09-08 15:08:33 -040068
Takad16f5c92017-12-05 14:58:12 -050069- The APPC Client Library is called using an asynchronous API utilizing a full command object, which is mapped to a JSON representation.
Scott Seaboltc449e8c2018-03-23 23:38:20 -040070- The APPC client calls the DMaaP client and sends the JSON command to a configured topic.
Scott Seabolt59153e92017-09-08 15:08:33 -040071- The APPC client pulls response messages from the configured topic.
Scott Seaboltd51cafc2017-09-20 10:33:30 -040072- 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 -040073
Scott Seaboltf7824832017-10-10 11:27:11 -040074Synchronous Flow
75^^^^^^^^^^^^^^^^
Scott Seabolt59153e92017-09-08 15:08:33 -040076
Scott Seaboltd51cafc2017-09-20 10:33:30 -040077- The APPC Client Library is called using a synchronous API using a full command object, which is mapped to a JSON representation.
Scott Seaboltc449e8c2018-03-23 23:38:20 -040078- The APPC client calls the DMaaP client and sends the JSON command to a configured topic.
Scott Seabolt59153e92017-09-08 15:08:33 -040079- The APPC client pulls response messages from the configured topic.
Scott Seaboltd51cafc2017-09-20 10:33:30 -040080- 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 -040081
Scott Seaboltd51cafc2017-09-20 10:33:30 -040082Client Library Usage
83====================
Eric Debeaud057edd2017-10-19 17:09:44 +000084
Scott Seaboltd51cafc2017-09-20 10:33:30 -040085Jar Files
86---------
Scott Seabolt59153e92017-09-08 15:08:33 -040087
Scott Seaboltd51cafc2017-09-20 10:33:30 -040088The Java application that runs the APPC client kit uses the following jar files:
Scott Seabolt59153e92017-09-08 15:08:33 -040089
Patrick Brady07567592017-12-13 11:09:30 -080090 - org.onap.appc.client:client-kit
91 - org.onap.appc.client:client-lib
Scott Seabolt59153e92017-09-08 15:08:33 -040092
Scott Seaboltc449e8c2018-03-23 23:38:20 -040093The client library JAR files are located in the repository under ``com\att\appc\client``.
Scott Seabolt59153e92017-09-08 15:08:33 -040094
Eric Debeaud057edd2017-10-19 17:09:44 +000095Initialization
Scott Seabolt2406a972017-09-13 17:31:44 -040096--------------
Scott Seabolt59153e92017-09-08 15:08:33 -040097
Scott Seaboltd51cafc2017-09-20 10:33:30 -040098Initialize the client by calling the following method:
Scott Seabolt59153e92017-09-08 15:08:33 -040099
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400100``AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class).createLifeCycleManagerStateful()``
Scott Seabolt59153e92017-09-08 15:08:33 -0400101
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400102Specify the following configuration properties as method parameters:
Scott Seabolt59153e92017-09-08 15:08:33 -0400103
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400104 - "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
Scott Seaboltc449e8c2018-03-23 23:38:20 -0400114 - controllerType
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
Scott Seaboltc449e8c2018-03-23 23:38:20 -0400119Shutdown the client by calling the following method, first if Controller Type is not included, the second when Controller Type is included:
Scott Seabolt59153e92017-09-08 15:08:33 -0400120
Scott Seaboltc449e8c2018-03-23 23:38:20 -0400121``void shutdownLifeCycleManager(boolean isForceShutdown)``, or
122``void shutdownLifeCycleManager(boolean isForceShutdown, String controllerType)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400123
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400124If 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 -0400125
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400126If the ``isForceShutdown`` flag is set to true, the client shuts down immediately.
Scott Seabolt59153e92017-09-08 15:08:33 -0400127
128Invoking LCM Commands
Scott Seabolt2406a972017-09-13 17:31:44 -0400129---------------------
Scott Seabolt59153e92017-09-08 15:08:33 -0400130
131Invoke the LCM commands by:
132
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400133 - Creating input objects, such as AuditInput, LiveUpgradeInput, with relevant command information.
134 - Executing commands asynchronously, for example:
Scott Seabolt59153e92017-09-08 15:08:33 -0400135
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400136``void liveUpgrade(LiveUpgradeInput liveUpgradeInput, ResponseHandler<LiveUpgradeOutput> listener) throws AppcClientException;)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400137
138In this case, client should implement the ResponseHandler<T> interface.
139
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400140 - Executing commands synchronously, for example:
Scott Seabolt59153e92017-09-08 15:08:33 -0400141
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400142``LiveUpgradeOutput liveUpgrade(LiveUpgradeInput liveUpgradeInput) throws AppcClientException;)``
143
Scott Seabolt59153e92017-09-08 15:08:33 -0400144
145Client API
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400146==========
Scott Seabolt59153e92017-09-08 15:08:33 -0400147
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400148After initializing the client, a returned Object of type LifeCycleManagerStateful defines all the Life Cycle Management APIs
149 supported by APPC.
Scott Seabolt59153e92017-09-08 15:08:33 -0400150
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400151The interface contains two definitions for each RPC: one for Asynchronous call mode, and one for Synchronous.
Scott Seabolt59153e92017-09-08 15:08:33 -0400152
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400153In Asynchronous mode, client consumer should provide a callback function of type:
Scott Seabolt59153e92017-09-08 15:08:33 -0400154
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400155 ``ResponseHandler<RPC-NAMEOutput>``
Scott Seabolt59153e92017-09-08 15:08:33 -0400156
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400157where ``RPC-NAME`` is the command name, such as Audit or Snapshot.
Scott Seabolt59153e92017-09-08 15:08:33 -0400158
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400159There 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 -0400160
161LifeCycleManagerStateful Interface
162----------------------------------
163
Eric Debeaud057edd2017-10-19 17:09:44 +0000164Generated 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 -0400165
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400166``@RPC(name="audit", outputType=AuditOutput.class)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400167
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400168``AuditOutput audit(AuditInput auditInput) throws AppcClientException;``
Scott Seabolt59153e92017-09-08 15:08:33 -0400169
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400170For 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 -0400171
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400172``@RPC(name="audit", outputType=AuditOutput.class)``
Scott Seabolt59153e92017-09-08 15:08:33 -0400173
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400174``void audit(AuditInput auditInput, ResponseHandler<AuditOutput> listener) throws AppcClientException;``
Scott Seabolt59153e92017-09-08 15:08:33 -0400175
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400176For 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 -0400177
178API documentation
179-----------------
180
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400181The API documentation is also available as a swagger page generated from files at /client-kit/target/resources.
Scott Seabolt59153e92017-09-08 15:08:33 -0400182
183appc-provider-lcm
184-----------------
185
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400186This defines the services and request/response requirements for the APPC component.
Scott Seabolt59153e92017-09-08 15:08:33 -0400187
Eric Debeaud057edd2017-10-19 17:09:44 +0000188Methods
189-------
Scott Seabolt59153e92017-09-08 15:08:33 -0400190
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400191The methods should match the actions described in the LCM API Guide. For each method:
Scott Seabolt59153e92017-09-08 15:08:33 -0400192
193**Consumes**
194
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400195This API call consumes the following media types using the**Content-Type** request header:
Scott Seabolt59153e92017-09-08 15:08:33 -0400196
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400197 - ``application/json``
Scott Seabolt59153e92017-09-08 15:08:33 -0400198
199**Request body**
200
201The request body is the action name followed by Input (e.g., AuditInput)
202
203**Return type**
204
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400205The return type is the action name followed by Output (e.g., OutputInput)
Scott Seabolt59153e92017-09-08 15:08:33 -0400206
207**Produces**
208
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400209This 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 -0400210
Scott Seaboltd51cafc2017-09-20 10:33:30 -0400211 - ``application/json``
Scott Seabolt59153e92017-09-08 15:08:33 -0400212
213**Responses**
214
215200 Successful operation
216
217401 Unauthorized
218
219500 Internal server error
220
221.. |image0| image:: image2.png
222 :width: 5.60495in
223 :height: 4.55272in
Scott Seaboltc449e8c2018-03-23 23:38:20 -0400224