Skip to main content

Admin reference

The Admin class is designed to manage and facilitate the interactions with Edge organizations and users, including the roles associated with these entities. By providing a robust framework for CRUD operations, this class handles administrative tasks related to organizational structure, user management, and their respective roles within Edge.

# List organization names
[1]: edge.admin.list_organization_names()
list(str)

# Get organization
[2]: edge.admin.get_organization('myorg')
<edge.admin.organization.Organization>

Constructor

Constructing these yourself is not recommended. You should make an EdgeSession and access the .admin property.


Methods

list_organization_names

list_organization_names() -> list(str)

List names of stored organizations.

Returns

list(str) Names of stored organizations.


get_organization

get_organization(organization_name) -> Organization

Retrieve a stored organization object, given its name.

Parameters

  • organization_name (str)
    Name of the organization to retrieve.

Returns

edge.admin.organization.Organization The object corresponding to the retrieved organization.

Raises

  • NotFound: Raised if an organization with the given name is not found.

add_organization

add_organization(organization)

Creates an organization.

Parameters

  • organization (edge.admin.Organization)
    Organization object to store.

Raises

  • AlreadyExists: Raised if an organization with the given name already exists.
  • BadEntry: Raised if the organization definition or name is invalid.

update_organization

update_organization(organization)

Changes an organization.

Parameters

  • organization (edge.admin.Organization)
    Organization object to update.

Raises

  • NotFound: Raised if the organization doesn't already exist.
  • BadEntry: Raised if the organization definition is invalid.

remove_organization

remove_organization(organization_name)

Delete a given organization from storage.

Parameters

  • organization_name (str)
    Name of the organization to remove.

invite_to_organization

invite_to_organization(organization_name, email, license_name=None, roles=None) -> dict

Send an invitation for an organization to a user. If the user does not already exist on Edge, they will be created.

Parameters

  • organization_name (str)
    Name of the organization to send the invite for.
  • email (str)
    The e-mail address to send the invitation to. This should also be the user_name of the invited user.
  • license_name (str)
    Optional; A license name to assign the user upon creation.
  • roles list(str)
    Optional; A list of roles for the user. The "user" role is always added for the user.

Returns

dict A result object, with fields:

  • operation : str or None
    A user operation "create", "update" or None.
  • roles : List[str]
    A list of organization roles given to the user.
  • email : bool
    True, if an invitation email was successfully sent.

set_organization_invite_template

set_organization_invite_template(organization_name, template)

Sets the e-mail template for an organization's invites.

Parameters

  • organization_name (str)
    The organization to set the template for.
  • template (str)
    The template text.

get_organization_invite_template

get_organization_invite_template(organization_name) -> str

Sets the e-mail template for an organization's invites.

Parameters

  • organization_name (str)
    The organization to get the template for.

Returns

str The template text.

Raises

  • NotFound: Raised if the organization does not have an invite template set.

remove_organization_invite_template

remove_organization_invite_template(organization_name)

Removes the organization invite e-mail template.

Parameters

  • organization_name (str)
    The organization to remove the template for.

list_user_names

list_user_names() -> list(str)

List names of stored users.

Returns

list(str) Names of users.


get_user

get_user(user_name) -> User

Retrieve a stored user object, given its name.

Parameters

  • user_name (str)
    Name of the user to retrieve.

Returns

User The object corresponding to the retrieved user.

Raises

  • NotFound: Raised if a user with the given name is not found.

add_user

add_user(user)

Adds a user.

Parameters

  • user (edge.admin.User)
    User object to store.

Raises

  • AlreadyExists: Raised if a user with the given name already exists.
  • BadEntry: Raised if the user definition is invalid.

update_user

update_user(user)

Changes a user.

Parameters

  • user (edge.admin.User)
    User object to store.

Raises

  • AlreadyExists: Raised if a user with the given name already exists.
  • BadEntry: Raised if the user definition is invalid.

remove_user

remove_user(user_name)

Delete a given user from storage.

Parameters

  • user_name (User)
    Name of the user to remove.

list_org_users

list_org_users(org_name) -> list(User)

List users in an organization.

Parameters

  • org_name (str)
    Organization to list users of.

Returns

list(User) A list of User objects.


list_org_user_names

list_org_user_names(org_name) -> list(str)

List names of stored users in an organization.

Parameters

  • org_name (str)
    Organization to list users of.

Returns

list(str) Names of users.


get_org_user

get_org_user(org_name, user_name) -> User

Retrieve a stored user object, given its name, constrained to an organization.

Parameters

  • org_name (str)
    Organization to list users of.
  • user_name (str)
    Name of the user to retrieve.

Returns

User The object corresponding to the retrieved user.

