Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from golemcloud/update-client
Browse files Browse the repository at this point in the history
Update client to latest
  • Loading branch information
vigoo authored Sep 6, 2023
2 parents a3b7c37 + abc3b5a commit 0178d44
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ clap = { version = "4.4.1", features = ["derive"] }
clap-verbosity-flag = "2.0.1"
derive_more = "0.99.17"
futures-util = "0.3.28"
golem-client = "0.0.30"
golem-client = "0.0.31"
golem-examples = "0.1.3"
http = "0.2.9"
indoc = "2.0.3"
Expand Down
4 changes: 0 additions & 4 deletions src/clients/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ fn render_type(tpe: &Type) -> String {

format!("{{{}}}", pairs.join(", "))
}
Type::Union(types) => {
let tpes: Vec<String> = types.iter().map(|tpe| render_type(&tpe)).collect();
format!("{{{}}}", tpes.join(" | "))
}
Type::Tuple(elems) => {
let tpes: Vec<String> = elems.iter().map(|tpe| render_type(&tpe)).collect();
format!("({})", tpes.join(", "))
Expand Down
12 changes: 12 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl From<AccountError> for GolemError {
AccountError::RequestFailure(err) => GolemError(format!("Unexpected request failure: {err}")),
AccountError::InvalidHeaderValue(err) => GolemError(format!("Unexpected invalid header value: {err}")),
AccountError::UnexpectedStatus(sc) => GolemError(format!("Unexpected status: {sc}")),
AccountError::Status401 { message } => GolemError(format!("Unauthorized: {message}")),
AccountError::Status404 { message } => GolemError(format!("Not found: {message}")),
AccountError::Status400 { errors } => {
let msg = errors.join(", ");
Expand All @@ -73,6 +74,7 @@ impl From<TokenError> for GolemError {
TokenError::RequestFailure(err) => GolemError(format!("Unexpected request failure: {err}")),
TokenError::InvalidHeaderValue(err) => GolemError(format!("Unexpected invalid header value: {err}")),
TokenError::UnexpectedStatus(sc) => GolemError(format!("Unexpected status: {sc}")),
TokenError::Status401 { message } => GolemError(format!("Unauthorized: {message}")),
TokenError::Status404 { message } => GolemError(format!("Not found: {message}")),
TokenError::Status400 { errors } => {
let msg = errors.join(", ");
Expand All @@ -89,6 +91,7 @@ impl From<ComponentError> for GolemError {
ComponentError::RequestFailure(err) => GolemError(format!("Unexpected request failure: {err}")),
ComponentError::InvalidHeaderValue(err) => GolemError(format!("Unexpected invalid header value: {err}")),
ComponentError::UnexpectedStatus(sc) => GolemError(format!("Unexpected status: {sc}")),
ComponentError::Status401 { error } => GolemError(format!("Unauthorized: {error}")),
ComponentError::Status504 => GolemError(format!("Gateway Timeout")),
ComponentError::Status404 { message } => GolemError(message),
ComponentError::Status403 { error } => GolemError(format!("Limit Exceeded: {error}")),
Expand All @@ -108,6 +111,10 @@ impl From<LoginError> for GolemError {
LoginError::RequestFailure(err) => GolemError(format!("Unexpected request failure: {err}")),
LoginError::InvalidHeaderValue(err) => GolemError(format!("Unexpected invalid header value: {err}")),
LoginError::UnexpectedStatus(sc) => GolemError(format!("Unexpected status: {sc}")),
LoginError::Status400 { errors } => {
let joined = errors.join(", ");
GolemError(format!("Invalid request: {joined}"))
}
LoginError::Status403 { .. } => {
let msg = indoc! {"
At the moment account creation is restricted.
Expand All @@ -133,6 +140,7 @@ impl From<ProjectError> for GolemError {
let msg = errors.join(", ");
GolemError(format!("Invalid API call: {msg}"))
}
ProjectError::Status401 { message } => GolemError(format!("Unauthorized: {message}")),
ProjectError::Status403 { error } => GolemError(format!("Limit Exceeded: {error}")),
ProjectError::Status500 { error } => GolemError(format!("Internal server error: {error}")),
}
Expand All @@ -145,6 +153,7 @@ impl From<GrantError> for GolemError {
GrantError::RequestFailure(err) => GolemError(format!("Unexpected request failure: {err}")),
GrantError::InvalidHeaderValue(err) => GolemError(format!("Unexpected invalid header value: {err}")),
GrantError::UnexpectedStatus(sc) => GolemError(format!("Unexpected status: {sc}")),
GrantError::Status401 { message } => GolemError(format!("Unauthorized: {message}")),
GrantError::Status404 { message } => GolemError(format!("Not found: {message}")),
GrantError::Status400 { errors } => {
let msg = errors.join(", ");
Expand All @@ -166,6 +175,7 @@ impl From<ProjectPolicyError> for GolemError {
let msg = errors.join(", ");
GolemError(format!("Invalid API call: {msg}"))
}
ProjectPolicyError::Status401 { message } => GolemError(format!("Unauthorized: {message}")),
ProjectPolicyError::Status403 { error } => GolemError(format!("Limit Exceeded: {error}")),
ProjectPolicyError::Status500 { error } => GolemError(format!("Internal server error: {error}")),
}
Expand All @@ -183,6 +193,7 @@ impl From<ProjectGrantError> for GolemError {
let msg = errors.join(", ");
GolemError(format!("Invalid API call: {msg}"))
}
ProjectGrantError::Status401 { message } => GolemError(format!("Unauthorized: {message}")),
ProjectGrantError::Status403 { error } => GolemError(format!("Limit Exceeded: {error}")),
ProjectGrantError::Status500 { error } => GolemError(format!("Internal server error: {error}")),
}
Expand All @@ -202,6 +213,7 @@ impl From<InstanceError> for GolemError {
let msg = errors.join(", ");
GolemError(format!("Invalid API call: {msg}"))
}
InstanceError::Status401 { error } => GolemError(format!("Unauthorized: {error}")),
InstanceError::Status500 { golem_error } => GolemError(format!("Internal server error: {golem_error:?}")),
InstanceError::Status409 { error } => GolemError(error),
}
Expand Down

0 comments on commit 0178d44

Please sign in to comment.