Skip to content
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ clickhousectl cloud service reset-password <service-id> \
--new-password-hash <base64-sha256-hash> \
--new-double-sha1-hash <mysql-double-sha1-hash>

# Query endpoint management (manualfor custom roles or sharing keys with other tools)
# Query endpoint management (manual, for sharing keys with other tools)
clickhousectl cloud service query-endpoint get <service-id>
clickhousectl cloud service query-endpoint create <service-id> \
--role admin \
--role sql_console_admin \
--open-api-key key-1 \
--allowed-origins https://app.example.com
clickhousectl cloud service query-endpoint delete <service-id>
Expand Down
4 changes: 2 additions & 2 deletions crates/clickhouse-cloud-api/src/client/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ impl Client {
db_user: Option<&str>,
db_operation: Option<&str>,
app: Option<&str>,
sort_by: Option<&str>,
sort_order: Option<&str>,
sort_by: Option<&SlowQueryPatternsGetListSortby>,
sort_order: Option<&SlowQueryPatternsGetListSortorder>,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<ApiResponse<Vec<PostgresSlowQueryPattern>>, Error> {
Expand Down
36 changes: 19 additions & 17 deletions crates/clickhouse-cloud-api/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ pub use backups::{
GcpBackupBucketPropertiesBucketprovider,
};
pub use byoc::{
ByocConfig, ByocConfigCloudprovider, ByocConfigRegionid, ByocConfigState,
ByocInfrastructurePatchRequest, ByocInfrastructurePostRequest,
ByocAvailabilityZoneSuffix, ByocConfig, ByocConfigCloudprovider, ByocConfigRegionid,
ByocConfigState, ByocInfrastructurePatchRequest, ByocInfrastructurePostRequest,
ByocInfrastructurePostRequestRegionid,
};
pub use clickpipes::*;
Expand Down Expand Up @@ -197,7 +197,8 @@ pub use postgres::{
PostgresServicePasswordResource, PostgresServicePatchRequest, PostgresServicePostRequest,
PostgresServiceReadReplicaRequest, PostgresServiceRestoreRequest, PostgresServiceSetPassword,
PostgresServiceSetState, PostgresServiceSetStateCommand, PostgresSlowQueryPattern,
PostgresSlowQueryPatternDetail,
PostgresSlowQueryPatternDetail, SlowQueryPatternsGetListSortby,
SlowQueryPatternsGetListSortorder,
};
pub use quotas::{OrganizationQuota, OrganizationQuotaQuotacode, OrganizationQuotaScope};
pub use rbac::{
Expand All @@ -221,25 +222,26 @@ pub use services::{
AutoscalingMode, CurrentScaling, CurrentScalingEffectiveautoscalingmode,
InstancePrivateEndpoint, InstancePrivateEndpointCloudprovider, InstancePrivateEndpointRegion,
InstancePrivateEndpointsPatch, InstanceServiceQueryApiEndpointsPostRequest, InstanceTagsPatch,
PrivateEndpointConfig, ScalingSchedule, ScalingScheduleBaseConfig, ScalingScheduleEntry,
ScalingScheduleEntryRequest, ScalingSchedulePostRequest, ServicPrivateEndpointePostRequest,
Service, ServiceClickhouseSetting, ServiceClickhouseSettingSchemaEntry,
ServiceClickhouseSettingWarning, ServiceClickhouseSettingsList,
ServiceClickhouseSettingsPatchRequest, ServiceClickhouseSettingsPatchResponse,
ServiceClickhouseSettingsSchema, ServiceCompliancetype, ServiceEndpoint, ServiceEndpointChange,
ServiceEndpointChangeProtocol, ServiceEndpointProtocol, ServicePasswordPatchRequest,
ServicePasswordPatchResponse, ServicePatchRequest, ServicePatchRequestReleasechannel,
ServicePostRequest, ServicePostRequestCompliancetype, ServicePostRequestProfile,
ServicePostRequestProvider, ServicePostRequestRegion, ServicePostRequestReleasechannel,
ServicePostRequestTier, ServicePostResponse, ServiceProfile, ServiceProvider,
ServiceQueryAPIEndpoint, ServiceRegion, ServiceReleasechannel,
PrivateEndpointConfig, QueryEndpointRole, ScalingSchedule, ScalingScheduleBaseConfig,
ScalingScheduleEntry, ScalingScheduleEntryRequest, ScalingSchedulePostRequest,
ServicPrivateEndpointePostRequest, Service, ServiceClickhouseSetting,
ServiceClickhouseSettingSchemaEntry, ServiceClickhouseSettingWarning,
ServiceClickhouseSettingsList, ServiceClickhouseSettingsPatchRequest,
ServiceClickhouseSettingsPatchResponse, ServiceClickhouseSettingsSchema, ServiceCompliancetype,
ServiceEndpoint, ServiceEndpointChange, ServiceEndpointChangeProtocol, ServiceEndpointProtocol,
ServicePasswordPatchRequest, ServicePasswordPatchResponse, ServicePatchRequest,
ServicePatchRequestReleasechannel, ServicePostRequest, ServicePostRequestCompliancetype,
ServicePostRequestProfile, ServicePostRequestProvider, ServicePostRequestRegion,
ServicePostRequestReleasechannel, ServicePostRequestTier, ServicePostResponse, ServiceProfile,
ServiceProvider, ServiceQueryAPIEndpoint, ServiceRegion, ServiceReleasechannel,
ServiceReplicaScalingPatchRequest, ServiceScalingPatchRequest, ServiceScalingPatchResponse,
ServiceScalingPatchResponseCompliancetype, ServiceScalingPatchResponseProfile,
ServiceScalingPatchResponseProvider, ServiceScalingPatchResponseRegion,
ServiceScalingPatchResponseReleasechannel, ServiceScalingPatchResponseState,
ServiceScalingPatchResponseTier, ServiceState, ServiceStatePatchRequest,
ServiceStatePatchRequestCommand, ServiceTier, UpgradeWindow, UpgradeWindowPutRequest,
UsageCost, UsageCostMetrics, UsageCostRecord, UsageCostRecordEntitytype,
ServiceStatePatchRequestCommand, ServiceTier, UpgradeWindow, UpgradeWindowDuration,
UpgradeWindowPutRequest, UpgradeWindowStartHourUtc, UsageCost, UsageCostMetrics,
UsageCostRecord, UsageCostRecordEntitytype,
};
pub use shared::{
ApiResponse, AssignedRole, AssignedRoleRoletype, IpAccessListEntry, IpAccessListEntryResponse,
Expand Down
37 changes: 36 additions & 1 deletion crates/clickhouse-cloud-api/src/models/byoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,41 @@ impl std::fmt::Display for ByocInfrastructurePostRequestRegionid {
}
}

/// Allowed availability-zone suffixes for BYOC infrastructure.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub enum ByocAvailabilityZoneSuffix {
#[serde(rename = "a")]
#[default]
A,
#[serde(rename = "b")]
B,
#[serde(rename = "c")]
C,
#[serde(rename = "d")]
D,
#[serde(rename = "e")]
E,
#[serde(rename = "f")]
F,
/// Catch-all for unknown or newly-added values.
#[serde(untagged)]
Unknown(String),
}

impl std::fmt::Display for ByocAvailabilityZoneSuffix {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::A => write!(f, "a"),
Self::B => write!(f, "b"),
Self::C => write!(f, "c"),
Self::D => write!(f, "d"),
Self::E => write!(f, "e"),
Self::F => write!(f, "f"),
Self::Unknown(s) => write!(f, "{s}"),
}
}
}

