1pub const BETA_OPERATIONS: &[&str] = &[
23 "backup_bucket_create",
24 "backup_bucket_delete",
25 "backup_bucket_get",
26 "backup_bucket_update",
27 "click_stack_create_alert",
28 "click_stack_create_dashboard",
29 "click_stack_delete_alert",
30 "click_stack_delete_dashboard",
31 "click_stack_get_alert",
32 "click_stack_get_dashboard",
33 "click_stack_list_alerts",
34 "click_stack_list_dashboards",
35 "click_stack_list_sources",
36 "click_stack_list_webhooks",
37 "click_stack_update_alert",
38 "click_stack_update_dashboard",
39 "postgres_instance_config_get",
40 "postgres_instance_config_patch",
41 "postgres_instance_config_post",
42 "postgres_instance_create_read_replica",
43 "postgres_instance_prometheus_get",
44 "postgres_instance_restore",
45 "postgres_org_prometheus_get",
46 "postgres_service_certs_get",
47 "postgres_service_create",
48 "postgres_service_delete",
49 "postgres_service_get",
50 "postgres_service_get_list",
51 "postgres_service_patch",
52 "postgres_service_patch_state",
53 "postgres_service_set_password",
54 "scaling_schedule_delete",
55 "scaling_schedule_get",
56 "scaling_schedule_upsert",
57 "service_clickhouse_setting_get",
58 "service_clickhouse_settings_list_get",
59 "service_clickhouse_settings_schema_get",
60 "service_clickhouse_settings_update",
61];
62
63pub fn is_beta_operation(name: &str) -> bool {
67 BETA_OPERATIONS.binary_search(&name).is_ok()
68}
69
70pub const DEPRECATED_FIELDS: &[(&str, &str)] = &[
99 ("ApiKey", "roles"),
100 ("ApiKeyPatchRequest", "roles"),
101 ("ApiKeyPostRequest", "roles"),
102 ("ClickPipeScaling", "concurrency"),
103 ("ClickPipeScalingPatchRequest", "concurrency"),
104 ("ClickStackTileInput", "asRatio"),
105 ("ClickStackTileInput", "series"),
106 ("Invitation", "role"),
107 ("InvitationPostRequest", "role"),
108 ("Member", "role"),
109 ("MemberPatchRequest", "role"),
110 ("OrganizationPrivateEndpointsPatch", "add"),
111 ("Service", "maxTotalMemoryGb"),
112 ("Service", "minTotalMemoryGb"),
113 ("Service", "tier"),
114 ("ServicePostRequest", "maxTotalMemoryGb"),
115 ("ServicePostRequest", "minTotalMemoryGb"),
116 ("ServicePostRequest", "privateEndpointIds"),
117 ("ServicePostRequest", "tier"),
118 ("ServiceScalingPatchRequest", "maxTotalMemoryGb"),
119 ("ServiceScalingPatchRequest", "minTotalMemoryGb"),
120 ("ServiceScalingPatchResponse", "maxTotalMemoryGb"),
121 ("ServiceScalingPatchResponse", "minTotalMemoryGb"),
122 ("ServiceScalingPatchResponse", "tier"),
123];
124
125pub fn is_deprecated_field(struct_name: &str, field_name: &str) -> bool {
131 DEPRECATED_FIELDS
132 .binary_search(&(struct_name, field_name))
133 .is_ok()
134}
135
136#[cfg(test)]
137mod tests {
138 use super::*;
139
140 #[test]
141 fn list_is_sorted_and_unique() {
142 for pair in BETA_OPERATIONS.windows(2) {
143 assert!(
144 pair[0] < pair[1],
145 "BETA_OPERATIONS must be sorted and unique; {:?} >= {:?}",
146 pair[0],
147 pair[1],
148 );
149 }
150 }
151
152 #[test]
153 fn is_beta_operation_matches_constant() {
154 assert!(is_beta_operation("scaling_schedule_get"));
155 assert!(is_beta_operation("postgres_service_get_list"));
156 assert!(!is_beta_operation("services_list"));
157 assert!(!is_beta_operation("not_a_real_op"));
158 }
159
160 #[test]
161 fn deprecated_fields_are_sorted_and_unique() {
162 for pair in DEPRECATED_FIELDS.windows(2) {
163 assert!(
164 pair[0] < pair[1],
165 "DEPRECATED_FIELDS must be sorted and unique; {:?} >= {:?}",
166 pair[0],
167 pair[1],
168 );
169 }
170 }
171
172 #[test]
173 fn is_deprecated_field_matches_constant() {
174 assert!(is_deprecated_field("Service", "tier"));
175 assert!(is_deprecated_field("ApiKey", "roles"));
176 assert!(is_deprecated_field("ServicePostRequest", "tier"));
177 assert!(is_deprecated_field("InvitationPostRequest", "role"));
178 assert!(!is_deprecated_field("Service", "name"));
179 assert!(!is_deprecated_field("NotAStruct", "tier"));
180 }
181}