drawio

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package drawio provides functionality to parse resources from a draw.io XML file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diagram

type Diagram struct {
	XMLName      xml.Name     `xml:"diagram"`
	MxGraphModel MxGraphModel `xml:"mxGraphModel"`
}

Diagram represents the diagram element within the draw.io XML file.

type GenericResource added in v0.4.0

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

GenericResource represents a generic resource.

func NewGenericResource added in v0.5.2

func NewGenericResource(id, value string, resourceType ResourceType) *GenericResource

func (*GenericResource) ID added in v0.4.0

func (r *GenericResource) ID() string

func (*GenericResource) ResourceType added in v0.6.2

func (r *GenericResource) ResourceType() ResourceType

func (*GenericResource) Value added in v0.4.0

func (r *GenericResource) Value() string

type Geometry

type Geometry struct {
	XMLName xml.Name `xml:"mxGeometry"`
	X       float64  `xml:"x,attr"`
	Y       float64  `xml:"y,attr"`
	Width   float64  `xml:"width,attr"`
	Height  float64  `xml:"height,attr"`
}

Geometry represents the geometry element within a cell of the draw.io XML file.

type MxCell

type MxCell struct {
	XMLName  xml.Name `xml:"mxCell"`
	ID       string   `xml:"id,attr"`
	Value    string   `xml:"value,attr"`
	Style    string   `xml:"style,attr"`
	Parent   string   `xml:"parent,attr"`
	Vertex   bool     `xml:"vertex,attr"`
	Source   string   `xml:"source,attr"`
	Target   string   `xml:"target,attr"`
	Geometry Geometry `xml:"mxGeometry"`
}

MxCell represents a cell element within the draw.io XML file.

type MxFile

type MxFile struct {
	XMLName xml.Name `xml:"mxfile"`
	Diagram Diagram  `xml:"diagram"`
}

MxFile represents the root element of the draw.io XML file.

func Parse

func Parse(fileName string) (*MxFile, error)

Parse parses a draw.io XML file and returns an MxFile struct.

type MxGraphModel

type MxGraphModel struct {
	XMLName xml.Name `xml:"mxGraphModel"`
	Root    Root     `xml:"root"`
}

MxGraphModel represents the graph model element within the draw.io XML file.

type Relationship

type Relationship struct {
	Source Resource
	Target Resource
}

Relationship struct representing the relationship between resources.

type Resource

type Resource interface {
	ID() string
	Value() string
	ResourceType() ResourceType
}

Resource interface for all resource types.

type ResourceCollection

type ResourceCollection struct {
	Resources     []Resource
	Relationships []Relationship
}

ResourceCollection represents a collection of resources and their relationships.

func NewResourceCollection added in v0.4.0

func NewResourceCollection() *ResourceCollection

NewResourceCollection creates a new ResourceCollection.

func ParseResources

func ParseResources(mxFile *MxFile) (*ResourceCollection, error)

ParseResources parses resources from the MxFile.

func (*ResourceCollection) AddRelationship added in v0.4.0

func (rc *ResourceCollection) AddRelationship(source, target Resource)

AddRelationship adds a relationship to the collection.

func (*ResourceCollection) AddResource added in v0.4.0

func (rc *ResourceCollection) AddResource(resource Resource)

AddResource adds a resource to the collection.

type ResourceType added in v0.4.0

type ResourceType int

ResourceType represents the type of a resource.

const (
	// APIGatewayType represents the API Gateway resource type.
	APIGatewayType ResourceType = iota
	// CronType represents the Cron resource type.
	CronType
	// DatabaseType represents the Database resource type.
	DatabaseType
	// EndpointType represents the Endpoint resource type.
	EndpointType
	// KinesisType represents the Kinesis resource type.
	KinesisType
	// LambdaType represents the Lambda resource type.
	LambdaType
	// RestfulAPIType represents the Restful API resource type.
	RestfulAPIType
	// S3Type represents the S3 resource type.
	S3Type
	// SNSType represents the SNS resource type.
	SNSType
	// SQSType represents the SQS resource type.
	SQSType
	// UnknownType represents an unknown resource type.
	UnknownType
)

func ParseResourceType added in v0.4.0

func ParseResourceType(s string) ResourceType

ParseResourceType parses a ResourceType from a string.

func (ResourceType) String added in v0.4.0

func (rt ResourceType) String() string

String returns the string representation of a ResourceType.

type Root

type Root struct {
	XMLName xml.Name `xml:"root"`
	MxCells []MxCell `xml:"mxCell"`
}

Root represents the root element within the graph model of the draw.io XML file.

Jump to

Keyboard shortcuts

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