mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-05 22:08:27 +00:00
mirror api: update documentation
This commit is contained in:
161
api/mirror.go
161
api/mirror.go
@@ -32,9 +32,10 @@ func getVerifier(keyRings []string) (pgp.Verifier, error) {
|
||||
}
|
||||
|
||||
// @Summary Get mirrors
|
||||
// @Description Show list of currently available mirrors. Each mirror is returned as in “show” API.
|
||||
// @Description **Show list of currently available mirrors**
|
||||
// @Description Each mirror is returned as in “show” API.
|
||||
// @Tags Mirrors
|
||||
// @Produce json
|
||||
// @Produce json
|
||||
// @Success 200 {array} deb.RemoteRepo
|
||||
// @Router /api/mirrors [get]
|
||||
func apiMirrorsList(c *gin.Context) {
|
||||
@@ -50,45 +51,49 @@ func apiMirrorsList(c *gin.Context) {
|
||||
c.JSON(200, result)
|
||||
}
|
||||
|
||||
type mirrorCreateParams struct {
|
||||
// Name of mirror to be created
|
||||
Name string `binding:"required" json:"Name" example:"mirror2"`
|
||||
// Url of the archive to mirror
|
||||
ArchiveURL string `binding:"required" json:"ArchiveURL" example:"http://deb.debian.org/debian"`
|
||||
// Distribution name to mirror
|
||||
Distribution string ` json:"Distribution" example:"'buster', for flat repositories use './'"`
|
||||
// Package query that is applied to mirror packages
|
||||
Filter string ` json:"Filter" example:"xserver-xorg"`
|
||||
// Components to mirror, if not specified aptly would fetch all components
|
||||
Components []string ` json:"Components" example:"main"`
|
||||
// Limit mirror to those architectures, if not specified aptly would fetch all architectures
|
||||
Architectures []string ` json:"Architectures" example:"amd64"`
|
||||
// Gpg keyring(s) for verifying Release file
|
||||
Keyrings []string ` json:"Keyrings" example:"trustedkeys.gpg"`
|
||||
// Set "true" to mirror source packages
|
||||
DownloadSources bool ` json:"DownloadSources"`
|
||||
// Set "true" to mirror udeb files
|
||||
DownloadUdebs bool ` json:"DownloadUdebs"`
|
||||
// Set "true" to mirror installer files
|
||||
DownloadInstaller bool ` json:"DownloadInstaller"`
|
||||
// Set "true" to include dependencies of matching packages when filtering
|
||||
FilterWithDeps bool ` json:"FilterWithDeps"`
|
||||
// Set "true" to skip if the given components are in the Release file
|
||||
SkipComponentCheck bool ` json:"SkipComponentCheck"`
|
||||
// Set "true" to skip the verification of architectures
|
||||
SkipArchitectureCheck bool ` json:"SkipArchitectureCheck"`
|
||||
// Set "true" to skip the verification of Release file signatures
|
||||
IgnoreSignatures bool ` json:"IgnoreSignatures"`
|
||||
}
|
||||
|
||||
// @Summary Create mirror
|
||||
// @Description Create empty mirror with specified parameters.
|
||||
// @Description **Create a mirror**
|
||||
// @Tags Mirrors
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Name query string true "mirror name"
|
||||
// @Param ArchiveURL query string true "url of the archive to mirror e.g. http://deb.debian.org/debian/"
|
||||
// @Param Distribution query string false "distribution name to mirror e.g. `buster`, for flat repositories use `./` instead of distribution name"
|
||||
// @Param Filter query string false "package query that is applied to packages in the mirror"
|
||||
// @Param Components query []string false "components to mirror, if not specified aptly would fetch all components"
|
||||
// @Param Architectures query []string false "limit mirror to those architectures, if not specified aptly would fetch all architectures"
|
||||
// @Param Keyrings query []string false "gpg keyring(s) to use when verifying `Release` file"
|
||||
// @Param DownloadSources query bool false "whether to mirror sources"
|
||||
// @Param DownloadUdebs query bool false "whether to mirror `.udeb` packages (Debian installer support)"
|
||||
// @Param DownloadInstaller query bool false "whether to download additional not packaged installer files"
|
||||
// @Param FilterWithDeps query bool false "when filtering, include dependencies of matching packages as well"
|
||||
// @Param SkipComponentCheck query bool false "whether to skip if the given components are in the `Release` file"
|
||||
// @Param IgnoreSignatures query bool false "whether to skip the verification of `Release` file signatures"
|
||||
// @Consume json
|
||||
// @Param request body mirrorCreateParams true "Parameters"
|
||||
// @Produce json
|
||||
// @Success 200 {object} deb.RemoteRepo
|
||||
// @Failure 400 {object} Error "Bad Request"
|
||||
// @Router /api/mirrors [post]
|
||||
func apiMirrorsCreate(c *gin.Context) {
|
||||
var err error
|
||||
var b struct {
|
||||
Name string `binding:"required"`
|
||||
ArchiveURL string `binding:"required"`
|
||||
Distribution string
|
||||
Filter string
|
||||
Components []string
|
||||
Architectures []string
|
||||
Keyrings []string
|
||||
DownloadSources bool
|
||||
DownloadUdebs bool
|
||||
DownloadInstaller bool
|
||||
FilterWithDeps bool
|
||||
SkipComponentCheck bool
|
||||
SkipArchitectureCheck bool
|
||||
IgnoreSignatures bool
|
||||
}
|
||||
var b mirrorCreateParams
|
||||
|
||||
b.DownloadSources = context.Config().DownloadSourcePackages
|
||||
b.IgnoreSignatures = context.Config().GpgDisableVerify
|
||||
@@ -155,12 +160,11 @@ func apiMirrorsCreate(c *gin.Context) {
|
||||
}
|
||||
|
||||
// @Summary Delete Mirror
|
||||
// @Description Delete a mirror
|
||||
// @Description **Delete a mirror**
|
||||
// @Tags Mirrors
|
||||
// @Consume json
|
||||
// @Produce json
|
||||
// @Param name path string true "mirror name"
|
||||
// @Param force query int true "force: 1 to enable"
|
||||
// @Produce json
|
||||
// @Success 200 {object} task.ProcessReturnValue
|
||||
// @Failure 404 {object} Error "Mirror not found"
|
||||
// @Failure 403 {object} Error "Unable to delete mirror with snapshots"
|
||||
@@ -205,11 +209,10 @@ func apiMirrorsDrop(c *gin.Context) {
|
||||
}
|
||||
|
||||
// @Summary Show Mirror
|
||||
// @Description Get mirror information by name
|
||||
// @Description **Get mirror information by name**
|
||||
// @Tags Mirrors
|
||||
// @Consume json
|
||||
// @Produce json
|
||||
// @Param name path string true "mirror name"
|
||||
// @Produce json
|
||||
// @Success 200 {object} deb.RemoteRepo
|
||||
// @Failure 404 {object} Error "Mirror not found"
|
||||
// @Failure 500 {object} Error "Internal Error"
|
||||
@@ -234,13 +237,12 @@ func apiMirrorsShow(c *gin.Context) {
|
||||
}
|
||||
|
||||
// @Summary List Mirror Packages
|
||||
// @Description Get a list of packages from a mirror
|
||||
// @Description **Get a list of packages from a mirror**
|
||||
// @Tags Mirrors
|
||||
// @Consume json
|
||||
// @Produce json
|
||||
// @Param name path string true "mirror name"
|
||||
// @Param q query string false "search query"
|
||||
// @Param format query string false "format: `details` for more detailed information"
|
||||
// @Produce json
|
||||
// @Success 200 {array} deb.Package "List of Packages"
|
||||
// @Failure 400 {object} Error "Unable to determine list of architectures"
|
||||
// @Failure 404 {object} Error "Mirror not found"
|
||||
@@ -323,26 +325,46 @@ func apiMirrorsPackages(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
type mirrorUpdateParams struct {
|
||||
// Change mirror name to `Name`
|
||||
Name string ` json:"Name" example:"mirror1"`
|
||||
// Url of the archive to mirror
|
||||
ArchiveURL string ` json:"ArchiveURL" example:"http://deb.debian.org/debian"`
|
||||
// Package query that is applied to mirror packages
|
||||
Filter string ` json:"Filter" example:"xserver-xorg"`
|
||||
// Limit mirror to those architectures, if not specified aptly would fetch all architectures
|
||||
Architectures []string ` json:"Architectures" example:"amd64"`
|
||||
// Components to mirror, if not specified aptly would fetch all components
|
||||
Components []string ` json:"Components" example:"main"`
|
||||
// Gpg keyring(s) for verifing Release file
|
||||
Keyrings []string ` json:"Keyrings" example:"trustedkeys.gpg"`
|
||||
// Set "true" to include dependencies of matching packages when filtering
|
||||
FilterWithDeps bool ` json:"FilterWithDeps"`
|
||||
// Set "true" to mirror source packages
|
||||
DownloadSources bool ` json:"DownloadSources"`
|
||||
// Set "true" to mirror udeb files
|
||||
DownloadUdebs bool ` json:"DownloadUdebs"`
|
||||
// Set "true" to skip checking if the given components are in the Release file
|
||||
SkipComponentCheck bool ` json:"SkipComponentCheck"`
|
||||
// Set "true" to skip checking if the given architectures are in the Release file
|
||||
SkipArchitectureCheck bool ` json:"SkipArchitectureCheck"`
|
||||
// Set "true" to ignore checksum errors
|
||||
IgnoreChecksums bool ` json:"IgnoreChecksums"`
|
||||
// Set "true" to skip the verification of Release file signatures
|
||||
IgnoreSignatures bool ` json:"IgnoreSignatures"`
|
||||
// Set "true" to force a mirror update even if another process is already updating the mirror (use with caution!)
|
||||
ForceUpdate bool ` json:"ForceUpdate"`
|
||||
// Set "true" to skip downloading already downloaded packages
|
||||
SkipExistingPackages bool ` json:"SkipExistingPackages"`
|
||||
}
|
||||
|
||||
// @Summary Update Mirror
|
||||
// @Description Update Mirror and download packages
|
||||
// @Description **Update Mirror and download packages**
|
||||
// @Tags Mirrors
|
||||
// @Consume json
|
||||
// @Produce json
|
||||
// @Param name path string true "mirror name to update"
|
||||
// @Param Name query string false "change mirror name"
|
||||
// @Param ArchiveURL query string false "ArchiveURL"
|
||||
// @Param Filter query string false "Filter"
|
||||
// @Param Architectures query []string false "Architectures"
|
||||
// @Param Components query []string false "Components"
|
||||
// @Param Keyrings query []string false "Keyrings"
|
||||
// @Param FilterWithDeps query bool false "FilterWithDeps"
|
||||
// @Param DownloadSources query bool false "DownloadSources"
|
||||
// @Param DownloadUdebs query bool false "DownloadUdebs"
|
||||
// @Param SkipComponentCheck query bool false "SkipComponentCheck"
|
||||
// @Param IgnoreChecksums query bool false "IgnoreChecksums"
|
||||
// @Param IgnoreSignatures query bool false "IgnoreSignatures"
|
||||
// @Param ForceUpdate query bool false "ForceUpdate"
|
||||
// @Param SkipExistingPackages query bool false "SkipExistingPackages"
|
||||
// @Consume json
|
||||
// @Param request body mirrorUpdateParams true "Parameters"
|
||||
// @Produce json
|
||||
// @Success 200 {object} task.ProcessReturnValue "Mirror was updated successfully"
|
||||
// @Success 202 {object} task.Task "Mirror is being updated"
|
||||
// @Failure 400 {object} Error "Unable to determine list of architectures"
|
||||
@@ -353,26 +375,9 @@ func apiMirrorsUpdate(c *gin.Context) {
|
||||
var (
|
||||
err error
|
||||
remote *deb.RemoteRepo
|
||||
b mirrorUpdateParams
|
||||
)
|
||||
|
||||
var b struct {
|
||||
Name string
|
||||
ArchiveURL string
|
||||
Filter string
|
||||
Architectures []string
|
||||
Components []string
|
||||
Keyrings []string
|
||||
FilterWithDeps bool
|
||||
DownloadSources bool
|
||||
DownloadUdebs bool
|
||||
SkipComponentCheck bool
|
||||
SkipArchitectureCheck bool
|
||||
IgnoreChecksums bool
|
||||
IgnoreSignatures bool
|
||||
ForceUpdate bool
|
||||
SkipExistingPackages bool
|
||||
}
|
||||
|
||||
collectionFactory := context.NewCollectionFactory()
|
||||
collection := collectionFactory.RemoteRepoCollection()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user