Skip to content

Commit

Permalink
[CLO-267] add protected field (#73)
Browse files Browse the repository at this point in the history
* add protected field

* fix an error

* more errors to fix

* update ubuntu to 20.04
  • Loading branch information
agadelshin authored Aug 11, 2023
1 parent af71fee commit b8d1914
Show file tree
Hide file tree
Showing 14 changed files with 465 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Build
strategy:
matrix:
os: [ubuntu-18.04, windows-2019, macos-11]
os: [ubuntu-20.04, windows-2019, macos-11]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Release
strategy:
matrix:
os: [ubuntu-18.04, windows-2019, macos-11]
os: [ubuntu-20.04, windows-2019, macos-11]

runs-on: ${{ matrix.os }}

Expand Down
10 changes: 9 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,9 @@ struct CreateCluster {

#[structopt(long, help = "Throughput in Mb/s for disk (only AWS)")]
pub disk_throughput: Option<i32>,

#[structopt(long, help = "The protected flag prevents from accidental deletion")]
protected: Option<bool>,
}

#[derive(Debug, StructOpt)]
Expand Down Expand Up @@ -857,7 +860,10 @@ struct UpdateCluster {
id: esc_api::ClusterId,

#[structopt(long, help = "A human-readable description of the cluster")]
description: String,
description: Option<String>,

#[structopt(long, help = "The protected flag prevents from accidental deletion")]
protected: Option<bool>,
}

#[derive(Debug, StructOpt)]
Expand Down Expand Up @@ -2141,6 +2147,7 @@ async fn call_api<'a, 'b>(
source_backup_id: params.source_backup_id,
source_node_index: None, // TODO: add source_node_index
topology: params.topology,
protected: params.protected,
},
)
.await?;
Expand Down Expand Up @@ -2179,6 +2186,7 @@ async fn call_api<'a, 'b>(
params.id,
esc_api::mesdb::UpdateClusterRequest {
description: params.description,
protected: params.protected,
},
)
.await?;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/v1/infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl ToV1 for esc_api::infra::Network {
project_id: self.project_id,
provider: Provider::from_string(&self.provider),
region: self.region,
status: self.status,
status: self.status.to_string(),
}
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ impl ToV1 for esc_api::infra::Peering {
project_id: self.project_id,
provider: Provider::from_string(&self.provider),
routes: self.routes,
status: self.status,
status: self.status.to_string(),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cli/src/v1/integrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum IntegrationData {
Unsupported,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Integration {
#[serde(rename = "created")]
pub created: DateTime<Utc>,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl ToV1 for esc_api::integrate::CreateIntegrationResponse {
}
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GetIntegrationResponse {
#[serde(rename = "integration")]
pub integration: Integration,
Expand All @@ -121,7 +121,7 @@ impl ToV1 for esc_api::integrate::GetIntegrationResponse {
}
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ListIntegrationsResponse {
#[serde(rename = "integrations")]
pub integrations: Vec<Integration>,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/v1/mesdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl ToV1 for esc_api::mesdb::Cluster {
provider: Provider::from_string(&self.provider),
region: self.region,
server_version: self.server_version,
status: self.status,
status: self.status.to_string(),
topology: self.topology,
};
let mut tcp = Vec::new();
Expand Down
93 changes: 61 additions & 32 deletions generated/src/access/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use chrono::Utc;
use std::collections::HashMap;

/// describes what a subject of athe policy's actions
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Action {
Create,
Expand All @@ -25,36 +25,52 @@ impl std::fmt::Display for Action {
}
}
}
impl std::cmp::PartialEq<&str> for Action {
fn eq(&self, other: &&str) -> bool {
match self {
Action::Create => *other == "create",
Action::Delete => *other == "delete",
Action::Modify => *other == "modify",
Action::_None => *other == "none",
Action::Read => *other == "read",
}
}
}
impl std::cmp::PartialEq<Action> for &str {
fn eq(&self, other: &Action) -> bool {
other == self
}
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateGroupRequest {
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub members: Option<Vec<MemberId>>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateGroupResponse {
pub id: GroupId,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateInviteRequest {
pub user_email: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub groups: Option<Vec<GroupId>>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateInviteResponse {
pub id: InviteId,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreatePolicy {
pub actions: Vec<Action>,
Expand All @@ -64,20 +80,20 @@ pub struct CreatePolicy {
pub subjects: Vec<String>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreatePolicyRequest {
pub policy: CreatePolicy,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreatePolicyResponse {
pub id: PolicyId,
}

/// the policy's effect
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Effect {
Allow,
Expand All @@ -91,34 +107,47 @@ impl std::fmt::Display for Effect {
}
}
}
impl std::cmp::PartialEq<&str> for Effect {
fn eq(&self, other: &&str) -> bool {
match self {
Effect::Allow => *other == "allow",
Effect::Deny => *other == "deny",
}
}
}
impl std::cmp::PartialEq<Effect> for &str {
fn eq(&self, other: &Effect) -> bool {
other == self
}
}

pub type Fields = HashMap<String, String>;

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetGroupResponse {
pub group: Group,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetMemberResponse {
pub member: Member,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetPolicyResponse {
pub policy: Policy,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetSettingsResponse {
pub settings: Settings,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Group {
pub created: DateTime<Utc>,
Expand All @@ -129,7 +158,7 @@ pub struct Group {
pub organization_id: OrganizationId,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Invite {
pub accepted: bool,
Expand All @@ -143,37 +172,37 @@ pub struct Invite {
pub organization_id: OrganizationId,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListGroupsResponse {
pub groups: Vec<Group>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListInvitesResponse {
pub invites: Vec<Invite>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListMembersResponse {
pub members: Vec<Member>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListPoliciesResponse {
pub policies: Vec<Policy>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListUserRefreshTokensResponse {
pub tokens: Vec<UserRefreshToken>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Member {
pub active: bool,
Expand All @@ -184,7 +213,7 @@ pub struct Member {
pub organization_id: String,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Policy {
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -202,33 +231,33 @@ pub struct Policy {
pub subjects: Option<Vec<String>>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PolicyAllowedRequest {
pub action: String,
pub resource: Action,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PolicyAllowedResponse {
pub allowed: bool,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ResendInviteRequest {
pub id: InviteId,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Settings {
pub require_mfa: bool,
pub restrict_invite_domain: String,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateGroupRequest {
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -237,13 +266,13 @@ pub struct UpdateGroupRequest {
pub members: Option<Vec<String>>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateMemberRequest {
pub active: bool,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdatePolicy {
pub actions: Vec<Action>,
Expand All @@ -253,13 +282,13 @@ pub struct UpdatePolicy {
pub subjects: Vec<String>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdatePolicyRequest {
pub policy: UpdatePolicy,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSettingsRequest {
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -268,7 +297,7 @@ pub struct UpdateSettingsRequest {
pub restrict_invite_domain: Option<String>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserRefreshToken {
pub id: String,
Expand Down
Loading

0 comments on commit b8d1914

Please sign in to comment.