-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User Management Documentation (#200)
* Adds user management module * Additional Documentation for Users Module
- Loading branch information
1 parent
73b853d
commit 507b378
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Caracara Examples Collection. | ||
add_user.py | ||
This example will use the API credentials configured in your config.yml file to | ||
add a user in the Falcon tenant. | ||
""" | ||
import logging | ||
|
||
from examples.common import caracara_example, pretty_print | ||
|
||
from caracara import Client | ||
|
||
|
||
|
||
@caracara_example | ||
def add_user(first_name, last_name, email_address, **kwargs): | ||
"""Add User Example.""" | ||
client: Client = kwargs["client"] | ||
logger: logging.Logger = kwargs["logger"] | ||
|
||
logger.info("Adding a user in the Falcon tenant") | ||
new_user_data = client.users.add_user(first_name, last_name, email_address) | ||
logger.info(pretty_print(new_user_data)) | ||
|
||
|
||
if __name__ == "__main__": | ||
FIRST_NAME = "sampleName" | ||
LAST_NAME = "sampleLastName" | ||
EMAIL_ADDRESS = "sample.email@example.com" | ||
add_user(FIRST_NAME, LAST_NAME, EMAIL_ADDRESS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Caracara Examples Collection. | ||
delete_user.py | ||
This example will use the API credentials configured in your config.yml file to | ||
delete a user in the Falcon tenant. | ||
""" | ||
import logging | ||
|
||
from examples.common import caracara_example, pretty_print | ||
|
||
from caracara import Client | ||
|
||
|
||
@caracara_example | ||
def delete_user(uuid, **kwargs): | ||
"""Delete Users Example.""" | ||
client: Client = kwargs["client"] | ||
logger: logging.Logger = kwargs["logger"] | ||
|
||
logger.info("Deleting a user in the Falcon tenant") | ||
deleted_user_data = client.users.add_user(uuid) | ||
logger.info(pretty_print(deleted_user_data)) | ||
|
||
|
||
@caracara_example | ||
def get_uuid(email_address, **kwargs): | ||
"""Get UUID for Delete Users Example.""" | ||
client: Client = kwargs["client"] | ||
logger: logging.Logger = kwargs["logger"] | ||
|
||
logger.info("Retrieving UUID for a user in the Falcon tenant") | ||
uuid_data = client.users.get_uuid_by_email(email_address) | ||
return uuid_data | ||
|
||
|
||
if __name__ == "__main__": | ||
# delete_user requires a uuid, a string of characters | ||
# you can find this via get_uuid_by_email (from caracara) if needed | ||
EMAIL = "sample_email" | ||
fetched_uuid = get_uuid(EMAIL) | ||
delete_user(fetched_uuid) |