Documentation ¶
Overview ¶
Package cloudcraft provides a Go SDK for rendering AWS and Azure diagrams using the Cloudcraft API.
Index ¶
- Constants
- type AWSAccount
- type AWSService
- func (s *AWSService) Create(ctx context.Context, account *AWSAccount) (*AWSAccount, *Response, error)
- func (s *AWSService) Delete(ctx context.Context, id string) (*Response, error)
- func (s *AWSService) IAMParameters(ctx context.Context) (*IAMParams, *Response, error)
- func (s *AWSService) IAMPolicy(ctx context.Context) (*IAMPolicy, *Response, error)
- func (s *AWSService) List(ctx context.Context) ([]*AWSAccount, *Response, error)
- func (s *AWSService) Snapshot(ctx context.Context, id, region, format string, params *SnapshotParams) ([]byte, *Response, error)
- func (s *AWSService) Update(ctx context.Context, account *AWSAccount) (*Response, error)
- type AzureAccount
- type AzureService
- func (s *AzureService) Create(ctx context.Context, account *AzureAccount) (*AzureAccount, *Response, error)
- func (s *AzureService) Delete(ctx context.Context, id string) (*Response, error)
- func (s *AzureService) List(ctx context.Context) ([]*AzureAccount, *Response, error)
- func (s *AzureService) Snapshot(ctx context.Context, id, region, format string, params *SnapshotParams) ([]byte, *Response, error)
- func (s *AzureService) Update(ctx context.Context, account *AzureAccount) (*Response, error)
- type Blueprint
- type BlueprintData
- type BlueprintService
- func (s *BlueprintService) Create(ctx context.Context, blueprint *Blueprint) (*Blueprint, *Response, error)
- func (s *BlueprintService) Delete(ctx context.Context, id string) (*Response, error)
- func (s *BlueprintService) ExportBudget(ctx context.Context, id string, format string, params *BudgetExportParams) ([]byte, *Response, error)
- func (s *BlueprintService) ExportImage(ctx context.Context, id string, format string, params *ImageExportParams) ([]byte, *Response, error)
- func (s *BlueprintService) Get(ctx context.Context, id string) (*Blueprint, *Response, error)
- func (s *BlueprintService) List(ctx context.Context) ([]*Blueprint, *Response, error)
- func (s *BlueprintService) Update(ctx context.Context, blueprint *Blueprint, etag string) (*Response, error)
- type BudgetExportParams
- type Client
- type Config
- type IAMParams
- type IAMPolicy
- type IAMStatement
- type ImageExportParams
- type LiveAccount
- type LiveOptions
- type Members
- type Response
- type SnapshotParams
- type Team
- type TeamService
- type Theme
- type User
- type UserService
Constants ¶
const ( // DefaultSnapshotFormat is the default format used for account snapshots. DefaultSnapshotFormat string = "png" // DefaultSnapshotWidth is the default width used for account snapshots. DefaultSnapshotWidth int = 1920 // DefaultSnapshotHeight is the default height used for account snapshots. DefaultSnapshotHeight int = 1080 )
const ( // ErrEmptyApplicationID is returned when an Azure account is created with // an empty application ID. ErrEmptyApplicationID xerrors.Error = "field 'ApplicationID' cannot be empty" // ErrEmptyDirectoryID is returned when an Azure account is created with // an empty directory ID. ErrEmptyDirectoryID xerrors.Error = "field 'DirectoryID' cannot be empty" // ErrEmptySubscriptionID is returned when an Azure account is created with // an empty subscription ID. ErrEmptySubscriptionID xerrors.Error = "field 'SubscriptionID' cannot be empty" // ErrEmptyClientSecret is returned when an Azure account is created with // an empty client secret. ErrEmptyClientSecret xerrors.Error = "field 'ClientSecret' cannot be empty" )
const ( // ErrNilBlueprint is returned when you try to send a request without a // blueprint. ErrNilBlueprint xerrors.Error = "blueprint cannot be nil" // ErrBlueprintKey is returned when the response from the API does to a List // call is not a list of blueprints. ErrBlueprintKey xerrors.Error = "key 'blueprints' not found in the response" // ErrMissingID is returned when you try to send a request without the ID of // a blueprint. ErrMissingBlueprintID xerrors.Error = "missing blueprint ID" )
const ( // DefaultImageExportFormat is the default format used to export blueprint // images. DefaultImageExportFormat string = "png" // DefaultImageExportWidth is the default width used to export blueprint // images. DefaultImageExportWidth int = 1920 // DefaultImageExportHeight is the default height used to export blueprint // images. DefaultImageExportHeight int = 1080 // DefaultBudgetExportFormat is the default format used to export a // blueprint's budget. DefaultBudgetExportFormat string = "csv" // DefaultBudgetExportCurrency is the default currency used to export a // blueprint's budget. DefaultBudgetExportCurrency string = "USD" // DefaultBudgetExportPeriod is the default period used to export a blueprint's // budget. DefaultBudgetExportPeriod string = "m" )
const ( // ErrInvalidConfig is returned when a Client is created with an invalid // Config. ErrInvalidConfig xerrors.Error = "invalid config" // ErrRequestFailed is returned when a request to the Cloudcraft API fails // for unknown reasons. ErrRequestFailed xerrors.Error = "request failed with status code" // ErrMaxRetriesExceeded is returned when the maximum number of retries is // exceeded for HTTP requests. ErrMaxRetriesExceeded xerrors.Error = "maximum number of retries exceeded" )
const ( // ErrInvalidEndpoint is returned when the endpoint is not a valid URL. ErrInvalidEndpoint xerrors.Error = "invalid endpoint" // ErrMissingEndpointScheme is returned when a Config is created without a // scheme for the endpoint. ErrMissingEndpointScheme xerrors.Error = "missing endpoint scheme" // ErrMissingEndpointHost is returned when a Config is created without a // host for the endpoint. ErrMissingEndpointHost xerrors.Error = "missing endpoint host" // ErrMissingKey is returned when a Config is created without an API key. ErrMissingKey xerrors.Error = "missing API key" // ErrInvalidKey is returned when a Config is created with an invalid API // key. ErrInvalidKey xerrors.Error = "invalid API key; length must be 44" )
const ( // DefaultSceme is the default protocol scheme, such as "http" or "https". DefaultScheme string = "https" // DefaultHost is the default host name or IP address of the Cloudcraft API. DefaultHost string = "api.cloudcraft.co" // DefaultPort is the default port number of the Cloudcraft API. DefaultPort string = "443" // DefaultPath is the default path to the Cloudcraft API. DefaultPath string = "/" // DefaultMaxRetries is the default maximum number of times the client will // retry a request if it fails. DefaultMaxRetries int = 3 // DefaultTimeout is the default timeout for requests made by the Cloudcraft // API client. DefaultTimeout time.Duration = time.Second * 120 )
const ( EnvScheme string = "CLOUDCRAFT_PROTOCOL" EnvHost string = "CLOUDCRAFT_HOST" EnvPort string = "CLOUDCRAFT_PORT" EnvPath string = "CLOUDCRAFT_PATH" EnvMaxRetries string = "CLOUDCRAFT_MAX_RETRIES" EnvTimeout string = "CLOUDCRAFT_TIMEOUT" EnvAPIKey string = "CLOUDCRAFT_API_KEY" //nolint:gosec // false positive )
Environment variables used to configure the Config struct.
const ( // ErrNilContext is returned when a nil context is passed to a function. ErrNilContext xerrors.Error = "context cannot be nil" // ErrNilAccount is returned when a nil account is passed as an argument. ErrNilAccount xerrors.Error = "account cannot be nil" // ErrAccountsKey is returned when the response from the API to a List call // is not a list of AWS or Azure accounts. ErrAccountsKey xerrors.Error = "key 'accounts' not found in response" // ErrEmptyAccountName is returned when an empty account name is passed as // an argument. ErrEmptyAccountName xerrors.Error = "account name cannot be empty" // ErrMissingAccountID is returned when an empty account ID is passed as an // argument. ErrEmptyAccountID xerrors.Error = "account ID cannot be empty" // ErrEmptyRegion is returned when an empty region is passed as an argument. ErrEmptyRegion xerrors.Error = "region cannot be empty" )
const ( // ErrEmptyRoleARN is returned when the AWS account's role ARN is empty. ErrEmptyRoleARN xerrors.Error = "role ARN cannot be empty" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSAccount ¶
type AWSAccount struct { CreatedAt time.Time `json:"createdAt,omitempty"` UpdatedAt time.Time `json:"updatedAt,omitempty"` ReadAccess *[]string `json:"readAccess,omitempty"` WriteAccess *[]string `json:"writeAccess,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` RoleARN string `json:"roleArn,omitempty"` ExternalID string `json:"externalId,omitempty"` CreatorID string `json:"CreatorId,omitempty"` Source string `json:"source,omitempty"` }
AWSAccount represents an AWS account registered with Cloudcraft.
type AWSService ¶
type AWSService service
AWSService handles communication with the "/aws" endpoint of Cloudcraft's developer API.
func (*AWSService) Create ¶
func (s *AWSService) Create(ctx context.Context, account *AWSAccount) (*AWSAccount, *Response, error)
Create registers a new AWS account with Cloudcraft.
func (*AWSService) IAMParameters ¶
IAMParameters list all parameters required for registering a new IAM Role in AWS for use with Cloudcraft.
func (*AWSService) IAMPolicy ¶
IAMPolicy lists all permissions required for registering a new IAM Role in AWS for use with Cloudcraft.
func (*AWSService) List ¶
func (s *AWSService) List(ctx context.Context) ([]*AWSAccount, *Response, error)
List lists your AWS accounts linked with Cloudcraft.
func (*AWSService) Snapshot ¶
func (s *AWSService) Snapshot( ctx context.Context, id, region, format string, params *SnapshotParams, ) ([]byte, *Response, error)
Snapshot scans and render a region of an AWS account into a blueprint in JSON, SVG, PNG, PDF or MxGraph format.
func (*AWSService) Update ¶
func (s *AWSService) Update(ctx context.Context, account *AWSAccount) (*Response, error)
Update updates an AWS account registered in Cloudcraft.
type AzureAccount ¶
type AzureAccount struct { CreatedAt time.Time `json:"createdAt,omitempty"` UpdatedAt time.Time `json:"updatedAt,omitempty"` ReadAccess *[]string `json:"readAccess,omitempty"` WriteAccess *[]string `json:"writeAccess,omitempty"` CustomerID *string `json:"CustomerId,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` ApplicationID string `json:"applicationId,omitempty"` DirectoryID string `json:"directoryId,omitempty"` SubscriptionID string `json:"subscriptionId,omitempty"` ClientSecret string `json:"clientSecret,omitempty"` CreatorID string `json:"CreatorId,omitempty"` Hint string `json:"hint,omitempty"` Source string `json:"source,omitempty"` }
AzureAccount represents an Azure account registered with Cloudcraft.
type AzureService ¶
type AzureService service
AzureService handles communication with the "/azure" endpoint of Cloudcraft's developer API.
func (*AzureService) Create ¶
func (s *AzureService) Create(ctx context.Context, account *AzureAccount) (*AzureAccount, *Response, error)
Create registers a new Azure account with Cloudcraft.
func (*AzureService) List ¶
func (s *AzureService) List(ctx context.Context) ([]*AzureAccount, *Response, error)
List returns a list of Azure accounts linked with Cloudcraft.
func (*AzureService) Snapshot ¶
func (s *AzureService) Snapshot( ctx context.Context, id, region, format string, params *SnapshotParams, ) ([]byte, *Response, error)
Snapshot scans and render a region of an Azure account into a blueprint in JSON, SVG, PNG, PDF or MxGraph format.
func (*AzureService) Update ¶
func (s *AzureService) Update(ctx context.Context, account *AzureAccount) (*Response, error)
Update updates an AWS account registered in Cloudcraft.
type Blueprint ¶
type Blueprint struct { CustomerID *string `json:"CustomerId,omitempty"` ReadAccess *[]string `json:"readAccess,omitempty"` WriteAccess *[]string `json:"writeAccess,omitempty"` Tags *[]string `json:"tags,omitempty"` Data *BlueprintData `json:"data,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` UpdatedAt time.Time `json:"updatedAt,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` CreatorID string `json:"CreatorId,omitempty"` CurrentVersionID string `json:"CurrentVersionId,omitempty"` LastUserID string `json:"LastUserId,omitempty"` }
Blueprint represents a blueprint in Cloudcraft.
type BlueprintData ¶
type BlueprintData struct { LiveAccount *LiveAccount `json:"liveAccount,omitempty"` Theme *Theme `json:"theme,omitempty"` LiveOptions *LiveOptions `json:"liveOptions,omitempty"` Name string `json:"name,omitempty"` Projection string `json:"projection,omitempty"` LinkKey string `json:"linkKey,omitempty"` Grid string `json:"grid,omitempty"` Images []map[string]any `json:"images,omitempty"` Groups []map[string]any `json:"groups,omitempty"` Nodes []map[string]any `json:"nodes,omitempty"` Icons []map[string]any `json:"icons,omitempty"` Surfaces []map[string]any `json:"surfaces,omitempty"` Connectors []map[string]any `json:"connectors,omitempty"` Edges []map[string]any `json:"edges,omitempty"` Text []map[string]any `json:"text,omitempty"` DisabledLayers []string `json:"disabledLayers,omitempty"` Version int `json:"version,omitempty"` }
BlueprintData represents a collection of data that makes up a blueprint.
type BlueprintService ¶
type BlueprintService service
BlueprintService handles communication with the "/blueprint" endpoint of Cloudcraft's developer API.
func (*BlueprintService) Create ¶
func (s *BlueprintService) Create(ctx context.Context, blueprint *Blueprint) (*Blueprint, *Response, error)
Create creates a new blueprint.
func (*BlueprintService) ExportBudget ¶
func (s *BlueprintService) ExportBudget( ctx context.Context, id string, format string, params *BudgetExportParams, ) ([]byte, *Response, error)
ExportBudget exports a blueprint's budget in CSV or XLSX format.
func (*BlueprintService) ExportImage ¶
func (s *BlueprintService) ExportImage( ctx context.Context, id string, format string, params *ImageExportParams, ) ([]byte, *Response, error)
ExportImage renders a blueprint for export in SVG, PNG, PDF or MxGraph format.
type BudgetExportParams ¶
BudgetExportParams represents optional query parameters that can be used to customize an a budget export.
type Client ¶
type Client struct { // Cloudcraft API service fields. Azure *AzureService AWS *AWSService Blueprint *BlueprintService Team *TeamService User *UserService // contains filtered or unexported fields }
Client is a client for the Cloudcraft API.
type Config ¶
type Config struct { // Scheme is the protocol scheme, such as "http" or "https", to use when // calling the API. // // If not set, the value of the CLOUDCRAFT_PROTOCOL environment variable is // used. If the environment variable is not set, the default value is // "https". // // This field is optional. Scheme string // Host is the host name or IP address of the Cloudcraft API. // // If not set, the value of the CLOUDCRAFT_HOST environment variable is // used. If the environment variable is not set, the default value is the // public instance of Cloudcraft, "api.cloudcraft.co". // // This field is optional. Host string // Port is the port number of the Cloudcraft API. // // If not set, the value of the CLOUDCRAFT_PORT environment variable is // used. If the environment variable is not set, the default value is "443". // // This field is optional. Port string // Path is the path to the Cloudcraft API. // // If not set, the value of the CLOUDCRAFT_PATH environment variable is // used. If the environment variable is not set, the default value is "/". // // This field is optional. Path string // Key is the API key used to authenticate with the Cloudcraft API. // // This field is required. [Learn more]. // // [Learn more]: https://developers.cloudcraft.co/#authentication Key string // MaxRetries is the maximum number of times the client will retry a request // if it fails. // // If not set, the value of the CLOUDCRAFT_MAX_RETRIES environment variable // is used. If the environment variable is not set, the default value is 3. // // This field is optional. MaxRetries int // Timeout is the time limit for requests made by the Cloudcraft API client // to the Cloudcraft API. // // If not set, the value of the CLOUDCRAFT_TIMEOUT environment variable is // used. If the environment variable is not set, the default value is 80 // seconds. // // This field is optional. Timeout time.Duration // contains filtered or unexported fields }
Config holds the basic configuration for the Cloudcraft API.
func NewConfigFromEnv ¶
func NewConfigFromEnv() *Config
NewConfigFromEnv returns a new Config from values set in the environment.
type IAMParams ¶
type IAMParams struct { AccountID string `json:"accountId,omitempty"` ExternalID string `json:"externalId,omitempty"` AWSConsoleURL string `json:"awsConsoleUrl,omitempty"` }
IAMParams represents the AWS IAM role parameters used by Cloudcraft.
type IAMPolicy ¶
type IAMPolicy struct { Version string `json:"Version,omitempty"` Statement []IAMStatement `json:"Statement,omitempty"` }
IAMPolicy represents the AWS IAM policy used by Cloudcraft.
type IAMStatement ¶
type IAMStatement struct { Action any `json:"Action,omitempty"` Resource any `json:"Resource,omitempty"` Effect string `json:"Effect,omitempty"` }
IAMStatement represents an AWS IAM policy statement.
type ImageExportParams ¶
type ImageExportParams struct { PaperSize string Grid bool Transparent bool Landscape bool Scale float32 Width int Height int }
ImageExportParams represents optional query parameters that can be used to customize an image export.
type LiveAccount ¶
LiveAccount represents the AWS account that a blueprint is connected to.
type LiveOptions ¶
type LiveOptions struct { ExcludedTypes []string `json:"excludedTypes,omitempty"` AutoLabel bool `json:"autoLabel,omitempty"` AutoConnect bool `json:"autoConnect,omitempty"` UpdatesEnabled bool `json:"updatesEnabled,omitempty"` UpdateAllOnScan bool `json:"updateAllOnScan,omitempty"` UpdateGroupsOnScan bool `json:"updateGroupsOnScan,omitempty"` UpdateNodeOnSelect bool `json:"updateNodeOnSelect,omitempty"` }
LiveOptions represents options for a blueprint's live view.
type Members ¶ added in v1.2.0
type Members struct { ID string `json:"id,omitempty"` Role string `json:"role,omitempty"` UserID *string `json:"userId,omitempty"` Name *string `json:"name,omitempty"` Email string `json:"email,omitempty"` MFAEnabled bool `json:"mfaEnabled,omitempty"` }
Members represents a list of members in a team.
type Response ¶
type Response struct { // Header contains the response headers. Header http.Header // Body contains the response body as a byte slice. Body []byte // Status is the HTTP status code of the response. Status int }
Response represents a response from the Cloudcraft API.
type SnapshotParams ¶
type SnapshotParams struct { PaperSize string Projection string Theme string Filter []string Exclude []string Label bool Autoconnect bool Grid bool Transparent bool Landscape bool Scale float32 Width int Height int }
SnapshotParams represents query parameters used to customize an Azure or AWS account snapshot.
type Team ¶ added in v1.2.0
type Team struct { UpdatedAt time.Time `json:"updatedAt,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` CustomerID string `json:"customerId,omitempty"` Role string `json:"role,omitempty"` Members []Members `json:"members,omitempty"` Visible bool `json:"visible,omitempty"` CrossOrganizational bool `json:"crossOrganizational,omitempty"` ExternalSharing bool `json:"externalSharing,omitempty"` }
Team represents a team in Cloudcraft.
type TeamService ¶ added in v1.2.0
type TeamService service
TeamService handles communication with the "/team" endpoint of Cloudcraft's developer API.
type Theme ¶
type Theme struct {
Base string `json:"base,omitempty"`
}
Theme represents the color scheme of a blueprint.
type User ¶
type User struct { AccessedAt time.Time `json:"accessedAt,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` UpdatedAt time.Time `json:"updatedAt,omitempty"` Settings map[string]any `json:"settings,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Email string `json:"email,omitempty"` }
User represents a Cloudcraft user.
type UserService ¶
type UserService service
UserService handles communication with the "/user" endpoint of Cloudcraft's developer API.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
internal
|
|
endpoint
Package endpoint provides a function to parse fragments of an URL into an *url.URL.
|
Package endpoint provides a function to parse fragments of an URL into an *url.URL. |
meta
Package meta provides build information about the cloudcraft module.
|
Package meta provides build information about the cloudcraft module. |
xerrors
Package xerrors provides helper functions and types for error handling.
|
Package xerrors provides helper functions and types for error handling. |
xhttp
Package xhttp provides utilities and functions for working with HTTP.
|
Package xhttp provides utilities and functions for working with HTTP. |
xos
Package xos provides extensions for Go's standard os package.
|
Package xos provides extensions for Go's standard os package. |
xtesting
Package xtesting provides functions and utilities for testing the Cloudcraft SDK.
|
Package xtesting provides functions and utilities for testing the Cloudcraft SDK. |
tests
|
|
integration
Package integration contains live integration tests for Cloudcraft's developer API.
|
Package integration contains live integration tests for Cloudcraft's developer API. |