Skip to content

Commit 8e68845

Browse files
authored
Merge pull request #50 from wd-mgreynolds/master
Update for Prism V3
2 parents 58511d5 + 67ac6db commit 8e68845

24 files changed

+2965
-618
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: [3.7, 3.8, 3.9]
11+
python-version: [3.8, 3.9]
1212

1313
steps:
1414
- uses: actions/checkout@v2

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Pycharm
22
.idea/
33

4+
# MacOS - Desktop Services Store file(s)
5+
.DS_Store
6+
47
# Byte-compiled / optimized / DLL files
58
__pycache__/
69
*.py[cod]
@@ -12,6 +15,7 @@ __pycache__/
1215
# Distribution / packaging
1316
.Python
1417
env/
18+
venv/
1519
build/
1620
develop-eggs/
1721
dist/

README.md

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,62 @@
33
# Prism-Python
44

55
Python client library and command line interface (CLI) for interacting with
6-
Workday’s Prism API V2.
6+
Workday’s Prism API V3.
7+
8+
Workday provides the Prism Analytics REST API web service to work with
9+
Workday Prism Analytics tables, data change tasks, and datasets. You can develop
10+
a software program that uses the different REST endpoints to
11+
programmatically create Prism Analytics tables and datasets and modify
12+
data in them.
13+
14+
The Python **client library** is a REST API wrapper managing the HTTP methods,
15+
URL endpoints and the data required by specific Workday Prism Analytics API
16+
REST operations. Using this client library in Python projects simplifies interactions
17+
with the Workday Prism Analytics REST API providing the rich functionality
18+
of Workday Prism Analytics to your Python project.
19+
20+
The **CLI** is a powerful tool for interacting with a Workday Prism Analytics
21+
REST API client library, allowing you to quickly and easily perform Workday
22+
Prism Analytics tasks from any command line.
723

824
## Install
9-
You may install the latest version directly from GitHub with:
25+
26+
To automatically retrieve and install the latest version of this
27+
package directly GitHub, use the following command:
1028

1129
```bash
12-
pip install git+https://github.com/Workday/prism-python.git
30+
$ pip install git+https://github.com/Workday/prism-python.git
1331
```
1432

1533
It is also possible to install a specific tagged release with:
1634

1735
```bash
18-
pip install git+https://github.com/Workday/prism-python.git@0.2.0
36+
$ pip install git+https://github.com/Workday/prism-python.git@0.3.0
1937
```
2038

2139
## Requirements
2240

