service

package
v0.0.0-...-3759697 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const K = "VCh4IbXtYuFYnNa4L0xC1F49gZKZaNgrqJPMvNmac5T1W3zH0e"

Variables

View Source
var (
	ErrNotFound         = errors.New("item not found")
	ErrInvalidItemValue = errors.New("invalid item value, schema verification failed")
	ErrItemTypeNotFound = errors.New("item type not found")
)
View Source
var Version = "0"

Functions

func DeleteItemHandler

func DeleteItemHandler(w http.ResponseWriter, r *http.Request)

DeleteItemHandler @Summary Delete a configuration item @Description Delete a configuration item @Tags Items @Router /item/{key} [delete] @Param key path string true "the key for the configuration item to delete" @Produce json @Failure 400 {string} the request is not correct @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func DeleteLinksHandler

func DeleteLinksHandler(w http.ResponseWriter, r *http.Request)

DeleteLinksHandler @Summary Delete all configuration links @Description Delete all configuration links @Tags Linking @Router /link [delete] @Accepts json @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func DeleteTagHandler

func DeleteTagHandler(w http.ResponseWriter, r *http.Request)

DeleteTagHandler @Summary Untag a configuration @Description Delete the Tag associated with an item @Tags Tagging @Router /item/{key}/tag/{name} [delete] @Param key path string true "the key for the item to untag" @Param name path string true "the name of the tag to delete" @Accepts json @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 204 {string} the request was successful

func DeleteTypeHandler

func DeleteTypeHandler(w http.ResponseWriter, r *http.Request)

DeleteTypeHandler @Summary Delete a configuration type @Description Delete a configuration type @Tags Validation @Router /type/{key} [delete] @Param key path string true "the key for the configuration type to delete" @Produce json @Failure 400 {string} the request is not correct @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetAllTagsHandler

func GetAllTagsHandler(w http.ResponseWriter, r *http.Request)

GetAllTagsHandler @Summary Get all tags for a all configurations @Description Get all tags for a all configurations @Tags Tagging @Router /tag [get] @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetChildrenHandler

func GetChildrenHandler(w http.ResponseWriter, r *http.Request)

GetChildrenHandler @Summary Get the children linked to a configuration @Description Get the children linked to a configuration @Tags Items @Router /item/{key}/children [get] @Param key path string true "the key for the item having the children" @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetItemHandler

func GetItemHandler(w http.ResponseWriter, r *http.Request)

GetItemHandler @Summary Get the value of a configuration item @Description Get value of a configuration item @Tags Items @Router /item/{key} [get] @Param key path string true "the key for the configuration item to get" @Produce json @Failure 400 {string} the request is not correct @Failure 404 {string} configuration not found @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetItemsByTypeHandler

func GetItemsByTypeHandler(w http.ResponseWriter, r *http.Request)

GetItemsByTypeHandler @Summary Get all the configurations that have the specified type @Description Get all the configurations that have the specified type @Tags Items @Router /item/type/{type} [get] @Param type path string true "the type of the configurations to retrieve" @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetItemsHandler

func GetItemsHandler(w http.ResponseWriter, r *http.Request)

GetItemsHandler @Summary Get all the configurations @Description Get all the configurations @Tags Items @Router /item [get] @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetLinksHandler

func GetLinksHandler(w http.ResponseWriter, r *http.Request)

GetLinksHandler @Summary Get all configuration links @Description Get all configuration links @Tags Linking @Router /link [get] @Accepts json @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetParentsHandler

func GetParentsHandler(w http.ResponseWriter, r *http.Request)

GetParentsHandler @Summary Get the parents linked to a configuration @Description Get the parents linked to a configuration @Tags Items @Router /item/{key}/parents [get] @Param key path string true "the key for the item having the children" @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetTagValueHandler

func GetTagValueHandler(w http.ResponseWriter, r *http.Request)

GetTagValueHandler @Summary Get a tag value @Description Get the value of a tag for a configuration @Tags Tagging @Router /item/{key}/tag/{name} [get] @Param key path string true "the key for the item having the tag" @Param name path string true "the name of the tag having the value that has to be retrieved" @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetTaggedItemsHandler

func GetTaggedItemsHandler(w http.ResponseWriter, r *http.Request)

GetTaggedItemsHandler @Summary Get all the configurations that have the specified tags @Description Get all the configurations that have the specified tags @Tags Items @Router /item/tag/{tags} [get] @Param tags path string true "a pipe separated list of tags (e.g. tag1|tag2|tag3) where tag is the tag name, not the value" @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetTagsHandler

func GetTagsHandler(w http.ResponseWriter, r *http.Request)

GetTagsHandler @Summary Get all tags for a configuration @Description Get all tags for a configuration @Tags Tagging @Router /item/{key}/tag [get] @Param key path string true "the key for the item whose tags are to be retrieved" @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetTypeHandler

func GetTypeHandler(w http.ResponseWriter, r *http.Request)