/// `ByocConfig` from the ClickHouse Cloud API.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ByocConfig {
Expand Down Expand Up @@ -259,7 +294,7 @@ pub struct ByocInfrastructurePostRequest {
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "availabilityZoneSuffixes")]
pub availability_zone_suffixes: Vec<String>,
pub availability_zone_suffixes: Vec<ByocAvailabilityZoneSuffix>,
#[serde(rename = "displayName")]
pub display_name: String,
#[serde(rename = "regionId")]
Expand Down
79 changes: 79 additions & 0 deletions crates/clickhouse-cloud-api/src/models/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,85 @@ impl std::fmt::Display for PostgresLogsGetListSortorder {
}
}

/// Inline enum for `slowQueryPatternsGetList.sort_by`.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub enum SlowQueryPatternsGetListSortby {
#[serde(rename = "total_duration")]
#[default]
Total_duration,
#[serde(rename = "avg_duration")]
Avg_duration,
#[serde(rename = "call_count")]
Call_count,
#[serde(rename = "total_blks_read")]
Total_blks_read,
#[serde(rename = "total_cpu_time")]
Total_cpu_time,
#[serde(rename = "error_count")]
Error_count,
#[serde(rename = "max_duration")]
Max_duration,
#[serde(rename = "p50_duration")]
P50_duration,
#[serde(rename = "p95_duration")]
P95_duration,
#[serde(rename = "p99_duration")]
P99_duration,
#[serde(rename = "total_rows")]
Total_rows,
#[serde(rename = "total_shared_blks_hit")]
Total_shared_blks_hit,
#[serde(rename = "total_wal_bytes")]
Total_wal_bytes,
/// Catch-all for unknown or newly-added values.
#[serde(untagged)]
Unknown(String),
}

