Skip to content

Update bindings to use the reqwest-trait template #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
76 changes: 75 additions & 1 deletion Cargo.lock

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

11 changes: 5 additions & 6 deletions bitwarden_license/bitwarden-sm/src/projects/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@
});

let config = client.internal.get_api_configurations().await;
let res = bitwarden_api_api::apis::projects_api::organizations_organization_id_projects_post(
&config.api,
input.organization_id,
project,
)
.await?;
let res = config
.api_client
.projects_api()
.organizations_organization_id_projects_post(input.organization_id, project)
.await?;

Check warning on line 47 in bitwarden_license/bitwarden-sm/src/projects/create.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/projects/create.rs#L43-L47

Added lines #L43 - L47 were not covered by tests

ProjectResponse::process_response(res, &mut key_store.context())
}
Expand Down
8 changes: 5 additions & 3 deletions bitwarden_license/bitwarden-sm/src/projects/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
input: ProjectsDeleteRequest,
) -> Result<ProjectsDeleteResponse, SecretsManagerError> {
let config = client.internal.get_api_configurations().await;
let res =
bitwarden_api_api::apis::projects_api::projects_delete_post(&config.api, Some(input.ids))
.await?;
let res = config
.api_client
.projects_api()
.projects_delete_post(Some(input.ids))
.await?;

Check warning on line 28 in bitwarden_license/bitwarden-sm/src/projects/delete.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/projects/delete.rs#L24-L28

Added lines #L24 - L28 were not covered by tests

ProjectsDeleteResponse::process_response(res)
}
Expand Down
6 changes: 5 additions & 1 deletion bitwarden_license/bitwarden-sm/src/projects/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
) -> Result<ProjectResponse, SecretsManagerError> {
let config = client.internal.get_api_configurations().await;

let res = bitwarden_api_api::apis::projects_api::projects_id_get(&config.api, input.id).await?;
let res = config
.api_client
.projects_api()
.projects_id_get(input.id)
.await?;

Check warning on line 26 in bitwarden_license/bitwarden-sm/src/projects/get.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/projects/get.rs#L22-L26

Added lines #L22 - L26 were not covered by tests

let key_store = client.internal.get_key_store();

Expand Down
10 changes: 5 additions & 5 deletions bitwarden_license/bitwarden-sm/src/projects/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
input: &ProjectsListRequest,
) -> Result<ProjectsResponse, SecretsManagerError> {
let config = client.internal.get_api_configurations().await;
let res = bitwarden_api_api::apis::projects_api::organizations_organization_id_projects_get(
&config.api,
input.organization_id,
)
.await?;
let res = config
.api_client
.projects_api()
.organizations_organization_id_projects_get(input.organization_id)
.await?;

Check warning on line 27 in bitwarden_license/bitwarden-sm/src/projects/list.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/projects/list.rs#L23-L27

Added lines #L23 - L27 were not covered by tests

let key_store = client.internal.get_key_store();

Expand Down
8 changes: 5 additions & 3 deletions bitwarden_license/bitwarden-sm/src/projects/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
});

let config = client.internal.get_api_configurations().await;
let res =
bitwarden_api_api::apis::projects_api::projects_id_put(&config.api, input.id, project)
.await?;
let res = config
.api_client
.projects_api()
.projects_id_put(input.id, project)
.await?;

Check warning on line 49 in bitwarden_license/bitwarden-sm/src/projects/update.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/projects/update.rs#L45-L49

Added lines #L45 - L49 were not covered by tests

ProjectResponse::process_response(res, &mut key_store.context())
}
Expand Down
11 changes: 5 additions & 6 deletions bitwarden_license/bitwarden-sm/src/secrets/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@
};

let config = client.internal.get_api_configurations().await;
let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_post(
&config.api,
input.organization_id,
secret,
)
.await?;
let res = config
.api_client
.secrets_api()
.organizations_organization_id_secrets_post(input.organization_id, secret)
.await?;

Check warning on line 62 in bitwarden_license/bitwarden-sm/src/secrets/create.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/secrets/create.rs#L58-L62

Added lines #L58 - L62 were not covered by tests

