Documentation
¶
Overview ¶
Package papi contains code for exporting properties.
Index ¶
- Variables
- func AsInt(f any) int64
- func CheckErrors() (string, error)
- func CmdCreateInclude(c *cli.Context) error
- func CmdCreateProperty(c *cli.Context) error
- func ReportError(format string, a ...any) string
- type EdgeHostname
- type Hostname
- type HostnameBucketDetails
- type HostnameItem
- type NetworkInfo
- type RuleTemplate
- type RulesTemplate
- type TFData
- type TFIncludeData
- type TFPropertyData
- type WrappedRules
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFetchingActivations is returned when fetching activations of include request failed ErrFetchingActivations = errors.New("fetching include activations") // ErrFetchingLatestIncludeVersion is returned when fetching latest version of include request failed ErrFetchingLatestIncludeVersion = errors.New("fetching latest include version") // ErrIncludeNotFound is returned when include couldn't be found ErrIncludeNotFound = errors.New("include name not found") // ErrIncludeRulesNotFound is returned when include rules couldn't be found ErrIncludeRulesNotFound = errors.New("include rules not found") )
var ( // ErrHostnamesNotFound is returned when hostnames couldn't be found ErrHostnamesNotFound = errors.New("hostnames not found") // ErrPropertyVersionNotFound is returned when property version couldn't be found ErrPropertyVersionNotFound = errors.New("property version not found") // ErrPropertyVersionNotValid is returned when property version couldn't be found ErrPropertyVersionNotValid = errors.New("property version not valid") // ErrProductNameNotFound is returned when product couldn't be found ErrProductNameNotFound = errors.New("product name not found") // ErrFetchingActivationDetails is returned when fetching activation details request failed ErrFetchingActivationDetails = errors.New("fetching activations") // ErrFetchingHostnameDetails is returned when fetching hostname details request failed ErrFetchingHostnameDetails = errors.New("fetching hostnames") // ErrSavingSnippets is returned when error appeared while saving property snippet JSON files ErrSavingSnippets = errors.New("saving snippets") // ErrPropertyRulesNotFound is returned when property rules couldn't be found ErrPropertyRulesNotFound = errors.New("property rules not found") // ErrGroupNotFound is returned when group couldn't be found ErrGroupNotFound = errors.New("group not found") // ErrPropertyNotFound is returned when property couldn't be found ErrPropertyNotFound = errors.New("property not found") // ErrSavingFiles is returned when an issue with processing templates occurs ErrSavingFiles = errors.New("saving terraform project files") // ErrUnsupportedRuleFormat is returned when there is no template for provided rule format ErrUnsupportedRuleFormat = errors.New("unsupported rule format") // ErrListActivePropertyHostnames is returned when listing active property hostnames failed ErrListActivePropertyHostnames = errors.New("list active property hostnames failed") // ErrListPropertyHostnameActivations is returned when listing property hostnames activations failed ErrListPropertyHostnameActivations = errors.New("list property hostnames activations failed") )
Functions ¶
func CheckErrors ¶
CheckErrors is used to fail the processing of the template in case of any unknown behaviors or criteria
As per template.FuncMap definition, for the error to be treated as error (rather than regular value), it has to be returned as second returned value. Therefor always returning "" as first returned value.
func CmdCreateInclude ¶
func CmdCreateInclude(c *cli.Context) error
CmdCreateInclude is an entrypoint to export-include include sub-command
func CmdCreateProperty ¶
func CmdCreateProperty(c *cli.Context) error
CmdCreateProperty is an entrypoint to create-property command
func ReportError ¶
ReportError is used to report unknown behaviors or criteria during processing the template
Types ¶
type EdgeHostname ¶
type EdgeHostname struct { EdgeHostname string EdgeHostnameID string ContractID string GroupID string ID string IPv6 string EdgeHostnameResourceName string SecurityType string UseCases string CertificateID int64 TTL int }
EdgeHostname represents EdgeHostname resource
type Hostname ¶
type Hostname struct { CnameFrom string CnameTo string EdgeHostnameResourceName string CertProvisioningType string IsActive bool }
Hostname represents edge hostname resource
type HostnameBucketDetails ¶ added in v2.1.0
type HostnameBucketDetails struct { StagingNotifyEmails []string ProductionNotifyEmails []string StagingNote string ProductionNote string HasStagingActivation bool HasProductionActivation bool Hostnames map[string]HostnameItem }
HostnameBucketDetails contains details about staging and production hostname buckets
type HostnameItem ¶ added in v2.1.0
type HostnameItem struct { CnameTo string CertProvisioningType string EdgeHostnameID string Staging bool Production bool ProductionCertProvisioningType *string ProductionEdgeHostnameID *string }
HostnameItem represents hostname in a bucket. By default, `CertProvisioningType` and `EdgeHostnameID` should be the same for both STAGING and PRODUCTION networks. If they are not, `ProductionCertType` and `ProductionEdgeHostnameID` are set to distinguish between them. It's needed to handle an edge case, in which there is the same hostname on STAGING and PRODUCTION networks, but it differs in cert_provisioning_type or edge_hostname_id. We need to generate separate configuration variable for this case.
type NetworkInfo ¶
type NetworkInfo struct { Emails []string ActivationNote string HasActivation bool Version int IsActiveOnLatestVersion bool }
NetworkInfo holds details for specific network
type RuleTemplate ¶
type RuleTemplate struct { Name string `json:"name"` Criteria []papi.RuleBehavior `json:"criteria,omitempty"` Behaviors []papi.RuleBehavior `json:"behaviors,omitempty"` Children []string `json:"children,omitempty"` Comments string `json:"comments,omitempty"` CriteriaLocked bool `json:"criteriaLocked,omitempty"` CriteriaMustSatisfy papi.RuleCriteriaMustSatisfy `json:"criteriaMustSatisfy,omitempty"` UUID string `json:"uuid,omitempty"` Variables []papi.RuleVariable `json:"variables,omitempty"` AdvancedOverride string `json:"advancedOverride,omitempty"` Options struct { IsSecure bool `json:"is_secure,omitempty"` } `json:"options,omitempty"` CustomOverride *papi.RuleCustomOverride `json:"customOverride,omitempty"` }
RuleTemplate represent data used for single rule
type RulesTemplate ¶
type RulesTemplate struct { AccountID string `json:"accountId"` ContractID string `json:"contractId"` GroupID string `json:"groupId"` PropertyID string `json:"propertyId,omitempty"` IncludeID string `json:"includeId,omitempty"` PropertyVersion int `json:"propertyVersion,omitempty"` IncludeVersion int `json:"includeVersion,omitempty"` IncludeType string `json:"includeType,omitempty"` Etag string `json:"etag"` RuleFormat string `json:"ruleFormat"` Comments string `json:"comments,omitempty"` Rule *RuleTemplate `json:"rules"` Errors []*papi.Error `json:"errors,omitempty"` }
RulesTemplate represent data used for rules
type TFData ¶
type TFData struct { Includes []TFIncludeData Property TFPropertyData Section string Rules []*WrappedRules RulesAsHCL bool UseBootstrap bool UseSplitDepth bool RootRule string }
TFData holds template data
type TFIncludeData ¶
type TFIncludeData struct { ContractID string GroupID string IncludeID string IncludeName string IncludeType string RuleFormat string Rules []*WrappedRules ProductID string ProductionInfo NetworkInfo StagingInfo NetworkInfo RootRule string }
TFIncludeData holds template data for include
type TFPropertyData ¶
type TFPropertyData struct { GroupName string GroupID string ContractID string PropertyResourceName string PropertyName string PropertyID string ProductID string ProductName string RuleFormat string IsSecure string EdgeHostnames map[string]EdgeHostname Hostnames map[string]Hostname HostnameBucket *HostnameBucketDetails ReadVersion string ProductionInfo NetworkInfo StagingInfo NetworkInfo }
TFPropertyData holds template data for property
type WrappedRules ¶
type WrappedRules struct { Rule papi.Rules TerraformName string FileName string Children []*WrappedRules IsRoot bool }
WrappedRules is a wrapper around Rule which simplifies flattening rule tree into list and adjust names of the datasources