Skip to content

Commit

Permalink
Merge pull request #90 from EventStore/brockshelton/clo-851-add-suppo…
Browse files Browse the repository at this point in the history
…rt-for-getting-member-details

add Get member cli command
  • Loading branch information
bshelton authored Apr 5, 2024
2 parents e54f543 + 7409083 commit 25b3ab9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub mod resources {
// All of the following using statements are just to keep compatability with the
// test code. In the future they'll be scrapped.
pub use access::GroupId;
pub use access::MemberId;
pub use access::PolicyId;
pub use esc_client_base::Client as EscRequestSender;
pub use infra::NetworkId;
Expand Down
24 changes: 23 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod output;
mod utils;
mod v1;

use esc_api::{GroupId, OrgId};
use esc_api::{GroupId, MemberId, OrgId};
use output::OutputFormat;
use serde::Serialize;
use std::collections::HashMap;
Expand Down Expand Up @@ -315,9 +315,20 @@ enum GroupsCommand {

#[derive(StructOpt, Debug)]
enum MembersCommand {
Get(GetMember),
List(ListMembers),
}

#[derive(StructOpt, Debug)]
#[structopt(about = "Read information about a Member")]
struct GetMember {
#[structopt(long, short, parse(try_from_str = parse_member_id))]
id: MemberId,

#[structopt(long, short, parse(try_from_str = parse_org_id), default_value = "")]
org_id: OrgId,
}

#[derive(StructOpt, Debug)]
#[structopt(about = "List members")]
struct ListMembers {
Expand Down Expand Up @@ -1467,6 +1478,10 @@ fn parse_policy_id(src: &str) -> Result<esc_api::PolicyId, String> {
Ok(esc_api::PolicyId(src.to_string()))
}

fn parse_member_id(src: &str) -> Result<esc_api::MemberId, String> {
Ok(esc_api::MemberId(src.to_string()))
}

fn parse_provider(src: &str) -> Result<esc_api::infra::Provider, String> {
parse_enum(&PROVIDERS, src)
}
Expand Down Expand Up @@ -1931,6 +1946,13 @@ async fn call_api<'a, 'b>(
let resp = esc_api::access::list_members(&client, params.org_id).await?;
printer.print(resp)?;
}

MembersCommand::Get(params) => {
let client = client_builder.create().await?;
let resp =
esc_api::access::get_member(&client, params.org_id, params.id).await?;
printer.print(resp)?;
}
},
},

Expand Down
7 changes: 7 additions & 0 deletions cli/src/v1/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ impl ToV1 for esc_api::access::Member {
}
}

impl ToV1 for esc_api::access::GetMemberResponse {
type V1Type = Member;
fn to_v1(self) -> Self::V1Type {
self.member.to_v1()
}
}

impl ToV1 for esc_api::access::ListMembersResponse {
type V1Type = List<Member>;
fn to_v1(self) -> Self::V1Type {
Expand Down

0 comments on commit 25b3ab9

Please sign in to comment.