|
| 1 | +import "@typespec/openapi"; |
| 2 | + |
| 3 | +namespace Api; |
| 4 | + |
| 5 | +using TypeSpec.Http; |
| 6 | +using OpenAPI; |
| 7 | + |
| 8 | +@route("/api/clusters/{clusterName}/acls") |
| 9 | +@tag("Acls") |
| 10 | +interface AclApi { |
| 11 | + @summary("listKafkaAcls") |
| 12 | + @get |
| 13 | + @operationId("listAcls") |
| 14 | + listAcls( |
| 15 | + @path clusterName: string, |
| 16 | + @query resourceType?: KafkaAclResourceType, |
| 17 | + @query resourceName?: string, |
| 18 | + @query namePatternType?: KafkaAclNamePatternType, |
| 19 | + @query search?: string |
| 20 | + ): KafkaAcl[]; |
| 21 | + |
| 22 | + @route("/csv") |
| 23 | + @summary("getAclAsCsv") |
| 24 | + @get |
| 25 | + @operationId("getAclAsCsv") |
| 26 | + getAclAsCsv(@path clusterName: string): string; |
| 27 | + |
| 28 | + @route("/csv") |
| 29 | + @summary("syncAclsCsv") |
| 30 | + @post |
| 31 | + @operationId("syncAclsCsv") |
| 32 | + syncAclsCsv(@path clusterName: string, @body content: string): void | ApiBadRequestResponse; |
| 33 | + |
| 34 | + @post |
| 35 | + @operationId("createAcl") |
| 36 | + @summary("createAcl") |
| 37 | + createAcl(@path clusterName: string, @body acl: KafkaAcl): void | ApiBadRequestResponse; |
| 38 | + |
| 39 | + @summary("deleteAcl") |
| 40 | + @delete |
| 41 | + @operationId("deleteAcl") |
| 42 | + @summary("deleteAcl") |
| 43 | + deleteAcl( |
| 44 | + @path clusterName: string, |
| 45 | + @body acl: KafkaAcl, |
| 46 | + ): void | ApiNotFoundResponse; |
| 47 | + |
| 48 | + @route("/consumer") |
| 49 | + @post |
| 50 | + @operationId("createConsumerAcl") |
| 51 | + @summary("createConsumerAcl") |
| 52 | + createConsumerAcl( |
| 53 | + @path clusterName: string, |
| 54 | + @body payload: CreateConsumerAcl, |
| 55 | + ): void | ApiBadRequestResponse; |
| 56 | + |
| 57 | + @route("/producer") |
| 58 | + @summary("createProducerAcl") |
| 59 | + @operationId("createProducerAcl") |
| 60 | + @post |
| 61 | + createProducerAcl( |
| 62 | + @path clusterName: string, |
| 63 | + @body payload: CreateProducerAcl, |
| 64 | + ): void | ApiBadRequestResponse; |
| 65 | + |
| 66 | + @route("/streamapp") |
| 67 | + @summary("createStreamAppAcl") |
| 68 | + @post |
| 69 | + @operationId("createStreamAppAcl") |
| 70 | + createStreamAppAcl( |
| 71 | + @path clusterName: string, |
| 72 | + @body payload: CreateStreamAppAcl, |
| 73 | + ): void | ApiBadRequestResponse; |
| 74 | +} |
| 75 | + |
| 76 | +model KafkaAcl { |
| 77 | + resourceType: KafkaAclResourceType; |
| 78 | + resourceName: string; // "*" if acl can be applied to any resource of given type |
| 79 | + namePatternType: KafkaAclNamePatternType; |
| 80 | + principal: string; |
| 81 | + host: string; |
| 82 | + operation: KafkaAclOpeations; |
| 83 | + permission: "ALLOW" | "DENY"; |
| 84 | +} |
| 85 | + |
| 86 | +alias KafkaAclOpeations = |
| 87 | + "UNKNOWN" |
| 88 | + | "ALL" |
| 89 | + | "READ" |
| 90 | + | "WRITE" |
| 91 | + | "CREATE" |
| 92 | + | "DELETE" |
| 93 | + | "ALTER" |
| 94 | + | "DESCRIBE" |
| 95 | + | "CLUSTER_ACTION" |
| 96 | + | "DESCRIBE_CONFIGS" |
| 97 | + | "ALTER_CONFIGS" |
| 98 | + | "IDEMPOTENT_WRITE" |
| 99 | + | "CREATE_TOKENS" |
| 100 | + | "DESCRIBE_TOKENS"; |
| 101 | + |
| 102 | +enum KafkaAclResourceType { |
| 103 | + UNKNOWN, |
| 104 | + TOPIC, |
| 105 | + GROUP, |
| 106 | + CLUSTER, |
| 107 | + TRANSACTIONAL_ID, |
| 108 | + DELEGATION_TOKEN, |
| 109 | + USER, |
| 110 | +} |
| 111 | + |
| 112 | +enum KafkaAclNamePatternType { |
| 113 | + MATCH, |
| 114 | + LITERAL, |
| 115 | + PREFIXED, |
| 116 | +} |
| 117 | + |
| 118 | +model CreateConsumerAcl { |
| 119 | + principal?: string; |
| 120 | + host?: string; |
| 121 | + topics?: string[]; |
| 122 | + topicsPrefix?: string; |
| 123 | + consumerGroups?: string[]; |
| 124 | + consumerGroupsPrefix?: string; |
| 125 | +} |
| 126 | + |
| 127 | +model CreateProducerAcl { |
| 128 | + principal?: string; |
| 129 | + host?: string; |
| 130 | + topics?: string[]; |
| 131 | + topicsPrefix?: string; |
| 132 | + transactionalId?: string; |
| 133 | + transactionsIdPrefix?: string; |
| 134 | + idempotent?: boolean = false; |
| 135 | +} |
| 136 | + |
| 137 | +model CreateStreamAppAcl { |
| 138 | + principal?: string; |
| 139 | + host?: string; |
| 140 | + inputTopics?: string[]; |
| 141 | + outputTopics?: string[]; |
| 142 | + applicationId?: string; |
| 143 | +} |
0 commit comments