def login_to_tenant(self, tenant_slug: str=None, tenant_id: str=None) -> bool:
    "\n        Log in to a specific tenant\n\n        NOTE: this should only be called by users who have provided a USER-scoped API token.\n\n        Args:\n            - tenant_slug (str): the tenant's slug\n            - tenant_id (str): the tenant's id\n\n        Returns:\n            - bool: True if the login was successful\n\n        Raises:\n            - ValueError: if at least one of `tenant_slug` or `tenant_id` isn't provided\n            - ValueError: if the `tenant_id` is not a valid UUID\n            - ValueError: if no matching tenants are found\n\n        "
    if ((tenant_slug is None) and (tenant_id is None)):
        raise ValueError('At least one of `tenant_slug` or `tenant_id` must be provided.')
    elif tenant_id:
        try:
            uuid.UUID(tenant_id)
        except ValueError as exc:
            raise ValueError('The `tenant_id` must be a valid UUID.') from exc
    tenant = self.graphql({'query($slug: String, $id: uuid)': {'tenant(where: {slug: { _eq: $slug }, id: { _eq: $id } })': {'id'}}}, variables=dict(slug=tenant_slug, id=tenant_id), token=self._api_token)
    if (not tenant.data.tenant):
        raise ValueError('No matching tenants found.')
    tenant_id = tenant.data.tenant[0].id
    if (prefect.config.backend == 'cloud'):
        payload = self.graphql({'mutation($input: switch_tenant_input!)': {'switch_tenant(input: $input)': {'access_token', 'expires_at', 'refresh_token'}}}, variables=dict(input=dict(tenant_id=tenant_id)), token=self._api_token)
        self._access_token = payload.data.switch_tenant.access_token
        self._access_token_expires_at = pendulum.parse(payload.data.switch_tenant.expires_at)
        self._refresh_token = payload.data.switch_tenant.refresh_token
    self._active_tenant_id = tenant_id
    settings = self._load_local_settings()
    settings['active_tenant_id'] = self._active_tenant_id
    self._save_local_settings(settings)
    return True
Log in to a specific tenant

NOTE: this should only be called by users who have provided a USER-scoped API token.

Args:
    - tenant_slug (str): the tenant's slug
    - tenant_id (str): the tenant's id

Returns:
    - bool: True if the login was successful

Raises:
    - ValueError: if at least one of `tenant_slug` or `tenant_id` isn't provided
    - ValueError: if the `tenant_id` is not a valid UUID
    - ValueError: if no matching tenants are found
def login_to_tenant(self, tenant_slug: str=None, tenant_id: str=None) -> bool:
    "\n        Log in to a specific tenant\n\n        NOTE: this should only be called by users who have provided a USER-scoped API token.\n\n        Args:\n            - tenant_slug (str): the tenant's slug\n            - tenant_id (str): the tenant's id\n\n        Returns:\n            - bool: True if the login was successful\n\n        Raises:\n            - ValueError: if at least one of `tenant_slug` or `tenant_id` isn't provided\n            - ValueError: if the `tenant_id` is not a valid UUID\n            - ValueError: if no matching tenants are found\n\n        "
    if ((tenant_slug is None) and (tenant_id is None)):
        raise ValueError('At least one of `tenant_slug` or `tenant_id` must be provided.')
    elif tenant_id:
        try:
            uuid.UUID(tenant_id)
        except ValueError as exc:
            raise ValueError('The `tenant_id` must be a valid UUID.') from exc
    tenant = self.graphql({'query($slug: String, $id: uuid)': {'tenant(where: {slug: { _eq: $slug }, id: { _eq: $id } })': {'id'}}}, variables=dict(slug=tenant_slug, id=tenant_id), token=self._api_token)
    if (not tenant.data.tenant):
        raise ValueError('No matching tenants found.')
    tenant_id = tenant.data.tenant[0].id
    if (prefect.config.backend == 'cloud'):
        payload = self.graphql({'mutation($input: switch_tenant_input!)': {'switch_tenant(input: $input)': {'access_token', 'expires_at', 'refresh_token'}}}, variables=dict(input=dict(tenant_id=tenant_id)), token=self._api_token)
        self._access_token = payload.data.switch_tenant.access_token
        self._access_token_expires_at = pendulum.parse(payload.data.switch_tenant.expires_at)
        self._refresh_token = payload.data.switch_tenant.refresh_token
    self._active_tenant_id = tenant_id
    settings = self._load_local_settings()
    settings['active_tenant_id'] = self._active_tenant_id
    self._save_local_settings(settings)
    return True