Skip to content

Commit

Permalink
custom ids
Browse files Browse the repository at this point in the history
  • Loading branch information
andresperi committed Sep 17, 2024
1 parent 18a754c commit 32c569e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/api/artifact_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct CreateArtifactVersionParams {
pub artifact_prn: String,
#[validate(custom(function = "validators::validate_json_byte_length_1_000_000"))]
pub custom_metadata: Option<Map<String, Value>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub id: Option<String>,
pub description: Option<String>,
pub version: String,
}
Expand Down
3 changes: 3 additions & 0 deletions src/api/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub struct CreateArtifactParams {
#[validate(custom(function = "validators::validate_json_byte_length_1_000_000"))]
pub custom_metadata: Option<Map<String, Value>>,
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub id: Option<String>,
pub name: String,
pub organization_prn: String,
}
Expand Down
3 changes: 3 additions & 0 deletions src/api/binaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub struct CreateBinaryParams {
pub custom_metadata: Option<Map<String, Value>>,
pub description: Option<String>,
pub hash: String,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub id: Option<String>,
pub size: u64,
pub target: String,
}
Expand Down
3 changes: 3 additions & 0 deletions src/api/bundles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub struct Bundle {
#[derive(Debug, Serialize)]
pub struct CreateBundleParams {
pub artifact_version_prns: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub id: Option<String>,
pub organization_prn: String,
pub name: Option<String>,
}
Expand Down
1 change: 1 addition & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl Api {
.add_root_certificate(cert_admin_api)
.add_root_certificate(cert_peridio)
.add_root_certificate(cert_nerveshub)
.danger_accept_invalid_certs(true)
.use_rustls_tls();

let client_builder = if let Some(ca_bundle_path) = api_options.ca_bundle_path {
Expand Down
3 changes: 3 additions & 0 deletions tests/artifact_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async fn create_artifact_version() {
let expected_custom_metadata = json!({ "foo": "bar" });
let expected_description = "description";
let expected_version = "v0.0.1";
let expected_id = "uuid";

let api = Api::new(ApiOptions {
api_key: API_KEY.into(),
Expand All @@ -37,6 +38,7 @@ async fn create_artifact_version() {
artifact_prn: expected_artifact_prn.to_string(),
custom_metadata: Some(expected_custom_metadata.as_object().unwrap().clone()),
description: Some(expected_description.to_string()),
id: Some(expected_id.to_string()),
version: expected_version.to_string(),
};

Expand Down Expand Up @@ -78,6 +80,7 @@ async fn create_artifact_version() {
artifact_prn: expected_artifact_prn.to_string(),
custom_metadata: Some(expected_custom_metadata.as_object().unwrap().clone()),
description: Some(expected_description.to_string()),
id: Some(expected_id.to_string()),
version: expected_version.to_string(),
};

Expand Down
3 changes: 3 additions & 0 deletions tests/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async fn create_artifact() {
let expected_description = "test";
let expected_name = "a";
let expected_organization_prn = "string";
let expected_id = "uuid";

let api = Api::new(ApiOptions {
api_key: API_KEY.into(),
Expand All @@ -33,6 +34,7 @@ async fn create_artifact() {
let params = CreateArtifactParams {
custom_metadata: Some(expected_custom_metadata.as_object().unwrap().clone()),
description: Some(expected_description.to_string()),
id: Some(expected_id.to_string()),
name: expected_name.to_string(),
organization_prn: expected_organization_prn.to_string(),
};
Expand Down Expand Up @@ -71,6 +73,7 @@ async fn create_artifact() {
let params = CreateArtifactParams {
custom_metadata: Some(expected_custom_metadata.as_object().unwrap().clone()),
description: Some(expected_description.to_string()),
id: Some(expected_id.to_string()),
name: expected_name.to_string(),
organization_prn: expected_organization_prn.to_string(),
};
Expand Down
3 changes: 3 additions & 0 deletions tests/binaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async fn create_binary() {
let expected_organization_prn = "organization_prn";
let expected_size = 10;
let expected_target = "target";
let expected_id = "uuid";

let api = Api::new(ApiOptions {
api_key: API_KEY.into(),
Expand All @@ -41,6 +42,7 @@ async fn create_binary() {
custom_metadata: Some(expected_custom_metadata.as_object().unwrap().clone()),
description: Some(expected_description.to_string()),
hash: expected_hash.to_string(),
id: Some(expected_id.to_string()),
size: expected_size,
target: expected_target.to_string(),
};
Expand Down Expand Up @@ -87,6 +89,7 @@ async fn create_binary() {
custom_metadata: Some(expected_custom_metadata.as_object().unwrap().clone()),
description: Some(expected_description.to_string()),
hash: expected_hash.to_string(),
id: Some(expected_id.to_string()),
size: expected_size,
target: expected_target.to_string(),
};
Expand Down
2 changes: 2 additions & 0 deletions tests/bundles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async fn create_bundle() {
]
.to_vec();
let expected_name = "a";
let expected_id = "uuid";

let api = Api::new(ApiOptions {
api_key: API_KEY.into(),
Expand All @@ -36,6 +37,7 @@ async fn create_bundle() {
let params = CreateBundleParams {
organization_prn: expected_organization_prn.to_string(),
artifact_version_prns: expected_artifact_versions.clone(),
id: Some(expected_id.to_string()),
name: Some(expected_name.to_string()),
};

Expand Down

0 comments on commit 32c569e

Please sign in to comment.