#[allow(unused_imports)]
use progenitor_client::{encode_path, RequestBuilderExt};
pub use progenitor_client::{ByteStream, Error, ResponseValue};
#[allow(unused_imports)]
use reqwest::header::{HeaderMap, HeaderValue};
pub mod types {
use serde::{Deserialize, Serialize};
#[allow(unused_imports)]
use std::convert::TryFrom;
///EnrolBody
///
/// JSON schema
///
/// ```json
///{
/// "title": "EnrolBody",
/// "type": "object",
/// "required": [
/// "host",
/// "key"
/// ],
/// "properties": {
/// "host": {
/// "type": "string"
/// },
/// "key": {
/// "type": "string"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct EnrolBody {
pub host: String,
pub key: String,
}
impl From<&EnrolBody> for EnrolBody {
fn from(value: &EnrolBody) -> Self {
value.clone()
}
}
impl EnrolBody {
pub fn builder() -> builder::EnrolBody {
Default::default()
}
}
///GlobalJobsResult
///
/// JSON schema
///
/// ```json
///{
/// "title": "GlobalJobsResult",
/// "type": "object",
/// "required": [
/// "summary"
/// ],
/// "properties": {
/// "summary": {
/// "type": "array",
/// "items": {
/// "$ref": "#/components/schemas/ReportSummary"
/// }
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct GlobalJobsResult {
pub summary: Vec,
}
impl From<&GlobalJobsResult> for GlobalJobsResult {
fn from(value: &GlobalJobsResult) -> Self {
value.clone()
}
}
impl GlobalJobsResult {
pub fn builder() -> builder::GlobalJobsResult {
Default::default()
}
}
///OutputRecord
///
/// JSON schema
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "msg",
/// "stream",
/// "time"
/// ],
/// "properties": {
/// "msg": {
/// "type": "string"
/// },
/// "stream": {
/// "type": "string"
/// },
/// "time": {
/// "type": "string",
/// "format": "date-time"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct OutputRecord {
pub msg: String,
pub stream: String,
pub time: chrono::DateTime,
}
impl From<&OutputRecord> for OutputRecord {
fn from(value: &OutputRecord) -> Self {
value.clone()
}
}
impl OutputRecord {
pub fn builder() -> builder::OutputRecord {
Default::default()
}
}
///PingResult
///
/// JSON schema
///
/// ```json
///{
/// "title": "PingResult",
/// "type": "object",
/// "required": [
/// "host",
/// "ok"
/// ],
/// "properties": {
/// "host": {
/// "type": "string"
/// },
/// "ok": {
/// "type": "boolean"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct PingResult {
pub host: String,
pub ok: bool,
}
impl From<&PingResult> for PingResult {
fn from(value: &PingResult) -> Self {
value.clone()
}
}
impl PingResult {
pub fn builder() -> builder::PingResult {
Default::default()
}
}
///ReportFinishBody
///
/// JSON schema
///
/// ```json
///{
/// "title": "ReportFinishBody",
/// "type": "object",
/// "required": [
/// "duration_millis",
/// "end_time",
/// "exit_status",
/// "id"
/// ],
/// "properties": {
/// "duration_millis": {
/// "type": "integer",
/// "format": "int32"
/// },
/// "end_time": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "exit_status": {
/// "type": "integer",
/// "format": "int32"
/// },
/// "id": {
/// "$ref": "#/components/schemas/ReportId"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct ReportFinishBody {
pub duration_millis: usize,
pub end_time: chrono::DateTime,
pub exit_status: usize,
pub id: ReportId,
}
impl From<&ReportFinishBody> for ReportFinishBody {
fn from(value: &ReportFinishBody) -> Self {
value.clone()
}
}
impl ReportFinishBody {
pub fn builder() -> builder::ReportFinishBody {
Default::default()
}
}
///ReportId
///
/// JSON schema
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "host",
/// "job",
/// "pid",
/// "time",
/// "uuid"
/// ],
/// "properties": {
/// "host": {
/// "type": "string"
/// },
/// "job": {
/// "type": "string"
/// },
/// "pid": {
/// "type": "integer",
/// "format": "uint64",
/// "minimum": 0.0
/// },
/// "time": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "uuid": {
/// "type": "string"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct ReportId {
pub host: String,
pub job: String,
pub pid: u64,
pub time: chrono::DateTime,
pub uuid: String,
}
impl From<&ReportId> for ReportId {
fn from(value: &ReportId) -> Self {
value.clone()
}
}
impl ReportId {
pub fn builder() -> builder::ReportId {
Default::default()
}
}
///ReportOutputBody
///
/// JSON schema
///
/// ```json
///{
/// "title": "ReportOutputBody",
/// "type": "object",
/// "required": [
/// "id",
/// "record"
/// ],
/// "properties": {
/// "id": {
/// "$ref": "#/components/schemas/ReportId"
/// },
/// "record": {
/// "$ref": "#/components/schemas/OutputRecord"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct ReportOutputBody {
pub id: ReportId,
pub record: OutputRecord,
}
impl From<&ReportOutputBody> for ReportOutputBody {
fn from(value: &ReportOutputBody) -> Self {
value.clone()
}
}
impl ReportOutputBody {
pub fn builder() -> builder::ReportOutputBody {
Default::default()
}
}
///ReportResult
///
/// JSON schema
///
/// ```json
///{
/// "title": "ReportResult",
/// "type": "object",
/// "required": [
/// "existed_already"
/// ],
/// "properties": {
/// "existed_already": {
/// "type": "boolean"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct ReportResult {
pub existed_already: bool,
}
impl From<&ReportResult> for ReportResult {
fn from(value: &ReportResult) -> Self {
value.clone()
}
}
impl ReportResult {
pub fn builder() -> builder::ReportResult {
Default::default()
}
}
///ReportStartBody
///
/// JSON schema
///
/// ```json
///{
/// "title": "ReportStartBody",
/// "type": "object",
/// "required": [
/// "id",
/// "script",
/// "start_time"
/// ],
/// "properties": {
/// "id": {
/// "$ref": "#/components/schemas/ReportId"
/// },
/// "script": {
/// "type": "string"
/// },
/// "start_time": {
/// "type": "string",
/// "format": "date-time"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct ReportStartBody {
pub id: ReportId,
pub script: String,
pub start_time: chrono::DateTime,
}
impl From<&ReportStartBody> for ReportStartBody {
fn from(value: &ReportStartBody) -> Self {
value.clone()
}
}
impl ReportStartBody {
pub fn builder() -> builder::ReportStartBody {
Default::default()
}
}
///ReportSummary
///
/// JSON schema
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "age_seconds",
/// "duration_seconds",
/// "host",
/// "job",
/// "status",
/// "when"
/// ],
/// "properties": {
/// "age_seconds": {
/// "type": "integer",
/// "format": "int32"
/// },
/// "duration_seconds": {
/// "type": "integer",
/// "format": "int32"
/// },
/// "host": {
/// "type": "string"
/// },
/// "job": {
/// "type": "string"
/// },
/// "status": {
/// "type": "integer",
/// "format": "int32"
/// },
/// "when": {
/// "type": "string",
/// "format": "date-time"
/// }
/// }
///}
/// ```
///
#[derive(Clone, Debug, Deserialize, Serialize, schemars :: JsonSchema)]
pub struct ReportSummary {
pub age_seconds: usize,
pub duration_seconds: usize,
pub host: String,
pub job: String,
pub status: usize,
pub when: chrono::DateTime,
}
impl From<&ReportSummary> for ReportSummary {
fn from(value: &ReportSummary) -> Self {
value.clone()
}
}
impl ReportSummary {
pub fn builder() -> builder::ReportSummary {
Default::default()
}
}
pub mod builder {
#[derive(Clone, Debug)]
pub struct EnrolBody {
host: Result,
key: Result,
}
impl Default for EnrolBody {
fn default() -> Self {
Self {
host: Err("no value supplied for host".to_string()),
key: Err("no value supplied for key".to_string()),
}
}
}
impl EnrolBody {
pub fn host(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.host = value
.try_into()
.map_err(|e| format!("error converting supplied value for host: {}", e));
self
}
pub fn key(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.key = value
.try_into()
.map_err(|e| format!("error converting supplied value for key: {}", e));
self
}
}
impl std::convert::TryFrom for super::EnrolBody {
type Error = String;
fn try_from(value: EnrolBody) -> Result {
Ok(Self {
host: value.host?,
key: value.key?,
})
}
}
impl From for EnrolBody {
fn from(value: super::EnrolBody) -> Self {
Self {
host: Ok(value.host),
key: Ok(value.key),
}
}
}
#[derive(Clone, Debug)]
pub struct GlobalJobsResult {
summary: Result, String>,
}
impl Default for GlobalJobsResult {
fn default() -> Self {
Self {
summary: Err("no value supplied for summary".to_string()),
}
}
}
impl GlobalJobsResult {
pub fn summary(mut self, value: T) -> Self
where
T: std::convert::TryInto>,
T::Error: std::fmt::Display,
{
self.summary = value
.try_into()
.map_err(|e| format!("error converting supplied value for summary: {}", e));
self
}
}
impl std::convert::TryFrom for super::GlobalJobsResult {
type Error = String;
fn try_from(value: GlobalJobsResult) -> Result {
Ok(Self {
summary: value.summary?,
})
}
}
impl From for GlobalJobsResult {
fn from(value: super::GlobalJobsResult) -> Self {
Self {
summary: Ok(value.summary),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputRecord {
msg: Result,
stream: Result,
time: Result, String>,
}
impl Default for OutputRecord {
fn default() -> Self {
Self {
msg: Err("no value supplied for msg".to_string()),
stream: Err("no value supplied for stream".to_string()),
time: Err("no value supplied for time".to_string()),
}
}
}
impl OutputRecord {
pub fn msg(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.msg = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg: {}", e));
self
}
pub fn stream(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.stream = value
.try_into()
.map_err(|e| format!("error converting supplied value for stream: {}", e));
self
}
pub fn time(mut self, value: T) -> Self
where
T: std::convert::TryInto>,
T::Error: std::fmt::Display,
{
self.time = value
.try_into()
.map_err(|e| format!("error converting supplied value for time: {}", e));
self
}
}
impl std::convert::TryFrom for super::OutputRecord {
type Error = String;
fn try_from(value: OutputRecord) -> Result {
Ok(Self {
msg: value.msg?,
stream: value.stream?,
time: value.time?,
})
}
}
impl From for OutputRecord {
fn from(value: super::OutputRecord) -> Self {
Self {
msg: Ok(value.msg),
stream: Ok(value.stream),
time: Ok(value.time),
}
}
}
#[derive(Clone, Debug)]
pub struct PingResult {
host: Result,
ok: Result,
}
impl Default for PingResult {
fn default() -> Self {
Self {
host: Err("no value supplied for host".to_string()),
ok: Err("no value supplied for ok".to_string()),
}
}
}
impl PingResult {
pub fn host(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.host = value
.try_into()
.map_err(|e| format!("error converting supplied value for host: {}", e));
self
}
pub fn ok(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.ok = value
.try_into()
.map_err(|e| format!("error converting supplied value for ok: {}", e));
self
}
}
impl std::convert::TryFrom for super::PingResult {
type Error = String;
fn try_from(value: PingResult) -> Result {
Ok(Self {
host: value.host?,
ok: value.ok?,
})
}
}
impl From for PingResult {
fn from(value: super::PingResult) -> Self {
Self {
host: Ok(value.host),
ok: Ok(value.ok),
}
}
}
#[derive(Clone, Debug)]
pub struct ReportFinishBody {
duration_millis: Result,
end_time: Result, String>,
exit_status: Result,
id: Result,
}
impl Default for ReportFinishBody {
fn default() -> Self {
Self {
duration_millis: Err("no value supplied for duration_millis".to_string()),
end_time: Err("no value supplied for end_time".to_string()),
exit_status: Err("no value supplied for exit_status".to_string()),
id: Err("no value supplied for id".to_string()),
}
}
}
impl ReportFinishBody {
pub fn duration_millis(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.duration_millis = value.try_into().map_err(|e| {
format!("error converting supplied value for duration_millis: {}", e)
});
self
}
pub fn end_time(mut self, value: T) -> Self
where
T: std::convert::TryInto>,
T::Error: std::fmt::Display,
{
self.end_time = value
.try_into()
.map_err(|e| format!("error converting supplied value for end_time: {}", e));
self
}
pub fn exit_status(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.exit_status = value
.try_into()
.map_err(|e| format!("error converting supplied value for exit_status: {}", e));
self
}
pub fn id(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {}", e));
self
}
}
impl std::convert::TryFrom for super::ReportFinishBody {
type Error = String;
fn try_from(value: ReportFinishBody) -> Result {
Ok(Self {
duration_millis: value.duration_millis?,
end_time: value.end_time?,
exit_status: value.exit_status?,
id: value.id?,
})
}
}
impl From for ReportFinishBody {
fn from(value: super::ReportFinishBody) -> Self {
Self {
duration_millis: Ok(value.duration_millis),
end_time: Ok(value.end_time),
exit_status: Ok(value.exit_status),
id: Ok(value.id),
}
}
}
#[derive(Clone, Debug)]
pub struct ReportId {
host: Result,
job: Result,
pid: Result,
time: Result, String>,
uuid: Result,
}
impl Default for ReportId {
fn default() -> Self {
Self {
host: Err("no value supplied for host".to_string()),
job: Err("no value supplied for job".to_string()),
pid: Err("no value supplied for pid".to_string()),
time: Err("no value supplied for time".to_string()),
uuid: Err("no value supplied for uuid".to_string()),
}
}
}
impl ReportId {
pub fn host(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.host = value
.try_into()
.map_err(|e| format!("error converting supplied value for host: {}", e));
self
}
pub fn job(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.job = value
.try_into()
.map_err(|e| format!("error converting supplied value for job: {}", e));
self
}
pub fn pid(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.pid = value
.try_into()
.map_err(|e| format!("error converting supplied value for pid: {}", e));
self
}
pub fn time(mut self, value: T) -> Self
where
T: std::convert::TryInto>,
T::Error: std::fmt::Display,
{
self.time = value
.try_into()
.map_err(|e| format!("error converting supplied value for time: {}", e));
self
}
pub fn uuid(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.uuid = value
.try_into()
.map_err(|e| format!("error converting supplied value for uuid: {}", e));
self
}
}
impl std::convert::TryFrom for super::ReportId {
type Error = String;
fn try_from(value: ReportId) -> Result {
Ok(Self {
host: value.host?,
job: value.job?,
pid: value.pid?,
time: value.time?,
uuid: value.uuid?,
})
}
}
impl From for ReportId {
fn from(value: super::ReportId) -> Self {
Self {
host: Ok(value.host),
job: Ok(value.job),
pid: Ok(value.pid),
time: Ok(value.time),
uuid: Ok(value.uuid),
}
}
}
#[derive(Clone, Debug)]
pub struct ReportOutputBody {
id: Result,
record: Result,
}
impl Default for ReportOutputBody {
fn default() -> Self {
Self {
id: Err("no value supplied for id".to_string()),
record: Err("no value supplied for record".to_string()),
}
}
}
impl ReportOutputBody {
pub fn id(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {}", e));
self
}
pub fn record(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.record = value
.try_into()
.map_err(|e| format!("error converting supplied value for record: {}", e));
self
}
}
impl std::convert::TryFrom for super::ReportOutputBody {
type Error = String;
fn try_from(value: ReportOutputBody) -> Result {
Ok(Self {
id: value.id?,
record: value.record?,
})
}
}
impl From for ReportOutputBody {
fn from(value: super::ReportOutputBody) -> Self {
Self {
id: Ok(value.id),
record: Ok(value.record),
}
}
}
#[derive(Clone, Debug)]
pub struct ReportResult {
existed_already: Result,
}
impl Default for ReportResult {
fn default() -> Self {
Self {
existed_already: Err("no value supplied for existed_already".to_string()),
}
}
}
impl ReportResult {
pub fn existed_already(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.existed_already = value.try_into().map_err(|e| {
format!("error converting supplied value for existed_already: {}", e)
});
self
}
}
impl std::convert::TryFrom for super::ReportResult {
type Error = String;
fn try_from(value: ReportResult) -> Result {
Ok(Self {
existed_already: value.existed_already?,
})
}
}
impl From for ReportResult {
fn from(value: super::ReportResult) -> Self {
Self {
existed_already: Ok(value.existed_already),
}
}
}
#[derive(Clone, Debug)]
pub struct ReportStartBody {
id: Result,
script: Result,
start_time: Result, String>,
}
impl Default for ReportStartBody {
fn default() -> Self {
Self {
id: Err("no value supplied for id".to_string()),
script: Err("no value supplied for script".to_string()),
start_time: Err("no value supplied for start_time".to_string()),
}
}
}
impl ReportStartBody {
pub fn id(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {}", e));
self
}
pub fn script(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.script = value
.try_into()
.map_err(|e| format!("error converting supplied value for script: {}", e));
self
}
pub fn start_time(mut self, value: T) -> Self
where
T: std::convert::TryInto>,
T::Error: std::fmt::Display,
{
self.start_time = value
.try_into()
.map_err(|e| format!("error converting supplied value for start_time: {}", e));
self
}
}
impl std::convert::TryFrom for super::ReportStartBody {
type Error = String;
fn try_from(value: ReportStartBody) -> Result {
Ok(Self {
id: value.id?,
script: value.script?,
start_time: value.start_time?,
})
}
}
impl From for ReportStartBody {
fn from(value: super::ReportStartBody) -> Self {
Self {
id: Ok(value.id),
script: Ok(value.script),
start_time: Ok(value.start_time),
}
}
}
#[derive(Clone, Debug)]
pub struct ReportSummary {
age_seconds: Result,
duration_seconds: Result,
host: Result,
job: Result,
status: Result,
when: Result, String>,
}
impl Default for ReportSummary {
fn default() -> Self {
Self {
age_seconds: Err("no value supplied for age_seconds".to_string()),
duration_seconds: Err("no value supplied for duration_seconds".to_string()),
host: Err("no value supplied for host".to_string()),
job: Err("no value supplied for job".to_string()),
status: Err("no value supplied for status".to_string()),
when: Err("no value supplied for when".to_string()),
}
}
}
impl ReportSummary {
pub fn age_seconds(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.age_seconds = value
.try_into()
.map_err(|e| format!("error converting supplied value for age_seconds: {}", e));
self
}
pub fn duration_seconds(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.duration_seconds = value.try_into().map_err(|e| {
format!(
"error converting supplied value for duration_seconds: {}",
e
)
});
self
}
pub fn host(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.host = value
.try_into()
.map_err(|e| format!("error converting supplied value for host: {}", e));
self
}
pub fn job(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.job = value
.try_into()
.map_err(|e| format!("error converting supplied value for job: {}", e));
self
}
pub fn status(mut self, value: T) -> Self
where
T: std::convert::TryInto,
T::Error: std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {}", e));
self
}
pub fn when(mut self, value: T) -> Self
where
T: std::convert::TryInto>,
T::Error: std::fmt::Display,
{
self.when = value
.try_into()
.map_err(|e| format!("error converting supplied value for when: {}", e));
self
}
}
impl std::convert::TryFrom for super::ReportSummary {
type Error = String;
fn try_from(value: ReportSummary) -> Result {
Ok(Self {
age_seconds: value.age_seconds?,
duration_seconds: value.duration_seconds?,
host: value.host?,
job: value.job?,
status: value.status?,
when: value.when?,
})
}
}
impl From for ReportSummary {
fn from(value: super::ReportSummary) -> Self {
Self {
age_seconds: Ok(value.age_seconds),
duration_seconds: Ok(value.duration_seconds),
host: Ok(value.host),
job: Ok(value.job),
status: Ok(value.status),
when: Ok(value.when),
}
}
}
}
}
#[derive(Clone, Debug)]
///Client for Keeper API
///
///report execution of cron jobs through a mechanism other than mail
///
///Version: 1.0
pub struct Client {
pub(crate) baseurl: String,
pub(crate) client: reqwest::Client,
}
impl Client {
/// Create a new client.
///
/// `baseurl` is the base URL provided to the internal
/// `reqwest::Client`, and should include a scheme and hostname,
/// as well as port and a path stem if applicable.
pub fn new(baseurl: &str) -> Self {
#[cfg(not(target_arch = "wasm32"))]
let client = {
let dur = std::time::Duration::from_secs(15);
reqwest::ClientBuilder::new()
.connect_timeout(dur)
.timeout(dur)
};
#[cfg(target_arch = "wasm32")]
let client = reqwest::ClientBuilder::new();
Self::new_with_client(baseurl, client.build().unwrap())
}
/// Construct a new client with an existing `reqwest::Client`,
/// allowing more control over its configuration.
///
/// `baseurl` is the base URL provided to the internal
/// `reqwest::Client`, and should include a scheme and hostname,
/// as well as port and a path stem if applicable.
pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self {
Self {
baseurl: baseurl.to_string(),
client,
}
}
/// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String {
&self.baseurl
}
/// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client {
&self.client
}
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"1.0"
}
}
impl Client {
///Sends a `POST` request to `/enrol`
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///```ignore
/// let response = client.enrol()
/// .authorization(authorization)
/// .body(body)
/// .send()
/// .await;
/// ```
pub fn enrol(&self) -> builder::Enrol {
builder::Enrol::new(self)
}
///Sends a `GET` request to `/global/jobs`
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
///```ignore
/// let response = client.global_jobs()
/// .authorization(authorization)
/// .send()
/// .await;
/// ```
pub fn global_jobs(&self) -> builder::GlobalJobs {
builder::GlobalJobs::new(self)
}
///Sends a `GET` request to `/ping`
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
///```ignore
/// let response = client.ping()
/// .authorization(authorization)
/// .send()
/// .await;
/// ```
pub fn ping(&self) -> builder::Ping {
builder::Ping::new(self)
}
///Sends a `POST` request to `/report/finish`
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///```ignore
/// let response = client.report_finish()
/// .authorization(authorization)
/// .body(body)
/// .send()
/// .await;
/// ```
pub fn report_finish(&self) -> builder::ReportFinish {
builder::ReportFinish::new(self)
}
///Sends a `POST` request to `/report/output`
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///```ignore
/// let response = client.report_output()
/// .authorization(authorization)
/// .body(body)
/// .send()
/// .await;
/// ```
pub fn report_output(&self) -> builder::ReportOutput {
builder::ReportOutput::new(self)
}
///Sends a `POST` request to `/report/start`
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///```ignore
/// let response = client.report_start()
/// .authorization(authorization)
/// .body(body)
/// .send()
/// .await;
/// ```
pub fn report_start(&self) -> builder::ReportStart {
builder::ReportStart::new(self)
}
}
pub mod builder {
use super::types;
#[allow(unused_imports)]
use super::{
encode_path, ByteStream, Error, HeaderMap, HeaderValue, RequestBuilderExt, ResponseValue,
};
///Builder for [`Client::enrol`]
///
///[`Client::enrol`]: super::Client::enrol
#[derive(Debug, Clone)]
pub struct Enrol<'a> {
client: &'a super::Client,
authorization: Result,
body: Result,
}
impl<'a> Enrol<'a> {
pub fn new(client: &'a super::Client) -> Self {
Self {
client: client,
authorization: Err("authorization was not initialized".to_string()),
body: Ok(types::builder::EnrolBody::default()),
}
}
pub fn authorization(mut self, value: V) -> Self
where
V: std::convert::TryInto,
{
self.authorization = value
.try_into()
.map_err(|_| "conversion to `String` for authorization failed".to_string());
self
}
pub fn body(mut self, value: V) -> Self
where
V: std::convert::TryInto,
>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `EnrolBody` for body failed: {}", s));
self
}
pub fn body_map(mut self, f: F) -> Self
where
F: std::ops::FnOnce(types::builder::EnrolBody) -> types::builder::EnrolBody,
{
self.body = self.body.map(f);
self
}
///Sends a `POST` request to `/enrol`
pub async fn send(self) -> Result, Error<()>> {
let Self {
client,
authorization,
body,
} = self;
let authorization = authorization.map_err(Error::InvalidRequest)?;
let body = body
.and_then(std::convert::TryInto::::try_into)
.map_err(Error::InvalidRequest)?;
let url = format!("{}/enrol", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client
.client
.post(url)
.json(&body)
.headers(header_map)
.build()?;
let result = client.client.execute(request).await;
let response = result?;
match response.status().as_u16() {
201u16 => Ok(ResponseValue::empty(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
///Builder for [`Client::global_jobs`]
///
///[`Client::global_jobs`]: super::Client::global_jobs
#[derive(Debug, Clone)]
pub struct GlobalJobs<'a> {
client: &'a super::Client,
authorization: Result,
}
impl<'a> GlobalJobs<'a> {
pub fn new(client: &'a super::Client) -> Self {
Self {
client: client,
authorization: Err("authorization was not initialized".to_string()),
}
}
pub fn authorization(mut self, value: V) -> Self
where
V: std::convert::TryInto,
{
self.authorization = value
.try_into()
.map_err(|_| "conversion to `String` for authorization failed".to_string());
self
}
///Sends a `GET` request to `/global/jobs`
pub async fn send(self) -> Result, Error<()>> {
let Self {
client,
authorization,
} = self;
let authorization = authorization.map_err(Error::InvalidRequest)?;
let url = format!("{}/global/jobs", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client
.client
.get(url)
.header(
reqwest::header::ACCEPT,
reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let result = client.client.execute(request).await;
let response = result?;
match response.status().as_u16() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
///Builder for [`Client::ping`]
///
///[`Client::ping`]: super::Client::ping
#[derive(Debug, Clone)]
pub struct Ping<'a> {
client: &'a super::Client,
authorization: Result,
}
impl<'a> Ping<'a> {
pub fn new(client: &'a super::Client) -> Self {
Self {
client: client,
authorization: Err("authorization was not initialized".to_string()),
}
}
pub fn authorization(mut self, value: V) -> Self
where
V: std::convert::TryInto,
{
self.authorization = value
.try_into()
.map_err(|_| "conversion to `String` for authorization failed".to_string());
self
}
///Sends a `GET` request to `/ping`
pub async fn send(self) -> Result, Error<()>> {
let Self {
client,
authorization,
} = self;
let authorization = authorization.map_err(Error::InvalidRequest)?;
let url = format!("{}/ping", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client
.client
.get(url)
.header(
reqwest::header::ACCEPT,
reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let result = client.client.execute(request).await;
let response = result?;
match response.status().as_u16() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
///Builder for [`Client::report_finish`]
///
///[`Client::report_finish`]: super::Client::report_finish
#[derive(Debug, Clone)]
pub struct ReportFinish<'a> {
client: &'a super::Client,
authorization: Result,
body: Result,
}
impl<'a> ReportFinish<'a> {
pub fn new(client: &'a super::Client) -> Self {
Self {
client: client,
authorization: Err("authorization was not initialized".to_string()),
body: Ok(types::builder::ReportFinishBody::default()),
}
}
pub fn authorization(mut self, value: V) -> Self
where
V: std::convert::TryInto,
{
self.authorization = value
.try_into()
.map_err(|_| "conversion to `String` for authorization failed".to_string());
self
}
pub fn body(mut self, value: V) -> Self
where
V: std::convert::TryInto,
>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `ReportFinishBody` for body failed: {}", s));
self
}
pub fn body_map(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ReportFinishBody,
) -> types::builder::ReportFinishBody,
{
self.body = self.body.map(f);
self
}
///Sends a `POST` request to `/report/finish`
pub async fn send(self) -> Result, Error<()>> {
let Self {
client,
authorization,
body,
} = self;
let authorization = authorization.map_err(Error::InvalidRequest)?;
let body = body
.and_then(std::convert::TryInto::::try_into)
.map_err(Error::InvalidRequest)?;
let url = format!("{}/report/finish", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client
.client
.post(url)
.header(
reqwest::header::ACCEPT,
reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let result = client.client.execute(request).await;
let response = result?;
match response.status().as_u16() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
///Builder for [`Client::report_output`]
///
///[`Client::report_output`]: super::Client::report_output
#[derive(Debug, Clone)]
pub struct ReportOutput<'a> {
client: &'a super::Client,
authorization: Result,
body: Result,
}
impl<'a> ReportOutput<'a> {
pub fn new(client: &'a super::Client) -> Self {
Self {
client: client,
authorization: Err("authorization was not initialized".to_string()),
body: Ok(types::builder::ReportOutputBody::default()),
}
}
pub fn authorization(mut self, value: V) -> Self
where
V: std::convert::TryInto,
{
self.authorization = value
.try_into()
.map_err(|_| "conversion to `String` for authorization failed".to_string());
self
}
pub fn body(mut self, value: V) -> Self
where
V: std::convert::TryInto,
>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `ReportOutputBody` for body failed: {}", s));
self
}
pub fn body_map(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ReportOutputBody,
) -> types::builder::ReportOutputBody,
{
self.body = self.body.map(f);
self
}
///Sends a `POST` request to `/report/output`
pub async fn send(self) -> Result, Error<()>> {
let Self {
client,
authorization,
body,
} = self;
let authorization = authorization.map_err(Error::InvalidRequest)?;
let body = body
.and_then(std::convert::TryInto::::try_into)
.map_err(Error::InvalidRequest)?;
let url = format!("{}/report/output", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client
.client
.post(url)
.header(
reqwest::header::ACCEPT,
reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let result = client.client.execute(request).await;
let response = result?;
match response.status().as_u16() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
///Builder for [`Client::report_start`]
///
///[`Client::report_start`]: super::Client::report_start
#[derive(Debug, Clone)]
pub struct ReportStart<'a> {
client: &'a super::Client,
authorization: Result,
body: Result,
}
impl<'a> ReportStart<'a> {
pub fn new(client: &'a super::Client) -> Self {
Self {
client: client,
authorization: Err("authorization was not initialized".to_string()),
body: Ok(types::builder::ReportStartBody::default()),
}
}
pub fn authorization(mut self, value: V) -> Self
where
V: std::convert::TryInto,
{
self.authorization = value
.try_into()
.map_err(|_| "conversion to `String` for authorization failed".to_string());
self
}
pub fn body(mut self, value: V) -> Self
where
V: std::convert::TryInto,
>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `ReportStartBody` for body failed: {}", s));
self
}
pub fn body_map(mut self, f: F) -> Self
where
F: std::ops::FnOnce(types::builder::ReportStartBody) -> types::builder::ReportStartBody,
{
self.body = self.body.map(f);
self
}
///Sends a `POST` request to `/report/start`
pub async fn send(self) -> Result, Error<()>> {
let Self {
client,
authorization,
body,
} = self;
let authorization = authorization.map_err(Error::InvalidRequest)?;
let body = body
.and_then(std::convert::TryInto::::try_into)
.map_err(Error::InvalidRequest)?;
let url = format!("{}/report/start", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client
.client
.post(url)
.header(
reqwest::header::ACCEPT,
reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let result = client.client.execute(request).await;
let response = result?;
match response.status().as_u16() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
}
pub mod prelude {
pub use self::super::Client;
}