GetTypeHandler @Summary Get the json schema for a configuration item @Description Get the json schema for a configuration item @Tags Validation @Router /type/{key} [get] @Param key path string true "the key for the type of configuration item json schema" @Produce json @Failure 400 {string} the request is not correct @Failure 404 {string} json schema not found @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func GetTypesHandler

func GetTypesHandler(w http.ResponseWriter, r *http.Request)

GetTypesHandler @Summary Get all the item types @Description Get all the item types @Tags Validation @Router /type [get] @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 200 {string} the request was successful

func LinkHandler

func LinkHandler(w http.ResponseWriter, r *http.Request)

LinkHandler @Summary Link two configurations @Description Link two configurations @Tags Linking @Router /link/{from-key}/to/{to-key} [put] @Param from-key path string true "the key for the first configuration to link" @Param to-key path string true "the key for the second configuration to link" @Accepts json @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 204 {string} the request was successful

func PopNewestByTypeHandler

func PopNewestByTypeHandler(w http.ResponseWriter, r *http.Request)

PopNewestByTypeHandler @Summary Get the newest configuration that have the specified type and remove it from the database effectively acting as a LIFO queue @Description Get the newest configuration that have the specified type and remove it from the database effectively acting as a LIFO queue @Tags Items @Router /item/pop/newest/{type} [delete] @Param type path string true "the type of the configuration to pop" @Produce json @Failure 500 {string} there was an unexpected error processing the request @Failure 404 {string} there was no item to pop @Success 200 {string} the request was successful

func PopOldestByTypeHandler

func PopOldestByTypeHandler(w http.ResponseWriter, r *http.Request)

PopOldestByTypeHandler @Summary Get the oldest configuration that have the specified type and remove it from the database effectively acting as a FIFO queue @Description Get the oldest configuration that have the specified type and remove it from the database effectively acting as a FIFO queue @Tags Items @Router /item/pop/oldest/{type} [delete] @Param type path string true "the type of the configuration to pop" @Produce json @Failure 500 {string} there was an unexpected error processing the request @Failure 404 {string} there was no item to pop @Success 200 {string} the request was successful

func ReadyHandler

func ReadyHandler(w http.ResponseWriter, r *http.Request)

ReadyHandler @Summary Check service readiness @Description Check any relevant backends are online and healthy. @Tags Health @Router /ready [get] @Accepts json @Produce json @Failure 500 {string} the service is not ready @Success 200 {string} the service is ready

func SetItemHandler

func SetItemHandler(w http.ResponseWriter, r *http.Request)

SetItemHandler @Summary Set the value of a configuration item @Description Set value of a configuration item @Tags Items @Router /item/{key} [put] @Param key path string true "the key for the configuration item to set" @Param schema body string true "the json based configuration" @Param Source-Type header string false "the key that defines the type of item for validation purposes. If not specified, no validation is performed." @Accepts json @Produce json @Failure 400 {string} the request is not correct @Failure 500 {string} there was an unexpected error processing the request @Success 204 {string} the request was successful

func SetTagHandler

func SetTagHandler(w http.ResponseWriter, r *http.Request)

SetTagHandler @Summary Tag an item @Description Tag the item identified by its key with a name @Tags Tagging @Router /item/{key}/tag/{name-value} [put] @Param key path string true "the key for the item to tag" @Param name-value path string true "the name / value of the tag in the format '{name}|{value}'. It is possible to have tags with no value, in which case the expression should be just '{name}'" @Accepts json @Produce json @Failure 400 {string} the request is not correct @Failure 500 {string} there was an unexpected error processing the request @Success 204 {string} the request was successful

func SetTypeHandler

func SetTypeHandler(w http.ResponseWriter, r *http.Request)

SetTypeHandler @Summary Set the validation for an item type @Description Set the json schema to validate an item of the specific type @Tags Validation @Router /type [put] @Param schema body src.TT true "the json schema to apply to the item type and an example prototype" @Accepts json @Produce json @Failure 400 {string} the request is not correct @Failure 500 {string} there was an unexpected error processing the request @Success 204 {string} the request was successful

func UnlinkHandler

func UnlinkHandler(w http.ResponseWriter, r *http.Request)

UnlinkHandler @Summary Unlink two configurations @Description Unlink two configurations @Tags Linking @Router /link/{from-key}/to/{to-key} [delete] @Param from-key path string true "the key for the first configuration to unlink" @Param to-key path string true "the key for the second configuration to unlink" @Accepts json @Produce json @Failure 500 {string} there was an unexpected error processing the request @Success 204 {string} the request was successful

Types

type DataBase

type DataBase struct {
	// contains filtered or unexported fields
}

DataBase the definition of the configuration database

func (*DataBase) DeleteItem

func (d *DataBase) DeleteItem(key string) error

DeleteItem delete the specified item

func (*DataBase) DeleteType

func (d *DataBase) DeleteType(key string) error

DeleteType delete a json schema for an item type Can be done with existing items, as a result items of the missing type are not validated

func (d *DataBase) Link(from, to string) error

Link add an association between two items

func (*DataBase) SetItem

func (d *DataBase) SetItem(key, iType string, value interface{}) (error, bool)

SetItem set the value of an item

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL