Code Monkey home page Code Monkey logo

apicurio-registry-client-sdk-go's Introduction

Apicurio Registry Client SDK for Go

Apicurio Registry is a datastore for standard event schemas and API designs. Apicurio Registry enables developers to manage and share the structure of their data using a REST interface. For example, client applications can dynamically push or pull the latest updates to or from the registry without needing to redeploy. Apicurio Registry also enables developers to create rules that govern how registry content can evolve over time. For example, this includes rules for content validation and version compatibility.

The Apicurio Registry REST API enables client applications to manage the artifacts in the registry. This API provides create, read, update, and delete operations for schema and API artifacts, rules, versions, and metadata.

The supported artifact types include:

  • Apache Avro schema
  • AsyncAPI specification
  • Google protocol buffers
  • GraphQL schema
  • JSON Schema
  • Kafka Connect schema
  • OpenAPI specification
  • Web Services Description Language
  • XML Schema Definition

Important: The Apicurio Registry REST API is available from https://MY-REGISTRY-URL/apis/registry/v2 by default. Therefore you must prefix all API operation paths with ../apis/registry/v2 in this case. For example: ../apis/registry/v2/ids/globalIds/{globalId}.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

Installation

Install the client SDK library to your Go project:

go get github.com/Apicurio/apicurio-registry-client-sdk-go

Add the following import to use it:

import "github.com/Apicurio/apicurio-registry-client-sdk-go"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Creating an API client

To create an API client using the default configuration options:

cfg := registryclient.NewConfiguration()
registryClient := registryclient.NewAPIClient(&cfg)

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), registryclient.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), registryclient.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), registryclient.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), registryclient.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
AdminAPI CreateGlobalRule Post /admin/rules Create global rule
AdminAPI CreateRoleMapping Post /admin/roleMappings Create a new role mapping
AdminAPI DeleteAllGlobalRules Delete /admin/rules Delete all global rules
AdminAPI DeleteGlobalRule Delete /admin/rules/{rule} Delete global rule
AdminAPI DeleteRoleMapping Delete /admin/roleMappings/{principalId} Delete a role mapping
AdminAPI ExportData Get /admin/export Export registry data
AdminAPI GetConfigProperty Get /admin/config/properties/{propertyName} Get configuration property value
AdminAPI GetGlobalRuleConfig Get /admin/rules/{rule} Get global rule configuration
AdminAPI GetRoleMapping Get /admin/roleMappings/{principalId} Return a single role mapping
AdminAPI ImportData Post /admin/import Import registry data
AdminAPI ListArtifactTypes Get /admin/artifactTypes List artifact types
AdminAPI ListConfigProperties Get /admin/config/properties List all configuration properties
AdminAPI ListGlobalRules Get /admin/rules List global rules
AdminAPI ListRoleMappings Get /admin/roleMappings List all role mappings
AdminAPI ResetConfigProperty Delete /admin/config/properties/{propertyName} Reset a configuration property
AdminAPI UpdateConfigProperty Put /admin/config/properties/{propertyName} Update a configuration property
AdminAPI UpdateGlobalRuleConfig Put /admin/rules/{rule} Update global rule configuration
AdminAPI UpdateRoleMapping Put /admin/roleMappings/{principalId} Update a role mapping
ArtifactRulesAPI CreateArtifactRule Post /groups/{groupId}/artifacts/{artifactId}/rules Create artifact rule
ArtifactRulesAPI DeleteArtifactRule Delete /groups/{groupId}/artifacts/{artifactId}/rules/{rule} Delete artifact rule
ArtifactRulesAPI DeleteArtifactRules Delete /groups/{groupId}/artifacts/{artifactId}/rules Delete artifact rules
ArtifactRulesAPI GetArtifactRuleConfig Get /groups/{groupId}/artifacts/{artifactId}/rules/{rule} Get artifact rule configuration
ArtifactRulesAPI ListArtifactRules Get /groups/{groupId}/artifacts/{artifactId}/rules List artifact rules
ArtifactRulesAPI TestUpdateArtifact Put /groups/{groupId}/artifacts/{artifactId}/test Test update artifact
ArtifactRulesAPI UpdateArtifactRuleConfig Put /groups/{groupId}/artifacts/{artifactId}/rules/{rule} Update artifact rule configuration
ArtifactTypeAPI ListArtifactTypes Get /admin/artifactTypes List artifact types
ArtifactsAPI CreateArtifact Post /groups/{groupId}/artifacts Create artifact
ArtifactsAPI DeleteArtifact Delete /groups/{groupId}/artifacts/{artifactId} Delete artifact
ArtifactsAPI DeleteArtifactsInGroup Delete /groups/{groupId}/artifacts Delete artifacts in group
ArtifactsAPI GetContentByGlobalId Get /ids/globalIds/{globalId} Get artifact by global ID
ArtifactsAPI GetContentByHash Get /ids/contentHashes/{contentHash}/ Get artifact content by SHA-256 hash
ArtifactsAPI GetContentById Get /ids/contentIds/{contentId}/ Get artifact content by ID
ArtifactsAPI GetLatestArtifact Get /groups/{groupId}/artifacts/{artifactId} Get latest artifact
ArtifactsAPI ListArtifactsInGroup Get /groups/{groupId}/artifacts List artifacts in group
ArtifactsAPI ReferencesByContentHash Get /ids/contentHashes/{contentHash}/references List artifact references by hash
ArtifactsAPI ReferencesByContentId Get /ids/contentIds/{contentId}/references List artifact references by content ID
ArtifactsAPI ReferencesByGlobalId Get /ids/globalIds/{globalId}/references List artifact references by global ID
ArtifactsAPI SearchArtifacts Get /search/artifacts Search for artifacts
ArtifactsAPI SearchArtifactsByContent Post /search/artifacts Search for artifacts by content
ArtifactsAPI UpdateArtifact Put /groups/{groupId}/artifacts/{artifactId} Update artifact
ArtifactsAPI UpdateArtifactState Put /groups/{groupId}/artifacts/{artifactId}/state Update artifact state
GroupsAPI CreateGroup Post /groups Create a new group
GroupsAPI DeleteGroupById Delete /groups/{groupId} Delete a group by the specified ID.
GroupsAPI GetGroupById Get /groups/{groupId} Get a group by the specified ID.
GroupsAPI ListGroups Get /groups List groups
MetadataAPI DeleteArtifactVersionMetaData Delete /groups/{groupId}/artifacts/{artifactId}/versions/{version}/meta Delete artifact version metadata
MetadataAPI GetArtifactMetaData Get /groups/{groupId}/artifacts/{artifactId}/meta Get artifact metadata
MetadataAPI GetArtifactOwner Get /groups/{groupId}/artifacts/{artifactId}/owner Get artifact owner
MetadataAPI GetArtifactVersionMetaData Get /groups/{groupId}/artifacts/{artifactId}/versions/{version}/meta Get artifact version metadata
MetadataAPI GetArtifactVersionMetaDataByContent Post /groups/{groupId}/artifacts/{artifactId}/meta Get artifact version metadata by content
MetadataAPI UpdateArtifactMetaData Put /groups/{groupId}/artifacts/{artifactId}/meta Update artifact metadata
MetadataAPI UpdateArtifactOwner Put /groups/{groupId}/artifacts/{artifactId}/owner Update artifact owner
MetadataAPI UpdateArtifactVersionMetaData Put /groups/{groupId}/artifacts/{artifactId}/versions/{version}/meta Update artifact version metadata
SystemAPI GetResourceLimits Get /system/limits Get resource limits information
SystemAPI GetSystemInfo Get /system/info Get system information
UsersAPI GetCurrentUserInfo Get /users/me Get current user
VersionsAPI AddArtifactVersionComment Post /groups/{groupId}/artifacts/{artifactId}/versions/{version}/comments Add new comment
VersionsAPI CreateArtifactVersion Post /groups/{groupId}/artifacts/{artifactId}/versions Create artifact version
VersionsAPI DeleteArtifactVersion Delete /groups/{groupId}/artifacts/{artifactId}/versions/{version} Delete artifact version
VersionsAPI DeleteArtifactVersionComment Delete /groups/{groupId}/artifacts/{artifactId}/versions/{version}/comments/{commentId} Delete a single comment
VersionsAPI GetArtifactVersion Get /groups/{groupId}/artifacts/{artifactId}/versions/{version} Get artifact version
VersionsAPI GetArtifactVersionComments Get /groups/{groupId}/artifacts/{artifactId}/versions/{version}/comments Get artifact version comments
VersionsAPI GetArtifactVersionReferences Get /groups/{groupId}/artifacts/{artifactId}/versions/{version}/references Get artifact version references
VersionsAPI ListArtifactVersions Get /groups/{groupId}/artifacts/{artifactId}/versions List artifact versions
VersionsAPI UpdateArtifactVersionComment Put /groups/{groupId}/artifacts/{artifactId}/versions/{version}/comments/{commentId} Update a comment
VersionsAPI UpdateArtifactVersionState Put /groups/{groupId}/artifacts/{artifactId}/versions/{version}/state Update artifact version state

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

[email protected]

apicurio-registry-client-sdk-go's People

Contributors

apicurio-ci avatar carlesarnal avatar craicoverflow avatar ericwittmann avatar matthyx avatar riprasad avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apicurio-registry-client-sdk-go's Issues

Duplicate API clients are generated for endpoints which have multiple tags

OpenAPI Generator for Go generates separate clients for each tag defined. If an endpoint has more than one tag the same code will be generated twice in each client. This is a problem in Go as all the generated code is defined in the same package, so it causes conflicts and won't compile.

method Limit already declared for type ApiSearchArtifactsRequest struct{ctx context.Context; ApiService *ArtifactsApiService; name *string; offset *int32; limit *int32; order *SortOrder; orderby *SortBy; labels *[]string; properties *[]string; description *string; group *string} (see details)compiler[DuplicateDecl](https://pkg.go.dev/golang.org/x/tools/internal/typesinternal?utm_source%3Dgopls#DuplicateDecl)
[api_search.go(57, 36): ]()method Limit already declared for type ApiSearchArtifactsRequest struct{ctx context.Context; ApiService *ArtifactsApiService; name *string; offset *int32; limit *int32; order *SortOrder; orderby *SortBy; labels *[]string; properties *[]string; description *string; group *string}

There are two places where "Search" and "Artifacts" are defined together:

Creating an artifact fails if the groupID doesn't exist

CreateArtifact requires a groupID to create an artifact, but accessing /groups/{groupID}/artifacts fails if the group doesn't already exist.

{"message":"RESTEASY003210: Could not find resource for full path: http://localhost:8080/groups/schemaGroupID/artifacts","error_code":404,"detail":"NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/groups/schemaGroupID/artifacts","name":"NotFoundException"}

There's no API call available to create a group, and the REST API doesn't have a CreateGroup endpoint documented.

Unable to parse time returned from API call

Attempting to use generated client and ArtifactsApi.CreateArtifact fails attempting to parse the timestamps in the response. The artifact is was created, but if I attempt MetadataApi.GetArtifactMetaData on that artifact I get similar error.

parsing time "\"2022-02-14T21:31:10+0000\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse "+0000\

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.