Raises

  • NotFound: Raised if a user with the given name is not found.

set_user_home_org

set_user_home_org(user_name, org_name) -> User

Sets a user's home organization. You must be an administrator of the organization that will become the user's home organization. The user must also not have a current home organization.

Parameters

  • user_name (str)
    User name.
  • org_name (str)
    The organization name to set as the user's home.

Returns

User The object corresponding to the updated user.

Raises

  • NotFound: Raised if a user with the given name is not found.

unset_user_home_org

unset_user_home_org(user_name) -> User

Unsets a user's home organization. The user must not have a license assigned to them. You must be an administrator of the user's current home organization.

Parameters

  • user_name (str)
    User name.

Returns

User The object corresponding to the updated user.

Raises

  • NotFound: Raised if a user with the given name is not found.
  • LicenseError: Raise if a user currently has a license.

list_org_roles

list_org_roles(org_name) -> list(dict)

List the organization roles for all users in the organization.

Parameters

  • org_name (str)
    The organization whose roles we are listing.

Returns

list(dict) A list of roles.

Raises

  • NotFound: Raise if the organization is not found.

list_user_org_roles

list_user_org_roles(org_name, user_name) -> list(str)

List the organization roles for this user.

Parameters

  • org_name (str)
    The organization whose roles we are listing.
  • user_name (str)
    The user whose roles we are listing.

Returns

list(str) A list of roles.

Raises

  • NotFound: Raised if the user or organization is not found.

update_user_org_roles

update_user_org_roles(org_name, user_name, roles)

Update the organization roles for this user.

Parameters

  • org_name (str)
    The organization whose roles we are updating.
  • user_name (str)
    The user whose roles we are updating.
  • roles list(str)
    The new set of roles for this user in this organization.

Raises

  • NotFound: Raised if the user or organization is not found.

get_org_license_quotas

get_org_license_quotas(org_name=None) -> list(dict)

List the organization license quotas.

Parameters

  • org_name (str)
    Optional; The organization whose license quotas we are retrieving. If org_name is None, then license quotas aggregated for all organizations are retrieved.

Returns

list(dict) A list of dictionaries, containing license_name, description, limit and used.

Raises

  • NotFound: Raised if if the organization not could not be found.

update_org_license_quotas

update_org_license_quotas(org_name, licenses)

Updates the license quotas for an organization. Licenses quotas that are not included are not updated.

Parameters

  • org_name (str)
    The organization name to set license quotas on.
  • licenses list(dict)
    A list of dictionaries with license limits, with keys:
    • license_name : str
    • limit : int

Raises

  • NotFound: If org_name or a license_name could not be found.
  • LicenseError: If setting the organization license quota would cause it to fall below that organization's current license usage.

get_org_license_logs

get_org_license_logs(org_name, start_time=None, end_time=None, event_type=None,
user_name=None) -> list(dict)

List the organization's license events.

Parameters

  • org_name (str)
    The organization to retrieve license events for.
  • start_time datetime
    Optional; A starting datetime to search for events. If None, then events from the start of the day will be returned.
  • end_time (datetime)
    Optional; An ending datetime for events, inclusive. If None, then all events up until now will be returned.
  • event_type (str)
    Optional; An event type to search for.
  • user_name (str)
    Optional; A user_name to filter for associated events.

Returns

list(dict) A list of dictionaries where each event is a licensing event associated with the given organization.

Raises

  • NotFound: Raised if if the organization not could not be found.

get_user_license

get_user_license(user_name) -> dict

Get the user's license.

Parameters

  • user_name (str)
    The user whose license we are retrieving.

Returns

dict A user's license.

Raises

  • NotFound: Raised if if the user name not could not be found.

set_user_license

set_user_license(user_name, license_name)

Set the user's Edge license.

Parameters

  • user_name (str)
    The user whose license we are setting.
  • license_name (str)
    The name of the license.

Raises

  • NotFound: Raised if if the user name not could not be found.

remove_user_license

remove_user_license(user_name)

Removes the Edge license from a user.

Parameters

  • user_name (str)
    The user whose license we are removing.

Raises

  • NotFound: Raised if if the user name not could not be found.

list_user_server_roles

list_user_server_roles(user_name) -> list(str)

List the server roles for this user.

Parameters

  • user_name (str)
    The user whose roles we are listing.

Returns

list(str) A list of server roles.

Raises

  • NotFound: Raised if if the user name not could not be found.

update_user_server_roles

update_user_server_roles(user_name, roles)

Update the server roles for this user.

Parameters

  • user_name (str)
    The user whose roles we are updating.
  • roles list(str)
    The new set of server roles for this user.

