//native
type Digitalocean = {
token: string;
};
/**
* Update Topic for a Kafka Cluster
* To update a topic attached to a Kafka cluster, send a PUT request to
`/v2/databases/$DATABASE_ID/topics/$TOPIC_NAME`.
The result will be a JSON object with a `topic` key.
*/
export async function main(
auth: Digitalocean,
database_cluster_uuid: string,
topic_name: string,
body: {
replication_factor?: number;
partition_count?: number;
config?: {
cleanup_policy?: "delete" | "compact" | "compact_delete";
compression_type?:
| "producer"
| "gzip"
| "snappy"
| "Iz4"
| "zstd"
| "uncompressed";
delete_retention_ms?: number;
file_delete_delay_ms?: number;
flush_messages?: number;
flush_ms?: number;
index_interval_bytes?: number;
max_compaction_lag_ms?: number;
max_message_bytes?: number;
message_down_conversion_enable?: false | true;
message_format_version?:
| "0.8.0"
| "0.8.1"
| "0.8.2"
| "0.9.0"
| "0.10.0-IV0"
| "0.10.0-IV1"
| "0.10.1-IV0"
| "0.10.1-IV1"
| "0.10.1-IV2"
| "0.10.2-IV0"
| "0.11.0-IV0"
| "0.11.0-IV1"
| "0.11.0-IV2"
| "1.0-IV0"
| "1.1-IV0"
| "2.0-IV0"
| "2.0-IV1"
| "2.1-IV0"
| "2.1-IV1"
| "2.1-IV2"
| "2.2-IV0"
| "2.2-IV1"
| "2.3-IV0"
| "2.3-IV1"
| "2.4-IV0"
| "2.4-IV1"
| "2.5-IV0"
| "2.6-IV0"
| "2.7-IV0"
| "2.7-IV1"
| "2.7-IV2"
| "2.8-IV0"
| "2.8-IV1"
| "3.0-IV0"
| "3.0-IV1"
| "3.1-IV0"
| "3.2-IV0"
| "3.3-IV0"
| "3.3-IV1"
| "3.3-IV2"
| "3.3-IV3";
message_timestamp_type?: "create_time" | "log_append_time";
min_cleanable_dirty_ratio?: number;
min_compaction_lag_ms?: number;
min_insync_replicas?: number;
preallocate?: false | true;
retention_bytes?: number;
retention_ms?: number;
segment_bytes?: number;
segment_jitter_ms?: number;
segment_ms?: number;
};
},
) {
const url = new URL(
`https://api.digitalocean.com/v2/databases/${database_cluster_uuid}/topics/${topic_name}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago