Documentation ¶
Index ¶
- type Content
- type ContentItem
- type ContentLinks
- type ContentResponse
- type ContentResponseAPI
- type LinkObject
- type Navigation
- type PrivateContentResponseAPI
- type PrivateSubtopics
- type PublicSubtopics
- type State
- type Topic
- type TopicLinks
- type TopicNonReferential
- type TopicRelease
- type TopicResponse
- type TypeLinkObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Content ¶ added in v0.4.0
type Content struct { State string `bson:"state,omitempty" json:"state,omitempty"` Spotlight *[]TypeLinkObject `bson:"spotlight,omitempty" json:"spotlight,omitempty"` Articles *[]TypeLinkObject `bson:"articles,omitempty" json:"articles,omitempty"` Bulletins *[]TypeLinkObject `bson:"bulletins,omitempty" json:"bulletins,omitempty"` Methodologies *[]TypeLinkObject `bson:"methodologies,omitempty" json:"methodologies,omitempty"` MethodologyArticles *[]TypeLinkObject `bson:"methodology_articles,omitempty" json:"methodology_articles,omitempty"` StaticDatasets *[]TypeLinkObject `bson:"static_datasets,omitempty" json:"static_datasets,omitempty"` Timeseries *[]TypeLinkObject `bson:"timeseries,omitempty" json:"timeseries,omitempty"` }
Content represents content schema as it is stored in mongoDB and is used for marshaling and unmarshaling json representation for API ID is a duplicate of ID in TopicResponse, to facilitate each subdocument being a full-formed response in its own right depending upon request being in publish or web and also authentication.
func (*Content) StateTransitionAllowed ¶ added in v0.4.0
StateTransitionAllowed checks if the content can transition from its current state to the provided target state
func (*Content) Validate ¶ added in v0.4.0
Validate checks that a content struct complies with the state constraints, if provided. TODO may want to add more in future
func (*Content) ValidateTransitionFrom ¶ added in v0.4.0
ValidateTransitionFrom checks that this content state can be validly transitioned from the existing state
type ContentItem ¶ added in v0.4.0
type ContentItem struct { Title string `json:"title,omitempty"` Type string `json:"type,omitempty"` Links *ContentLinks `json:"links,omitempty"` State string `json:"state,omitempty"` }
ContentItem is an individual content item
type ContentLinks ¶ added in v0.4.0
type ContentLinks struct { Self *LinkObject `json:"self,omitempty"` Topic *LinkObject `json:"topic,omitempty"` }
ContentLinks are content links
type ContentResponse ¶ added in v0.4.0
type ContentResponse struct { ID string `bson:"id,omitempty" json:"id,omitempty"` Next *Content `bson:"next,omitempty" json:"next,omitempty"` Current *Content `bson:"current,omitempty" json:"current,omitempty"` }
ContentResponse represents an evolving content with the current content and the updated content. This is for mongo storage / retrieval. The 'Next' is what gets updated throughout the publishing journey, and then the 'publish' step copies the 'Next' over the 'Current' document, so that 'Current' is whats always returned in the web view. ID is a duplicate of ID in TopicResponseStore.
type ContentResponseAPI ¶ added in v0.4.0
type ContentResponseAPI struct { Count int `json:"count"` Offset int `json:"offset_index"` Limit int `json:"limit"` TotalCount int `json:"total_count"` Items *[]ContentItem `json:"items"` }
ContentResponseAPI used for returning the Current OR Next & Current document(s) in REST API response
func (*ContentResponseAPI) AppendLinkInfo ¶ added in v0.4.0
func (contentList *ContentResponseAPI) AppendLinkInfo(typeName string, itemLink *[]TypeLinkObject, id, state string)
AppendLinkInfo appends to list more links sorted by HRef
type LinkObject ¶
type LinkObject struct { HRef string `bson:"href,omitempty" json:"href,omitempty"` ID string `bson:"id,omitempty" json:"id,omitempty"` }
LinkObject represents a generic structure for all links
type Navigation ¶ added in v0.8.0
type Navigation struct {}
Navigation is used to get high level list of topics and subtopics with links and description for site navigation.
type PrivateContentResponseAPI ¶ added in v0.4.0
type PrivateContentResponseAPI struct { Next *ContentResponseAPI `json:"next,omitempty"` Current *ContentResponseAPI `json:"current,omitempty"` }
PrivateContentResponseAPI represents an evolving content with the current content and the updated content. This is for the REST API response. The 'Next' is what gets updated throughout the publishing journey, and then the 'publish' step copies the 'Next' over the 'Current' document, so that 'Current' is whats always returned in the web view.
type PrivateSubtopics ¶
type PrivateSubtopics struct { Count int `bson:"count,omitempty" json:"count"` Limit int `bson:"limit,omitempty" json:"limit"` Offset int `bson:"offset_index,omitempty" json:"offset_index"` TotalCount int `bson:"total_count,omitempty" json:"total_count"` PrivateItems *[]TopicResponse `bson:"items,omitempty" json:"items"` }
PrivateSubtopics used for returning both Next and Current document(s) in REST API response
type PublicSubtopics ¶
type PublicSubtopics struct { Count int `bson:"count,omitempty" json:"count"` Limit int `bson:"limit,omitempty" json:"limit"` Offset int `bson:"offset_index,omitempty" json:"offset_index"` TotalCount int `bson:"total_count,omitempty" json:"total_count"` PublicItems *[]Topic `bson:"items,omitempty" json:"items"` }
PublicSubtopics used for returning just the Current document(s) in REST API response
type State ¶
type State int
State - iota enum of possible topic states
const ( // these from dp-image-api : StateCreated State = iota // this is 'in_progress' StatePublished StateCompleted )
Possible values for a State of a topic. It can only be one of the following:
func ParseState ¶
ParseState returns a state from its string representation
func (State) TransitionAllowed ¶
TransitionAllowed returns true only if the transition from the current state and the provided next is allowed
type Topic ¶
type Topic struct { ID string `bson:"id,omitempty" json:"id,omitempty"` Description string `bson:"description,omitempty" json:"description,omitempty"` Keywords []string `bson:"keywords,omitempty" json:"keywords,omitempty"` Links *TopicLinks `bson:"links,omitempty" json:"links,omitempty"` ReleaseDate *time.Time `bson:"release_date,omitempty" json:"release_date,omitempty"` State string `bson:"state,omitempty" json:"state,omitempty"` SubtopicIds []string `bson:"subtopics_ids,omitempty" json:"-"` Title string `bson:"title,omitempty" json:"title,omitempty"` }
Topic represents topic schema as it is stored in mongoDB and is used for marshaling and unmarshaling json representation for API ID is a duplicate of ID in TopicResponse, to facilitate each subdocument being a full-formed response in its own right depending upon request being in publish or web and also authentication. Subtopics contains TopicResonse ID(s).
func (*Topic) StateTransitionAllowed ¶
StateTransitionAllowed checks if the topic can transition from its current state to the provided target state
func (*Topic) Validate ¶
Validate checks that a topic struct complies with the state constraints, if provided. TODO may want to add more in future
func (*Topic) ValidateTransitionFrom ¶
ValidateTransitionFrom checks that this topic state can be validly transitioned from the existing state
type TopicLinks ¶
type TopicLinks struct { Content *LinkObject `bson:"content,omitempty" json:"content,omitempty"` Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"` Subtopics *LinkObject `bson:"subtopics,omitempty" json:"subtopics,omitempty"` }
TopicLinks represents a list of specific links related to the topic resource
type TopicNonReferential ¶ added in v0.8.0
type TopicNonReferential struct { Description string `json:"description,omitempty"` Label string `json:"label"` Links *TopicLinks `json:"links,omitempty"` Name string `json:"name"` SubtopicItems *[]TopicNonReferential `json:"subtopics,omitempty"` Title string `json:"title"` URI string `json:"uri"` }
TopicNonReferential is used to create a single comprehensive list of topics and subtopics.
type TopicRelease ¶ added in v0.14.0
type TopicRelease struct {
ReleaseDate string `json:"release_date"`
}
TopicRelease represents the incoming request structure containing release content
func ReadReleaseDate ¶ added in v0.14.0
func ReadReleaseDate(r io.Reader) (*TopicRelease, error)
ReadReleaseDate manages the creation of a release date object from a reader
type TopicResponse ¶
type TopicResponse struct { ID string `bson:"id,omitempty" json:"id,omitempty"` Current *Topic `bson:"current,omitempty" json:"current,omitempty"` Next *Topic `bson:"next,omitempty" json:"next,omitempty"` }
TopicResponse represents an evolving topic with the current topic and the updated topic The 'Next' is what gets updated throughout the publishing journey, and then the 'publish' step copies the 'Next' over the 'Current' document, so that 'Current' is whats always returned in the web view.
type TypeLinkObject ¶ added in v0.4.0
type TypeLinkObject struct { HRef string `bson:"href,omitempty" json:"href,omitempty"` Title string `bson:"title,omitempty" json:"title,omitempty"` }
TypeLinkObject represents a generic structure for all type links