Skip to content

Commit

Permalink
remove derive-getters, bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithe14 committed Jan 28, 2025
1 parent e4a7596 commit fdc2e4f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 25 deletions.
22 changes: 5 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oidc_agent_rs"
version = "0.2.4"
version = "0.2.5"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Unix only oidc-agent library for Rust."
Expand All @@ -12,9 +12,8 @@ all-features = true

[dependencies]
chrono = { version = "0.4.39", features = ["serde"] }
derive-getters = "0.4.0"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.135"
serde_json = "1.0.137"
tokio = { version = "1.43.0", optional = true, features = ["net", "io-util"] }
url = { version = "2.5.4", features = ["serde"] }

Expand Down
69 changes: 64 additions & 5 deletions src/responses.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::mytoken::{Capability, MyTokenType, Restriction, Rotation};
use crate::{Response, Token};
use chrono::{DateTime, Utc};
use derive_getters::Getters;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fmt::Display;
Expand All @@ -23,12 +22,18 @@ impl Display for Status {
}
}

#[derive(Serialize, Deserialize, Getters, Debug)]
#[derive(Serialize, Deserialize, Debug)]
pub struct OIDCAgentResponse {
status: Status,
}

#[derive(Serialize, Deserialize, Debug, Getters)]
impl OIDCAgentResponse {
pub fn status(&self) -> &Status {
&self.status
}
}

#[derive(Serialize, Deserialize, Debug)]
pub struct AccessTokenResponse {
access_token: Token,
issuer: Url,
Expand All @@ -37,9 +42,21 @@ pub struct AccessTokenResponse {
expires_at: DateTime<Utc>,
}

impl AccessTokenResponse {
pub fn access_token(&self) -> &Token {
&self.access_token
}
pub fn issuer(&self) -> &Url {
&self.issuer
}
pub fn expires_at(&self) -> &DateTime<Utc> {
&self.expires_at
}
}

impl Response for AccessTokenResponse {}

#[derive(Serialize, Deserialize, Getters, Debug)]
#[derive(Serialize, Deserialize, Debug)]
pub struct MyTokenResponse {
mytoken: Token,
mytoken_issuer: Url,
Expand All @@ -56,11 +73,53 @@ pub struct MyTokenResponse {
rotation: Option<Rotation>,
}

impl MyTokenResponse {
pub fn mytoken(&self) -> &Token {
&self.mytoken
}
pub fn mytoken_issuer(&self) -> &Url {
&self.mytoken_issuer
}
pub fn oidc_issuer(&self) -> &Url {
&self.oidc_issuer
}
pub fn expires_at(&self) -> Option<&DateTime<Utc>> {
self.expires_at.as_ref()
}
pub fn mytoken_type(&self) -> Option<&MyTokenType> {
self.mytoken_type.as_ref()
}
pub fn transfer_code(&self) -> Option<&String> {
self.transfer_code.as_ref()
}
pub fn expires_in(&self) -> Option<&u64> {
self.expires_in.as_ref()
}
pub fn mom_id(&self) -> Option<&String> {
self.mom_id.as_ref()
}
pub fn capabilities(&self) -> Option<&HashSet<Capability>> {
self.capabilities.as_ref()
}
pub fn restrictions(&self) -> Option<&HashSet<Restriction>> {
self.restrictions.as_ref()
}
pub fn rotation(&self) -> Option<&Rotation> {
self.rotation.as_ref()
}
}

impl Response for MyTokenResponse {}

#[derive(Serialize, Deserialize, Debug, Getters)]
#[derive(Serialize, Deserialize, Debug)]
pub struct AccountsResponse {
info: Vec<String>,
}

impl AccountsResponse {
pub fn info(&self) -> &Vec<String> {
&self.info
}
}

impl Response for AccountsResponse {}

0 comments on commit fdc2e4f

Please sign in to comment.