Documentation
¶
Index ¶
- Variables
- func CleanBundle(bundle *Bundle)
- func CleanContentItem(contentItem *ContentItem)
- func ValidateError(e *Error) error
- func ValidateRole(role Role) bool
- type Action
- type AuthEntityData
- type Bundle
- type BundleState
- type BundleType
- type Bundles
- type Code
- type ContentItem
- type ContentType
- type Contents
- type Error
- type ErrorList
- type ErrorResult
- func CreateBadRequestErrorResult[TError Error](err *TError) *ErrorResult[TError]
- func CreateErrorResult[TError Error](err *TError, httpStatusCode int) *ErrorResult[TError]
- func CreateInternalErrorResult[TError Error](err *TError) *ErrorResult[TError]
- func CreateNotFoundResult[TError Error](err *TError) *ErrorResult[TError]
- type Event
- type EventsList
- type Links
- type ManagedBy
- type Metadata
- type PaginationFields
- type PaginationResult
- type PaginationSuccessResult
- type PreviewTeam
- type RequestedBy
- type Role
- type Source
- type State
- type SuccessResult
- type UpdateStateRequest
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrorToModelErrorMap = map[error]*Error{ errs.ErrBundleNotFound: notFoundError, errs.ErrNotFound: notFoundError, errs.ErrBundleHasNoContentItems: notFoundError, errs.ErrContentItemNotFound: notFoundError, errs.ErrMissingIfMatchHeader: CreateModelError(CodeBadRequest, errs.ErrorDescriptionMissingIfMatchHeader), errs.ErrInvalidIfMatchHeader: CreateModelError(CodeConflict, errs.ErrorDescriptionInvalidIfMatchHeader), errs.ErrInvalidBundleState: invalidTransitionError, errs.ErrInvalidTransition: invalidTransitionError, errs.ErrInvalidBody: malformedRequestError, errs.ErrInternalServer: internalError, errs.ErrUnauthorised: CreateModelError(CodeUnauthorised, errs.ErrorDescriptionAccessDenied), }
API Errors -> Error map
Functions ¶
func CleanBundle ¶ added in v1.4.0
func CleanBundle(bundle *Bundle)
CleanBundle removes any whitespace from the Bundle fields (except for the CreatedAt, UpdatedAt, ScheduledAt and etag fields)
func CleanContentItem ¶ added in v1.3.0
func CleanContentItem(contentItem *ContentItem)
func ValidateError ¶ added in v1.2.0
func ValidateRole ¶ added in v1.12.0
Types ¶
type Action ¶ added in v1.2.0
type Action string
Action enum type representing the action taken by a user
type AuthEntityData ¶ added in v1.4.0
type AuthEntityData struct {
EntityData *permissionsAPISDK.EntityData
IsServiceAuth bool
Headers datasetAPISDK.Headers
}
func CreateAuthEntityData ¶ added in v1.4.0
func CreateAuthEntityData(entityData *permissionsAPISDK.EntityData, serviceToken string) *AuthEntityData
func (*AuthEntityData) GetUserEmail ¶ added in v1.4.0
func (a *AuthEntityData) GetUserEmail() string
func (*AuthEntityData) GetUserID ¶ added in v1.4.0
func (a *AuthEntityData) GetUserID() string
type Bundle ¶
type Bundle struct {
ID string `bson:"id" json:"id"`
BundleType BundleType `bson:"bundle_type" json:"bundle_type"`
CreatedBy *User `bson:"created_by,omitempty" json:"created_by,omitempty"`
CreatedAt *time.Time `bson:"created_at,omitempty" json:"created_at,omitempty"`
LastUpdatedBy *User `bson:"last_updated_by,omitempty" json:"last_updated_by,omitempty"`
PreviewTeams *[]PreviewTeam `bson:"preview_teams,omitempty" json:"preview_teams,omitempty"`
ScheduledAt *time.Time `bson:"scheduled_at,omitempty" json:"scheduled_at,omitempty"`
State BundleState `bson:"state" json:"state"`
Title string `bson:"title" json:"title"`
UpdatedAt *time.Time `bson:"updated_at,omitempty" json:"updated_at,omitempty"`
ManagedBy ManagedBy `bson:"managed_by" json:"managed_by"`
ETag string `bson:"e_tag" json:"-"`
}
Bundle represents the response body when retrieving a bundle
func CreateBundle ¶
CreateBundle creates a new Bundle from the provided reader
func (*Bundle) GenerateETag ¶ added in v1.4.0
type BundleState ¶ added in v1.2.0
type BundleState string
BundleState enum type representing the state of the bundle
const ( BundleStateDraft BundleState = "DRAFT" BundleStateInReview BundleState = "IN_REVIEW" BundleStateApproved BundleState = "APPROVED" BundleStatePublished BundleState = "PUBLISHED" )
Define the possible values for the BundleState enum
func (BundleState) IsValid ¶ added in v1.2.0
func (bs BundleState) IsValid() bool
IsValid validates that the BundleState is a valid enum value
func (BundleState) String ¶ added in v1.2.0
func (bs BundleState) String() string
String returns the string value of the BundleState
type BundleType ¶ added in v1.2.0
type BundleType string
BundleType enum type representing the type of the bundle
const ( BundleTypeManual BundleType = "MANUAL" BundleTypeScheduled BundleType = "SCHEDULED" )
Define the possible values for the BundleType enum
func (BundleType) IsValid ¶ added in v1.2.0
func (bt BundleType) IsValid() bool
IsValid validates that the BundleType is a valid enum value
func (BundleType) String ¶ added in v1.4.0
func (bt BundleType) String() string
String returns the string value of the BundleType
type Bundles ¶ added in v1.2.0
type Bundles struct {
Items *[]Bundle `bson:"items" json:"items"`
}
Bundles represents a list of bundles
type Code ¶ added in v1.2.0
type Code string
Code enum representing the error code
const ( CodeInternalError Code = "InternalError" CodeNotFound Code = "NotFound" CodeBadRequest Code = "BadRequest" CodeForbidden Code = "Forbidden" CodeConflict Code = "Conflict" CodeMissingParameters Code = "MissingParameters" CodeInvalidParameters Code = "InvalidParameters" CodeJSONMarshalError Code = "JSONMarshalError" CodeJSONUnmarshalError Code = "JSONUnmarshalError" CodeWriteResponseError Code = "WriteResponseError" )
Define possible values for the Code enum
type ContentItem ¶ added in v1.2.0
type ContentItem struct {
ID string `bson:"id" json:"id"`
BundleID string `bson:"bundle_id" json:"bundle_id"`
ContentType ContentType `bson:"content_type" json:"content_type"`
Metadata Metadata `bson:"metadata" json:"metadata"`
State *State `bson:"state,omitempty" json:"state,omitempty"`
Links Links `bson:"links" json:"links"`
}
ContentItem represents information about the datasets to be published as part of the bundle
func CreateContentItem ¶ added in v1.2.0
func CreateContentItem(reader io.Reader) (*ContentItem, error)
type ContentType ¶ added in v1.2.0
type ContentType string
ContentType enum represents the type of content
const (
ContentTypeDataset ContentType = "DATASET"
)
Define the possible values for the contentType enum
func (ContentType) IsValid ¶ added in v1.2.0
func (ct ContentType) IsValid() bool
IsValid validates that the ContentType is a valid enum value
func (ContentType) String ¶ added in v1.3.0
func (ct ContentType) String() string
String returns the string value of the ContentType
type Contents ¶ added in v1.2.0
type Contents struct {
PaginationFields
Items []ContentItem `bson:"contents,omitempty" json:"contents,omitempty"`
}
Contents represents a list of contents related to a bundle
type Error ¶ added in v1.2.0
type Error struct {
Code *Code `json:"code,omitempty"`
Description string `json:"description,omitempty"`
Source *Source `json:"source,omitempty"`
}
Error represents the details of a specific error
func CreateModelError ¶ added in v1.4.0
func GetMatchingModelError ¶ added in v1.4.0
func ValidateBundle ¶ added in v1.2.0
ValidateBundle checks that the Bundle has all mandatory fields and valid values
func ValidateContentItem ¶ added in v1.2.0
func ValidateContentItem(contentItem *ContentItem) []*Error
type ErrorList ¶ added in v1.2.0
type ErrorList struct {
Errors []*Error `json:"errors"`
}
ErrorList represents a list of errors
type ErrorResult ¶ added in v1.3.0
Struct to represent an API error, and the HTTP Status code to return
func CreateBadRequestErrorResult ¶ added in v1.4.0
func CreateBadRequestErrorResult[TError Error](err *TError) *ErrorResult[TError]
Create an error response with a 400 status code
func CreateErrorResult ¶ added in v1.3.0
func CreateErrorResult[TError Error](err *TError, httpStatusCode int) *ErrorResult[TError]
func CreateInternalErrorResult ¶ added in v1.4.0
func CreateInternalErrorResult[TError Error](err *TError) *ErrorResult[TError]
Create an error response with a 500 status code
func CreateNotFoundResult ¶ added in v1.3.0
func CreateNotFoundResult[TError Error](err *TError) *ErrorResult[TError]
Create an error response with a 404 status code
type Event ¶ added in v1.2.0
type Event struct {
CreatedAt *time.Time `bson:"created_at,omitempty" json:"created_at,omitempty"`
RequestedBy *RequestedBy `bson:"requested_by,omitempty" json:"requested_by,omitempty"`
Action Action `bson:"action" json:"action"`
Resource string `bson:"resource" json:"resource"`
ContentItem *ContentItem `bson:"content_item,omitempty" json:"content_item,omitempty"`
Bundle *Bundle `bson:"bundle,omitempty" json:"bundle,omitempty"`
}
Event represents details of a specific change event forming part of the change and audit log for a bundle
func CreateEventModel ¶ added in v1.4.0
func CreateEventModel(id, email string, action Action, bundle *Bundle, contentItem *ContentItem) (*Event, error)
CreateEventModel creates an Event model for either a Bundle or a ContentItem
type EventsList ¶ added in v1.2.0
type EventsList struct {
PaginationFields
Items *[]Event `bson:"items,omitempty" json:"items,omitempty"`
}
EventsList represents the list of change events which form the change and audit log for a bundle
type Links ¶ added in v1.2.0
type Links struct {
Edit string `bson:"edit" json:"edit"`
Preview string `bson:"preview" json:"preview"`
}
Links represents the navigational links for onward actions related to the content item
type ManagedBy ¶ added in v1.2.0
type ManagedBy string
ManagedBy enum type representing the system that created and manages the bundle
Define the possible values for the ManagedBy enum
type Metadata ¶ added in v1.2.0
type Metadata struct {
DatasetID string `bson:"dataset_id" json:"dataset_id"`
EditionID string `bson:"edition_id" json:"edition_id"`
Title string `bson:"title,omitempty" json:"title,omitempty"`
VersionID int `bson:"version_id" json:"version_id"`
}
Metadata represents the metadata for the content item
type PaginationFields ¶ added in v1.1.0
type PaginationFields struct {
Count int `json:"count"`
Limit int `json:"limit"`
Offset int `json:"offset"`
TotalCount int `json:"total_count"`
}
PaginationFields represents the fields used for pagination in an API response
type PaginationResult ¶ added in v1.3.0
type PaginationSuccessResult ¶ added in v1.3.0
type PaginationSuccessResult[TItem any] = SuccessResult[PaginationResult[TItem]]
type PreviewTeam ¶ added in v1.2.0
type PreviewTeam struct {
ID string `bson:"id" json:"id"`
}
PreviewTeam represents a team who have permissions to view the dataset series in the bundle
type RequestedBy ¶ added in v1.2.0
type RequestedBy struct {
ID string `bson:"id" json:"id"`
Email string `bson:"email,omitempty" json:"email,omitempty"`
}
RequestedBy represents the user who made the request
type Role ¶ added in v1.12.0
type Role string
const (
RoleDatasetsPreviewer Role = "datasets-previewer"
)
type Source ¶ added in v1.2.0
type Source struct {
Field string `json:"field,omitempty"`
Parameter string `json:"parameter,omitempty"`
Header string `json:"header,omitempty"`
}
Source represents the details of which field or parameter the error relates to. Used to return validation errors to 4xx requests. Only one of the properties below can be returned in any single error.
type State ¶ added in v1.2.0
type State string
State enum represents the state of the content item
Define the possible values for the state enum
type SuccessResult ¶ added in v1.3.0
Struct to represent a successful API result, and the HTTP status code to return
func CreateOkResult ¶ added in v1.3.0
func CreateOkResult[TResult any](result *TResult) *SuccessResult[TResult]
Create a success result with a 200 status
func CreatePaginationSuccessResult ¶ added in v1.3.0
func CreatePaginationSuccessResult[TItem any](items []*TItem, totalCount int) *SuccessResult[PaginationResult[TItem]]
func CreateSuccessResult ¶ added in v1.3.0
func CreateSuccessResult[TResult any](result *TResult, httpStatusCode int) *SuccessResult[TResult]
type UpdateStateRequest ¶ added in v1.4.0
type UpdateStateRequest struct {
State BundleState
}