Documentation
¶
Overview ¶
Package stz implements a client for the [Structurizr service HTTP APIs](https://structurizr.com/).
Package stz complements the serializable model defined in mdl package with data specific to Structurizr service.
The top level data structure is Workspace which replaces mdl.Design.
The JSON representation of the workspace data structure is compatible with the Structurizr service API (https://structurizr.com). The package also includes a Structurize API client that can be used to upload and download workspaces to and from the service.
Index ¶
- Constants
- Variables
- type Branding
- type Client
- type Configuration
- type Decision
- type DecisionStatusKind
- type DocFormatKind
- type Documentation
- type DocumentationSection
- type DocumentationTemplateMetadata
- type Doer
- type Font
- type Image
- type Response
- type SymbolKind
- type Terminology
- type User
- type ViewLayout
- type Views
- type Workspace
- type WorkspaceConfiguration
- type WorkspaceLayout
Constants ¶
const UserAgent = "structurizr-go/1.0"
UserAgent is the user agent used by this package.
Variables ¶
var ( // Host is the Structurizr API host (var for testing). Host = "api.structurizr.com" // Scheme is the HTTP scheme used to make requests to the Structurizr service. Scheme = "https" )
Functions ¶
This section is empty.
Types ¶
type Branding ¶
type Branding struct { // URL of PNG/JPG/GIF file, or Base64 data URI representation. Logo string `json:"logo,omitempty"` // Font details. Font *Font `json:"font,omitempty"` }
Branding is a wrapper for font and logo for diagram/documentation branding purposes.
type Client ¶
type Client struct { // Key is the API key. Key string // Secret is the API secret. Secret string // HTTP is the low level HTTP client. HTTP Doer }
Client holds the credentials needed to make the requests.
func (*Client) EnableDebug ¶
func (c *Client) EnableDebug()
EnableDebug causes the client to print debug information to Stderr.
type Configuration ¶
type Configuration struct { // Styles associated with views. Styles *mdl.Styles `json:"styles,omitempty"` // Key of view that was saved most recently. LastSavedView string `json:"lastSavedView,omitempty"` // Key of view shown by default. DefaultView string `json:"defaultView,omitempty"` // URL(s) of theme(s) used when rendering diagram. Themes []string `json:"themes,omitempty"` // Branding used in views. Branding *Branding `json:"branding,omitempty"` // Terminology used in workspace. Terminology *Terminology `json:"terminology,omitempty"` // Type of symbols used when rendering metadata. MetadataSymbols SymbolKind `json:"metadataSymbols,omitempty"` }
Configuration encapsulate Structurizr service specific view configuration information.
type Decision ¶
type Decision struct { // ID of decision. ID string `json:"id"` // Date of decision in ISO 8601 format. Date string `json:"date"` // Status of decision. Decision DecisionStatusKind `json:"decision"` // Title of decision Title string `json:"title"` // Markdown or AsciiDoc content of decision. Content string `json:"content"` // Content format. Format DocFormatKind `json:"format"` // ID of element (in model) that decision applies to (optional). ElementID string `json:"elementId,omitempty"` }
Decision record (e.g. architecture decision record).
type DecisionStatusKind ¶
type DecisionStatusKind int
DecisionStatusKind is the enum used to represent status of decision.
const ( DecisionUndefined DecisionStatusKind = iota DecisionProposed DecisionAccepted DecisionSuperseded DecisionDeprecated DecisionRejected )
func (DecisionStatusKind) MarshalJSON ¶
func (d DecisionStatusKind) MarshalJSON() ([]byte, error)
MarshalJSON replaces the constant value with the proper string value.
func (*DecisionStatusKind) UnmarshalJSON ¶
func (d *DecisionStatusKind) UnmarshalJSON(data []byte) error
UnmarshalJSON sets the constant from its JSON representation.
type DocFormatKind ¶
type DocFormatKind int
DocFormatKind is the enum used to represent documentation format.
const ( FormatUndefined DocFormatKind = iota FormatMarkdown FormatASCIIDoc )
func (DocFormatKind) MarshalJSON ¶
func (d DocFormatKind) MarshalJSON() ([]byte, error)
MarshalJSON replaces the constant value with the proper string value.
func (*DocFormatKind) UnmarshalJSON ¶
func (d *DocFormatKind) UnmarshalJSON(data []byte) error
UnmarshalJSON sets the constant from its JSON representation.
type Documentation ¶
type Documentation struct { // Documentation sections. Sections []*DocumentationSection `json:"sections,omitempty"` // ADR decisions. Decisions []*Decision `json:"decisions,omitempty"` // Images used in documentation. Images []*Image `json:"images,omitempty"` // Information about template used to render documentation. Template *DocumentationTemplateMetadata `json:"template,omitempty"` }
Documentation associated with software architecture model.
type DocumentationSection ¶
type DocumentationSection struct { // Title (name/section heading) of section. Title string `json:"title"` // Markdown or AsciiDoc content of section. Content string `json:"string"` // Content format. Format DocFormatKind `json:"format"` // Order (index) of section in document. Order int `json:"order"` // ID of element (in model) that section applies to (optional). ElementID string `json:"elementId,omitempty"` }
DocumentationSection corresponds to a documentation section.
type DocumentationTemplateMetadata ¶
type DocumentationTemplateMetadata struct { // Name of documentation template. Name string `json:"name"` // Name of author of documentation template. Author string `json:"author,omitempty"` // URL that points to more information about template. URL string `json:"url,omitempty"` }
DocumentationTemplateMetadata provides information about a documentation template used to create documentation.
type Font ¶
type Font struct { // Name of font. Name string `json:"name,omitempty"` // Web font URL. URL string `json:"url,omitempty"` }
Font details including name and optional URL for web fonts.
type Image ¶
type Image struct { // Name of image. Name string `json:"image"` // Base64 encoded content. Content string `json:"content"` // Image MIME type (e.g. "image/png") Type string `json:"type"` }
Image represents a Base64 encoded image (PNG/JPG/GIF).
type Response ¶
type Response struct { // Success is true if the API call was successful, false otherwise. Success bool `json:"success"` // Message is a human readable response message. Message string `json:"message"` // Revision is hte internal revision number. Revision int `json:"revision"` }
Response describes the API response returned by some endpoints.
type SymbolKind ¶
type SymbolKind int
SymbolKind is the enum used to represent symbols used to render metadata.
const ( SymbolUndefined SymbolKind = iota SymbolSquareBrackets SymbolRoundBrackets SymbolCurlyBrackets SymbolAngleBrackets SymbolDoubleAngleBrackets SymbolNone )
func (SymbolKind) MarshalJSON ¶
func (s SymbolKind) MarshalJSON() ([]byte, error)
MarshalJSON replaces the constant value with the proper string value.
func (*SymbolKind) UnmarshalJSON ¶
func (s *SymbolKind) UnmarshalJSON(data []byte) error
UnmarshalJSON sets the constant from its JSON representation.
type Terminology ¶
type Terminology struct { // Terminology used when rendering enterprise boundaries. Enterprise string `json:"enterprise,omitempty"` // Terminology used when rendering people. Person string `json:"person,omitempty"` // Terminology used when rendering software systems. SoftwareSystem string `json:"softwareSystem,omitempty"` // Terminology used when rendering containers. Container string `json:"container,omitempty"` // Terminology used when rendering components. Component string `json:"component,omitempty"` // Terminology used when rendering code elements. Code string `json:"code,omitempty"` // Terminology used when rendering deployment nodes. DeploymentNode string `json:"deploymentNode,omitempty"` // Terminology used when rendering relationships. Relationship string `json:"relationship,omitempty"` }
Terminology used on diagrams.
type User ¶
type User struct { Username string `json:"username"` // Role of user, one of "ReadWrite" or "ReadOnly". Role string `json:"role"` }
User of Structurizr service.
type ViewLayout ¶
type ViewLayout struct { Elements []*mdl.ElementView `json:"elements,omitempty"` Relationships []*mdl.RelationshipView `json:"relationships,omitempty"` }
ViewLayout contains the layout information for a given view.
func (*ViewLayout) MarshalJSON ¶
func (l *ViewLayout) MarshalJSON() ([]byte, error)
MarshalJSON guarantees the order of elements in generated JSON arrays that correspond to sets.
type Views ¶
type Views struct { // LandscapeViewss describe the system landscape views. LandscapeViews []*mdl.LandscapeView `json:"systemLandscapeViews,omitempty"` // ContextViews lists the system context views. ContextViews []*mdl.ContextView `json:"systemContextViews,omitempty"` // ContainerViews lists the container views. ContainerViews []*mdl.ContainerView `json:"containerViews,omitempty"` // ComponentViews lists the component views. ComponentViews []*mdl.ComponentView `json:"componentViews,omitempty"` // DynamicViews lists the dynamic views. DynamicViews []*mdl.DynamicView `json:"dynamicViews,omitempty"` // DeploymentViews lists the deployment views. DeploymentViews []*mdl.DeploymentView `json:"deploymentViews,omitempty"` // FilteredViews lists the filtered views. FilteredViews []*mdl.FilteredView `json:"filteredViews,omitempty"` // Configuration contains view specific configuration information. Configuration *Configuration `json:"configuration,omitempty"` }
Views is the container for all views.
type Workspace ¶
type Workspace struct { // ID of workspace. ID int `json:"id,omitempty"` // Name of workspace. Name string `json:"name"` // Description of workspace if any. Description string `json:"description,omitempty"` // Version number for the workspace. Version string `json:"version,omitempty"` // Revision number, automatically generated. Revision int `json:"revision,omitempty"` // Thumbnail associated with the workspace; a Base64 encoded PNG file as a // data URI (data:image/png;base64). Thumbnail string `json:"thumbnail,omitempty"` // The last modified date, in ISO 8601 format (e.g. "2018-09-08T12:40:03Z"). LastModifiedDate string `json:"lastModifiedDate,omitempty"` // A string identifying the user who last modified the workspace (e.g. an // e-mail address or username). LastModifiedUser string `json:"lastModifiedUser,omitempty"` // A string identifying the agent that was last used to modify the workspace // (e.g. "model-go/1.2.0"). LastModifiedAgent string `json:"lastModifiedAgent,omitempty"` // Model is the software architecture model. Model *mdl.Model `json:"model,omitempty"` // Views contains the views if any. Views *Views `json:"views,omitempty"` // Documentation associated with software architecture model. Documentation *Documentation `json:"documentation,omitempty"` // Configuration of workspace. Configuration *WorkspaceConfiguration `json:"configuration,omitempty"` }
Workspace describes a Structurizr service workspace.
func RunDSL ¶ added in v1.6.0
RunDSL runs the DSL defined in a global variable and returns the corresponding Structurize workspace.
func WorkspaceFromDesign ¶
WorkspaceFromDesign returns a Structurizr workspace initialized from the given design.
func (*Workspace) ApplyLayout ¶
func (w *Workspace) ApplyLayout(layout WorkspaceLayout)
ApplyLayout merges the layout into the views of w.
func (*Workspace) Layout ¶
func (w *Workspace) Layout() WorkspaceLayout
Layout returns the workspace layout. It makes sure to only return relevant data. That is the entries in the layout all have at least one non-default field value (X or Y not 0 for elements, position not 0 or routing not undefined or vertices exist for relationships).
func (*Workspace) MergeLayout ¶
MergeLayout merges the layout of elements and relationships in the views of remote into the views of w. The merge algorithm matches elements by name and relationships by matching source, destination and description (i.e. IDs don't have to be identical).
type WorkspaceConfiguration ¶
type WorkspaceConfiguration struct { // Users that have access to the workspace. Users []*User `json:"users"` }
WorkspaceConfiguration describes the workspace configuration.
type WorkspaceLayout ¶
type WorkspaceLayout map[string]*ViewLayout
WorkspaceLayout describes the view layouts of a workspace. The layout information includes element positions and relationship styles and vertices and is indexed by view keys.