Skip to content

list_principals async

list_principals(
    resource_owner: ResourceOwner,
    *,
    config_overrides: Optional[AsyncRAMClientConfig] = None,
    resource_arn: Optional[String] = None,
    principals: Optional[PrincipalArnOrIdList] = None,
    resource_type: Optional[String] = None,
    resource_share_arns: Optional[ResourceShareArnList] = None,
    next_token: Optional[String] = None,
    max_results: Optional[MaxResults] = None,
) -> ListPrincipalsResponse

Lists the principals that you are sharing resources with or that are sharing resources with you.

Always check the NextToken response parameter for a null value when calling a paginated operation. These operations can occasionally return an empty set of results even when there are more results available. The NextToken response parameter value is null only when there are no more results to display.

Parameters:

  • resource_owner (ResourceOwner) –

    Specifies that you want to list information for only resource shares that match the following:

    • SELF – principals that your account is sharing resources with

    • OTHER-ACCOUNTS – principals that are sharing resources with your account

  • resource_arn (Optional[String], default: None ) –

    Specifies that you want to list principal information for the resource share with the specified Amazon Resource Name (ARN).

  • principals (Optional[PrincipalArnOrIdList], default: None ) –

    Specifies that you want to list information for only the listed principals.

    You can include the following values:

    • An Amazon Web Services account ID, for example: 123456789012

    • An Amazon Resource Name (ARN) of an organization in Organizations, for example: organizations::123456789012:organization/o-exampleorgid

    • An ARN of an organizational unit (OU) in Organizations, for example: organizations::123456789012:ou/o-exampleorgid/ou-examplerootid-exampleouid123

    • An ARN of an IAM role, for example: iam::123456789012:role/rolename

    • An ARN of an IAM user, for example: iam::123456789012user/username

    • A service principal name, for example: service-id.amazonaws.com

    Not all resource types can be shared with IAM roles and users. For more information, see Sharing with IAM roles and users in the Resource Access Manager User Guide.

  • resource_type (Optional[String], default: None ) –

    Specifies that you want to list information for only principals associated with resource shares that include the specified resource type.

    For a list of valid values, query the ListResourceTypes operation.

  • resource_share_arns (Optional[ResourceShareArnList], default: None ) –

    Specifies that you want to list information for only principals associated with the resource shares specified by a list the Amazon Resource Names (ARNs).

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

    Specifies that you want to receive the next page of results. Valid only if you received a NextToken response in the previous request. If you did, it indicates that more output is available. Set this parameter to the value provided by the previous call's NextToken response to request the next page of results.

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

    Specifies the total number of results that you want included on each page of the response. If you do not include this parameter, it defaults to a value that is specific to the operation. If additional items exist beyond the number you specify, the NextToken response element is returned with a value (not null). Include the specified value as the NextToken request parameter in the next call to the operation to get the next part of the results. Note that the service might return fewer results than the maximum even when there are more results available. You should check NextToken after every operation to ensure that you receive all of the results.

Raises:

Source code in docs_src/capo_ram/_services/async_ram.py
async def list_principals(
    self,
    resource_owner: "capo_ram.types.resource_owner.ResourceOwner",
    *,
    config_overrides: Optional[AsyncRAMClientConfig] = None,
    resource_arn: Optional["capo_ram.types.string.String"] = None,
    principals: Optional[
        "capo_ram.types.principal_arn_or_id_list.PrincipalArnOrIdList"
    ] = None,
    resource_type: Optional["capo_ram.types.string.String"] = None,
    resource_share_arns: Optional[
        "capo_ram.types.resource_share_arn_list.ResourceShareArnList"
    ] = None,
    next_token: Optional["capo_ram.types.string.String"] = None,
    max_results: Optional["capo_ram.types.max_results.MaxResults"] = None,
) -> "capo_ram.types.list_principals_response.ListPrincipalsResponse":
    """<p>Lists the principals that you are sharing resources with or that are sharing resources with you.</p> <note> <p>Always check the <code>NextToken</code> response parameter for a <code>null</code> value when calling a paginated operation. These operations can occasionally return an empty set of results even when there are more results available. The <code>NextToken</code> response parameter value is <code>null</code> <i>only</i> when there are no more results to display.</p> </note>

    Args:
        resource_owner: <p>Specifies that you want to list information for only resource shares that match the following:</p> <ul> <li> <p> <b> <code>SELF</code> </b> – principals that your account is sharing resources with</p> </li> <li> <p> <b> <code>OTHER-ACCOUNTS</code> </b> – principals that are sharing resources with your account</p> </li> </ul>
        resource_arn: <p>Specifies that you want to list principal information for the resource share with the specified <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Name (ARN)</a>.</p>
        principals: <p>Specifies that you want to list information for only the listed principals.</p> <p>You can include the following values:</p> <ul> <li> <p>An Amazon Web Services account ID, for example: <code>123456789012</code> </p> </li> <li> <p>An <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Name (ARN)</a> of an organization in Organizations, for example: <code>organizations::123456789012:organization/o-exampleorgid</code> </p> </li> <li> <p>An ARN of an organizational unit (OU) in Organizations, for example: <code>organizations::123456789012:ou/o-exampleorgid/ou-examplerootid-exampleouid123</code> </p> </li> <li> <p>An ARN of an IAM role, for example: <code>iam::123456789012:role/rolename</code> </p> </li> <li> <p>An ARN of an IAM user, for example: <code>iam::123456789012user/username</code> </p> </li> <li> <p>A service principal name, for example: <code>service-id.amazonaws.com</code> </p> </li> </ul> <note> <p>Not all resource types can be shared with IAM roles and users. For more information, see <a href="https://docs.aws.amazon.com/ram/latest/userguide/permissions.html#permissions-rbp-supported-resource-types">Sharing with IAM roles and users</a> in the <i>Resource Access Manager User Guide</i>.</p> </note>
        resource_type: <p>Specifies that you want to list information for only principals associated with resource shares that include the specified resource type.</p> <p>For a list of valid values, query the <a>ListResourceTypes</a> operation.</p>
        resource_share_arns: <p>Specifies that you want to list information for only principals associated with the resource shares specified by a list the <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Names (ARNs)</a>.</p>
        next_token: <p>Specifies that you want to receive the next page of results. Valid only if you received a <code>NextToken</code> response in the previous request. If you did, it indicates that more output is available. Set this parameter to the value provided by the previous call's <code>NextToken</code> response to request the next page of results.</p>
        max_results: <p>Specifies the total number of results that you want included on each page of the response. If you do not include this parameter, it defaults to a value that is specific to the operation. If additional items exist beyond the number you specify, the <code>NextToken</code> response element is returned with a value (not null). Include the specified value as the <code>NextToken</code> request parameter in the next call to the operation to get the next part of the results. Note that the service might return fewer results than the maximum even when there are more results available. You should check <code>NextToken</code> after every operation to ensure that you receive all of the results.</p>

    Raises:
        capo_ram.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The operation failed because the specified value for <code>NextToken</code> isn't valid. You must specify a value you received in the <code>NextToken</code> response of a previous call to this operation.</p>
        capo_ram.errors.invalid_parameter_exception.InvalidParameterException: <p>The operation failed because a parameter you specified isn't valid.</p>
        capo_ram.errors.malformed_arn_exception.MalformedArnException: <p>The operation failed because the specified <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Name (ARN)</a> has a format that isn't valid.</p>
        capo_ram.errors.server_internal_exception.ServerInternalException: <p>The operation failed because the service could not respond to the request due to an internal problem. Try again later.</p>
        capo_ram.errors.service_unavailable_exception.ServiceUnavailableException: <p>The operation failed because the service isn't available. Try again later.</p>
        capo_ram.errors.unknown_resource_exception.UnknownResourceException: <p>The operation failed because a specified resource couldn't be found.</p>
        capo_ram.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ram.types.list_principals_request.ListPrincipalsRequest]",
    ) -> AsyncOperationResponse[
        "capo_ram.types.list_principals_response.ListPrincipalsResponse"
    ]:
        import capo_ram._operations.amazon_resource_sharing.list_principals

        (
            output,
            http_response,
        ) = await capo_ram._operations.amazon_resource_sharing.list_principals.async_list_principals(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListPrincipals")
    )
    input_: capo_ram.types.list_principals_request.ListPrincipalsRequest = {
        "resource_owner": resource_owner
    }
    if resource_arn is not None:
        input_["resource_arn"] = resource_arn
    if principals is not None:
        input_["principals"] = principals
    if resource_type is not None:
        input_["resource_type"] = resource_type
    if resource_share_arns is not None:
        input_["resource_share_arns"] = resource_share_arns
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

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