Documentation
¶
Overview ¶
Package API is used to make the functions related to each endpoints.
Index ¶
- Constants
- func AddOidcClient(c *gin.Context)
- func CreateLicense(c *gin.Context)
- func CreateObligation(c *gin.Context)
- func CreateObligationClassification(c *gin.Context)
- func CreateObligationType(c *gin.Context)
- func DeleteObligation(c *gin.Context)
- func DeleteObligationClassification(c *gin.Context)
- func DeleteObligationType(c *gin.Context)
- func ExportLicenses(c *gin.Context)
- func ExportObligations(c *gin.Context)
- func FilterLicense(c *gin.Context)
- func GetAPICollection(c *gin.Context)
- func GetAllAudit(c *gin.Context)
- func GetAllLicensePreviews(c *gin.Context)
- func GetAllObligation(c *gin.Context)
- func GetAllObligationClassification(c *gin.Context)
- func GetAllObligationPreviews(c *gin.Context)
- func GetAllObligationType(c *gin.Context)
- func GetAudit(c *gin.Context)
- func GetChangeLogbyId(c *gin.Context)
- func GetChangeLogs(c *gin.Context)
- func GetDashboardData(c *gin.Context)
- func GetHealth(c *gin.Context)
- func GetLicense(c *gin.Context)
- func GetObligation(c *gin.Context)
- func GetObligationAudits(c *gin.Context)
- func GetObligationMapByLicenseId(c *gin.Context)
- func GetObligationMapByObligationId(c *gin.Context)
- func GetUserOidcClients(c *gin.Context)
- func HandleInvalidUrl(c *gin.Context)
- func ImportLicenses(c *gin.Context)
- func ImportObligations(c *gin.Context)
- func PatchObligationMap(c *gin.Context)
- func RevokeClient(c *gin.Context)
- func Router() *gin.Engine
- func SearchInLicense(c *gin.Context)
- func UpdateLicense(c *gin.Context)
- func UpdateLicenseInObligationMap(c *gin.Context)
- func UpdateObligation(c *gin.Context)
Constants ¶
const ( DEFAULT_PORT = "8080" DEFAULT_READ_API_AUTHENTICATION_ENABLED = false )
Variables ¶
This section is empty.
Functions ¶
func AddOidcClient ¶
AddOidcClient adds a new oidc client.
@Summary Adds a new oidc client
@Description Add a new client for initiating M2M flow with fossology
@Id CreateOidcClient
@Tags OIDC Clients
@Accept json
@Produce json
@Param oidc_client body models.CreateDeleteOidcClientDTO true "Oidc client to add"
@Success 201 {object} models.OidcClientsResponse
@Failure 400 {object} models.LicenseError "invalid json body"
@Failure 409 {object} models.LicenseError "oidc client already exists"
@Failure 500 {object} models.LicenseError "something went wrong while adding new oidc client"
@Security ApiKeyAuth
@Router /oidcClients [post]
func CreateLicense ¶
CreateLicense creates a new license in the database.
@Summary Create a new license
@Description Create a new license in the service
@Id CreateLicense
@Tags Licenses
@Accept json
@Produce json
@Param license body models.LicenseCreateDTO true "New license to be created"
@Success 201 {object} models.LicenseResponse "New license created successfully"
@Failure 400 {object} models.LicenseError "Invalid request body"
@Failure 500 {object} models.LicenseError "Failed to create license"
@Security ApiKeyAuth
@Router /licenses [post]
func CreateObligation ¶
CreateObligation creates a new obligation record and associates it with relevant licenses.
@Summary Create an obligation
@Description Create an obligation and associate it with licenses
@Id CreateObligation
@Tags Obligations
@Accept json
@Produce json
@Param obligation body models.ObligationCreateDTO true "Obligation to create"
@Success 201 {object} models.ObligationResponse
@Failure 400 {object} models.LicenseError "Bad request body"
@Failure 500 {object} models.LicenseError "Unable to create obligation"
@Security ApiKeyAuth
@Router /obligations [post]
func CreateObligationClassification ¶
CreateObligationClassification creates a new obligation classification.
@Summary Create an obligation classification
@Description Create an obligation classification
@Id CreateObligationClassification
@Tags Obligations
@Accept json
@Produce json
@Param obligation_classification body models.ObligationClassification true "Obligation classification to create"
@Success 201 {object} models.ObligationClassificationResponse
@Failure 400 {object} models.LicenseError "invalid json body"
@Failure 409 {object} models.LicenseError "obligation classification already exists"
@Failure 500 {object} models.LicenseError "something went wrong while creating new obligation classification"
@Security ApiKeyAuth
@Router /obligations/classifications [post]
func CreateObligationType ¶
CreateObligationType creates a new obligation type.
@Summary Create an obligation type
@Description Create an obligation type
@Id CreateObligationType
@Tags Obligations
@Accept json
@Produce json
@Param obligation_type body models.ObligationType true "Obligation type to create"
@Success 201 {object} models.ObligationTypeResponse
@Failure 400 {object} models.LicenseError "invalid json body"
@Failure 409 {object} models.LicenseError "obligation type already exists"
@Failure 500 {object} models.LicenseError "something went wrong while creating new obligation type"
@Security ApiKeyAuth
@Router /obligations/types [post]
func DeleteObligation ¶
DeleteObligation marks an existing obligation record as inactive
@Summary Deactivate obligation
@Description Deactivate an obligation
@Id DeleteObligation
@Tags Obligations
@Accept json
@Produce json
@Param id path string true "Id of the obligation to be updated"
@Success 204
@Failure 404 {object} models.LicenseError "No obligation with given id found"
@Security ApiKeyAuth
@Router /obligations/{id} [delete]
func DeleteObligationClassification ¶
DeleteObligationClassification marks an existing obligation classification record as inactive
@Summary Deactivate obligation classification
@Description Deactivate an obligation classification
@Id DeleteObligationClassification
@Tags Obligations
@Accept json
@Produce json
@Param classification path string true "Obligation Classification"
@Success 200
@Failure 400 {object} models.LicenseError "cannot delete obligation classification 'GREEN' as it's still referenced by some obligations"
@Failure 404 {object} models.LicenseError "obligation classification 'GREEN' not found"
@Failure 500 {object} models.LicenseError "something went wrong while deleting obligation classification"
@Security ApiKeyAuth
@Router /obligations/classifications/{classification} [delete]
func DeleteObligationType ¶
DeleteObligationType marks an existing obligation type record as inactive
@Summary Deactivate obligation type
@Description Deactivate an obligation type
@Id DeleteObligationType
@Tags Obligations
@Accept json
@Produce json
@Param type path string true "Obligation Type"
@Success 200
@Failure 400 {object} models.LicenseError "cannot delete obligation type 'RISK' as it's still referenced by some obligations"
@Failure 404 {object} models.LicenseError "obligation type 'RISK' not found"
@Failure 500 {object} models.LicenseError "something went wrong while deleting obligation type"
@Security ApiKeyAuth
@Router /obligations/types/{type} [delete]
func ExportLicenses ¶
ExportLicenses gives users all licenses as a json file.
@Summary Export all licenses as a json file
@Description Export all licenses as a json file
@Id ExportLicenses
@Tags Licenses
@Produce json
@Success 200 {array} models.LicenseResponseDTO
@Failure 500 {object} models.LicenseError "Failed to fetch Licenses"
@Security ApiKeyAuth || {}
@Router /licenses/export [get]
func ExportObligations ¶
ExportObligations gives users all obligations as a json file.
@Summary Export all obligations as a json file
@Description Export all obligations as a json file
@Id ExportObligations
@Tags Obligations
@Produce json
@Success 200 {array} models.ObligationResponseDTO
@Failure 500 {object} models.LicenseError "Failed to fetch obligations"
@Security ApiKeyAuth || {}
@Router /obligations/export [get]
func FilterLicense ¶
FilterLicense Get licenses from service based on different filters.
@Summary Filter licenses
@Description Filter licenses based on different parameters
@Id FilterLicense
@Tags Licenses
@Accept json
@Produce json
@Param spdxid query string false "SPDX ID of the license"
@Param active query bool false "Active license only"
@Param osiapproved query bool false "OSI Approved flag status of license"
@Param copyleft query bool false "Copyleft flag status of license"
@Param page query int false "Page number"
@Param limit query int false "Limit of responses per page"
@Param externalRef query string false "External reference parameters"
@Param sort_by query string false "Sort by field" Enums(spdx_id, shortname, fullname) default(shortname)
@Param order_by query string false "Asc or desc ordering" Enums(asc, desc) default(asc)
@Success 200 {object} models.LicenseResponse "Filtered licenses"
@Failure 400 {object} models.LicenseError "Invalid value"
@Security ApiKeyAuth || {}
@Router /licenses [get]
func GetAPICollection ¶
The GetAPICollection function returns the apis which require authentication and which do not
@Summary Returns the apis which require authentication and which do not
@Description Returns the apis which require authentication and which do not
@Id getAPICollection
@Tags API Collection
@Accept json
@Produce json
@Success 200 {object} models.APICollectionResponse
@Failure 500 {object} models.LicenseError "Unable to parse swagger docs"
@Router /apiCollection [get]
func GetAllAudit ¶
GetAllAudit retrieves a list of all audit records from the database
@Summary Get audit records
@Description Get all audit records from the server
@Id GetAllAudit
@Tags Audits
@Accept json
@Produce json
@Param page query int false "Page number"
@Param limit query int false "Number of records per page"
@Success 200 {object} models.AuditResponse "Audit records"
@Failure 404 {object} models.LicenseError "Not changelogs in DB"
@Security ApiKeyAuth || {}
@Router /audits [get]
func GetAllLicensePreviews ¶
GetAllLicensePreviews retrieves a list of shortnames and ids of all licenses
@Summary Get shortnames and ids of all active licenses
@Description Get shortnames and ids of all active licenses from the service
@Id GetAllLicensePreviews
@Tags Licenses
@Accept json
@Produce json
@Param active query bool true "Active license only"
@Success 200 {object} models.LicensePreviewResponse
@Failure 400 {object} models.LicenseError "Invalid active value"
@Failure 500 {object} models.LicenseError "Unable to fetch licenses"
@Security ApiKeyAuth || {}
@Router /licenses/preview [get]
func GetAllObligation ¶
GetAllObligation retrieves a list of all obligation records
@Summary Get all active obligations
@Description Get all active obligations from the service
@Id GetAllObligation
@Tags Obligations
@Accept json
@Produce json
@Param active query bool true "Active obligation only"
@Param page query int false "Page number"
@Param limit query int false "Number of records per page"
@Param order_by query string false "Asc or desc ordering" Enums(asc, desc) default(asc)
@Success 200 {object} models.ObligationResponse
@Failure 400 {object} models.LicenseError "Invalid active value"
@Failure 500 {object} models.LicenseError "Internal server error"
@Security ApiKeyAuth || {}
@Router /obligations [get]
func GetAllObligationClassification ¶
GetAllObligationClassification retrieves a list of all obligation classifications
@Summary Get all active obligation classifications
@Description Get all active obligation classifications from the service
@Id GetAllObligationClassification
@Tags Obligations
@Accept json
@Produce json
@Param active query bool true "Active obligation classification only"
@Success 200 {object} models.ObligationClassificationResponse
@Failure 404 {object} models.LicenseError "No obligation classifications in DB"
@Security ApiKeyAuth || {}
@Router /obligations/classifications [get]
func GetAllObligationPreviews ¶
GetAllObligationPreviews retrieves a list of topics and types of all obligations
@Summary Get topic and types of all active obligations
@Description Get topic and type of all active obligations from the service
@Id GetAllObligationPreviews
@Tags Obligations
@Accept json
@Produce json
@Param active query bool true "Active obligation only"
@Success 200 {object} models.ObligationPreviewResponse
@Security ApiKeyAuth || {}
@Router /obligations/preview [get]
func GetAllObligationType ¶
GetAllObligationType retrieves a list of all obligation types
@Summary Get all active obligation types
@Description Get all active obligation types from the service
@Id GetAllObligationType
@Tags Obligations
@Accept json
@Produce json
@Param active query bool true "Active obligation type only"
@Success 200 {object} models.ObligationTypeResponse
@Failure 404 {object} models.LicenseError "No obligation types in DB"
@Security ApiKeyAuth || {}
@Router /obligations/types [get]
func GetAudit ¶
GetAudit retrieves a specific audit record by its ID from the database
@Summary Get an audit record
@Description Get a specific audit records by ID
@Id GetAudit
@Tags Audits
@Accept json
@Produce json
@Param audit_id path string true "Audit ID"
@Success 200 {object} models.AuditResponse
@Failure 400 {object} models.LicenseError "Invalid audit ID"
@Failure 404 {object} models.LicenseError "No audit entry with given ID"
@Security ApiKeyAuth || {}
@Router /audits/{audit_id} [get]
func GetChangeLogbyId ¶
GetChangeLogbyId retrieves a specific change history record by its ID for a given audit.
@Summary Get a changelog
@Description Get a specific changelog of an audit record by its ID
@Id GetChangeLogbyId
@Tags Audits
@Accept json
@Produce json
@Param audit_id path string true "Audit ID"
@Param id path string true "Changelog ID"
@Success 200 {object} models.ChangeLogResponse
@Failure 400 {object} models.LicenseError "Invalid ID"
@Failure 404 {object} models.LicenseError "No changelog with given ID found"
@Security ApiKeyAuth || {}
@Router /audits/{audit_id}/changes/{id} [get]
func GetChangeLogs ¶
GetChangeLogs retrieves a list of change history records associated with a specific audit
@Summary Get changelogs
@Description Get changelogs of an audit record
@Id GetChangeLogs
@Tags Audits
@Accept json
@Produce json
@Param audit_id path string true "Audit ID"
@Success 200 {object} models.ChangeLogResponse
@Failure 400 {object} models.LicenseError "Invalid audit ID"
@Failure 404 {object} models.LicenseError "No audit entry with given ID"
@Failure 500 {object} models.LicenseError "unable to find changes"
@Security ApiKeyAuth || {}
@Router /audits/{audit_id}/changes [get]
func GetDashboardData ¶
GetDashboardData fetches data to be displayed on the dashboard
@Summary Fetches data to be displayed on the dashboard
@Description Fetches data to be displayed on the dashboard
@Id GetDashboardData
@Tags Dashboard
@Accept json
@Produce json
@Success 200 {object} models.DashboardResponse
@Failure 500 {object} models.LicenseError "Something went wrong"
@Security ApiKeyAuth || {}
@Router /dashboard [get]
func GetHealth ¶
The GetHealth function returns if the DB is running and connected.
@Summary Check health
@Description Check health of the service
@Id getHealth
@Tags Health
@Accept json
@Produce json
@Success 200 {object} models.LicenseError "Heath is OK"
@Failure 500 {object} models.LicenseError "Connection to DB failed"
@Router /health [get]
func GetLicense ¶
GetLicense to get a single license by its id
@Summary Get a license by id
@Description Get a single license by its id
@Id GetLicense
@Tags Licenses
@Accept json
@Produce json
@Param id path string true "Id of the license"
@Success 200 {object} models.LicenseResponse
@Failure 404 {object} models.LicenseError "License with id not found"
@Security ApiKeyAuth || {}
@Router /licenses/{id} [get]
func GetObligation ¶
GetObligation retrieves an active obligation record
@Summary Get an obligation
@Description Get an active based on given id
@Id GetObligation
@Tags Obligations
@Accept json
@Produce json
@Param id path string true "Id of the obligation"
@Success 200 {object} models.ObligationResponse
@Failure 404 {object} models.LicenseError "No obligation with given id found"
@Security ApiKeyAuth || {}
@Router /obligations/{id} [get]
func GetObligationAudits ¶
GetObligationAudits fetches audits corresponding to an obligation
@Summary Fetches audits corresponding to an obligation
@Description Fetches audits corresponding to an obligation
@Id GetObligationAudits
@Tags Obligations
@Accept json
@Produce json
@Param id path string true "Id of the obligation for which audits need to be fetched"
@Param page query int false "Page number"
@Param limit query int false "Number of records per page"
@Success 200 {object} models.AuditResponse
@Failure 404 {object} models.LicenseError "No obligation with given id found"
@Failure 500 {object} models.LicenseError "unable to find audits with such obligation id"
@Security ApiKeyAuth || {}
@Router /obligations/{id}/audits [get]
func GetObligationMapByLicenseId ¶
GetObligationMapByLicenseId retrieves obligation maps for given license id
@Summary Get maps for a license
@Description Get obligation maps for a given license id
@Id GetObligationMapByLicenseId
@Tags Obligations
@Accept json
@Produce json
@Param license path string true "id of the license"
@Success 200 {object} models.ObligationMapResponse
@Failure 404 {object} models.LicenseError "No license with given id found"
@Security ApiKeyAuth || {}
@Router /obligation_maps/license/{id} [get]
func GetObligationMapByObligationId ¶
GetObligationMapByObligationId retrieves obligation maps for a given obligation id
@Summary Get maps for an obligation
@Description Get obligation maps for a given obligation id
@Id GetObligationMapByObligationId
@Tags Obligations
@Accept json
@Produce json
@Param id path string true "Id of the obligation"
@Success 200 {object} models.ObligationMapResponse
@Failure 404 {object} models.LicenseError "No obligation with given id found"
@Security ApiKeyAuth || {}
@Router /obligation_maps/obligation/{id} [get]
func GetUserOidcClients ¶
GetUserOidcClients retrieves a list of all oidc clients added by the user
@Summary Get all oidc clients added by the user
@Description Get all oidc clients added by the user for initiating M2M flow with fossology
@Id GetUserOidcClients
@Tags OIDC Clients
@Produce json
@Success 200 {object} models.OidcClientsResponse
@Failure 500 {object} models.LicenseError "Something went wrong"
@Security ApiKeyAuth
@Router /oidcClients [get]
func HandleInvalidUrl ¶
The HandleInvalidUrl function returns the error when an invalid url is entered
func ImportLicenses ¶
ImportLicenses creates new licenses records via a json file.
@Summary Import licenses by uploading a json file
@Description Import licenses by uploading a json file
@Id ImportLicenses
@Tags Licenses
@Accept multipart/form-data
@Produce json
@Param file formData file true "licenses json file list"
@Success 200 {object} models.ImportLicensesResponse{data=[]models.LicenseImportStatus}
@Failure 400 {object} models.LicenseError "input file must be present"
@Failure 500 {object} models.LicenseError "Internal server error"
@Security ApiKeyAuth
@Router /licenses/import [post]
func ImportObligations ¶
ImportObligations creates new obligation records via a json file.
@Summary Import obligations by uploading a json file
@Description Import obligations by uploading a json file
@Id ImportObligations
@Tags Obligations
@Accept multipart/form-data
@Produce json
@Param file formData file true "obligations json file list"
@Success 200 {object} models.ImportObligationsResponse{data=[]models.ObligationImportStatus}
@Failure 400 {object} models.LicenseError "input file must be present"
@Failure 500 {object} models.LicenseError "Internal server error"
@Security ApiKeyAuth
@Router /obligations/import [post]
func PatchObligationMap ¶
PatchObligationMap Add or remove licenses from obligation map for a given obligation id
@Summary Add or remove licenses from obligation map
@Description Add or remove licenses from obligation map for a given obligation id
@Id PatchObligationMap
@Tags Obligations
@Accept json
@Produce json
@Param id path string true "Id of the obligation"
@Param license_maps body models.LicenseMapInput true "License ids with action"
@Success 200 {object} models.ObligationMapResponse
@Failure 400 {object} models.LicenseError "Invalid json body"
@Failure 404 {object} models.LicenseError "No license or obligation found."
@Failure 500 {object} models.LicenseError "Failure to insert new maps"
@Security ApiKeyAuth
@Router /obligation_maps/obligations/{id}/license [patch]
func RevokeClient ¶
RevokeClient removes an oidc client
@Summary Remove an oidc client
@Description Remove an oidc client if it gets expired or is compromised
@Id RevokeClient
@Tags OIDC Clients
@Accept json
@Produce json
@Param oidc_client body models.CreateDeleteOidcClientDTO true "Oidc client to add"
@Success 204
@Failure 404 {object} models.LicenseError "Oidc Client not found"
@Security ApiKeyAuth
@Router /oidcClients [delete]
func SearchInLicense ¶
SearchInLicense Search for license data based on user-provided search criteria.
@Summary Search licenses
@Description Search licenses on different filters and algorithms
@Id SearchInLicense
@Tags Licenses
@Accept json
@Produce json
@Param search body models.SearchLicense true "Search criteria"
@Success 200 {object} models.LicenseResponse "Licenses matched"
@Failure 400 {object} models.LicenseError "Invalid request"
@Failure 404 {object} models.LicenseError "Search algorithm doesn't exist"
@Security ApiKeyAuth || {}
@Router /search [post]
func UpdateLicense ¶
UpdateLicense Update license with given id and create audit and changelog entries.
@Summary Update a license
@Description Update a license in the service
@Id UpdateLicense
@Tags Licenses
@Accept json
@Produce json
@Param id path string true "Id of the license to be updated"
@Param license body models.LicenseUpdateDTO true "Update license body (requires only the fields to be updated)"
@Success 200 {object} models.LicenseResponse "License updated successfully"
@Failure 400 {object} models.LicenseError "Invalid license body"
@Failure 404 {object} models.LicenseError "License with id not found"
@Failure 500 {object} models.LicenseError "Failed to update license"
@Security ApiKeyAuth
@Router /licenses/{id} [patch]
func UpdateLicenseInObligationMap ¶
UpdateLicenseInObligationMap Update license list of an obligation map
@Summary Change license list
@Description Replaces the license list of an obligation id with the given list in the obligation map.
@Id UpdateLicenseInObligationMap
@Tags Obligations
@Accept json
@Produce json
@Param id path string true "Id of the obligation"
@Param Ids body models.LicenseListInput true "Ids of the licenses to be in map"
@Success 200 {object} models.ObligationMapResponse
@Failure 400 {object} models.LicenseError "Invalid json body"
@Failure 404 {object} models.LicenseError "No license or obligation found."
@Security ApiKeyAuth
@Router /obligation_maps/obligations/{id}/license [put]
func UpdateObligation ¶
UpdateObligation updates an existing active obligation record
@Summary Update obligation
@Description Update an existing obligation record
@Id UpdateObligation
@Tags Obligations
@Accept json
@Produce json
@Param id path string true "Id of the obligation to be updated"
@Param obligation body models.ObligationUpdateDTO true "Obligation to be updated"
@Success 200 {object} models.ObligationResponse
@Failure 400 {object} models.LicenseError "Invalid request"
@Failure 404 {object} models.LicenseError "No obligation with given id found"
@Failure 500 {object} models.LicenseError "Unable to update obligation"
@Security ApiKeyAuth
@Router /obligations/{id} [patch]
Types ¶
This section is empty.