impl std::fmt::Display for SlowQueryPatternsGetListSortby {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Total_duration => write!(f, "total_duration"),
Self::Avg_duration => write!(f, "avg_duration"),
Self::Call_count => write!(f, "call_count"),
Self::Total_blks_read => write!(f, "total_blks_read"),
Self::Total_cpu_time => write!(f, "total_cpu_time"),
Self::Error_count => write!(f, "error_count"),
Self::Max_duration => write!(f, "max_duration"),
Self::P50_duration => write!(f, "p50_duration"),
Self::P95_duration => write!(f, "p95_duration"),
Self::P99_duration => write!(f, "p99_duration"),
Self::Total_rows => write!(f, "total_rows"),
Self::Total_shared_blks_hit => write!(f, "total_shared_blks_hit"),
Self::Total_wal_bytes => write!(f, "total_wal_bytes"),
Self::Unknown(s) => write!(f, "{s}"),
}
}
}

/// Inline enum for `slowQueryPatternsGetList.sort_order`.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub enum SlowQueryPatternsGetListSortorder {
#[serde(rename = "asc")]
Asc,
#[serde(rename = "desc")]
#[default]
Desc,
/// Catch-all for unknown or newly-added values.
#[serde(untagged)]
Unknown(String),
}

impl std::fmt::Display for SlowQueryPatternsGetListSortorder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Asc => write!(f, "asc"),
Self::Desc => write!(f, "desc"),
Self::Unknown(s) => write!(f, "{s}"),
}
}
}

/// `pgSize` enum from the ClickHouse Cloud API.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub enum PgSize {
Expand Down
119 changes: 114 additions & 5 deletions crates/clickhouse-cloud-api/src/models/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,115 @@ impl AutoscalingMode {
pub const VALUES: &'static [&'static str] = &["vertical", "horizontal"];
}

/// Role granted to a query API endpoint.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub enum QueryEndpointRole {
#[serde(rename = "sql_console_read_only")]
#[default]
SqlConsoleReadOnly,
#[serde(rename = "sql_console_admin")]
SqlConsoleAdmin,
/// Catch-all for unknown or newly-added values.
#[serde(untagged)]
Unknown(String),
}

impl std::fmt::Display for QueryEndpointRole {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::SqlConsoleReadOnly => write!(f, "sql_console_read_only"),
Self::SqlConsoleAdmin => write!(f, "sql_console_admin"),
Self::Unknown(s) => write!(f, "{s}"),
}
}
}

impl QueryEndpointRole {
/// Wire values accepted by the API, excluding the catch-all.
pub const VALUES: &'static [&'static str] = &["sql_console_read_only", "sql_console_admin"];
}

