Skip to content

Commit 9f506ef

Browse files
authored
Merge pull request #484 from sigmacomputing/new-api-recipe
Reassign-Ownership-by-Email
2 parents f278ef2 + e35e693 commit 9f506ef

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed
149 KB
Loading

site/sigmaguides/src/developers_api_code_samples/developers_api_code_samples.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ It also exports a Javascript function to request a bearer token (token) each tim
200200
<aside class="positive">
201201
<strong>IMPORTANT:</strong><br> The token is valid for 3599 seconds (just under one hour) and needs to be refreshed. Our Javascript function will handle that.
202202
</aside>
203-
`
204203
In the project root directory, open the file `get-access-token.js` and review it's contents. Each section is commented so it can be understood.
205204

206205
Start the VSCode debugger against this code by pressing `F5` on your keyboard.
@@ -1166,7 +1165,7 @@ Duration: 20
11661165

11671166
A common use case is to programmatically initiate an existing materialization job in Sigma, via API.
11681167

1169-
This section demonstrates the code that was provided on the `API Code Samples` > `Workbook: Workbook: Initiate Materialization Job` page, [located here.](https://help.sigmacomputing.com/recipes/workbook-initiate-materialization-job)
1168+
This section demonstrates the code that was provided on the `API Code Samples` > `Workbook: Initiate Materialization Job` page, [located here.](https://help.sigmacomputing.com/recipes/workbook-initiate-materialization-job)
11701169

11711170
<aside class="positive">
11721171
<strong>IMPORTANT:</strong><br> This script will call the get-access-token > getBearerToken function to get a new/refreshed token automatically so there is no need to do anything else, assuming you have completed the section of this QuickStart "Authentication - REQUIRED" and ensured your .env file is configured correctly.
@@ -1346,6 +1345,51 @@ The expected response is:
13461345
![Footer](assets/sigma_footer.png)
13471346
<!-- END OF SECTION-->
13481347

1348+
## Workbook: Reassign Ownership by Email
1349+
Duration: 20
1350+
1351+
A common use case is to programmatically reassign workbook ownership based on email addresses in Sigma, via API.
1352+
1353+
This section demonstrates the code that was provided on the `API Code Samples` > `Workbook: Reassign Ownership by Email` page, [located here.](https://help.sigmacomputing.com/recipes/Reassign-Ownership-by-Email)
1354+
1355+
<aside class="positive">
1356+
<strong>IMPORTANT:</strong><br> This script will call the get-access-token > getBearerToken function to get a new/refreshed token automatically so there is no need to do anything else, assuming you have completed the section of this QuickStart "Authentication - REQUIRED" and ensured your .env file is configured correctly.
1357+
</aside>
1358+
1359+
### Description
1360+
This recipe will change the owner of all workbooks owned by the email address in the `OLD_OWNER_EMAIL` parameter in the .env file.
1361+
1362+
The new owner will be the email based on the `NEW_OWNER_EMAIL` parameter.
1363+
1364+
### Running the Script
1365+
Open the file `transfer-all-workbooks.js` in the `workbooks` folder:
1366+
1367+
Each code block is commented to explain what operations are being performed.
1368+
1369+
In the `.env` file there are two additional required parameters, one for the current owner and one for the new:
1370+
```code
1371+
OLD_OWNER_EMAIL=
1372+
NEW_OWNER_EMAIL=
1373+
```
1374+
1375+
<aside class="positive">
1376+
<strong>IMPORTANT:</strong><br> Take care running this script as ALL WORKBOOKS assigned to the OLD_OWNER_EMAIL will be reassigned!
1377+
1378+
Both emails need to exist in Sigma.
1379+
</aside>
1380+
1381+
Press `F5` to run the script with VSCode's debugger.
1382+
1383+
The expected response is:
1384+
1385+
<img src="assets/apics74.png" width="800"/>
1386+
1387+
Verify the workbooks are assigned to the new owner by looking at the Sigma portal and locating a few of the workbooks listed in Sigma.
1388+
1389+
![Footer](assets/sigma_footer.png)
1390+
<!-- END OF SECTION-->
1391+
1392+
13491393
## Workbook: Shared with Me
13501394
Duration: 20
13511395

0 commit comments

Comments
 (0)