Skip to content

Commit fb8df47

Browse files
committed
provisioning docs
1 parent 47915f9 commit fb8df47

File tree

5 files changed

+633
-41
lines changed

5 files changed

+633
-41
lines changed

docs/content/en/latest/pipelines-overview.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Here are a couple of introductory examples how to manage GoodData resources usin
2929

3030
### Provision Child Workspaces
3131
```python
32-
from gooddata_pipelines import WorkspaceProvisioner, WorkspaceFullLoad
32+
from gooddata_pipelines import WorkspaceFullLoad, WorkspaceProvisioner
3333

3434
# GoodData.CN host in the form of uri eg. "http://localhost:3000"
3535
host = "http://localhost:3000"
@@ -42,21 +42,21 @@ provisioner = WorkspaceProvisioner.create(host=host, token=token)
4242

4343
# Gather the definitions of the workspaces you want to create
4444
raw_data: list[dict] = [
45-
{
46-
"parent_id": "parent_workspace_id",
47-
"workspace_id": "child_workspace_0",
48-
"workspace_name": "Child Workspace 0",
49-
"workspace_data_filter_id": "data_filter_id",
50-
"workspace_data_filter_values": ["value_0"],
51-
},
52-
...
53-
]
45+
{
46+
"parent_id": "parent_workspace_id",
47+
"workspace_id": "child_workspace_0",
48+
"workspace_name": "Child Workspace 0",
49+
"workspace_data_filter_id": "data_filter_id",
50+
"workspace_data_filter_values": ["value_0"],
51+
},
52+
]
5453

5554
# Validate the data
5655
validated_data = [WorkspaceFullLoad(**item) for item in raw_data]
5756

5857
# Run the provisioning
5958
provisioner.full_load(validated_data)
59+
6060
```
6161

6262
### Workspace Backup

docs/content/en/latest/pipelines/provisioning/user_groups.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,180 @@ title: "User Groups"
33
linkTitle: "User Group"
44
weight: 3
55
---
6+
7+
User group provisioning allows you to create, update or delete user groups.
8+
9+
You can provision user groups using full or incremental load methods. Each of these methods requires a specific input type.
10+
11+
## Usage
12+
13+
Start by importing and initializing the UserGroupProvisioner.
14+
15+
```python
16+
17+
from gooddata_pipelines import UserGroupProvisioner
18+
19+
host="http://localhost:3000"
20+
token="some_user_token"
21+
22+
# Initialize the provisioner with GoodData credentials
23+
provisioner = UserGroupProvisioner.create(host=host, token=token)
24+
25+
```
26+
27+
28+
Then validate your data using an input model corresponding with the provisioned resource and selected workflow type, i.e., `UserGroupFullLoad` if you intend to run the provisioning in full load mode, or `UserGroupIncrementalLoad` if you want to provision incrementally.
29+
30+
The models expect following fields:
31+
```python
32+
class UserGroupFullLoad
33+
user_group_id: str
34+
user_group_name: str
35+
parent_user_groups: list[str] # A list of parent user group IDs. Can be empty or None
36+
37+
class UserGroupIncrementalLoad
38+
user_group_id: str
39+
user_group_name: str
40+
parent_user_groups: list[str]
41+
is_active: bool # Set to True to keep the user, False to delete it
42+
43+
```
44+
45+
> **Note on IDs**: Each ID can only contain allowed characters. See [Workspace Object Identification](https://www.gooddata.com/docs/cloud/create-workspaces/objects-identification/) to learn more about object identifiers.
46+
47+
Use the appropriate model to validate your data:
48+
49+
```python
50+
# Add the model to the imports
51+
from gooddata_pipelines import UserGroupFullLoad, UserGroupProvisioner
52+
53+
host = "http://localhost:3000"
54+
token = "some_user_token"
55+
56+
# Initialize the provisioner with GoodData credentials
57+
provisioner = UserGroupProvisioner.create(host=host, token=token)
58+
59+
# Load your data
60+
raw_data = [
61+
{
62+
"user_group_id": "user_group_1",
63+
"user_group_name": "User Group 1",
64+
"parent_user_groups": [],
65+
},
66+
]
67+
68+
# Validate the data
69+
validated_data = [
70+
UserGroupFullLoad(
71+
user_group_id=item["user_group_id"],
72+
user_group_name=item["user_group_name"],
73+
parent_user_groups=item["parent_user_groups"],
74+
)
75+
for item in raw_data
76+
]
77+
78+
```
79+
80+
Now with the provisioner initialized and your data validated, you can run the provisioner:
81+
82+
```python
83+
# Import, initialize, validate...
84+
...
85+
86+
# Run the provisiong method
87+
provisioner.full_load(validated_data)
88+
89+
```
90+
91+
## Examples
92+
93+
Here are full examples of a full load and incremental load user group provisioning workflows:
94+
95+
### Full Load
96+
97+
```python
98+
import logging
99+
100+
from gooddata_pipelines import UserGroupFullLoad, UserGroupProvisioner
101+
102+
host = "http://localhost:3000"
103+
token = "some_user_token"
104+
105+
# Initialize the provisioner
106+
provisioner = UserGroupProvisioner.create(host=host, token=token)
107+
108+
# Optional: set up logging and subscribe to logs emited by the provisioner
109+
logging.basicConfig(level=logging.INFO)
110+
logger = logging.getLogger(__name__)
111+
112+
provisioner.logger.subscribe(logger)
113+
114+
# Prepare your data
115+
raw_data = [
116+
{
117+
"user_group_id": "user_group_1",
118+
"user_group_name": "User Group 1",
119+
"parent_user_groups": [],
120+
},
121+
]
122+
123+
# Validate the data
124+
validated_data = [
125+
UserGroupFullLoad(
126+
user_group_id=item["user_group_id"],
127+
user_group_name=item["user_group_name"],
128+
parent_user_groups=item["parent_user_groups"],
129+
)
130+
for item in raw_data
131+
]
132+
133+
# Run the provisioning with the validated data
134+
provisioner.full_load(validated_data)
135+
136+
```
137+
138+
139+
### Incremental Load
140+
141+
```python
142+
import logging
143+
144+
from gooddata_pipelines import UserGroupIncrementalLoad, UserGroupProvisioner
145+
146+
host = "http://localhost:3000"
147+
token = "some_user_token"
148+
149+
# Initialize the provisioner
150+
provisioner = UserGroupProvisioner.create(host=host, token=token)
151+
152+
# Optional: set up logging and subscribe to logs emited by the provisioner
153+
logging.basicConfig(level=logging.INFO)
154+
logger = logging.getLogger(__name__)
155+
156+
provisioner.logger.subscribe(logger)
157+
158+
# Prepare your data
159+
raw_data = [
160+
{
161+
"user_group_id": "user_group_1",
162+
"user_group_name": "User Group 1",
163+
"parent_user_groups": [],
164+
"is_active": True,
165+
},
166+
]
167+
168+
# Validate the data
169+
validated_data = [
170+
UserGroupIncrementalLoad(
171+
user_group_id=item["user_group_id"],
172+
user_group_name=item["user_group_name"],
173+
parent_user_groups=item["parent_user_groups"],
174+
is_active=item["is_active"],
175+
)
176+
for item in raw_data
177+
]
178+
179+
# Run the provisioning with the validated data
180+
provisioner.incremental_load(validated_data)
181+
182+
```

0 commit comments

Comments
 (0)