23-
1. [Register a Workday Prism Analytics API Client.](https://doc.workday.com/reader/J1YvI9CYZUWl1U7_PSHyHA/qAugF2pRAGtECVLHKdMO_A)
41+
Workday Prism Analytics REST APIs use OAuth authentication and the Workday
42+
configurable security model to authorize Workday Prism Analytics operations
43+
in end-user applications. The Workday Prism REST APIs act on behalf of
44+
a Workday user using the client. The user's security profile affects the
45+
REST API access to Workday resources.
2446

25-
In Workday, register an integrations API client with Prism Analytics as its
26-
scope. Obtain the Client ID, Client Secret, and Refresh Token values that the
27-
Prism class requires as parameters.
47+
The Prism client library, and by extension the CLI, require API Client
48+
credentials setup in the target Workday tenant. The API Client credentials
49+
authorize programmatic access to the Workday tenant and provides the identity
50+
of the Workday user to enforce security for all operations.
2851

29-
2. [Obtain the Workday REST API Endpoint.](https://doc.workday.com/reader/J1YvI9CYZUWl1U7_PSHyHA/L_RKkfJI6bKu1M2~_mfesQ)
52+
1. [Register a Workday Prism Analytics API Client.](https://doc.workday.com/admin-guide/en-us/workday-studio/integration-design/common-components/the-prismanalytics-subassembly/tzr1533120600898.html)
53+
2. [Create Refresh Token](https://doc.workday.com/reader/J1YvI9CYZUWl1U7_PSHyHA/L_RKkfJI6bKu1M2~_mfesQ)
54+
3. [Obtain the Workday REST API Endpoint.](https://doc.workday.com/reader/J1YvI9CYZUWl1U7_PSHyHA/L_RKkfJI6bKu1M2~_mfesQ)
3055

31-
In Workday, obtain the Workday REST API endpoint that the Prism class requires
32-
as a parameter.
33-
34-
3. For ease of use, set the following environment variables using the values obtained above:
35-
36-
```bash
37-
export workday_base_url=<INSERT WORKDAY BASE URL HERE>
38-
export workday_tenant_name=<INSERT WORKDAY TENANT NAME HERE>
39-
export prism_client_id=<INERT PRISM CLIENT ID HERE>
40-
export prism_client_secret=<INSERT PRISM CLIENT SECRET HERE>
41-
export prism_refresh_token=<INSERT PRISM REFRESH TOKEN HERE>
42-
```
4356

4457
## Python Example
4558

46-
### Create a new table with Prism API Version 2
59+
### Create a new table with Prism API Version 3
4760

48-
```python
61+
```{python}
4962
import os
5063
import prism
5164
@@ -55,50 +68,50 @@ p = prism.Prism(
5568
os.getenv("workday_tenant_name"),
5669
os.getenv("prism_client_id"),
5770
os.getenv("prism_client_secret"),
58-
os.getenv("prism_refresh_token"),
59-
version="v2"
71+
os.getenv("prism_refresh_token")
6072
)
6173
62-
# read in your table schema
63-
schema = prism.load_schema("/path/to/schema.json")
64-
65-
# create an empty API table with your schema
66-
table = prism.create_table(p, "my_new_table", schema=schema["fields"])
74+
# create a new table based on the schema.json file
75+
table = prism.tables_create(
76+
p,
77+
table_name="my_new_table",
78+
file="/path/to/schema.json"
79+
)
6780
68-
# print details about new table
81+
# print JSON response body describing the new table.
6982
print(table)
7083
```
7184

72-
### Manage data in an existing table with Prism API Version 2
85+
### Manage data in an existing table with Prism API Version 3
7386
Table Operations Available: `TruncateandInsert`, `Insert`, `Update`, `Upsert`,
7487
`Delete`.
7588

76-
To use the `Update`, `Upsert`, or `Delete` operations, you must specify an
77-
external id field within your table schema.
78-
79-
```python
80-
# upload GZIP CSV file to your table
81-
prism.upload_file(p, "/path/to/file.csv.gz", table["id"], operation="TruncateandInsert")
89+
```{python}
90+
prism.upload_file(
91+
p,
92+
file="/path/to/data.csv.gz",
93+
table_id=table["id"],
94+
operation="Insert"
95+
)
8296
```
8397

8498
## CLI Example
8599

86-
The command line interface (CLI) provides another way to interact with the Prism API.
87-
The CLI expects your credentials to be stored as environment variables, but they can
88-
also be passed into the CLI manually through the use of optional arguments.
89-
90100
```bash
91101
# get help with the CLI
92-
prism --help
102+
$ prism --help
103+
104+
# get help for the tables command
105+
$ prism tables --help
93106

94-
# list the Prism API tables that you have access to
95-
prism list
107+
# list Prism tables you have access to.
108+
$ prism tables get
96109

97-
# create a new Prism API table
98-
prism create my_new_table /path/to/schema.json
110+
# create a new Prism table
111+
$ prism tables create my_new_table /path/to/schema.json
99112

100-
# upload data to a Prism API table
101-
prism upload /path/to/file.csv.gz bbab30e3018b01a723524ce18010811b
113+
# upload data to the new table
114+
$ prism tables upload 83dd72bd7b911000ca2d790e719a0000 /path/to/file1.csv.gz
102115
```
103116

104117
## Bugs

environment.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: prism-dev
22
channels:
33
- defaults
44
dependencies:
5-
- python=3.7
6-
- click>=6,<8
7-
- requests>=2.20.0,<3
5+
- python=3.8
6+
- click
7+
- requests
88
- pytest
9-
- black=19.10b0
9+
- black
1010
- flake8

examples/1_extract_data.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/2_predict_topics.py

Lines changed: 0 additions & 94 deletions
This file was deleted.

examples/3_upload_predictions.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/README.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/environment.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)