gestalt-sdk 0.0.1-alpha.26

Rust SDK scaffolding and generated protocol bindings for Gestalt executable providers
Documentation
// Code generated by sdkgen. DO NOT EDIT.

//! Generated wire conversions for identity.proto.

use crate::generated::v1;
use crate::identity::{
    AuthorizeRequest, AuthorizeResponse, GetGrantRequest, GetGrantResponse, GrantScope,
    IntrospectRequest, IntrospectResponse, ListGrantsRequest, ListGrantsResponse,
    RevokeGrantRequest, RevokeGrantResponse, TokenRequest, TokenResponse, UserInfoRequest,
    UserInfoResponse,
};

/// Converts a native `AuthorizeRequest` to its wire message.
pub(crate) fn to_wire_authorize_request(value: AuthorizeRequest) -> v1::AuthorizeRequest {
    v1::AuthorizeRequest {
        response_type: value.response_type,
        client_id: value.client_id,
        redirect_uri: value.redirect_uri,
        scope: value.scope,
        state: value.state,
    }
}

/// Converts a wire `AuthorizeResponse` to its native message.
pub(crate) fn from_wire_authorize_response(value: v1::AuthorizeResponse) -> AuthorizeResponse {
    AuthorizeResponse {
        redirect_uri: value.redirect_uri,
    }
}

/// Converts a native `GetGrantRequest` to its wire message.
pub(crate) fn to_wire_get_grant_request(value: GetGrantRequest) -> v1::GetGrantRequest {
    v1::GetGrantRequest {
        grant_id: value.grant_id,
    }
}

/// Converts a wire `GetGrantResponse` to its native message.
pub(crate) fn from_wire_get_grant_response(value: v1::GetGrantResponse) -> GetGrantResponse {
    GetGrantResponse {
        scopes: value
            .scopes
            .into_iter()
            .map(from_wire_grant_scope)
            .collect(),
        created_at: value.created_at,
        expires_at: value.expires_at,
    }
}

/// Converts a wire `GrantScope` to its native message.
pub(crate) fn from_wire_grant_scope(value: v1::GrantScope) -> GrantScope {
    GrantScope {
        scope: value.scope,
        resource: value.resource,
    }
}

/// Converts a native `IntrospectRequest` to its wire message.
pub(crate) fn to_wire_introspect_request(value: IntrospectRequest) -> v1::IntrospectRequest {
    v1::IntrospectRequest {
        token: value.token,
        token_type_hint: value.token_type_hint,
    }
}

/// Converts a wire `IntrospectResponse` to its native message.
pub(crate) fn from_wire_introspect_response(value: v1::IntrospectResponse) -> IntrospectResponse {
    IntrospectResponse {
        active: value.active,
        subject: value.subject,
        scope: value.scope,
        client_id: value.client_id,
        audience: value.audience,
    }
}

/// Converts a native `ListGrantsRequest` to its wire message.
pub(crate) fn to_wire_list_grants_request(_value: ListGrantsRequest) -> v1::ListGrantsRequest {
    v1::ListGrantsRequest {}
}

/// Converts a wire `ListGrantsResponse` to its native message.
pub(crate) fn from_wire_list_grants_response(value: v1::ListGrantsResponse) -> ListGrantsResponse {
    ListGrantsResponse {
        grant_ids: value.grant_ids,
    }
}

/// Converts a native `RevokeGrantRequest` to its wire message.
pub(crate) fn to_wire_revoke_grant_request(value: RevokeGrantRequest) -> v1::RevokeGrantRequest {
    v1::RevokeGrantRequest {
        grant_id: value.grant_id,
    }
}

/// Converts a wire `RevokeGrantResponse` to its native message.
pub(crate) fn from_wire_revoke_grant_response(
    _value: v1::RevokeGrantResponse,
) -> RevokeGrantResponse {
    RevokeGrantResponse {}
}

/// Converts a native `TokenRequest` to its wire message.
pub(crate) fn to_wire_token_request(value: TokenRequest) -> v1::TokenRequest {
    v1::TokenRequest {
        grant_type: value.grant_type,
        code: value.code,
        redirect_uri: value.redirect_uri,
        client_id: value.client_id,
        state: value.state,
        scope: value.scope,
        subject_token: value.subject_token,
        subject_token_type: value.subject_token_type,
        expires_in: value.expires_in,
    }
}

/// Converts a wire `TokenResponse` to its native message.
pub(crate) fn from_wire_token_response(value: v1::TokenResponse) -> TokenResponse {
    TokenResponse {
        access_token: value.access_token,
        token_type: value.token_type,
        expires_in: value.expires_in,
        refresh_token: value.refresh_token,
        scope: value.scope,
        grant_id: value.grant_id,
    }
}

/// Converts a native `UserInfoRequest` to its wire message.
pub(crate) fn to_wire_user_info_request(_value: UserInfoRequest) -> v1::UserInfoRequest {
    v1::UserInfoRequest {}
}

/// Converts a wire `UserInfoResponse` to its native message.
pub(crate) fn from_wire_user_info_response(value: v1::UserInfoResponse) -> UserInfoResponse {
    UserInfoResponse {
        subject_id: value.subject_id,
        email: value.email,
        name: value.name,
    }
}