Skip to content

update_key

update_key(
    key_name: ResourceName,
    *,
    config_overrides: Optional[LocationClientConfig] = None,
    description: Optional[ResourceDescription] = None,
    expire_time: Optional[Timestamp] = None,
    no_expiry: Optional[bool] = None,
    force_update: Optional[bool] = None,
    restrictions: Optional[ApiKeyRestrictions] = None,
) -> UpdateKeyResponse

Updates the specified properties of a given API key resource.

Parameters:

  • key_name (ResourceName) –

    The name of the API key resource to update.

  • description (Optional[ResourceDescription], default: None ) –

    Updates the description for the API key resource.

  • expire_time (Optional[Timestamp], default: None ) –

    Updates the timestamp for when the API key resource will expire in ISO 8601 format: YYYY-MM-DDThh:mm:ss.sssZ.

  • no_expiry (Optional[bool], default: None ) –

    Whether the API key should expire. Set to true to set the API key to have no expiration time.

  • force_update (Optional[bool], default: None ) –

    The boolean flag to be included for updating ExpireTime or Restrictions details.

    Must be set to true to update an API key resource that has been used in the past 7 days.

    False if force update is not preferred

    Default value: False

  • restrictions (Optional[ApiKeyRestrictions], default: None ) –

    Updates the API key restrictions for the API key resource.

Raises:

  • AccessDeniedException –

    The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.

  • InternalServerException –

    The request has failed to process because of an unknown server error, exception, or failure.

  • ResourceNotFoundException –

    The resource that you've entered was not found in your AWS account.

  • ThrottlingException –

    The request was denied because of request throttling.

  • ValidationException –

    The input failed to meet the constraints specified by the AWS service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_location/_services/location.py
def update_key(
    self,
    key_name: "capo_location.types.resource_name.ResourceName",
    *,
    config_overrides: Optional[LocationClientConfig] = None,
    description: Optional[
        "capo_location.types.resource_description.ResourceDescription"
    ] = None,
    expire_time: Optional["capo_location.types.timestamp.Timestamp"] = None,
    no_expiry: Optional[bool] = None,
    force_update: Optional[bool] = None,
    restrictions: Optional[
        "capo_location.types.api_key_restrictions.ApiKeyRestrictions"
    ] = None,
) -> "capo_location.types.update_key_response.UpdateKeyResponse":
    """<p>Updates the specified properties of a given API key resource.</p>

    Args:
        key_name: <p>The name of the API key resource to update.</p>
        description: <p>Updates the description for the API key resource.</p>
        expire_time: <p>Updates the timestamp for when the API key resource will expire in <a href="https://www.iso.org/iso-8601-date-and-time-format.html"> ISO 8601</a> format: <code>YYYY-MM-DDThh:mm:ss.sssZ</code>. </p>
        no_expiry: <p>Whether the API key should expire. Set to <code>true</code> to set the API key to have no expiration time.</p>
        force_update: <p>The boolean flag to be included for updating <code>ExpireTime</code> or <code>Restrictions</code> details.</p> <p>Must be set to <code>true</code> to update an API key resource that has been used in the past 7 days.</p> <p> <code>False</code> if force update is not preferred</p> <p>Default value: <code>False</code> </p>
        restrictions: <p>Updates the API key restrictions for the API key resource.</p>

    Raises:
        capo_location.errors.access_denied_exception.AccessDeniedException: <p>The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.</p>
        capo_location.errors.internal_server_exception.InternalServerException: <p>The request has failed to process because of an unknown server error, exception, or failure.</p>
        capo_location.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource that you've entered was not found in your AWS account.</p>
        capo_location.errors.throttling_exception.ThrottlingException: <p>The request was denied because of request throttling.</p>
        capo_location.errors.validation_exception.ValidationException: <p>The input failed to meet the constraints specified by the AWS service. </p>
        capo_location.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_location.types.update_key_request.UpdateKeyRequest]",
    ) -> OperationResponse[
        "capo_location.types.update_key_response.UpdateKeyResponse"
    ]:
        import capo_location._operations.location_service.update_key

        output, http_response = (
            capo_location._operations.location_service.update_key.update_key(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_location.types.update_key_request.UpdateKeyRequest",
    ) -> dict[str, Any]:
        import capo_location.types.update_key_request

        return capo_location.types.update_key_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_location.types.update_key_response.UpdateKeyResponse",
    ) -> dict[str, Any]:
        import capo_location.types.update_key_response

        return capo_location.types.update_key_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateKey", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_location.types.update_key_request.UpdateKeyRequest = {
        "key_name": key_name
    }
    if description is not None:
        input_["description"] = description
    if expire_time is not None:
        input_["expire_time"] = expire_time
    if no_expiry is not None:
        input_["no_expiry"] = no_expiry
    if force_update is not None:
        input_["force_update"] = force_update
    if restrictions is not None:
        input_["restrictions"] = restrictions

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output