Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 PrivateSubtopics ¶
type PrivateSubtopics struct {
Count int `bson:"count,omitempty" json:"count"`
Offset int `bson:"offset_index,omitempty" json:"offset_index"`
Limit int `bson:"limit,omitempty" json:"limit"`
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)
type PublicSubtopics ¶
type PublicSubtopics struct {
Count int `bson:"count,omitempty" json:"count"`
Offset int `bson:"offset_index,omitempty" json:"offset_index"`
Limit int `bson:"limit,omitempty" json:"limit"`
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)
type State ¶
type State int
State - iota enum of possible topic states
const ( // these from dp-image-api : StateTopicCreated State = iota // this is 'in_progress' StateTopicPublished StateTopicCompleted )
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"`
Title string `bson:"title,omitempty" json:"title,omitempty"`
Keywords []string `bson:"keywords,omitempty" json:"keywords,omitempty"`
State string `bson:"state,omitempty" json:"state,omitempty"`
Links *TopicLinks `bson:"links,omitempty" json:"links,omitempty"`
SubtopicIds []string `bson:"subtopics_ids,omitempty" json:"-"`
}
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. !!! 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 {
Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"`
Subtopics *LinkObject `bson:"subtopics,omitempty" json:"subtopics,omitempty"`
Content *LinkObject `bson:"content,omitempty" json:"content,omitempty"`
}
TopicLinks represents a list of specific links related to the topic resource
type TopicResponse ¶
type TopicResponse struct {
ID string `bson:"id,omitempty" json:"id,omitempty"`
Next *Topic `bson:"next,omitempty" json:"next,omitempty"`
Current *Topic `bson:"current,omitempty" json:"current,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.