Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Management Documentation #200

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)