Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cloudflare-examples/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ fn list_routes(arg_matches: &ArgMatches, api_client: &HttpApiClient) {
print_response_json(response);
}

fn account(arg_matches: &ArgMatches, api_client: &HttpApiClient) {
let account_identifier = arg_matches.get_one::<String>("account_identifier");
let endpoint = account::account_details::AccountDetails {
account_identifier: account_identifier.unwrap(),
};
if api_client.is_mock() {
add_static_mock(&endpoint);
}
let response = api_client.request(&endpoint);
print_response(response)
}

fn list_accounts(_arg_matches: &ArgMatches, api_client: &HttpApiClient) {
let endpoint = account::ListAccounts { params: None };
if api_client.is_mock() {
Expand Down Expand Up @@ -282,6 +294,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
function: list_routes,
},
),
(
"account",
Section {
args: vec![Arg::new("account_identifier").required(true)],
description: "Get information about a specific account that you are a member of",
function: account,
},
),
(
"list_accounts",
Section {
Expand Down
19 changes: 19 additions & 0 deletions cloudflare/src/endpoints/account/account_details.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::endpoints::account::Account;
use crate::framework::endpoint::{EndpointSpec, Method};

/// Account Details
/// <https://developers.cloudflare.com/api/resources/accounts/methods/get/>
#[derive(Debug)]
pub struct AccountDetails<'a> {
pub account_identifier: &'a str,
}

impl<'a> EndpointSpec<Account> for AccountDetails<'a> {
fn method(&self) -> Method {
Method::GET
}

fn path(&self) -> String {
format!("accounts/{}", self.account_identifier)
}
}
1 change: 1 addition & 0 deletions cloudflare/src/endpoints/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::framework::response::ApiResult;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

pub mod account_details;
pub mod list_accounts;
pub use list_accounts::ListAccounts;

Expand Down