diff --git a/Taskfile.yml b/Taskfile.yml index 5feea90..77889ec 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,11 +15,11 @@ tasks: cmds: - rm -rf {{.GEN_OUT_DIR}} - GEN_OUT_DIR={{.GEN_OUT_DIR}} go run -tags=generator ./generator/... + - task: fmt-imports generate: cmds: - task: get-openapi-spec - task: go-generate - - task: fmt-imports test: cmds: - go test -v ./... diff --git a/handler/kafkaschemaregistry/kafkaschemaregistry.go b/handler/kafkaschemaregistry/kafkaschemaregistry.go index 6f3b181..211beeb 100644 --- a/handler/kafkaschemaregistry/kafkaschemaregistry.go +++ b/handler/kafkaschemaregistry/kafkaschemaregistry.go @@ -68,7 +68,7 @@ type Handler interface { // ServiceSchemaRegistrySubjectVersionGet get Schema Registry Subject version // GET /v1/project/{project}/service/{service_name}/kafka/schema/subjects/{subject_name}/versions/{version_id} // https://api.aiven.io/doc/#tag/Service:_Kafka/operation/ServiceSchemaRegistrySubjectVersionGet - ServiceSchemaRegistrySubjectVersionGet(ctx context.Context, project string, serviceName string, subjectName string, versionId int) error + ServiceSchemaRegistrySubjectVersionGet(ctx context.Context, project string, serviceName string, subjectName string, versionId int) (*ServiceSchemaRegistrySubjectVersionGetOut, error) // ServiceSchemaRegistrySubjectVersionPost register a new Schema in Schema Registry // POST /v1/project/{project}/service/{service_name}/kafka/schema/subjects/{subject_name}/versions @@ -222,10 +222,18 @@ func (h *KafkaSchemaRegistryHandler) ServiceSchemaRegistrySubjectVersionDelete(c _, err := h.doer.Do(ctx, "ServiceSchemaRegistrySubjectVersionDelete", "DELETE", path, nil) return err } -func (h *KafkaSchemaRegistryHandler) ServiceSchemaRegistrySubjectVersionGet(ctx context.Context, project string, serviceName string, subjectName string, versionId int) error { +func (h *KafkaSchemaRegistryHandler) ServiceSchemaRegistrySubjectVersionGet(ctx context.Context, project string, serviceName string, subjectName string, versionId int) (*ServiceSchemaRegistrySubjectVersionGetOut, error) { path := fmt.Sprintf("/v1/project/%s/service/%s/kafka/schema/subjects/%s/versions/%d", url.PathEscape(project), url.PathEscape(serviceName), url.PathEscape(subjectName), versionId) - _, err := h.doer.Do(ctx, "ServiceSchemaRegistrySubjectVersionGet", "GET", path, nil) - return err + b, err := h.doer.Do(ctx, "ServiceSchemaRegistrySubjectVersionGet", "GET", path, nil) + if err != nil { + return nil, err + } + out := new(serviceSchemaRegistrySubjectVersionGetOut) + err = json.Unmarshal(b, out) + if err != nil { + return nil, err + } + return &out.Version, nil } func (h *KafkaSchemaRegistryHandler) ServiceSchemaRegistrySubjectVersionPost(ctx context.Context, project string, serviceName string, subjectName string, in *ServiceSchemaRegistrySubjectVersionPostIn) (int, error) { path := fmt.Sprintf("/v1/project/%s/service/%s/kafka/schema/subjects/%s/versions", url.PathEscape(project), url.PathEscape(serviceName), url.PathEscape(subjectName)) @@ -345,6 +353,15 @@ type ServiceSchemaRegistrySubjectConfigPutIn struct { Compatibility CompatibilityType `json:"compatibility"` // Configuration } +// ServiceSchemaRegistrySubjectVersionGetOut Version +type ServiceSchemaRegistrySubjectVersionGetOut struct { + Id int `json:"id"` // Version + Schema string `json:"schema"` + SchemaType SchemaType `json:"schemaType,omitempty"` // Schema type + Subject string `json:"subject"` + Version int `json:"version"` +} + // ServiceSchemaRegistrySubjectVersionPostIn ServiceSchemaRegistrySubjectVersionPostRequestBody type ServiceSchemaRegistrySubjectVersionPostIn struct { References *[]ReferenceIn `json:"references,omitempty"` // Schema references @@ -392,6 +409,11 @@ type serviceSchemaRegistrySubjectConfigPutOut struct { Compatibility CompatibilityType `json:"compatibility"` // Configuration } +// serviceSchemaRegistrySubjectVersionGetOut ServiceSchemaRegistrySubjectVersionGetResponse +type serviceSchemaRegistrySubjectVersionGetOut struct { + Version ServiceSchemaRegistrySubjectVersionGetOut `json:"version"` // Version +} + // serviceSchemaRegistrySubjectVersionPostOut ServiceSchemaRegistrySubjectVersionPostResponse type serviceSchemaRegistrySubjectVersionPostOut struct { Id int `json:"id"` // Version