@platformatic/kafka 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +270 -0
- package/dist/apis/admin/alter-client-quotas.d.ts +33 -0
- package/dist/apis/admin/alter-client-quotas.js +64 -0
- package/dist/apis/admin/alter-configs.d.ts +26 -0
- package/dist/apis/admin/alter-configs.js +57 -0
- package/dist/apis/admin/alter-partition-reassignments.d.ts +30 -0
- package/dist/apis/admin/alter-partition-reassignments.js +68 -0
- package/dist/apis/admin/alter-partition.d.ts +39 -0
- package/dist/apis/admin/alter-partition.js +87 -0
- package/dist/apis/admin/alter-replica-log-dirs.d.ts +26 -0
- package/dist/apis/admin/alter-replica-log-dirs.js +55 -0
- package/dist/apis/admin/alter-user-scram-credentials.d.ts +27 -0
- package/dist/apis/admin/alter-user-scram-credentials.js +60 -0
- package/dist/apis/admin/consumer-group-describe.d.ts +41 -0
- package/dist/apis/admin/consumer-group-describe.js +103 -0
- package/dist/apis/admin/create-acls.d.ts +24 -0
- package/dist/apis/admin/create-acls.js +55 -0
- package/dist/apis/admin/create-delegation-token.d.ts +24 -0
- package/dist/apis/admin/create-delegation-token.js +54 -0
- package/dist/apis/admin/create-partitions.d.ts +24 -0
- package/dist/apis/admin/create-partitions.js +54 -0
- package/dist/apis/admin/create-topics.d.ts +42 -0
- package/dist/apis/admin/create-topics.js +86 -0
- package/dist/apis/admin/delete-acls.d.ts +36 -0
- package/dist/apis/admin/delete-acls.js +82 -0
- package/dist/apis/admin/delete-groups.d.ts +14 -0
- package/dist/apis/admin/delete-groups.js +40 -0
- package/dist/apis/admin/delete-records.d.ts +27 -0
- package/dist/apis/admin/delete-records.js +59 -0
- package/dist/apis/admin/delete-topics.d.ts +21 -0
- package/dist/apis/admin/delete-topics.js +50 -0
- package/dist/apis/admin/describe-acls.d.ts +25 -0
- package/dist/apis/admin/describe-acls.js +66 -0
- package/dist/apis/admin/describe-client-quotas.d.ts +30 -0
- package/dist/apis/admin/describe-client-quotas.js +57 -0
- package/dist/apis/admin/describe-cluster.d.ts +23 -0
- package/dist/apis/admin/describe-cluster.js +50 -0
- package/dist/apis/admin/describe-configs.d.ts +38 -0
- package/dist/apis/admin/describe-configs.js +85 -0
- package/dist/apis/admin/describe-delegation-token.d.ts +31 -0
- package/dist/apis/admin/describe-delegation-token.js +62 -0
- package/dist/apis/admin/describe-groups.d.ts +28 -0
- package/dist/apis/admin/describe-groups.js +67 -0
- package/dist/apis/admin/describe-log-dirs.d.ts +32 -0
- package/dist/apis/admin/describe-log-dirs.js +75 -0
- package/dist/apis/admin/describe-producers.d.ts +33 -0
- package/dist/apis/admin/describe-producers.js +70 -0
- package/dist/apis/admin/describe-quorum.d.ts +50 -0
- package/dist/apis/admin/describe-quorum.js +116 -0
- package/dist/apis/admin/describe-topic-partitions.d.ts +42 -0
- package/dist/apis/admin/describe-topic-partitions.js +94 -0
- package/dist/apis/admin/describe-transactions.d.ts +24 -0
- package/dist/apis/admin/describe-transactions.js +59 -0
- package/dist/apis/admin/describe-user-scram-credentials.d.ts +26 -0
- package/dist/apis/admin/describe-user-scram-credentials.js +62 -0
- package/dist/apis/admin/envelope.d.ts +10 -0
- package/dist/apis/admin/envelope.js +32 -0
- package/dist/apis/admin/expire-delegation-token.d.ts +11 -0
- package/dist/apis/admin/expire-delegation-token.js +29 -0
- package/dist/apis/admin/incremental-alter-configs.d.ts +27 -0
- package/dist/apis/admin/incremental-alter-configs.js +58 -0
- package/dist/apis/admin/index.d.ts +37 -0
- package/dist/apis/admin/index.js +37 -0
- package/dist/apis/admin/list-groups.d.ts +18 -0
- package/dist/apis/admin/list-groups.js +43 -0
- package/dist/apis/admin/list-partition-reassignments.d.ts +27 -0
- package/dist/apis/admin/list-partition-reassignments.js +56 -0
- package/dist/apis/admin/list-transactions.d.ts +18 -0
- package/dist/apis/admin/list-transactions.js +45 -0
- package/dist/apis/admin/offset-delete.d.ts +26 -0
- package/dist/apis/admin/offset-delete.js +59 -0
- package/dist/apis/admin/renew-delegation-token.d.ts +11 -0
- package/dist/apis/admin/renew-delegation-token.js +29 -0
- package/dist/apis/admin/unregister-broker.d.ts +12 -0
- package/dist/apis/admin/unregister-broker.js +28 -0
- package/dist/apis/admin/update-features.d.ts +23 -0
- package/dist/apis/admin/update-features.js +60 -0
- package/dist/apis/consumer/consumer-group-heartbeat.d.ts +27 -0
- package/dist/apis/consumer/consumer-group-heartbeat.js +70 -0
- package/dist/apis/consumer/fetch.d.ts +46 -0
- package/dist/apis/consumer/fetch.js +121 -0
- package/dist/apis/consumer/heartbeat.d.ts +11 -0
- package/dist/apis/consumer/heartbeat.js +34 -0
- package/dist/apis/consumer/index.d.ts +9 -0
- package/dist/apis/consumer/index.js +9 -0
- package/dist/apis/consumer/join-group.d.ts +27 -0
- package/dist/apis/consumer/join-group.js +71 -0
- package/dist/apis/consumer/leave-group.d.ts +22 -0
- package/dist/apis/consumer/leave-group.js +57 -0
- package/dist/apis/consumer/list-offsets.d.ts +30 -0
- package/dist/apis/consumer/list-offsets.js +68 -0
- package/dist/apis/consumer/offset-commit.d.ts +29 -0
- package/dist/apis/consumer/offset-commit.js +68 -0
- package/dist/apis/consumer/offset-fetch.d.ts +37 -0
- package/dist/apis/consumer/offset-fetch.js +81 -0
- package/dist/apis/consumer/sync-group.d.ts +18 -0
- package/dist/apis/consumer/sync-group.js +49 -0
- package/dist/apis/definitions.d.ts +16 -0
- package/dist/apis/definitions.js +12 -0
- package/dist/apis/enumerations.d.ts +114 -0
- package/dist/apis/enumerations.js +78 -0
- package/dist/apis/index.d.ts +8 -0
- package/dist/apis/index.js +10 -0
- package/dist/apis/metadata/api-versions.d.ts +17 -0
- package/dist/apis/metadata/api-versions.js +41 -0
- package/dist/apis/metadata/find-coordinator.d.ts +19 -0
- package/dist/apis/metadata/find-coordinator.js +50 -0
- package/dist/apis/metadata/index.d.ts +3 -0
- package/dist/apis/metadata/index.js +3 -0
- package/dist/apis/metadata/metadata.d.ts +37 -0
- package/dist/apis/metadata/metadata.js +92 -0
- package/dist/apis/producer/add-offsets-to-txn.d.ts +10 -0
- package/dist/apis/producer/add-offsets-to-txn.js +34 -0
- package/dist/apis/producer/add-partitions-to-txn.d.ts +34 -0
- package/dist/apis/producer/add-partitions-to-txn.js +79 -0
- package/dist/apis/producer/end-txn.d.ts +10 -0
- package/dist/apis/producer/end-txn.js +34 -0
- package/dist/apis/producer/index.d.ts +6 -0
- package/dist/apis/producer/index.js +6 -0
- package/dist/apis/producer/init-producer-id.d.ts +21 -0
- package/dist/apis/producer/init-producer-id.js +38 -0
- package/dist/apis/producer/produce.d.ts +29 -0
- package/dist/apis/producer/produce.js +104 -0
- package/dist/apis/producer/txn-offset-commit.d.ts +29 -0
- package/dist/apis/producer/txn-offset-commit.js +77 -0
- package/dist/apis/security/index.d.ts +2 -0
- package/dist/apis/security/index.js +2 -0
- package/dist/apis/security/sasl-authenticate.d.ts +15 -0
- package/dist/apis/security/sasl-authenticate.js +30 -0
- package/dist/apis/security/sasl-handshake.d.ts +10 -0
- package/dist/apis/security/sasl-handshake.js +28 -0
- package/dist/apis/telemetry/get-telemetry-subscriptions.d.ts +18 -0
- package/dist/apis/telemetry/get-telemetry-subscriptions.js +46 -0
- package/dist/apis/telemetry/index.d.ts +3 -0
- package/dist/apis/telemetry/index.js +3 -0
- package/dist/apis/telemetry/list-client-metrics-resources.d.ts +14 -0
- package/dist/apis/telemetry/list-client-metrics-resources.js +32 -0
- package/dist/apis/telemetry/push-telemetry.d.ts +10 -0
- package/dist/apis/telemetry/push-telemetry.js +36 -0
- package/dist/clients/admin/admin.d.ts +18 -0
- package/dist/clients/admin/admin.js +322 -0
- package/dist/clients/admin/index.d.ts +3 -0
- package/dist/clients/admin/index.js +3 -0
- package/dist/clients/admin/options.d.ts +135 -0
- package/dist/clients/admin/options.js +81 -0
- package/dist/clients/admin/types.d.ts +56 -0
- package/dist/clients/admin/types.js +1 -0
- package/dist/clients/base/base.d.ts +48 -0
- package/dist/clients/base/base.js +242 -0
- package/dist/clients/base/index.d.ts +3 -0
- package/dist/clients/base/index.js +3 -0
- package/dist/clients/base/options.d.ts +115 -0
- package/dist/clients/base/options.js +59 -0
- package/dist/clients/base/types.d.ts +38 -0
- package/dist/clients/base/types.js +1 -0
- package/dist/clients/callbacks.d.ts +8 -0
- package/dist/clients/callbacks.js +42 -0
- package/dist/clients/consumer/consumer.d.ts +33 -0
- package/dist/clients/consumer/consumer.js +767 -0
- package/dist/clients/consumer/index.d.ts +5 -0
- package/dist/clients/consumer/index.js +5 -0
- package/dist/clients/consumer/messages-stream.d.ts +56 -0
- package/dist/clients/consumer/messages-stream.js +404 -0
- package/dist/clients/consumer/options.d.ts +521 -0
- package/dist/clients/consumer/options.js +177 -0
- package/dist/clients/consumer/topics-map.d.ts +8 -0
- package/dist/clients/consumer/topics-map.js +48 -0
- package/dist/clients/consumer/types.d.ts +74 -0
- package/dist/clients/consumer/types.js +11 -0
- package/dist/clients/index.d.ts +6 -0
- package/dist/clients/index.js +6 -0
- package/dist/clients/producer/index.d.ts +3 -0
- package/dist/clients/producer/index.js +3 -0
- package/dist/clients/producer/options.d.ts +122 -0
- package/dist/clients/producer/options.js +47 -0
- package/dist/clients/producer/producer.d.ts +13 -0
- package/dist/clients/producer/producer.js +272 -0
- package/dist/clients/producer/types.d.ts +29 -0
- package/dist/clients/producer/types.js +1 -0
- package/dist/clients/serde.d.ts +40 -0
- package/dist/clients/serde.js +49 -0
- package/dist/errors.d.ts +67 -0
- package/dist/errors.js +160 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +10 -0
- package/dist/network/connection-pool.d.ts +11 -0
- package/dist/network/connection-pool.js +101 -0
- package/dist/network/connection.d.ts +49 -0
- package/dist/network/connection.js +319 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.js +2 -0
- package/dist/protocol/apis.d.ts +2 -0
- package/dist/protocol/apis.js +191 -0
- package/dist/protocol/compression.d.ts +70 -0
- package/dist/protocol/compression.js +114 -0
- package/dist/protocol/crc32c.d.ts +2 -0
- package/dist/protocol/crc32c.js +83 -0
- package/dist/protocol/definitions.d.ts +12 -0
- package/dist/protocol/definitions.js +11 -0
- package/dist/protocol/dynamic-buffer.d.ts +65 -0
- package/dist/protocol/dynamic-buffer.js +557 -0
- package/dist/protocol/errors.d.ts +8 -0
- package/dist/protocol/errors.js +908 -0
- package/dist/protocol/index.d.ts +14 -0
- package/dist/protocol/index.js +14 -0
- package/dist/protocol/murmur2.d.ts +1 -0
- package/dist/protocol/murmur2.js +55 -0
- package/dist/protocol/reader.d.ts +58 -0
- package/dist/protocol/reader.js +296 -0
- package/dist/protocol/records.d.ts +110 -0
- package/dist/protocol/records.js +149 -0
- package/dist/protocol/sasl/plain.d.ts +3 -0
- package/dist/protocol/sasl/plain.js +3 -0
- package/dist/protocol/sasl/scram-sha.d.ts +28 -0
- package/dist/protocol/sasl/scram-sha.js +104 -0
- package/dist/protocol/varint.d.ts +12 -0
- package/dist/protocol/varint.js +36 -0
- package/dist/protocol/writer.d.ts +48 -0
- package/dist/protocol/writer.js +223 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +127 -0
- package/package.json +75 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
AlterPartitionReassignments Request (Version: 0) => timeout_ms [topics] TAG_BUFFER
|
|
6
|
+
timeout_ms => INT32
|
|
7
|
+
topics => name [partitions] TAG_BUFFER
|
|
8
|
+
name => COMPACT_STRING
|
|
9
|
+
partitions => partition_index [replicas] TAG_BUFFER
|
|
10
|
+
partition_index => INT32
|
|
11
|
+
replicas => INT32
|
|
12
|
+
*/
|
|
13
|
+
export function createRequest(timeoutMs, topics) {
|
|
14
|
+
return Writer.create()
|
|
15
|
+
.appendInt32(timeoutMs)
|
|
16
|
+
.appendArray(topics, (w, t) => {
|
|
17
|
+
w.appendString(t.name).appendArray(t.partitions, (w, p) => {
|
|
18
|
+
w.appendInt32(p.partitionIndex).appendArray(p.replicas, (w, r) => w.appendInt32(r), true, false);
|
|
19
|
+
});
|
|
20
|
+
})
|
|
21
|
+
.appendTaggedFields();
|
|
22
|
+
}
|
|
23
|
+
/*
|
|
24
|
+
AlterPartitionReassignments Response (Version: 0) => throttle_time_ms error_code error_message [responses] TAG_BUFFER
|
|
25
|
+
throttle_time_ms => INT32
|
|
26
|
+
error_code => INT16
|
|
27
|
+
error_message => COMPACT_NULLABLE_STRING
|
|
28
|
+
responses => name [partitions] TAG_BUFFER
|
|
29
|
+
name => COMPACT_STRING
|
|
30
|
+
partitions => partition_index error_code error_message TAG_BUFFER
|
|
31
|
+
partition_index => INT32
|
|
32
|
+
error_code => INT16
|
|
33
|
+
error_message => COMPACT_NULLABLE_STRING
|
|
34
|
+
*/
|
|
35
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
36
|
+
const errors = [];
|
|
37
|
+
const throttleTimeMs = reader.readInt32();
|
|
38
|
+
const errorCode = reader.readInt16();
|
|
39
|
+
if (errorCode !== 0) {
|
|
40
|
+
errors.push(['', errorCode]);
|
|
41
|
+
}
|
|
42
|
+
const response = {
|
|
43
|
+
throttleTimeMs,
|
|
44
|
+
errorCode,
|
|
45
|
+
errorMessage: reader.readNullableString(),
|
|
46
|
+
responses: reader.readArray((r, i) => {
|
|
47
|
+
return {
|
|
48
|
+
name: r.readString(),
|
|
49
|
+
partitions: r.readArray((r, j) => {
|
|
50
|
+
const partition = {
|
|
51
|
+
partitionIndex: r.readInt32(),
|
|
52
|
+
errorCode: r.readInt16(),
|
|
53
|
+
errorMessage: r.readNullableString()
|
|
54
|
+
};
|
|
55
|
+
if (partition.errorCode !== 0) {
|
|
56
|
+
errors.push([`responses/${i}/partitions/${j}`, partition.errorCode]);
|
|
57
|
+
}
|
|
58
|
+
return partition;
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
if (errors.length) {
|
|
64
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
65
|
+
}
|
|
66
|
+
return response;
|
|
67
|
+
}
|
|
68
|
+
export const api = createAPI(45, 0, createRequest, parseResponse);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
2
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
3
|
+
export interface AlterPartitionRequestISR {
|
|
4
|
+
brokerId: number;
|
|
5
|
+
brokerEpoch: bigint;
|
|
6
|
+
}
|
|
7
|
+
export interface AlterPartitionRequestPartition {
|
|
8
|
+
partitionIndex: number;
|
|
9
|
+
leaderEpoch: number;
|
|
10
|
+
newIsrWithEpochs: AlterPartitionRequestISR[];
|
|
11
|
+
leaderRecoveryState: number;
|
|
12
|
+
partitionEpoch: number;
|
|
13
|
+
}
|
|
14
|
+
export interface AlterPartitionRequestTopic {
|
|
15
|
+
topicId: string;
|
|
16
|
+
partitions: AlterPartitionRequestPartition[];
|
|
17
|
+
}
|
|
18
|
+
export type AlterPartitionRequest = Parameters<typeof createRequest>;
|
|
19
|
+
export interface AlterPartitionResponsePartition {
|
|
20
|
+
partitionIndex: number;
|
|
21
|
+
errorCode: number;
|
|
22
|
+
leaderId: number;
|
|
23
|
+
leaderEpoch: number;
|
|
24
|
+
isr: number;
|
|
25
|
+
leaderRecoveryState: number;
|
|
26
|
+
partitionEpoch: number;
|
|
27
|
+
}
|
|
28
|
+
export interface AlterPartitionResponseTopic {
|
|
29
|
+
topicId: string;
|
|
30
|
+
partitions: AlterPartitionResponsePartition[];
|
|
31
|
+
}
|
|
32
|
+
export interface AlterPartitionResponse {
|
|
33
|
+
throttleTimeMs: number;
|
|
34
|
+
errorCode: number;
|
|
35
|
+
topics: AlterPartitionResponseTopic[];
|
|
36
|
+
}
|
|
37
|
+
export declare function createRequest(brokerId: number, brokerEpoch: bigint, topic: AlterPartitionRequestTopic[]): Writer;
|
|
38
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AlterPartitionResponse;
|
|
39
|
+
export declare const api: import("../definitions.ts").API<[brokerId: number, brokerEpoch: bigint, topic: AlterPartitionRequestTopic[]], AlterPartitionResponse>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
AlterPartition Request (Version: 3) => broker_id broker_epoch [topics] TAG_BUFFER
|
|
6
|
+
broker_id => INT32
|
|
7
|
+
broker_epoch => INT64
|
|
8
|
+
topics => topic_id [partitions] TAG_BUFFER
|
|
9
|
+
topic_id => UUID
|
|
10
|
+
partitions => partition_index leader_epoch [new_isr_with_epochs] leader_recovery_state partition_epoch TAG_BUFFER
|
|
11
|
+
partition_index => INT32
|
|
12
|
+
leader_epoch => INT32
|
|
13
|
+
new_isr_with_epochs => broker_id broker_epoch TAG_BUFFER
|
|
14
|
+
broker_id => INT32
|
|
15
|
+
broker_epoch => INT64
|
|
16
|
+
leader_recovery_state => INT8
|
|
17
|
+
partition_epoch => INT32
|
|
18
|
+
*/
|
|
19
|
+
export function createRequest(brokerId, brokerEpoch, topic) {
|
|
20
|
+
return Writer.create()
|
|
21
|
+
.appendInt32(brokerId)
|
|
22
|
+
.appendInt64(brokerEpoch)
|
|
23
|
+
.appendArray(topic, (w, t) => {
|
|
24
|
+
w.appendString(t.topicId).appendArray(t.partitions, (w, p) => {
|
|
25
|
+
w.appendInt32(p.partitionIndex)
|
|
26
|
+
.appendInt32(p.leaderEpoch)
|
|
27
|
+
.appendArray(p.newIsrWithEpochs, (w, n) => {
|
|
28
|
+
w.appendInt32(n.brokerId).appendInt64(n.brokerEpoch);
|
|
29
|
+
})
|
|
30
|
+
.appendInt8(p.leaderRecoveryState)
|
|
31
|
+
.appendInt32(p.partitionEpoch);
|
|
32
|
+
});
|
|
33
|
+
})
|
|
34
|
+
.appendTaggedFields();
|
|
35
|
+
}
|
|
36
|
+
/*
|
|
37
|
+
AlterPartition Response (Version: 3) => throttle_time_ms error_code [topics] TAG_BUFFER
|
|
38
|
+
throttle_time_ms => INT32
|
|
39
|
+
error_code => INT16
|
|
40
|
+
topics => topic_id [partitions] TAG_BUFFER
|
|
41
|
+
topic_id => UUID
|
|
42
|
+
partitions => partition_index error_code leader_id leader_epoch [isr] leader_recovery_state partition_epoch TAG_BUFFER
|
|
43
|
+
partition_index => INT32
|
|
44
|
+
error_code => INT16
|
|
45
|
+
leader_id => INT32
|
|
46
|
+
leader_epoch => INT32
|
|
47
|
+
isr => INT32
|
|
48
|
+
leader_recovery_state => INT8
|
|
49
|
+
partition_epoch => INT32
|
|
50
|
+
*/
|
|
51
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
52
|
+
const errors = [];
|
|
53
|
+
const throttleTimeMs = reader.readInt32();
|
|
54
|
+
const errorCode = reader.readInt16();
|
|
55
|
+
if (errorCode !== 0) {
|
|
56
|
+
errors.push(['/', errorCode]);
|
|
57
|
+
}
|
|
58
|
+
const response = {
|
|
59
|
+
throttleTimeMs,
|
|
60
|
+
errorCode,
|
|
61
|
+
topics: reader.readArray((r, i) => {
|
|
62
|
+
return {
|
|
63
|
+
topicId: r.readString(),
|
|
64
|
+
partitions: r.readArray((r, j) => {
|
|
65
|
+
const partition = {
|
|
66
|
+
partitionIndex: r.readInt32(),
|
|
67
|
+
errorCode: r.readInt16(),
|
|
68
|
+
leaderId: r.readInt32(),
|
|
69
|
+
leaderEpoch: r.readInt32(),
|
|
70
|
+
isr: r.readInt32(),
|
|
71
|
+
leaderRecoveryState: r.readInt8(),
|
|
72
|
+
partitionEpoch: r.readInt32()
|
|
73
|
+
};
|
|
74
|
+
if (partition.errorCode !== 0) {
|
|
75
|
+
errors.push([`/topics/${i}/partitions/${j}`, partition.errorCode]);
|
|
76
|
+
}
|
|
77
|
+
return partition;
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
})
|
|
81
|
+
};
|
|
82
|
+
if (errors.length) {
|
|
83
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
84
|
+
}
|
|
85
|
+
return response;
|
|
86
|
+
}
|
|
87
|
+
export const api = createAPI(56, 3, createRequest, parseResponse);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
2
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
3
|
+
export interface AlterReplicaLogDirsRequestTopic {
|
|
4
|
+
name: string;
|
|
5
|
+
partitions: number[];
|
|
6
|
+
}
|
|
7
|
+
export interface AlterReplicaLogDirsRequestDir {
|
|
8
|
+
path: string;
|
|
9
|
+
topics: AlterReplicaLogDirsRequestTopic[];
|
|
10
|
+
}
|
|
11
|
+
export type AlterReplicaLogDirsRequest = Parameters<typeof createRequest>;
|
|
12
|
+
export interface AlterReplicaLogDirsResponsePartition {
|
|
13
|
+
partitionIndex: number;
|
|
14
|
+
errorCode: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AlterReplicaLogDirsResponseResult {
|
|
17
|
+
topicName: string;
|
|
18
|
+
partitions: AlterReplicaLogDirsResponsePartition[];
|
|
19
|
+
}
|
|
20
|
+
export interface AlterReplicaLogDirsResponse {
|
|
21
|
+
throttleTimeMs?: number;
|
|
22
|
+
results: AlterReplicaLogDirsResponseResult[];
|
|
23
|
+
}
|
|
24
|
+
export declare function createRequest(dirs: AlterReplicaLogDirsRequestDir[]): Writer;
|
|
25
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AlterReplicaLogDirsResponse;
|
|
26
|
+
export declare const api: import("../definitions.ts").API<[dirs: AlterReplicaLogDirsRequestDir[]], AlterReplicaLogDirsResponse>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
AlterReplicaLogDirs Request (Version: 2) => [dirs] TAG_BUFFER
|
|
6
|
+
dirs => path [topics] TAG_BUFFER
|
|
7
|
+
path => COMPACT_STRING
|
|
8
|
+
topics => name [partitions] TAG_BUFFER
|
|
9
|
+
name => COMPACT_STRING
|
|
10
|
+
partitions => INT32
|
|
11
|
+
*/
|
|
12
|
+
export function createRequest(dirs) {
|
|
13
|
+
return Writer.create()
|
|
14
|
+
.appendArray(dirs, (w, d) => {
|
|
15
|
+
w.appendString(d.path).appendArray(d.topics, (w, t) => {
|
|
16
|
+
w.appendString(t.name).appendArray(t.partitions, (w, p) => w.appendInt32(p), true, false);
|
|
17
|
+
});
|
|
18
|
+
})
|
|
19
|
+
.appendTaggedFields();
|
|
20
|
+
}
|
|
21
|
+
/*
|
|
22
|
+
AlterReplicaLogDirs Response (Version: 2) => throttle_time_ms [results] TAG_BUFFER
|
|
23
|
+
throttle_time_ms => INT32
|
|
24
|
+
results => topic_name [partitions] TAG_BUFFER
|
|
25
|
+
topic_name => COMPACT_STRING
|
|
26
|
+
partitions => partition_index error_code TAG_BUFFER
|
|
27
|
+
partition_index => INT32
|
|
28
|
+
error_code => INT16
|
|
29
|
+
*/
|
|
30
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
31
|
+
const errors = [];
|
|
32
|
+
const response = {
|
|
33
|
+
throttleTimeMs: reader.readInt32(),
|
|
34
|
+
results: reader.readArray((r, i) => {
|
|
35
|
+
return {
|
|
36
|
+
topicName: r.readString(),
|
|
37
|
+
partitions: r.readArray((r, j) => {
|
|
38
|
+
const partition = {
|
|
39
|
+
partitionIndex: r.readInt32(),
|
|
40
|
+
errorCode: r.readInt16()
|
|
41
|
+
};
|
|
42
|
+
if (partition.errorCode !== 0) {
|
|
43
|
+
errors.push([`/results/${i}/partitions/${j}`, partition.errorCode]);
|
|
44
|
+
}
|
|
45
|
+
return partition;
|
|
46
|
+
})
|
|
47
|
+
};
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
if (errors.length) {
|
|
51
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
52
|
+
}
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
55
|
+
export const api = createAPI(34, 2, createRequest, parseResponse);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type NullableString } from '../../protocol/definitions.ts';
|
|
2
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
3
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
4
|
+
export interface AlterUserScramCredentialsRequestDeletions {
|
|
5
|
+
name: string;
|
|
6
|
+
mechanism: number;
|
|
7
|
+
}
|
|
8
|
+
export interface AlterUserScramCredentialsRequestUpsertions {
|
|
9
|
+
name: string;
|
|
10
|
+
mechanism: number;
|
|
11
|
+
iterations: number;
|
|
12
|
+
salt: Buffer;
|
|
13
|
+
saltedPassword: Buffer;
|
|
14
|
+
}
|
|
15
|
+
export type AlterUserScramCredentialsRequest = Parameters<typeof createRequest>;
|
|
16
|
+
export interface AlterUserScramCredentialsResponseResult {
|
|
17
|
+
user: string;
|
|
18
|
+
errorCode: number;
|
|
19
|
+
errorMessage: NullableString;
|
|
20
|
+
}
|
|
21
|
+
export interface AlterUserScramCredentialsResponse {
|
|
22
|
+
throttleTimeMs: number;
|
|
23
|
+
results: AlterUserScramCredentialsResponseResult[];
|
|
24
|
+
}
|
|
25
|
+
export declare function createRequest(deletions: AlterUserScramCredentialsRequestDeletions[], upsertions: AlterUserScramCredentialsRequestUpsertions[]): Writer;
|
|
26
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AlterUserScramCredentialsResponse;
|
|
27
|
+
export declare const api: import("../definitions.ts").API<[deletions: AlterUserScramCredentialsRequestDeletions[], upsertions: AlterUserScramCredentialsRequestUpsertions[]], AlterUserScramCredentialsResponse>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
AlterUserScramCredentials Request (Version: 0) => [deletions] [upsertions] TAG_BUFFER
|
|
6
|
+
deletions => name mechanism TAG_BUFFER
|
|
7
|
+
name => COMPACT_STRING
|
|
8
|
+
mechanism => INT8
|
|
9
|
+
upsertions => name mechanism iterations salt salted_password TAG_BUFFER
|
|
10
|
+
name => COMPACT_STRING
|
|
11
|
+
mechanism => INT8
|
|
12
|
+
iterations => INT32
|
|
13
|
+
salt => COMPACT_BYTES
|
|
14
|
+
salted_password => COMPACT_BYTES
|
|
15
|
+
*/
|
|
16
|
+
export function createRequest(deletions, upsertions) {
|
|
17
|
+
return Writer.create()
|
|
18
|
+
.appendArray(deletions, (w, d) => {
|
|
19
|
+
w.appendString(d.name).appendInt8(d.mechanism);
|
|
20
|
+
})
|
|
21
|
+
.appendArray(upsertions, (w, u) => {
|
|
22
|
+
w.appendString(u.name)
|
|
23
|
+
.appendInt8(u.mechanism)
|
|
24
|
+
.appendInt32(u.iterations)
|
|
25
|
+
.appendBytes(u.salt)
|
|
26
|
+
.appendBytes(u.saltedPassword);
|
|
27
|
+
})
|
|
28
|
+
.appendTaggedFields()
|
|
29
|
+
.appendTaggedFields();
|
|
30
|
+
}
|
|
31
|
+
/*
|
|
32
|
+
AlterUserScramCredentials Response (Version: 0) => throttle_time_ms [results] TAG_BUFFER
|
|
33
|
+
throttle_time_ms => INT32
|
|
34
|
+
results => user error_code error_message TAG_BUFFER
|
|
35
|
+
user => COMPACT_STRING
|
|
36
|
+
error_code => INT16
|
|
37
|
+
error_message => COMPACT_NULLABLE_STRING
|
|
38
|
+
*/
|
|
39
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
40
|
+
const errors = [];
|
|
41
|
+
const response = {
|
|
42
|
+
throttleTimeMs: reader.readInt32(),
|
|
43
|
+
results: reader.readArray((r, i) => {
|
|
44
|
+
const result = {
|
|
45
|
+
user: r.readString(),
|
|
46
|
+
errorCode: r.readInt16(),
|
|
47
|
+
errorMessage: r.readNullableString()
|
|
48
|
+
};
|
|
49
|
+
if (result.errorCode !== 0) {
|
|
50
|
+
errors.push([`/results/${i}`, result.errorCode]);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
if (errors.length) {
|
|
56
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
57
|
+
}
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
export const api = createAPI(51, 0, createRequest, parseResponse);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type NullableString } from '../../protocol/definitions.ts';
|
|
2
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
3
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
4
|
+
export type ConsumerGroupDescribeRequest = Parameters<typeof createRequest>;
|
|
5
|
+
export interface ConsumerGroupDescribeResponseMemberTopic {
|
|
6
|
+
topicId: string;
|
|
7
|
+
topicName: string;
|
|
8
|
+
partitions: number[];
|
|
9
|
+
}
|
|
10
|
+
export interface ConsumerGroupDescribeResponseMemberAssignment {
|
|
11
|
+
topicPartitions: ConsumerGroupDescribeResponseMemberTopic[];
|
|
12
|
+
}
|
|
13
|
+
export interface ConsumerGroupDescribeResponseMember {
|
|
14
|
+
memberId: string;
|
|
15
|
+
instanceId: NullableString;
|
|
16
|
+
rackId: NullableString;
|
|
17
|
+
memberEpoch: number;
|
|
18
|
+
clientId: string;
|
|
19
|
+
clientHost: string;
|
|
20
|
+
subscribedTopicNames: string;
|
|
21
|
+
subscribedTopicRegex: NullableString;
|
|
22
|
+
assignment: ConsumerGroupDescribeResponseMemberAssignment;
|
|
23
|
+
targetAssignment: ConsumerGroupDescribeResponseMemberAssignment;
|
|
24
|
+
}
|
|
25
|
+
export interface ConsumerGroupDescribeResponseGroup {
|
|
26
|
+
errorCode: number;
|
|
27
|
+
errorMessage: NullableString;
|
|
28
|
+
groupId: string;
|
|
29
|
+
groupState: string;
|
|
30
|
+
groupEpoch: number;
|
|
31
|
+
assignmentEpoch: number;
|
|
32
|
+
assignorName: string;
|
|
33
|
+
members: ConsumerGroupDescribeResponseMember[];
|
|
34
|
+
}
|
|
35
|
+
export interface ConsumerGroupDescribeResponse {
|
|
36
|
+
throttleTimeMs: number;
|
|
37
|
+
groups: ConsumerGroupDescribeResponseGroup[];
|
|
38
|
+
}
|
|
39
|
+
export declare function createRequest(groupIds: string[], includeAuthorizedOperations: boolean): Writer;
|
|
40
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ConsumerGroupDescribeResponse;
|
|
41
|
+
export declare const api: import("../definitions.ts").API<[groupIds: string[], includeAuthorizedOperations: boolean], ConsumerGroupDescribeResponse>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
ConsumerGroupDescribe Request (Version: 0) => [group_ids] include_authorized_operations TAG_BUFFER
|
|
6
|
+
group_ids => COMPACT_STRING
|
|
7
|
+
include_authorized_operations => BOOLEAN
|
|
8
|
+
*/
|
|
9
|
+
export function createRequest(groupIds, includeAuthorizedOperations) {
|
|
10
|
+
return Writer.create()
|
|
11
|
+
.appendArray(groupIds, (w, r) => w.appendString(r), true, false)
|
|
12
|
+
.appendBoolean(includeAuthorizedOperations)
|
|
13
|
+
.appendTaggedFields();
|
|
14
|
+
}
|
|
15
|
+
/*
|
|
16
|
+
ConsumerGroupDescribe Response (Version: 0) => throttle_time_ms [groups] TAG_BUFFER
|
|
17
|
+
throttle_time_ms => INT32
|
|
18
|
+
groups => error_code error_message group_id group_state group_epoch assignment_epoch assignor_name [members] authorized_operations TAG_BUFFER
|
|
19
|
+
error_code => INT16
|
|
20
|
+
error_message => COMPACT_NULLABLE_STRING
|
|
21
|
+
group_id => COMPACT_STRING
|
|
22
|
+
group_state => COMPACT_STRING
|
|
23
|
+
group_epoch => INT32
|
|
24
|
+
assignment_epoch => INT32
|
|
25
|
+
assignor_name => COMPACT_STRING
|
|
26
|
+
members => member_id instance_id rack_id member_epoch client_id client_host [subscribed_topic_names] subscribed_topic_regex assignment target_assignment TAG_BUFFER
|
|
27
|
+
member_id => COMPACT_STRING
|
|
28
|
+
instance_id => COMPACT_NULLABLE_STRING
|
|
29
|
+
rack_id => COMPACT_NULLABLE_STRING
|
|
30
|
+
member_epoch => INT32
|
|
31
|
+
client_id => COMPACT_STRING
|
|
32
|
+
client_host => COMPACT_STRING
|
|
33
|
+
subscribed_topic_names => COMPACT_STRING
|
|
34
|
+
subscribed_topic_regex => COMPACT_NULLABLE_STRING
|
|
35
|
+
assignment => [topic_partitions] TAG_BUFFER
|
|
36
|
+
topic_partitions => topic_id topic_name [partitions] TAG_BUFFER
|
|
37
|
+
topic_id => UUID
|
|
38
|
+
topic_name => COMPACT_STRING
|
|
39
|
+
partitions => INT32
|
|
40
|
+
target_assignment => [topic_partitions] TAG_BUFFER
|
|
41
|
+
topic_partitions => topic_id topic_name [partitions] TAG_BUFFER
|
|
42
|
+
topic_id => UUID
|
|
43
|
+
topic_name => COMPACT_STRING
|
|
44
|
+
partitions => INT32
|
|
45
|
+
authorized_operations => INT32
|
|
46
|
+
*/
|
|
47
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
48
|
+
const errors = [];
|
|
49
|
+
const response = {
|
|
50
|
+
throttleTimeMs: reader.readInt32(),
|
|
51
|
+
groups: reader.readArray((r, i) => {
|
|
52
|
+
const errorCode = r.readInt16();
|
|
53
|
+
if (errorCode !== 0) {
|
|
54
|
+
errors.push([`/groups/${i}`, errorCode]);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
errorCode,
|
|
58
|
+
errorMessage: r.readNullableString(),
|
|
59
|
+
groupId: r.readString(),
|
|
60
|
+
groupState: r.readString(),
|
|
61
|
+
groupEpoch: r.readInt32(),
|
|
62
|
+
assignmentEpoch: r.readInt32(),
|
|
63
|
+
assignorName: r.readString(),
|
|
64
|
+
members: r.readArray(r => {
|
|
65
|
+
return {
|
|
66
|
+
memberId: r.readString(),
|
|
67
|
+
instanceId: r.readNullableString(),
|
|
68
|
+
rackId: r.readNullableString(),
|
|
69
|
+
memberEpoch: r.readInt32(),
|
|
70
|
+
clientId: r.readString(),
|
|
71
|
+
clientHost: r.readString(),
|
|
72
|
+
subscribedTopicNames: r.readString(),
|
|
73
|
+
subscribedTopicRegex: r.readNullableString(),
|
|
74
|
+
assignment: {
|
|
75
|
+
topicPartitions: r.readArray(r => {
|
|
76
|
+
return {
|
|
77
|
+
topicId: r.readUUID(),
|
|
78
|
+
topicName: r.readString(),
|
|
79
|
+
partitions: r.readArray(() => r.readInt32())
|
|
80
|
+
};
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
targetAssignment: {
|
|
84
|
+
topicPartitions: r.readArray(r => {
|
|
85
|
+
return {
|
|
86
|
+
topicId: r.readUUID(),
|
|
87
|
+
topicName: r.readString(),
|
|
88
|
+
partitions: r.readArray(() => r.readInt32())
|
|
89
|
+
};
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}),
|
|
94
|
+
authorizedOperations: r.readInt32()
|
|
95
|
+
};
|
|
96
|
+
})
|
|
97
|
+
};
|
|
98
|
+
if (errors.length) {
|
|
99
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
100
|
+
}
|
|
101
|
+
return response;
|
|
102
|
+
}
|
|
103
|
+
export const api = createAPI(69, 0, createRequest, parseResponse);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type NullableString } from '../../protocol/definitions.ts';
|
|
2
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
3
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
4
|
+
export interface CreateAclsRequestCreation {
|
|
5
|
+
resourceType: number;
|
|
6
|
+
resourceName: string;
|
|
7
|
+
resourcePatternType: number;
|
|
8
|
+
principal: string;
|
|
9
|
+
host: string;
|
|
10
|
+
operation: number;
|
|
11
|
+
permissionType: number;
|
|
12
|
+
}
|
|
13
|
+
export type CreateAclsRequest = Parameters<typeof createRequest>;
|
|
14
|
+
export interface CreateAclsResponseResult {
|
|
15
|
+
errorCode: number;
|
|
16
|
+
errorMessage: NullableString;
|
|
17
|
+
}
|
|
18
|
+
export interface CreateAclsResponse {
|
|
19
|
+
throttleTimeMs: number;
|
|
20
|
+
results: CreateAclsResponseResult[];
|
|
21
|
+
}
|
|
22
|
+
export declare function createRequest(creations: CreateAclsRequestCreation[]): Writer;
|
|
23
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): CreateAclsResponse;
|
|
24
|
+
export declare const api: import("../definitions.ts").API<[creations: CreateAclsRequestCreation[]], CreateAclsResponse>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
CreateAcls Request (Version: 3) => [creations] TAG_BUFFER
|
|
6
|
+
creations => resource_type resource_name resource_pattern_type principal host operation permission_type TAG_BUFFER
|
|
7
|
+
resource_type => INT8
|
|
8
|
+
resource_name => COMPACT_STRING
|
|
9
|
+
resource_pattern_type => INT8
|
|
10
|
+
principal => COMPACT_STRING
|
|
11
|
+
host => COMPACT_STRING
|
|
12
|
+
operation => INT8
|
|
13
|
+
permission_type => INT8
|
|
14
|
+
*/
|
|
15
|
+
export function createRequest(creations) {
|
|
16
|
+
return Writer.create()
|
|
17
|
+
.appendArray(creations, (w, c) => {
|
|
18
|
+
w.appendInt8(c.resourceType)
|
|
19
|
+
.appendString(c.resourceName)
|
|
20
|
+
.appendInt8(c.resourcePatternType)
|
|
21
|
+
.appendString(c.principal)
|
|
22
|
+
.appendString(c.host)
|
|
23
|
+
.appendInt8(c.operation)
|
|
24
|
+
.appendInt8(c.permissionType);
|
|
25
|
+
})
|
|
26
|
+
.appendTaggedFields();
|
|
27
|
+
}
|
|
28
|
+
/*
|
|
29
|
+
CreateAcls Response (Version: 3) => throttle_time_ms [results] TAG_BUFFER
|
|
30
|
+
throttle_time_ms => INT32
|
|
31
|
+
results => error_code error_message TAG_BUFFER
|
|
32
|
+
error_code => INT16
|
|
33
|
+
error_message => COMPACT_NULLABLE_STRING
|
|
34
|
+
*/
|
|
35
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
36
|
+
const errors = [];
|
|
37
|
+
const response = {
|
|
38
|
+
throttleTimeMs: reader.readInt32(),
|
|
39
|
+
results: reader.readArray((r, i) => {
|
|
40
|
+
const result = {
|
|
41
|
+
errorCode: r.readInt16(),
|
|
42
|
+
errorMessage: r.readNullableString()
|
|
43
|
+
};
|
|
44
|
+
if (result.errorCode !== 0) {
|
|
45
|
+
errors.push([`/results/${i}`, result.errorCode]);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
if (errors.length) {
|
|
51
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
52
|
+
}
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
55
|
+
export const api = createAPI(30, 3, createRequest, parseResponse);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type NullableString } from '../../protocol/definitions.ts';
|
|
2
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
3
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
4
|
+
export interface CreateDelegationTokenRequestRenewer {
|
|
5
|
+
principalType: string;
|
|
6
|
+
principalName: string;
|
|
7
|
+
}
|
|
8
|
+
export type CreateDelegationTokenRequest = Parameters<typeof createRequest>;
|
|
9
|
+
export interface CreateDelegationTokenResponse {
|
|
10
|
+
errorCode: number;
|
|
11
|
+
principalType: string;
|
|
12
|
+
principalName: string;
|
|
13
|
+
tokenRequesterPrincipalType: string;
|
|
14
|
+
tokenRequesterPrincipalName: string;
|
|
15
|
+
issueTimestampMs: bigint;
|
|
16
|
+
expiryTimestampMs: bigint;
|
|
17
|
+
maxTimestampMs: bigint;
|
|
18
|
+
tokenId: string;
|
|
19
|
+
hmac: Buffer;
|
|
20
|
+
throttleTimeMs: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function createRequest(ownerPrincipalType: NullableString, ownerPrincipalName: NullableString, renewers: CreateDelegationTokenRequestRenewer[], maxLifetimeMs: bigint): Writer;
|
|
23
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): CreateDelegationTokenResponse;
|
|
24
|
+
export declare const api: import("../definitions.ts").API<[ownerPrincipalType: NullableString, ownerPrincipalName: NullableString, renewers: CreateDelegationTokenRequestRenewer[], maxLifetimeMs: bigint], CreateDelegationTokenResponse>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
CreateDelegationToken Request (Version: 3) => owner_principal_type owner_principal_name [renewers] max_lifetime_ms TAG_BUFFER
|
|
6
|
+
owner_principal_type => COMPACT_NULLABLE_STRING
|
|
7
|
+
owner_principal_name => COMPACT_NULLABLE_STRING
|
|
8
|
+
renewers => principal_type principal_name TAG_BUFFER
|
|
9
|
+
principal_type => COMPACT_STRING
|
|
10
|
+
principal_name => COMPACT_STRING
|
|
11
|
+
max_lifetime_ms => INT64
|
|
12
|
+
*/
|
|
13
|
+
export function createRequest(ownerPrincipalType, ownerPrincipalName, renewers, maxLifetimeMs) {
|
|
14
|
+
return Writer.create()
|
|
15
|
+
.appendString(ownerPrincipalType)
|
|
16
|
+
.appendString(ownerPrincipalName)
|
|
17
|
+
.appendArray(renewers, (w, r) => w.appendString(r.principalType).appendString(r.principalName))
|
|
18
|
+
.appendInt64(maxLifetimeMs)
|
|
19
|
+
.appendTaggedFields();
|
|
20
|
+
}
|
|
21
|
+
/*
|
|
22
|
+
CreateDelegationToken Response (Version: 3) => error_code principal_type principal_name token_requester_principal_type token_requester_principal_name issue_timestamp_ms expiry_timestamp_ms max_timestamp_ms token_id hmac throttle_time_ms TAG_BUFFER
|
|
23
|
+
error_code => INT16
|
|
24
|
+
principal_type => COMPACT_STRING
|
|
25
|
+
principal_name => COMPACT_STRING
|
|
26
|
+
token_requester_principal_type => COMPACT_STRING
|
|
27
|
+
token_requester_principal_name => COMPACT_STRING
|
|
28
|
+
issue_timestamp_ms => INT64
|
|
29
|
+
expiry_timestamp_ms => INT64
|
|
30
|
+
max_timestamp_ms => INT64
|
|
31
|
+
token_id => COMPACT_STRING
|
|
32
|
+
hmac => COMPACT_BYTES
|
|
33
|
+
throttle_time_ms => INT32
|
|
34
|
+
*/
|
|
35
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
36
|
+
const response = {
|
|
37
|
+
errorCode: reader.readInt16(),
|
|
38
|
+
principalType: reader.readString(),
|
|
39
|
+
principalName: reader.readString(),
|
|
40
|
+
tokenRequesterPrincipalType: reader.readString(),
|
|
41
|
+
tokenRequesterPrincipalName: reader.readString(),
|
|
42
|
+
issueTimestampMs: reader.readInt64(),
|
|
43
|
+
expiryTimestampMs: reader.readInt64(),
|
|
44
|
+
maxTimestampMs: reader.readInt64(),
|
|
45
|
+
tokenId: reader.readString(),
|
|
46
|
+
hmac: reader.readBytes(),
|
|
47
|
+
throttleTimeMs: reader.readInt32()
|
|
48
|
+
};
|
|
49
|
+
if (response.errorCode !== 0) {
|
|
50
|
+
throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
|
|
51
|
+
}
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
export const api = createAPI(38, 3, createRequest, parseResponse);
|