Skip to content
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

Feature/support all apis #3

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 86 additions & 245 deletions apis/admin_test.go

Large diffs are not rendered by default.

28 changes: 13 additions & 15 deletions apis/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ func NewArtifactsAPI(client *client.Client) *ArtifactsAPI {
}
}

var (
ErrArtifactNotFound = errors.New("artifact not found")
ErrMethodNotAllowed = errors.New("method not allowed or disabled on the server")
ErrInvalidInput = errors.New("input must be between 1 and 512 characters")
)

// GetArtifactByGlobalID Gets the content for an artifact version in the registry using its globally unique identifier.
// See https://schema-registry.dev.mollielabs.net/apis/registry/v3#operation/getContentByGlobalId
// See https://www.apicur.io/registry/docs/apicurio-registry/3.0.x/assets-attachments/registry-rest-api.htm#tag/Artifacts/operation/getContentByGlobalId
func (api *ArtifactsAPI) GetArtifactByGlobalID(ctx context.Context, globalID int64, params *models.GetArtifactByGlobalIDParams) (*models.ArtifactContent, error) {
returnArtifactType := false
query := ""
Expand Down Expand Up @@ -69,8 +63,8 @@ func (api *ArtifactsAPI) GetArtifactByGlobalID(ctx context.Context, globalID int

// SearchArtifacts - Search for artifacts using the given filter parameters.
// Search for artifacts using the given filter parameters.
// See https://schema-registry.dev.mollielabs.net/apis/registry/v3#operation/searchArtifacts
func (api *ArtifactsAPI) SearchArtifacts(ctx context.Context, params *models.SearchArtifactsParams) (*[]models.SearchedArtifact, error) {
// See https://www.apicur.io/registry/docs/apicurio-registry/3.0.x/assets-attachments/registry-rest-api.htm#tag/Artifacts/operation/searchArtifacts
func (api *ArtifactsAPI) SearchArtifacts(ctx context.Context, params *models.SearchArtifactsParams) ([]models.SearchedArtifact, error) {
query := ""
if params != nil {
if err := params.Validate(); err != nil {
Expand All @@ -90,13 +84,13 @@ func (api *ArtifactsAPI) SearchArtifacts(ctx context.Context, params *models.Sea
return nil, err
}

return &result.Artifacts, nil
return result.Artifacts, nil
}

// SearchArtifactsByContent searches for artifacts that match the provided content.
// Returns a paginated list of all artifacts with at least one version that matches the posted content.
// See https://www.apicur.io/registry/docs/apicurio-registry/3.0.x/assets-attachments/registry-rest-api.htm#tag/Artifacts/operation/searchArtifactsByContent
func (api *ArtifactsAPI) SearchArtifactsByContent(ctx context.Context, content []byte, params *models.SearchArtifactsByContentParams) (*[]models.SearchedArtifact, error) {
func (api *ArtifactsAPI) SearchArtifactsByContent(ctx context.Context, content []byte, params *models.SearchArtifactsByContentParams) ([]models.SearchedArtifact, error) {
// Convert params to query string
query := ""
if params != nil {
Expand All @@ -117,7 +111,7 @@ func (api *ArtifactsAPI) SearchArtifactsByContent(ctx context.Context, content [
return nil, err
}

return &result.Artifacts, nil
return result.Artifacts, nil
}

// ListArtifactReferences Returns a list containing all the artifact references using the artifact content ID.
Expand Down Expand Up @@ -164,7 +158,7 @@ func (api *ArtifactsAPI) ListArtifactReferencesByGlobalID(ctx context.Context, g

// ListArtifactReferencesByHash Returns a list containing all the artifact references using the artifact content hash.
// See https://www.apicur.io/registry/docs/apicurio-registry/3.0.x/assets-attachments/registry-rest-api.htm#tag/Artifacts/operation/referencesByContentHash
func (api *ArtifactsAPI) ListArtifactReferencesByHash(ctx context.Context, contentHash string) (*[]models.ArtifactReference, error) {
func (api *ArtifactsAPI) ListArtifactReferencesByHash(ctx context.Context, contentHash string) ([]models.ArtifactReference, error) {
url := fmt.Sprintf("%s/ids/contentHashes/%s/references", api.Client.BaseURL, contentHash)
resp, err := api.executeRequest(ctx, http.MethodGet, url, nil)
if err != nil {
Expand All @@ -176,7 +170,7 @@ func (api *ArtifactsAPI) ListArtifactReferencesByHash(ctx context.Context, conte
return nil, err
}

return &references, nil
return references, nil
}

// ListArtifactsInGroup lists all artifacts in a specified group.
Expand Down Expand Up @@ -295,7 +289,7 @@ func (api *ArtifactsAPI) DeleteArtifact(ctx context.Context, groupID, artifactId
if err != nil {
return err
}

return handleResponse(resp, http.StatusNoContent, nil)
}

Expand All @@ -306,6 +300,10 @@ func (api *ArtifactsAPI) CreateArtifact(ctx context.Context, groupId string, art
return nil, err
}

if err := artifact.Validate(); err != nil {
return nil, errors.Wrap(err, "invalid artifact provided")
}

query := ""
if params != nil {
if err := params.Validate(); err != nil {
Expand Down
Loading
Loading