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

Fixes 3877: Add required fields for API spec requests #870

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3352,6 +3352,9 @@ const docTemplate = `{
"definitions": {
"api.AddUploadsRequest": {
"type": "object",
"required": [
"uploads"
],
"properties": {
"artifacts": {
"description": "List of created artifacts",
Expand Down Expand Up @@ -3411,6 +3414,9 @@ const docTemplate = `{
},
"api.CreateUploadRequest": {
"type": "object",
"required": [
"size"
],
"properties": {
"size": {
"description": "Size of the upload in bytes",
Expand Down Expand Up @@ -3488,6 +3494,9 @@ const docTemplate = `{
},
"api.FetchGPGKeyRequest": {
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "The url from which to download the GPG Key.",
Expand Down Expand Up @@ -3544,6 +3553,10 @@ const docTemplate = `{
},
"api.ListSnapshotByDateRequest": {
"type": "object",
"required": [
"date",
"repository_uuids"
],
"properties": {
"date": {
"description": "Exact date to search by.",
Expand Down Expand Up @@ -3753,6 +3766,9 @@ const docTemplate = `{
},
"api.RepositoryExportRequest": {
"type": "object",
"required": [
"repository_uuids"
],
"properties": {
"repository_uuids": {
"description": "List of repository uuids to export",
Expand Down Expand Up @@ -4021,6 +4037,10 @@ const docTemplate = `{
},
"api.RepositoryRequest": {
"type": "object",
"required": [
"name",
"origin"
],
"properties": {
"distribution_arch": {
"description": "Architecture to restrict client usage to",
Expand Down Expand Up @@ -4735,6 +4755,12 @@ const docTemplate = `{
},
"api.TemplateRequest": {
"type": "object",
"required": [
"arch",
"name",
"repository_uuids",
"version"
],
"properties": {
"arch": {
"description": "Architecture of the template",
Expand Down Expand Up @@ -4880,6 +4906,9 @@ const docTemplate = `{
},
"api.UUIDListRequest": {
"type": "object",
"required": [
"uuids"
],
"properties": {
"uuids": {
"type": "array",
Expand Down
29 changes: 29 additions & 0 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"type": "array"
}
},
"required": [
"uploads"
],
"type": "object"
},
"api.Artifact": {
Expand Down Expand Up @@ -67,6 +70,9 @@
"type": "integer"
}
},
"required": [
"size"
],
"type": "object"
},
"api.DetectRpmsRequest": {
Expand Down Expand Up @@ -144,6 +150,9 @@
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
},
"api.FetchGPGKeyResponse": {
Expand Down Expand Up @@ -207,6 +216,10 @@
"type": "array"
}
},
"required": [
"date",
"repository_uuids"
],
"type": "object"
},
"api.ListSnapshotByDateResponse": {
Expand Down Expand Up @@ -404,6 +417,9 @@
"type": "array"
}
},
"required": [
"repository_uuids"
],
"type": "object"
},
"api.RepositoryExportResponse": {
Expand Down Expand Up @@ -706,6 +722,10 @@
"type": "string"
}
},
"required": [
"name",
"origin"
],
"type": "object"
},
"api.RepositoryResponse": {
Expand Down Expand Up @@ -1388,6 +1408,12 @@
"type": "string"
}
},
"required": [
"arch",
"name",
"repository_uuids",
"version"
],
"type": "object"
},
"api.TemplateResponse": {
Expand Down Expand Up @@ -1507,6 +1533,9 @@
"type": "array"
}
},
"required": [
"uuids"
],
"type": "object"
},
"api.Upload": {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Links struct {
}

type UUIDListRequest struct {
UUIDs []string `json:"uuids"`
UUIDs []string `json:"uuids" validate:"required"`
}

type AdminTaskFilterData struct {
Expand Down
14 changes: 7 additions & 7 deletions pkg/api/pulp.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package api

type CreateUploadRequest struct {
Size int64 `json:"size"` // Size of the upload in bytes
Size int64 `json:"size" validate:"required"` // Size of the upload in bytes
}

type PulpUploadChunkRequest struct {
UploadHref string `param:"upload_href"` // Upload identifier
File string `form:"file"` // A chunk of the uploaded file
Sha256 string `form:"sha256"` // SHA-256 checksum of the chunk
UploadHref string `param:"upload_href" validate:"required"` // Upload identifier
File string `form:"file" validate:"required"` // A chunk of the uploaded file
Sha256 string `form:"sha256" validate:"required"` // SHA-256 checksum of the chunk
}

type FinishUploadRequest struct {
UploadHref string `param:"upload_href"` // Upload identifier
Sha256 string `json:"sha256"` // Expected SHA-256 checksum for the file
UploadHref string `param:"upload_href" validate:"required"` // Upload identifier
Sha256 string `json:"sha256" validate:"required"` // Expected SHA-256 checksum for the file
}

type TaskRequest struct {
TaskHref string `param:"task_href"` // Task identifier
TaskHref string `param:"task_href" validate:"required"` // Task identifier
}
29 changes: 14 additions & 15 deletions pkg/api/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ type RepositoryResponse struct {

// RepositoryRequest holds data received from request to create repository
type RepositoryRequest struct {
UUID *string `json:"uuid" readonly:"true" swaggerignore:"true"`
AccountID *string `json:"account_id" readonly:"true" swaggerignore:"true"` // Account ID of the owner
OrgID *string `json:"org_id" readonly:"true" swaggerignore:"true"` // Organization ID of the owner
Origin *string `json:"origin" readonly:"true"` // Origin of the repository
ContentType *string `json:"content_type" readonly:"true" swaggerignore:"true"` // Content Type (rpm) of the repository

Name *string `json:"name"` // Name of the remote yum repository
URL *string `json:"url"` // URL of the remote yum repository
DistributionVersions *[]string `json:"distribution_versions" example:"7,8"` // Versions to restrict client usage to
DistributionArch *string `json:"distribution_arch" example:"x86_64"` // Architecture to restrict client usage to
GpgKey *string `json:"gpg_key"` // GPG key for repository
MetadataVerification *bool `json:"metadata_verification"` // Verify packages
ModuleHotfixes *bool `json:"module_hotfixes"` // Disable modularity filtering on this repository
Snapshot *bool `json:"snapshot"` // Enable snapshotting and hosting of this repository
UUID *string `json:"uuid" readonly:"true" swaggerignore:"true"`
AccountID *string `json:"account_id" readonly:"true" swaggerignore:"true"` // Account ID of the owner
OrgID *string `json:"org_id" readonly:"true" swaggerignore:"true"` // Organization ID of the owner
Origin *string `json:"origin" readonly:"true" validate:"required"` // Origin of the repository
ContentType *string `json:"content_type" readonly:"true" swaggerignore:"true"` // Content Type (rpm) of the repository
Name *string `json:"name" validate:"required"` // Name of the remote yum repository
URL *string `json:"url"` // URL of the remote yum repository
DistributionVersions *[]string `json:"distribution_versions" example:"7,8"` // Versions to restrict client usage to
DistributionArch *string `json:"distribution_arch" example:"x86_64"` // Architecture to restrict client usage to
GpgKey *string `json:"gpg_key"` // GPG key for repository
MetadataVerification *bool `json:"metadata_verification"` // Verify packages
ModuleHotfixes *bool `json:"module_hotfixes"` // Disable modularity filtering on this repository
Snapshot *bool `json:"snapshot"` // Enable snapshotting and hosting of this repository
}

type RepositoryUpdateRequest struct {
Expand Down Expand Up @@ -151,7 +150,7 @@ type RepositoryIntrospectRequest struct {
}

type RepositoryExportRequest struct {
RepositoryUuids []string `json:"repository_uuids"` // List of repository uuids to export
RepositoryUuids []string `json:"repository_uuids" validate:"required"` // List of repository uuids to export
}

type RepositoryExportResponse struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/repository_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type FetchGPGKeyResponse struct {
}

type FetchGPGKeyRequest struct {
URL string `json:"url"` // The url from which to download the GPG Key.
URL string `json:"url" validate:"required"` // The url from which to download the GPG Key.
}

// RepositoryParameterResponse holds data returned by a repositories API response
Expand Down
14 changes: 7 additions & 7 deletions pkg/api/rpms.go
Andrewgdewar marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ type RepositoryRpmCollectionResponse struct {
}

type SnapshotErrataListRequest struct {
UUID string `param:"uuid"` // Identifier of the repository
Search string `query:"search"` // Errata Id to optionally filter-on
Type []string `query:"type"` // Type to optionally filter-on
Severity []string `query:"severity"` // Severity to optionally filter-on
UUID string `param:"uuid" validate:"required"` // Identifier of the repository
Search string `query:"search"` // Errata Id to optionally filter-on
Type []string `query:"type"` // Type to optionally filter-on
Severity []string `query:"severity"` // Severity to optionally filter-on
}

type SnapshotErrata struct {
Expand Down Expand Up @@ -59,9 +59,9 @@ type SnapshotRpmCollectionResponse struct {
}

type RepositoryRpmRequest struct {
UUID string `param:"uuid"` // Identifier of the repository
Search string `query:"search"` // Search string based query to optionally filter-on
SortBy string `query:"sort_by"` // SortBy sets the sort order of the result
UUID string `param:"uuid" validate:"required"` // Identifier of the repository
Search string `query:"search"` // Search string based query to optionally filter-on
SortBy string `query:"sort_by"` // SortBy sets the sort order of the result
}

type SearchRpmRequest struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type SnapshotResponse struct {
}

type ListSnapshotByDateRequest struct {
RepositoryUUIDS []string `json:"repository_uuids"` // Repository UUIDs to find snapshots for
Date Date `json:"date"` // Exact date to search by.
RepositoryUUIDS []string `json:"repository_uuids" validate:"required"` // Repository UUIDs to find snapshots for
Date Date `json:"date" validate:"required"` // Exact date to search by.
}

type Date time.Time
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

type TemplateRequest struct {
UUID *string `json:"uuid" readonly:"true" swaggerignore:"true"`
Name *string `json:"name"` // Name of the template
Name *string `json:"name" validate:"required"` // Name of the template
Description *string `json:"description"` // Description of the template
RepositoryUUIDS []string `json:"repository_uuids"` // Repositories to add to the template
Arch *string `json:"arch"` // Architecture of the template
Version *string `json:"version"` // Version of the template
RepositoryUUIDS []string `json:"repository_uuids" validate:"required"` // Repositories to add to the template
Arch *string `json:"arch" validate:"required"` // Architecture of the template
Version *string `json:"version" validate:"required"` // Version of the template
Date *EmptiableDate `json:"date"` // Latest date to include snapshots for
OrgID *string `json:"org_id" readonly:"true" swaggerignore:"true"` // Organization ID of the owner
User *string `json:"created_by" readonly:"true" swaggerignore:"true"` // User creating the template
Expand Down
10 changes: 5 additions & 5 deletions pkg/api/uploads.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package api
import "time"

type AddUploadsRequest struct {
Uploads []Upload `json:"uploads"` // List of unfinished uploads
Artifacts []Artifact `json:"artifacts"` // List of created artifacts
Uploads []Upload `json:"uploads" validate:"required"` // List of unfinished uploads
Artifacts []Artifact `json:"artifacts"` // List of created artifacts
}

type Upload struct {
Expand All @@ -19,9 +19,9 @@ type Artifact struct {
}

type UploadChunkRequest struct {
UploadUuid string `param:"upload_uuid"` // Upload UUID
File string `form:"file"` // A chunk of the uploaded file
Sha256 string `form:"sha256"` // SHA-256 checksum of the chunk
UploadUuid string `param:"upload_uuid" validate:"required"` // Upload UUID
File string `form:"file" validate:"required"` // A chunk of the uploaded file
Sha256 string `form:"sha256" validate:"required"` // SHA-256 checksum of the chunk
}

type UploadResponse struct {
Expand Down
Loading