SecretResponse::process_response(res, &mut key_store.context())
}
Expand Down
8 changes: 5 additions & 3 deletions bitwarden_license/bitwarden-sm/src/secrets/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
input: SecretsDeleteRequest,
) -> Result<SecretsDeleteResponse, SecretsManagerError> {
let config = client.internal.get_api_configurations().await;
let res =
bitwarden_api_api::apis::secrets_api::secrets_delete_post(&config.api, Some(input.ids))
.await?;
let res = config
.api_client
.secrets_api()
.secrets_delete_post(Some(input.ids))
.await?;

Check warning on line 28 in bitwarden_license/bitwarden-sm/src/secrets/delete.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/secrets/delete.rs#L24-L28

Added lines #L24 - L28 were not covered by tests

SecretsDeleteResponse::process_response(res)
}
Expand Down
6 changes: 5 additions & 1 deletion bitwarden_license/bitwarden-sm/src/secrets/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ pub(crate) async fn get_secret(
input: &SecretGetRequest,
) -> Result<SecretResponse, SecretsManagerError> {
let config = client.internal.get_api_configurations().await;
let res = bitwarden_api_api::apis::secrets_api::secrets_id_get(&config.api, input.id).await?;
let res = config
.api_client
.secrets_api()
.secrets_id_get(input.id)
.await?;

let key_store = client.internal.get_key_store();

Expand Down
7 changes: 5 additions & 2 deletions bitwarden_license/bitwarden-sm/src/secrets/get_by_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@

let config = client.internal.get_api_configurations().await;

let res =
bitwarden_api_api::apis::secrets_api::secrets_get_by_ids_post(&config.api, request).await?;
let res = config
.api_client
.secrets_api()
.secrets_get_by_ids_post(request)
.await?;

Check warning on line 29 in bitwarden_license/bitwarden-sm/src/secrets/get_by_ids.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/secrets/get_by_ids.rs#L25-L29

Added lines #L25 - L29 were not covered by tests

let key_store = client.internal.get_key_store();

Expand Down
20 changes: 10 additions & 10 deletions bitwarden_license/bitwarden-sm/src/secrets/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
input: &SecretIdentifiersRequest,
) -> Result<SecretIdentifiersResponse, SecretsManagerError> {
let config = client.internal.get_api_configurations().await;
let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_get(
&config.api,
input.organization_id,
)
.await?;
let res = config
.api_client
.secrets_api()
.organizations_organization_id_secrets_get(input.organization_id)
.await?;

let key_store = client.internal.get_key_store();

Expand All @@ -50,11 +50,11 @@
input: &SecretIdentifiersByProjectRequest,
) -> Result<SecretIdentifiersResponse, SecretsManagerError> {
let config = client.internal.get_api_configurations().await;
let res = bitwarden_api_api::apis::secrets_api::projects_project_id_secrets_get(
&config.api,
input.project_id,
)
.await?;
let res = config
.api_client
.secrets_api()
.projects_project_id_secrets_get(input.project_id)
.await?;

Check warning on line 57 in bitwarden_license/bitwarden-sm/src/secrets/list.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/secrets/list.rs#L53-L57

Added lines #L53 - L57 were not covered by tests

let key_store = client.internal.get_key_store();

Expand Down
11 changes: 5 additions & 6 deletions bitwarden_license/bitwarden-sm/src/secrets/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
let config = client.internal.get_api_configurations().await;
let last_synced_date = input.last_synced_date.map(|date| date.to_rfc3339());

let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_sync_get(
&config.api,
input.organization_id,
last_synced_date,
)
.await?;
let res = config
.api_client
.secrets_api()
.organizations_organization_id_secrets_sync_get(input.organization_id, last_synced_date)
.await?;

Check warning on line 32 in bitwarden_license/bitwarden-sm/src/secrets/sync.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/secrets/sync.rs#L28-L32

Added lines #L28 - L32 were not covered by tests

let key_store = client.internal.get_key_store();

Expand Down
7 changes: 5 additions & 2 deletions bitwarden_license/bitwarden-sm/src/secrets/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@
};

let config = client.internal.get_api_configurations().await;
let res =
bitwarden_api_api::apis::secrets_api::secrets_id_put(&config.api, input.id, secret).await?;
let res = config
.api_client
.secrets_api()
.secrets_id_put(input.id, secret)
.await?;

Check warning on line 61 in bitwarden_license/bitwarden-sm/src/secrets/update.rs

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bitwarden-sm/src/secrets/update.rs#L57-L61

Added lines #L57 - L61 were not covered by tests

SecretResponse::process_response(res, &mut key_store.context())
}
Expand Down
5 changes: 5 additions & 0 deletions crates/bitwarden-api-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ repository.workspace = true
license-file.workspace = true
keywords.workspace = true

[features]
mockall = ["dep:mockall"]

[dependencies]
async-trait = { workspace = true }
mockall = { version = ">=0.13, <0.14", optional = true }
reqwest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-api-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bitwarden-api-api = { path = "./bitwarden-api-api" }

## Documentation for API Endpoints

All URIs are relative to _http://localhost_
All URIs are relative to *https://api.bitwarden.com*

| Class | Method | HTTP request | Description |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
Expand Down
Loading