Skip to content

Commit

Permalink
User Management Documentation (#200)
Browse files Browse the repository at this point in the history
* Adds user management module

* Additional Documentation for Users Module
  • Loading branch information
natalie363 authored Aug 21, 2024
1 parent 73b853d commit 507b378
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/users/add_user.py
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)
44 changes: 44 additions & 0 deletions examples/users/delete_user.py
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)

0 comments on commit 507b378

Please sign in to comment.