|
1 | | -# Deployment Successful! |
2 | | -You have succesfully deployed the SDK to this repository. |
| 1 | +# Getting started |
| 2 | + |
| 3 | +TODO: Add Description |
3 | 4 |
|
4 | | -This repository contains two branches. |
5 | | -* master |
6 | | -* CodeGen-PY |
| 5 | +## How to Build |
7 | 6 |
|
8 | | -Changes made on the generated branch will be overwritten. |
9 | 7 |
|
10 | | -Make sure to make your customisations on a different branch (e.g master) and then pull new versions of the generated code. |
| 8 | +You must have Python ```2 >=2.7.9``` or Python ```3 >=3.4``` installed on your system to install and run this SDK. This SDK package depends on other Python packages like nose, jsonpickle etc. |
| 9 | +These dependencies are defined in the ```requirements.txt``` file that comes with the SDK. |
| 10 | +To resolve these dependencies, you can use the PIP Dependency manager. Install it by following steps at [https://pip.pypa.io/en/stable/installing/](https://pip.pypa.io/en/stable/installing/). |
| 11 | + |
| 12 | +Python and PIP executables should be defined in your PATH. Open command prompt and type ```pip --version```. |
| 13 | +This should display the version of the PIP Dependency Manager installed if your installation was successful and the paths are properly defined. |
| 14 | + |
| 15 | +* Using command line, navigate to the directory containing the generated files (including ```requirements.txt```) for the SDK. |
| 16 | +* Run the command ```pip install -r requirements.txt```. This should install all the required dependencies. |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +## How to Use |
| 22 | + |
| 23 | +The following section explains how to use the Predix SDK package in a new project. |
| 24 | + |
| 25 | +### 1. Open Project in an IDE |
| 26 | + |
| 27 | +Open up a Python IDE like PyCharm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +Click on ```Open``` in PyCharm to browse to your generated SDK directory and then click ```OK```. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +The project files will be displayed in the side bar as follows: |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +### 2. Add a new Test Project |
| 40 | + |
| 41 | +Create a new directory by right clicking on the solution name as shown below: |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +Name the directory as "test" |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +Add a python file to this project with the name "testsdk" |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +Name it "testsdk" |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +In your python file you will be required to import the generated python library using the following code lines |
| 58 | + |
| 59 | +```Python |
| 60 | +from predix.predix_client import PredixClient |
| 61 | +``` |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +After this you can write code to instantiate an API client object, get a controller object and make API calls. Sample code is given in the subsequent sections. |
| 66 | + |
| 67 | +### 3. Run the Test Project |
| 68 | + |
| 69 | +To run the file within your test project, right click on your Python file inside your Test project and click on ```Run``` |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +## How to Test |
| 75 | + |
| 76 | +You can test the generated SDK and the server with automatically generated test |
| 77 | +cases. unittest is used as the testing framework and nose is used as the test |
| 78 | +runner. You can run the tests as follows: |
| 79 | + |
| 80 | + 1. From terminal/cmd navigate to the root directory of the SDK. |
| 81 | + 2. Invoke ```pip install -r test-requirements.txt``` |
| 82 | + 3. Invoke ```nosetests``` |
| 83 | + |
| 84 | +## Initialization |
| 85 | + |
| 86 | +### Authentication |
| 87 | +In order to setup authentication and initialization of the API client, you need the following information. |
| 88 | + |
| 89 | +| Parameter | Description | |
| 90 | +|-----------|-------------| |
| 91 | +| username | TODO: add a description | |
| 92 | +| password | TODO: add a description | |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +API client can be initialized as following. |
| 97 | + |
| 98 | +```python |
| 99 | +# Configuration parameters and credentials |
| 100 | +username = 'username' |
| 101 | +password = 'password' |
| 102 | + |
| 103 | +client = PredixClient(username, password) |
| 104 | +``` |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +# Class Reference |
| 109 | + |
| 110 | +## <a name="list_of_controllers"></a>List of Controllers |
| 111 | + |
| 112 | +* [APIController](#api_controller) |
| 113 | + |
| 114 | +## <a name="api_controller"></a> APIController |
| 115 | + |
| 116 | +### Get controller instance |
| 117 | + |
| 118 | +An instance of the ``` APIController ``` class can be accessed from the API Client. |
| 119 | + |
| 120 | +```python |
| 121 | + client_controller = client.client |
| 122 | +``` |
| 123 | + |
| 124 | +### <a name="create_get_token"></a> create_get_token |
| 125 | + |
| 126 | +> TODO: Add Description |
| 127 | +
|
| 128 | +```python |
| 129 | +def create_get_token(self, |
| 130 | + content_type, |
| 131 | + body) |
| 132 | +``` |
| 133 | + |
| 134 | +#### Parameters |
| 135 | + |
| 136 | +| Parameter | Tags | Description | |
| 137 | +|-----------|------|-------------| |
| 138 | +| contentType | ``` Required ``` | TODO: Add a parameter description | |
| 139 | +| body | ``` Required ``` | TODO: Add a parameter description | |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | +#### Example Usage |
| 144 | + |
| 145 | +```python |
| 146 | +content_type = 'application/x-www-form-urlencoded' |
| 147 | +body = 'grant_type=client_credentials' |
| 148 | + |
| 149 | +client_controller.create_get_token(content_type, body) |
| 150 | + |
| 151 | +``` |
| 152 | + |
| 153 | + |
| 154 | +### <a name="create_synchronous_execution_nlp"></a> create_synchronous_execution_nlp |
| 155 | + |
| 156 | +> Execute the analytic synchronously. The analytic_uri is the analytic catalog entry id followed by your Predix Platform domain name. |
| 157 | +
|
| 158 | +```python |
| 159 | +def create_synchronous_execution_nlp(self, |
| 160 | + content_type, |
| 161 | + predix_zone_id, |
| 162 | + body) |
| 163 | +``` |
| 164 | + |
| 165 | +#### Parameters |
| 166 | + |
| 167 | +| Parameter | Tags | Description | |
| 168 | +|-----------|------|-------------| |
| 169 | +| contentType | ``` Required ``` | TODO: Add a parameter description | |
| 170 | +| predixZoneId | ``` Required ``` | TODO: Add a parameter description | |
| 171 | +| body | ``` Required ``` | TODO: Add a parameter description | |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | +#### Example Usage |
| 176 | + |
| 177 | +```python |
| 178 | +content_type = 'application/json' |
| 179 | +predix_zone_id = '{{tenant_id}}' |
| 180 | +body_value = "{\"input_text\":\"UPS fails to come up Image:NONE-NONE-NONE\"}" |
| 181 | +body = json.loads(body_value) |
| 182 | + |
| 183 | +client_controller.create_synchronous_execution_nlp(content_type, predix_zone_id, body) |
| 184 | + |
| 185 | +``` |
| 186 | + |
| 187 | + |
| 188 | +### <a name="create_synchronous_execution_predict_resolutions"></a> create_synchronous_execution_predict_resolutions |
| 189 | + |
| 190 | +> Execute the analytic synchronously. The analytic_uri is the analytic catalog entry id followed by your Predix Platform domain name. |
| 191 | +
|
| 192 | +```python |
| 193 | +def create_synchronous_execution_predict_resolutions(self, |
| 194 | + content_type, |
| 195 | + predix_zone_id, |
| 196 | + body) |
| 197 | +``` |
| 198 | + |
| 199 | +#### Parameters |
| 200 | + |
| 201 | +| Parameter | Tags | Description | |
| 202 | +|-----------|------|-------------| |
| 203 | +| contentType | ``` Required ``` | TODO: Add a parameter description | |
| 204 | +| predixZoneId | ``` Required ``` | TODO: Add a parameter description | |
| 205 | +| body | ``` Required ``` | TODO: Add a parameter description | |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | +#### Example Usage |
| 210 | + |
| 211 | +```python |
| 212 | +content_type = 'application/json' |
| 213 | +predix_zone_id = '{{tenant_id}}' |
| 214 | +body_value = "{\"symptoms\":\"this is a test\",\"errors\":\"11011,10010\"}" |
| 215 | +body = json.loads(body_value) |
| 216 | + |
| 217 | +client_controller.create_synchronous_execution_predict_resolutions(content_type, predix_zone_id, body) |
| 218 | + |
| 219 | +``` |
| 220 | + |
| 221 | + |
| 222 | +[Back to List of Controllers](#list_of_controllers) |
11 | 223 |
|
12 | | -For any enquires contact [email protected] |
13 | 224 |
|
14 | | -Happy generating! |
15 | 225 |
|
16 | | -APIMATIC |
|
0 commit comments