/// Allowed UTC start hours for a ClickHouse upgrade window.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(from = "i64", into = "i64")]
#[repr(i64)]
pub enum UpgradeWindowStartHourUtc {
#[default]
Hour0 = 0,
Hour6 = 6,
Hour12 = 12,
Hour18 = 18,
/// Catch-all for unknown or newly-added values.
#[serde(untagged)]
Unknown(i64),
}

impl From<i64> for UpgradeWindowStartHourUtc {
fn from(value: i64) -> Self {
match value {
0 => Self::Hour0,
6 => Self::Hour6,
12 => Self::Hour12,
18 => Self::Hour18,
value => Self::Unknown(value),
}
}
}

impl From<UpgradeWindowStartHourUtc> for i64 {
fn from(value: UpgradeWindowStartHourUtc) -> Self {
match value {
UpgradeWindowStartHourUtc::Hour0 => 0,
UpgradeWindowStartHourUtc::Hour6 => 6,
UpgradeWindowStartHourUtc::Hour12 => 12,
UpgradeWindowStartHourUtc::Hour18 => 18,
UpgradeWindowStartHourUtc::Unknown(value) => value,
}
}
}

impl std::fmt::Display for UpgradeWindowStartHourUtc {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", i64::from(*self))
}
}

/// Duration of a ClickHouse upgrade window, in hours.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(from = "i64", into = "i64")]
#[repr(i64)]
pub enum UpgradeWindowDuration {
#[default]
SixHours = 6,
/// Catch-all for unknown or newly-added values.
#[serde(untagged)]
Unknown(i64),
}

impl From<i64> for UpgradeWindowDuration {
fn from(value: i64) -> Self {
match value {
6 => Self::SixHours,
value => Self::Unknown(value),
}
}
}

impl From<UpgradeWindowDuration> for i64 {
fn from(value: UpgradeWindowDuration) -> Self {
match value {
UpgradeWindowDuration::SixHours => 6,
UpgradeWindowDuration::Unknown(value) => value,
}
}
}

impl std::fmt::Display for UpgradeWindowDuration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", i64::from(*self))
}
}

/// Inline enum for `CurrentScaling.effectiveAutoscalingMode`.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub enum CurrentScalingEffectiveautoscalingmode {
Expand Down Expand Up @@ -1330,7 +1439,7 @@ pub struct InstanceServiceQueryApiEndpointsPostRequest {
pub allowed_origins: String,
#[serde(rename = "openApiKeys")]
pub open_api_keys: Vec<String>,
pub roles: Vec<String>,
pub roles: Vec<QueryEndpointRole>,
}

/// `InstanceTagsPatch` from the ClickHouse Cloud API.
Expand Down Expand Up @@ -1775,7 +1884,7 @@ pub struct ServiceQueryAPIEndpoint {
#[serde(rename = "openApiKeys", skip_serializing_if = "Option::is_none")]
pub open_api_keys: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub roles: Option<Vec<String>>,
pub roles: Option<Vec<QueryEndpointRole>>,
}

/// `ServiceReplicaScalingPatchRequest` from the ClickHouse Cloud API.
Expand Down Expand Up @@ -1927,9 +2036,9 @@ pub struct ServiceStatePatchRequest {
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct UpgradeWindow {
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<i64>,
pub duration: Option<UpgradeWindowDuration>,
#[serde(rename = "startHourUtc", skip_serializing_if = "Option::is_none")]
pub start_hour_utc: Option<i64>,
pub start_hour_utc: Option<UpgradeWindowStartHourUtc>,
#[serde(skip_serializing_if = "Option::is_none")]
pub weekday: Option<i64>,
}
Expand All @@ -1938,7 +2047,7 @@ pub struct UpgradeWindow {
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct UpgradeWindowPutRequest {
#[serde(rename = "startHourUtc")]
pub start_hour_utc: i64,
pub start_hour_utc: UpgradeWindowStartHourUtc,
pub weekday: i64,
}

Expand Down
Loading