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
9 .. https://creativecommons.org/licenses/by/4.0/
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============================================
18 .. _appc_client_library:
20 =========================
21 APPC Client Library Guide
22 =========================
31 This document is for an advanced technical audience, which includes engineers and technicians. Document revisions occur with the release of new software versions.
36 For additional information, see
41 Client Library Background
42 =========================
44 This guide discusses the Application Controller (APPC) Client Library and how to use it.
46 About the Client Library
47 ------------------------
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.
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.
56 VNF Lifecycle Management API
57 ----------------------------
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.
61 APP-C Client Library Flow
62 -------------------------
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.
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.
88 The Java application that runs the APPC client kit uses the following jar files:
90 - org.onap.appc.client:client-kit
91 - org.onap.appc.client:client-lib
93 The client library JAR files are located in the repository under ``com\att\appc\client``.
98 Initialize the client by calling the following method:
100 ``AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class).createLifeCycleManagerStateful()``
102 Specify the following configuration properties as method parameters:
105 - "topic.read.timeout"
112 - “client.response.timeout”
113 - “client.graceful.shutdown.timeout”
119 Shutdown the client by calling the following method, first if Controller Type is not included, the second when Controller Type is included:
121 ``void shutdownLifeCycleManager(boolean isForceShutdown)``, or
122 ``void shutdownLifeCycleManager(boolean isForceShutdown, String controllerType)``
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``).
126 If the ``isForceShutdown`` flag is set to true, the client shuts down immediately.
128 Invoking LCM Commands
129 ---------------------
131 Invoke the LCM commands by:
133 - Creating input objects, such as AuditInput, LiveUpgradeInput, with relevant command information.
134 - Executing commands asynchronously, for example:
136 ``void liveUpgrade(LiveUpgradeInput liveUpgradeInput, ResponseHandler<LiveUpgradeOutput> listener) throws AppcClientException;)``
138 In this case, client should implement the ResponseHandler<T> interface.
140 - Executing commands synchronously, for example:
142 ``LiveUpgradeOutput liveUpgrade(LiveUpgradeInput liveUpgradeInput) throws AppcClientException;)``
148 After initializing the client, a returned Object of type LifeCycleManagerStateful defines all the Life Cycle Management APIs
151 The interface contains two definitions for each RPC: one for Asynchronous call mode, and one for Synchronous.
153 In Asynchronous mode, client consumer should provide a callback function of type:
155 ``ResponseHandler<RPC-NAMEOutput>``
157 where ``RPC-NAME`` is the command name, such as Audit or Snapshot.
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’.
161 LifeCycleManagerStateful Interface
162 ----------------------------------
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:
166 ``@RPC(name="audit", outputType=AuditOutput.class)``
168 ``AuditOutput audit(AuditInput auditInput) throws AppcClientException;``
170 For a Synchronous call to Audit, the consumer thread is blocked until a response is received or a timeout exception is thrown.
172 ``@RPC(name="audit", outputType=AuditOutput.class)``
174 ``void audit(AuditInput auditInput, ResponseHandler<AuditOutput> listener) throws AppcClientException;``
176 For an Asynchronous call to Audit, a callback should be provided so that when a response is received the listener is called.
181 The API documentation is also available as a swagger page generated from files at /client-kit/target/resources.
186 This defines the services and request/response requirements for the APPC component.
191 The methods should match the actions described in the LCM API Guide. For each method:
195 This API call consumes the following media types using the**Content-Type** request header:
197 - ``application/json``
201 The request body is the action name followed by Input (e.g., AuditInput)
205 The return type is the action name followed by Output (e.g., OutputInput)
209 This API call produces the following media types according to the **Accept** request header; the **Content-Type** response header conveys the media type.
211 - ``application/json``
215 200 Successful operation
219 500 Internal server error
221 .. |image0| image:: image2.png