Skip to content

wait_until_user_exists

wait_until_user_exists(
    *,
    max_wait_time: float,
    min_delay: float = 1,
    max_delay: float = 120,
    config_overrides: Optional[IAMClientConfig] = None,
    user_name: Optional[existingUserNameType] = None,
) -> GetUserResponse

Wait for user_exists.

Parameters:

  • max_wait_time (float) –

    Maximum total seconds to wait before raising WaiterTimeoutError.

  • min_delay (float, default: 1 ) –

    Minimum seconds between operation attempts (spec default 2).

  • max_delay (float, default: 120 ) –

    Maximum seconds between operation attempts (spec default 120).

  • user_name (Optional[existingUserNameType], default: None ) –

    The name of the user to get information about.

    This parameter is optional. If it is not included, it defaults to the user making the request. This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Source code in docs_src/capo_iam/_services/iam.py
def wait_until_user_exists(
    self,
    *,
    max_wait_time: float,
    min_delay: float = 1,
    max_delay: float = 120,
    config_overrides: Optional[IAMClientConfig] = None,
    user_name: Optional[
        "capo_iam.types.existing_user_name_type.existingUserNameType"
    ] = None,
) -> "capo_iam.types.get_user_response.GetUserResponse":
    """Wait for user_exists.

    Args:
        max_wait_time: Maximum total seconds to wait before raising WaiterTimeoutError.
        min_delay: Minimum seconds between operation attempts (spec default 2).
        max_delay: Maximum seconds between operation attempts (spec default 120).
        user_name: <p>The name of the user to get information about.</p> <p>This parameter is optional. If it is not included, it defaults to the user making the request. This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
    """
    start = time.monotonic()
    attempt = 0
    while True:
        op_output: "capo_iam.types.get_user_response.GetUserResponse | None" = None
        op_error: ServiceError | None = None
        try:
            op_output = self.get_user(  # noqa: F841
                config_overrides=config_overrides, user_name=user_name
            )
        except ServiceError as e:
            op_error = e
        if op_output is not None:
            return op_output
        elif op_error is not None and op_error.code == "NoSuchEntity":
            pass
        elif op_error is not None:
            raise op_error

        elapsed = time.monotonic() - start
        remaining = max_wait_time - elapsed
        if remaining <= 0:
            raise WaiterTimeoutError("user_exists", max_wait_time)
        delay = min(max_delay, min_delay * (2**attempt))
        delay = random.uniform(min_delay, delay)
        delay = min(delay, remaining)
        time.sleep(delay)
        attempt += 1