ya_client/
identity.rs

1use ya_client_model::identity::Identity;
2
3use crate::web::{WebClient, WebInterface};
4use crate::Result;
5
6pub const IDENTITY_URL_ENV_VAR: &str = "YAGNA_IDENTITY_URL";
7
8/// Bindings for Requestor part of the Identity API.
9#[derive(Clone)]
10pub struct IdentityApi {
11    client: WebClient,
12}
13
14impl WebInterface for IdentityApi {
15    const API_URL_ENV_VAR: &'static str = "YAGNA_IDENTITY_URL";
16    const API_SUFFIX: &'static str = "";
17
18    fn from_client(client: WebClient) -> Self {
19        IdentityApi { client }
20    }
21}
22
23impl IdentityApi {
24    pub async fn me(&self) -> Result<Identity> {
25        self.client.get("me").send().json().await
26    }
27}