Raises

  • NotFound: Raised if if the user name not could not be found.

get_server_licenses

get_server_licenses() -> dict

Gets the server's licenses.

Returns

dict A dictionary with server license data.


update_server_licenses

update_server_licenses(signed_jwt) -> dict

Updates the server's license.

Parameters

  • signed_jwt (str)
    The signed license data.

Returns

dict A dictionary with server license data.

Raises

  • LicenseError

get_server_license_logs

get_server_license_logs(start_time=None, end_time=None, event_type=None,
user_name=None, org_name=None) -> list(dict)

List the organization's license events.

Parameters

  • start_time (datetime)
    Optional; A starting datetime to search for events. If None, then events from the start of the day will be returned.
  • end_time (datetime)
    Optional; An ending datetime for events, inclusive. If None, then all events up until now will be returned.
  • event_type (str)
    Optional; An event type to search for.
  • user_name (str)
    Optional; A user_name to filter for associated events.
  • org_name (str)
    Optional; The organization to retrieve license events for. If None, then all events regardless of organization are returned.

Returns

list(dict) A list of dictionaries where each event is a licensing event associated with the given organization.


query_cloud_usage

query_cloud_usage(usage_type=None, org_name=None, classification=None,
service=None, billing_date=None, data_range=None, start_after_id=None,
page_size=1000) -> BillingCloudUsage

Query cloud usage for this organization.

Parameters

  • usage_type (str)
    Optional; A usage type to filter for.
  • org_name (str)
    Optional; An org name to filter for.
  • classification (str)
    Optional; A classification to filter for.
  • service (str)
    Optional; A service to filter for.
  • billing_date (date)
    Optional; A billing_date to filter for. Mutually exclusive with date_range.
  • date_range (edge.edge_billing.DateRange)
    Optional; A date range to filter for. Mutually exclusive with billing_date.
  • start_after_id (int)
    Optional; A cloud usage ID to return query results after, for pagination.
  • page_size (int)
    Optional; A page size for paginated results. Default is 1000. Minimum is 100 and maximum is 10000.

Returns

edge.edge_billing.BillingCloudUsage Cloud Usage result.


query_computed_costs

query_computed_costs(usage_type=None, org_name=None, classification=None, service=None,
category=None, billing_date=None, include_unallocated=False, date_range=None,
start_after_id=None, page_size=1000) -> BillingComputedCost

Query cloud usage for this organization.

Parameters

  • usage_type (str)
    Optional; A usage type to filter for.
  • org_name (str)
    Optional; An org name to filter for.
  • classification (str)
    Optional; A classification to filter for.
  • service (str)
    Optional; A service to filter for.
  • category (str)
    Optional; A category to filter for.
  • billing_date (date)
    Optional; A billing_date to filter for. Mutually exclusive with date_range.
  • include_unallocated (bool)
    Optional; Whether or not to include unallocated costs. This option may only be True if you are a server admin.
  • date_range (edge.edge_billing.DateRange)
    Optional; A date range to filter for. Mutually exclusive with billing_date.
  • start_after_id (int)
    Optional; A cloud usage ID to return query results after, for pagination.
  • page_size (int)
    Optional; A page size for paginated results. Default is 1000. Minimum is 100 and maximum is 10000.

Returns

edge.edge_billing.BillingComputedCost Computed Cost result.


reset_service_defaults

reset_service_defaults(org_name=None)

Resets the default service status for this organization. If a service is a "default" service, then its server_admin_approved and org_admin_approved flags will be set to True. Other services will not be modified.

Parameters

  • org_name (str)
    Optional; The organization name to reset service defaults for. If None, then it defaults to the organization for this EdgeSession.

set_org_service_approval

set_org_service_approval(service_name, org_admin_approved=None,
server_admin_approved=None, org_name=None)

Sets the approval of a service for this organization. A service is available for use if both the org_admin_approved and server_admin_approved flags are set to True. Only a server admin may set the server_admin_approved flag.

Parameters

  • service_name (str)
    The name of the service to set approval for.
  • org_admin_approved (bool)
    Optional; If not None, then the org_admin approval flag for this service will be set to this argument's value (True or False). Requires org admin.
  • server_admin_approved (bool)
    Optional; If not None, then the server_admin approval flag for this service will be set to this argument's value (True or False). Requires server admin.
  • org_name (str)
    Optional; The organization name to reset service defaults for. If None, then it defaults to the organization for this EdgeSession.

Raises

  • NotFound: Raised if the organization or service name does not exist.
  • Forbidden: Raised if the service is mandatory. Approval flags do not impact mandatory services.
  • NotAuthorized: Raised if a non-server admin tries to write the server_admin_approved flag.