async fn run_operation_metadata(
    server_handle: &dyn ServerHandle,
    operation_state: ServerOperationIterationState<ServerOperationIterationStarting>,
) -> std::result::Result<
    ServerOperationIterationState<ServerOperationIterationSucceeded>,
    ServerOperationIterationState<ServerOperationIterationFailed>,
> {
    let url = create_metadata_url(server_handle);

    let client = match server_handle.client() {
        Ok(client) => client,
        Err(err) => {
            return Err(operation_state
                .completed()
                .failed(eyre!(format!("Unable to create client: '{}'", err))));
        }
    };

    let request_builder = server_handle.request_builder(client, http::Method::GET, url.clone());
    let response = request_builder
        .send()
        .instrument(trace_span!("GET request", %url))
        .await;

    let operation_state = operation_state.completed();

    match response {
        Ok(response) => {
            let response_status = response.status();

            // Always pull response body, to drain stream and release connection.
            let response_body = match response.text().await {
                Ok(response_body) => response_body,
                Err(err) => format!("Unable to retrieve response body due to error: '{}'", err),
            };

            if !response_status.is_success() {
                let error = eyre!(
                    "The GET /metadata to '{}' failed, with status '{}' and body: '{}'",
                    &url,
                    response_status,
                    response_body
                );
                let state = operation_state.failed(error);
                return Err(state);
            }

            // TODO more checks needed
            Ok(operation_state.succeeded())
        }
        Err(err) => Err(operation_state.failed(eyre!(format!("HTTP request failed: '{}'", err)))),
    }
}
/// Runs a single iteration of the `/metadata` operation and verifies its result, logging out any faults that
/// were found (in addition to returning the error).
///
/// Parameters:
/// * `server_handle`: the [ServerHandle] for the server to test
/// * `operation_state`: the initial state machine for this operation iteration
///
/// Returns the final [ServerOperationIterationState] containing information about the operation's
/// success or failure.
Runs a single iteration of the `/metadata` operation and verifies its result, logging out any faults that
were found (in addition to returning the error).

`server_handle`: the [ServerHandle] for the server to test
`operation_state`: the initial state machine for this operation iteration

Returns the final [ServerOperationIterationState] containing information about the operation's
success or failure.
Runs a single iteration of the ` / metadata ` operation and verifies its result logging out any faults that were found ( in addition to returning the error ) . ` server_handle ` : the [ ServerHandle ] for the server to test ` operation_state ` : the initial state machine for this operation iteration Returns the final [ ServerOperationIterationState ] containing information about the operation ' s success or failure .
async fn run_operation_metadata(
    server_handle: &dyn ServerHandle,
    operation_state: ServerOperationIterationState<ServerOperationIterationStarting>,
) -> std::result::Result<
    ServerOperationIterationState<ServerOperationIterationSucceeded>,
    ServerOperationIterationState<ServerOperationIterationFailed>,
> {
    let url = create_metadata_url(server_handle);
    let client = match server_handle.client() {
        Ok(client) => client,
        Err(err) => {
            return Err(operation_state
                .completed()
                .failed(eyre!(format!("Unable to create client: '{}'", err))));
        }
    };
    let request_builder = server_handle.request_builder(client, http::Method::GET, url.clone());
    let response = request_builder
        .send()
        .instrument(trace_span!("GET request", %url))
        .await;
    let operation_state = operation_state.completed();
    match response {
        Ok(response) => {
            let response_status = response.status();
            // Always pull response body, to drain stream and release connection.
            let response_body = match response.text().await {
                Ok(response_body) => response_body,
                Err(err) => format!("Unable to retrieve response body due to error: '{}'", err),
            };
            if !response_status.is_success() {
                let error = eyre!(
                    "The GET /metadata to '{}' failed, with status '{}' and body: '{}'",
                    &url,
                    response_status,
                    response_body
                );
                let state = operation_state.failed(error);
                return Err(state);
            }
            // TODO more checks needed
            Ok(operation_state.succeeded())
        }
        Err(err) => Err(operation_state.failed(eyre!(format!("HTTP request failed: '{}'", err)))),
    }
}
async fn run_operation_metadata ( server_handle : & dyn ServerHandle , operation_state : ServerOperationIterationState < ServerOperationIterationStarting > , ) -> std :: result :: Result < ServerOperationIterationState < ServerOperationIterationSucceeded > , ServerOperationIterationState < ServerOperationIterationFailed > , > { let url = create_metadata_url ( server_handle ) ; let client = match server_handle . client ( ) { Ok ( client ) => client , Err ( err ) => { return Err ( operation_state . completed ( ) . failed ( eyre ! ( format ( " " err ) ) ) ) ; } } ; let request_builder = server_handle . request_builder ( client , http :: Method :: GET , url . clone ( ) ) ; let response = request_builder . send ( ) . instrument ( trace_span ! ( " " url ) ) . await ; let operation_state = operation_state . completed ( ) ; match response { Ok ( response ) => { let response_status = response . status ( ) ; // Always pull response body, to drain stream and release connection. let response_body = match response . text ( ) . await { Ok ( response_body ) => response_body , Err ( err ) => format ! ( " " err ) , } ; if ! response_status . is_success ( ) { let error = eyre ! ( " " url response_status response_body ) ; let state = operation_state . failed ( error ) ; return Err ( state ) ; } // TODO more checks needed Ok ( operation_state . succeeded ( ) ) } Err ( err ) => Err ( operation_state . failed ( eyre ! ( format ( " " err ) ) ) ) , } }
Runs a single iteration of the `/metadata` operation and verifies its result, logging out any faults that
were found (in addition to returning the error).
Runs a single iteration of the ` / metadata ` operation and verifies its result logging out any faults that were found ( in addition to returning the error ) .
server_handle
&dyn ServerHandle
operation_state
ServerOperationIterationState<ServerOperationIterationStarting>
server_handle
&dyn ServerHandle
operation_state
ServerOperationIterationState<ServerOperationIterationStarting>