-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust: Move API resources into separate files (#1558)
… to prepare for these being replaced by generated files.
- Loading branch information
Showing
12 changed files
with
1,530 additions
and
1,498 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
use super::PostOptions; | ||
use crate::{apis::application_api, error::Result, models::*, Configuration}; | ||
|
||
#[derive(Default)] | ||
pub struct ApplicationListOptions { | ||
pub iterator: Option<String>, | ||
pub limit: Option<i32>, | ||
pub order: Option<Ordering>, | ||
} | ||
|
||
pub struct Application<'a> { | ||
cfg: &'a Configuration, | ||
} | ||
|
||
impl<'a> Application<'a> { | ||
pub(super) fn new(cfg: &'a Configuration) -> Self { | ||
Self { cfg } | ||
} | ||
|
||
pub async fn list( | ||
&self, | ||
options: Option<ApplicationListOptions>, | ||
) -> Result<ListResponseApplicationOut> { | ||
let ApplicationListOptions { | ||
iterator, | ||
limit, | ||
order, | ||
} = options.unwrap_or_default(); | ||
application_api::v1_period_application_period_list( | ||
self.cfg, | ||
application_api::V1PeriodApplicationPeriodListParams { | ||
iterator, | ||
limit, | ||
order, | ||
}, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn create( | ||
&self, | ||
application_in: ApplicationIn, | ||
options: Option<PostOptions>, | ||
) -> Result<ApplicationOut> { | ||
let PostOptions { idempotency_key } = options.unwrap_or_default(); | ||
application_api::v1_period_application_period_create( | ||
self.cfg, | ||
application_api::V1PeriodApplicationPeriodCreateParams { | ||
application_in, | ||
idempotency_key, | ||
get_if_exists: None, | ||
}, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn get_or_create( | ||
&self, | ||
application_in: ApplicationIn, | ||
options: Option<PostOptions>, | ||
) -> Result<ApplicationOut> { | ||
let PostOptions { idempotency_key } = options.unwrap_or_default(); | ||
application_api::v1_period_application_period_create( | ||
self.cfg, | ||
application_api::V1PeriodApplicationPeriodCreateParams { | ||
application_in, | ||
idempotency_key, | ||
get_if_exists: Some(true), | ||
}, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn get(&self, app_id: String) -> Result<ApplicationOut> { | ||
application_api::v1_period_application_period_get( | ||
self.cfg, | ||
application_api::V1PeriodApplicationPeriodGetParams { app_id }, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn update( | ||
&self, | ||
app_id: String, | ||
application_in: ApplicationIn, | ||
) -> Result<ApplicationOut> { | ||
application_api::v1_period_application_period_update( | ||
self.cfg, | ||
application_api::V1PeriodApplicationPeriodUpdateParams { | ||
app_id, | ||
application_in, | ||
}, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn patch( | ||
&self, | ||
app_id: String, | ||
application_patch: ApplicationPatch, | ||
) -> Result<ApplicationOut> { | ||
application_api::v1_period_application_period_patch( | ||
self.cfg, | ||
application_api::V1PeriodApplicationPeriodPatchParams { | ||
app_id, | ||
application_patch, | ||
}, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn delete(&self, app_id: String) -> Result<()> { | ||
application_api::v1_period_application_period_delete( | ||
self.cfg, | ||
application_api::V1PeriodApplicationPeriodDeleteParams { app_id }, | ||
) | ||
.await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use super::PostOptions; | ||
use crate::{apis::authentication_api, error::Result, models::*, Configuration}; | ||
pub struct Authentication<'a> { | ||
cfg: &'a Configuration, | ||
} | ||
|
||
impl<'a> Authentication<'a> { | ||
pub(super) fn new(cfg: &'a Configuration) -> Self { | ||
Self { cfg } | ||
} | ||
|
||
pub async fn dashboard_access( | ||
&self, | ||
app_id: String, | ||
options: Option<PostOptions>, | ||
) -> Result<DashboardAccessOut> { | ||
let options = options.unwrap_or_default(); | ||
authentication_api::v1_period_authentication_period_dashboard_access( | ||
self.cfg, | ||
authentication_api::V1PeriodAuthenticationPeriodDashboardAccessParams { | ||
app_id, | ||
idempotency_key: options.idempotency_key, | ||
}, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn app_portal_access( | ||
&self, | ||
app_id: String, | ||
app_portal_access_in: AppPortalAccessIn, | ||
options: Option<PostOptions>, | ||
) -> Result<AppPortalAccessOut> { | ||
let options = options.unwrap_or_default(); | ||
authentication_api::v1_period_authentication_period_app_portal_access( | ||
self.cfg, | ||
authentication_api::V1PeriodAuthenticationPeriodAppPortalAccessParams { | ||
app_id, | ||
app_portal_access_in, | ||
idempotency_key: options.idempotency_key, | ||
}, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn logout(&self, options: Option<PostOptions>) -> Result<()> { | ||
let PostOptions { idempotency_key } = options.unwrap_or_default(); | ||
authentication_api::v1_period_authentication_period_logout( | ||
self.cfg, | ||
authentication_api::V1PeriodAuthenticationPeriodLogoutParams { idempotency_key }, | ||
) | ||
.await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::{apis::background_tasks_api, error::Result, models::*, Configuration}; | ||
|
||
#[derive(Default)] | ||
pub struct BackgroundTaskListOptions { | ||
pub iterator: Option<String>, | ||
pub limit: Option<i32>, | ||
pub order: Option<Ordering>, | ||
pub status: Option<BackgroundTaskStatus>, | ||
pub task: Option<BackgroundTaskType>, | ||
} | ||
|
||
pub struct BackgroundTask<'a> { | ||
cfg: &'a Configuration, | ||
} | ||
|
||
impl<'a> BackgroundTask<'a> { | ||
pub(super) fn new(cfg: &'a Configuration) -> Self { | ||
Self { cfg } | ||
} | ||
|
||
pub async fn list( | ||
&self, | ||
options: Option<BackgroundTaskListOptions>, | ||
) -> Result<ListResponseBackgroundTaskOut> { | ||
let BackgroundTaskListOptions { | ||
iterator, | ||
limit, | ||
order, | ||
status, | ||
task, | ||
} = options.unwrap_or_default(); | ||
background_tasks_api::list_background_tasks( | ||
self.cfg, | ||
background_tasks_api::ListBackgroundTasksParams { | ||
status, | ||
task, | ||
limit, | ||
iterator, | ||
order, | ||
}, | ||
) | ||
.await | ||
} | ||
|
||
pub async fn get(&self, task_id: String) -> Result<BackgroundTaskOut> { | ||
background_tasks_api::get_background_task( | ||
self.cfg, | ||
background_tasks_api::GetBackgroundTaskParams { task_id }, | ||
) | ||
.await | ||
} | ||
} |
Oops, something went wrong.