Skip to content

search_principals async

search_principals(
    domain_id: DomainId,
    search_query: str,
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    max_results: Optional[int] = None,
    next_token: Optional[SearchPrincipalsNextToken] = None,
) -> SearchPrincipalsOutput

Searches Identity Center for users and groups in a domain. The domain must be configured with Identity Center. To grant access to a result, pass its principalId to CreateAccessGrant with a principalType of IDC_USER for a user or IDC_GROUP for a group.

Parameters:

  • domain_id (DomainId) –

    The ID of the domain to search within.

  • search_query (str) –

    A search term to match against user names, display names, and IDs. Pass * to list all principals. Maximum 128 characters.

  • max_results (Optional[int], default: None ) –

    The maximum number of results to return. Defaults to 10. Valid only when searchQuery is *; other searches reject this parameter and return at most 10 results.

  • next_token (Optional[SearchPrincipalsNextToken], default: None ) –

    A token to retrieve the next page of results. Valid only when searchQuery is *; other searches do not paginate and reject this parameter. Tokens expire after 24 hours.

Raises:

Examples:

Search principals by name The following example searches a domain for principals whose name matches a text query. A text search (any searchQuery other than *) returns at most 10 results and does not paginate, so maxResults and nextToken are not supplied and no nextToken is returned. To grant access to a result, pass its principalId to CreateAccessGrant with a principalType of IDC_USER for a user or IDC_GROUP for a group. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> await client.search_principals(domain_id='d-1a2b3c4d5e', search_query='jane')
Source code in docs_src/capo_cloudwatchomni/_services/async_cloud_watch_omni.py
async def search_principals(
    self,
    domain_id: "capo_cloudwatchomni.types.domain_id.DomainId",
    search_query: str,
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    max_results: Optional[int] = None,
    next_token: Optional[
        "capo_cloudwatchomni.types.search_principals_next_token.SearchPrincipalsNextToken"
    ] = None,
) -> "capo_cloudwatchomni.types.search_principals_output.SearchPrincipalsOutput":
    """Searches Identity Center for users and groups in a domain. The domain must be configured with Identity Center. To grant access to a result, pass its principalId to CreateAccessGrant with a principalType of IDC_USER for a user or IDC_GROUP for a group.

    Args:
        domain_id: The ID of the domain to search within.
        search_query: A search term to match against user names, display names, and IDs. Pass * to list all principals. Maximum 128 characters.
        max_results: The maximum number of results to return. Defaults to 10. Valid only when searchQuery is *; other searches reject this parameter and return at most 10 results.
        next_token: A token to retrieve the next page of results. Valid only when searchQuery is *; other searches do not paginate and reject this parameter. Tokens expire after 24 hours.

    Raises:
        capo_cloudwatchomni.errors.access_denied_exception.AccessDeniedException: The caller is not authorized to perform this action.
        capo_cloudwatchomni.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_cloudwatchomni.errors.resource_not_found_exception.ResourceNotFoundException: The specified resource does not exist.
        capo_cloudwatchomni.errors.throttling_exception.ThrottlingException: The request was throttled due to exceeding the allowed request rate.
        capo_cloudwatchomni.errors.validation_exception.ValidationException: A parameter is specified incorrectly.
        capo_cloudwatchomni.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Search principals by name
        The following example searches a domain for principals whose name matches a text query. A text search (any searchQuery other than *) returns at most 10 results and does not paginate, so maxResults and nextToken are not supplied and no nextToken is returned. To grant access to a result, pass its principalId to CreateAccessGrant with a principalType of IDC_USER for a user or IDC_GROUP for a group. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> await client.search_principals(domain_id='d-1a2b3c4d5e', search_query='jane')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatchomni.types.search_principals_input.SearchPrincipalsInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatchomni.types.search_principals_output.SearchPrincipalsOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.search_principals

        (
            output,
            http_response,
        ) = await capo_cloudwatchomni._operations.cloud_watch_omni_frontend.search_principals.async_search_principals(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SearchPrincipals")
    )
    input_: capo_cloudwatchomni.types.search_principals_input.SearchPrincipalsInput = {
        "domain_id": domain_id,
        "search_query": search_query,
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output