-
-
Notifications
You must be signed in to change notification settings - Fork 173
Feature: Switch to Typespec contract description model #1131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
8a03bfd
Use typespec contracts
germanosin 7d5af90
Merge branch 'main' into typespec
germanosin b8b91fc
Fixed styling
germanosin 155b038
Merge remote-tracking branch 'origin/typespec' into typespec
germanosin a2175a1
Fixed styling
germanosin 5d4f419
enable typespec by default
germanosin 8cd0a0a
Added info
germanosin 6ce97f8
Frontend use new contracts
germanosin a7a59d8
Fixes in contracts for backward compatibility
germanosin d0ef634
use typespec build
germanosin c29091f
Install pnpm dependencies
germanosin d67068c
Merged main
germanosin f114d44
Actualize typespec
germanosin 4279d6c
Actualize typespec
germanosin a1c261b
fixed frontend build
germanosin ea75152
fixed frontend build
germanosin 5341c20
fixed frontend build
germanosin c61da13
fixed frontend build
germanosin 2c670f6
fixed frontend build
germanosin 4bf3779
fixed frontend build
germanosin fa8b03b
fixed frontend build
germanosin bcae096
Enabled contract validation
germanosin db746fa
Removed frontend test report
germanosin a42e81e
Merge branch 'main' into typespec
germanosin 38ee6c9
Synced with main
germanosin 0474fd7
Synced with main
germanosin ed63a5f
Merge branch 'main' into typespec
germanosin 84e3d07
Merge branch 'main' into typespec
germanosin 279a09a
Added comment
germanosin 6ea8e2d
Merge branch 'main' into typespec
germanosin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import "@typespec/openapi"; | ||
|
||
using TypeSpec.Http; | ||
using OpenAPI; | ||
|
||
@route("/api/clusters/{clusterName}/acls") | ||
@tag("Acls") | ||
interface AclApi { | ||
@doc("listKafkaAcls") | ||
@get | ||
@operationId("listAcls") | ||
listAcls( | ||
@path clusterName: string, | ||
@query resourceType?: KafkaAclResourceType, | ||
@query resourceName?: string, | ||
@query namePatternType?: KafkaAclNamePatternType, | ||
): KafkaAcl[]; | ||
|
||
@route("/csv") | ||
@doc("getAclAsCsv") | ||
@get | ||
@operationId("getAclAsCsv") | ||
getAclAsCsv(@path clusterName: string): string; | ||
|
||
@route("/csv") | ||
@doc("syncAclsCsv") | ||
@post | ||
@operationId("syncAclsCsv") | ||
syncAclsCsv(@path clusterName: string, @body content: string): void | ApiBadRequestResponse; | ||
|
||
@doc("createAcl") | ||
@post | ||
@operationId("createAcl") | ||
createAcl(@path clusterName: string, @body acl: KafkaAcl): void | ApiBadRequestResponse; | ||
|
||
@doc("deleteAcl") | ||
@delete | ||
@operationId("deleteAcl") | ||
deleteAcl( | ||
@path clusterName: string, | ||
@body acl: KafkaAcl, | ||
): void | ApiNotFoundResponse; | ||
|
||
@route("/consumer") | ||
@doc("createConsumerAcl") | ||
@post | ||
@operationId("createConsumerAcl") | ||
createConsumerAcl( | ||
@path clusterName: string, | ||
@body payload: CreateConsumerAcl, | ||
): void | ApiBadRequestResponse; | ||
|
||
@route("/producer") | ||
@doc("createProducerAcl") | ||
@operationId("createProducerAcl") | ||
@post | ||
createProducerAcl( | ||
@path clusterName: string, | ||
@body payload: CreateProducerAcl, | ||
): void | ApiBadRequestResponse; | ||
|
||
@route("/streamApp") | ||
@doc("createStreamAppAcl") | ||
@post | ||
@operationId("createStreamAppAcl") | ||
createStreamAppAcl( | ||
@path clusterName: string, | ||
@body payload: CreateStreamAppAcl, | ||
): void | ApiBadRequestResponse; | ||
} | ||
|
||
model KafkaAcl { | ||
resourceType: KafkaAclResourceType; | ||
resourceName: string; // "*" if acl can be applied to any resource of given type | ||
namePatternType: KafkaAclNamePatternType; | ||
principal: string; | ||
host: string; | ||
operation: KafkaAclOpeations; | ||
permission: "ALLOW" | "DENY"; | ||
} | ||
|
||
alias KafkaAclOpeations = | ||
"UNKNOWN" | ||
| "ALL" | ||
| "READ" | ||
| "WRITE" | ||
| "CREATE" | ||
| "DELETE" | ||
| "ALTER" | ||
| "DESCRIBE" | ||
| "CLUSTER_ACTION" | ||
| "DESCRIBE_CONFIGS" | ||
| "ALTER_CONFIGS" | ||
| "IDEMPOTENT_WRITE" | ||
| "CREATE_TOKENS" | ||
| "DESCRIBE_TOKENS"; | ||
|
||
enum KafkaAclResourceType { | ||
UNKNOWN, | ||
TOPIC, | ||
GROUP, | ||
CLUSTER, | ||
TRANSACTIONAL_ID, | ||
DELEGATION_TOKEN, | ||
USER, | ||
} | ||
|
||
enum KafkaAclNamePatternType { | ||
MATCH, | ||
LITERAL, | ||
PREFIXED, | ||
} | ||
|
||
model CreateConsumerAcl { | ||
principal: string; | ||
host: string; | ||
topics?: string[]; | ||
topicsPrefix?: string; | ||
consumerGroups?: string[]; | ||
consumerGroupsPrefix?: string; | ||
} | ||
|
||
model CreateProducerAcl { | ||
principal: string; | ||
host: string; | ||
topics?: string[]; | ||
topicsPrefix?: string; | ||
transactionalId?: string; | ||
transactionsIdPrefix?: string; | ||
idempotent?: boolean = false; | ||
} | ||
|
||
model CreateStreamAppAcl { | ||
principal: string; | ||
host: string; | ||
inputTopics: string[]; | ||
outputTopics: string[]; | ||
applicationId: string; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import "@typespec/openapi"; | ||
|
||
using TypeSpec.Http; | ||
using OpenAPI; | ||
|
||
@tag("Authorization") | ||
interface AuthorizationApi { | ||
@route("/api/authorization") | ||
@doc("Get user authorization related info") | ||
@operationId("getUserAuthInfo") | ||
@get | ||
getUserAuthInfo(): AuthenticationInfo; | ||
} | ||
|
||
@route("/login") | ||
@doc("Authenticate") | ||
@operationId("authenticate") | ||
@post | ||
op authenticate(@body form: LoginForm): void | Http.Response<401>; | ||
|
||
model LoginForm { | ||
username: string; | ||
password: string; | ||
} | ||
|
||
model AuthenticationInfo { | ||
rbacEnabled: boolean; // true if role based access control is enabled and granular permission access is required | ||
userInfo?: UserInfo; | ||
} | ||
|
||
model UserInfo { | ||
username: string; | ||
permissions: UserPermission[]; | ||
} | ||
|
||
|
||
model UserPermission { | ||
clusters: string[]; | ||
resource: ResourceType; | ||
value?: string; | ||
actions: Action[]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import "@typespec/openapi"; | ||
|
||
using TypeSpec.Http; | ||
using OpenAPI; | ||
|
||
@route("/api/clusters/{clusterName}/brokers") | ||
@tag("Brokers") | ||
interface BrokersApi { | ||
@get | ||
@operationId("getBrokers") | ||
@doc("getBrokers") | ||
getBrokers(@path clusterName: string): Broker[]; | ||
|
||
@get | ||
@route("/{id}/configs") | ||
@operationId("getBrokerConfig") | ||
@doc("getBrokerConfig") | ||
getBrokerConfig(@path clusterName: string, @path id: int32): BrokerConfig[]; | ||
|
||
@put | ||
@route("/{id}/configs/{name}") | ||
@operationId("updateBrokerConfigByName") | ||
@doc("updateBrokerConfigByName") | ||
updateBrokerConfigByName( | ||
@path clusterName: string, | ||
@path id: int32, | ||
@path name: string, | ||
@body config: BrokerConfigItem, | ||
): void | ApiBadRequestResponse; | ||
|
||
@get | ||
@route("/{id}/metrics") | ||
@operationId("getBrokersMetrics") | ||
@doc("getBrokersMetrics") | ||
getBrokersMetrics(@path clusterName: string, @path id: int32): BrokerMetrics; | ||
|
||
@get | ||
@route("/logdirs") | ||
@operationId("getAllBrokersLogdirs") | ||
@doc("getAllBrokersLogdirs") | ||
getAllBrokersLogdirs( | ||
@path clusterName: string, | ||
@query broker?: int32[], | ||
): BrokersLogdirs[]; | ||
|
||
@patch(#{implicitOptionality: true}) | ||
@route("/{id}/logdirs") | ||
@operationId("updateBrokerTopicPartitionLogDir") | ||
@doc("updateBrokerTopicPartitionLogDir") | ||
updateBrokerTopicPartitionLogDir( | ||
@path clusterName: string, | ||
@path id: int32, | ||
@body update: BrokerLogdirUpdate, | ||
): void | ApiBadRequestResponse; | ||
} | ||
|
||
model Broker { | ||
id: int32; | ||
host?: string; | ||
port?: int32; | ||
bytesInPerSec?: float64; | ||
bytesOutPerSec?: float64; | ||
partitionsLeader?: int32; | ||
partitions?: int32; | ||
inSyncPartitions?: int32; | ||
partitionsSkew?: float64; | ||
leadersSkew?: float64; | ||
} | ||
|
||
model BrokerLogdirUpdate { | ||
topic?: string; | ||
partition?: int32; | ||
logDir?: string; | ||
} | ||
|
||
model BrokerConfig { | ||
name: string; | ||
value: string; | ||
source: ConfigSource; | ||
isSensitive: boolean; | ||
isReadOnly: boolean; | ||
synonyms?: ConfigSynonym[]; | ||
} | ||
|
||
model BrokerConfigItem { | ||
value?: string; | ||
} | ||
|
||
model BrokerMetrics { | ||
segmentSize: int64; | ||
segmentCount: int32; | ||
metrics: Metric[]; | ||
} | ||
|
||
model BrokersLogdirs { | ||
name: string; | ||
error: string; | ||
topics: BrokerTopicLogdirs[]; | ||
} | ||
|
||
model BrokerTopicLogdirs { | ||
name?: string; | ||
partitions?: BrokerTopicPartitionLogdir[]; | ||
} | ||
|
||
model BrokerTopicPartitionLogdir extends TopicPartitionLogdir { | ||
broker?: int32; | ||
} | ||
|
||
model TopicPartitionLogdir { | ||
partition?: int32; | ||
size?: int64; | ||
offsetLag?: int64; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.