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