rules

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package rules contains functionality for working with ECL Managed Load Balancer resources.

Example to list rules

listOpts := rules.ListOpts{}

allPages, err := rules.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allRules, err := rules.ExtractRules(allPages)
if err != nil {
	panic(err)
}

for _, rule := range allRules {
	fmt.Printf("%+v\n", rule)
}

Example to create a rule

condition := rules.CreateOptsCondition{
	PathPatterns: []string{"^/statics/"},
}
createOpts := rules.CreateOpts{
	Name: "rule",
	Description: "description",
	Tags: map[string]string{"key": "value"},
	Priority: 1,
	TargetGroupID: "29527a3c-9e5d-48b7-868f-6442c7d21a95",
	PolicyID: "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
	Conditions: &condition,
}

rule, err := rules.Create(managedLoadBalancerClient, createOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", rule)

Example to show a rule

showOpts := rules.ShowOpts{}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
rule, err := rules.Show(managedLoadBalancerClient, id, showOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", rule)

Example to update a rule

name := "rule"
description := "description"
updateOpts := rules.UpdateOpts{
	Name: &name,
	Description: &description,
	Tags: &map[string]string{"key": "value"},
}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
rule, err := rules.Update(managedLoadBalancerClient, updateOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", rule)

Example to delete a rule

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
err := rules.Delete(managedLoadBalancerClient, id).ExtractErr()
if err != nil {
	panic(err)
}

Example to create staged rule configurations

condition := rules.CreateStagedOptsCondition{
	PathPatterns: []string{"^/statics/"},
}
createStagedOpts := rules.CreateStagedOpts{
	Priority: 1,
	TargetGroupID: "29527a3c-9e5d-48b7-868f-6442c7d21a95",
	Conditions: &condition,
}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
ruleConfigurations, err := rules.CreateStaged(managedLoadBalancerClient, id, createStagedOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", ruleConfigurations)

Example to show staged rule configurations

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
ruleConfigurations, err := rules.ShowStaged(managedLoadBalancerClient, id).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", ruleConfigurations)

Example to update staged rule configurations

condition := rules.UpdateStagedOptsCondition{
	PathPatterns: &[]string{"^/statics/"},
}

priority := 1
targetGroupID := "29527a3c-9e5d-48b7-868f-6442c7d21a95"
updateStagedOpts := rules.UpdateStagedOpts{
	Priority: &priority,
	TargetGroupID: &targetGroupID,
	Conditions: &condition,
}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
ruleConfigurations, err := rules.UpdateStaged(managedLoadBalancerClient, updateStagedOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", ruleConfigurations)

Example to cancel staged rule configurations

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
err := rules.CancelStaged(managedLoadBalancerClient, id).ExtractErr()
if err != nil {
	panic(err)
}

Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractRulesInto

func ExtractRulesInto(r pagination.Page, v interface{}) error

ExtractRulesInto interprets the results of a single page from a List() call, producing a slice of rule entities.

func List

func List(c *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns a Pager which allows you to iterate over a collection of rules. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Types

type CancelStagedResult

type CancelStagedResult struct {
	eclcloud.ErrResult
}

CancelStagedResult represents the result of a CancelStaged operation. Call its ExtractErr method to determine if the request succeeded or failed.

func CancelStaged

func CancelStaged(c *eclcloud.ServiceClient, id string) (r CancelStagedResult)

CancelStaged accepts a unique ID and deletes rule configurations associated with it.

type ConditionInResponse

type ConditionInResponse struct {

	// - URL path patterns (regular expressions) of the condition
	PathPatterns []string `json:"path_patterns"`
}

ConditionInResponse represents a condition in a rule.

type ConfigurationInResponse

type ConfigurationInResponse struct {

	// - Priority of the rule
	Priority int `json:"priority,omitempty"`

	// - ID of the target group that assigned to the rule
	TargetGroupID string `json:"target_group_id,omitempty"`

	// - Conditions of the rules to distribute accesses to the target groups
	Conditions ConditionInResponse `json:"conditions"`
}

ConfigurationInResponse represents a configuration in a rule.

type CreateOpts

type CreateOpts struct {

	// - Name of the rule
	Name string `json:"name,omitempty"`

	// - Description of the rule
	Description string `json:"description,omitempty"`

	// - Tags of the rule
	// - Must be specified as JSON object
	Tags map[string]string `json:"tags,omitempty"`

	// - Priority of the rule
	// - Must be specified the unique number in all rules belongs to the same policy
	Priority int `json:"priority,omitempty"`

	// - ID of the target group that assigned to the rule
	// - Must be specified the different target group from `"default_target_group_id"` of the policy
	TargetGroupID string `json:"target_group_id,omitempty"`

	// - ID of the policy which the rule belongs to
	// - Must be specified a policy which has a listener of which protocol is either `"http"` or `"https"`
	PolicyID string `json:"policy_id,omitempty"`

	// - Conditions of the rules to distribute accesses to the target groups
	// - Must be specified one or more condition
	Conditions *CreateOptsCondition `json:"conditions,omitempty"`
}

CreateOpts represents options used to create a new rule.

func (CreateOpts) ToRuleCreateMap

func (opts CreateOpts) ToRuleCreateMap() (map[string]interface{}, error)

ToRuleCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToRuleCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateOptsCondition

type CreateOptsCondition struct {

	// - URL path patterns (regular expressions) of the condition
	// - Must be specified the unique string in all path patterns belongs to the same policy
	// - Must be specified as PCRE (Perl Compatible Regular Expressions) format
	//   - Capturing groups and backreferences are not supported
	PathPatterns []string `json:"path_patterns,omitempty"`
}

CreateOptsCondition represents condition information in the rule creation.

type CreateResult

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

CreateResult represents the result of a Create operation. Call its Extract method to interpret it as a Rule.

func Create

func Create(c *eclcloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create accepts a CreateOpts struct and creates a new rule using the values provided.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Rule, error)

Extract is a function that accepts a result and extracts a Rule resource.

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a rule, if possible.

type CreateStagedOpts

type CreateStagedOpts struct {

	// - Priority of the rule
	// - Must be specified the unique number in all rules belongs to the same policy
	Priority int `json:"priority,omitempty"`

	// - ID of the target group that assigned to the rule
	// - Must be specified the different target group from `"default_target_group_id"` of the policy
	TargetGroupID string `json:"target_group_id,omitempty"`

	// - Conditions of the rules to distribute accesses to the target groups
	// - Must be specified one or more condition
	Conditions *CreateStagedOptsCondition `json:"conditions,omitempty"`
}

CreateStagedOpts represents options used to create new rule configurations.

func (CreateStagedOpts) ToRuleCreateStagedMap

func (opts CreateStagedOpts) ToRuleCreateStagedMap() (map[string]interface{}, error)

ToRuleCreateStagedMap builds a request body from CreateStagedOpts.

type CreateStagedOptsBuilder

type CreateStagedOptsBuilder interface {
	ToRuleCreateStagedMap() (map[string]interface{}, error)
}

CreateStagedOptsBuilder allows extensions to add additional parameters to the CreateStaged request.

type CreateStagedOptsCondition

type CreateStagedOptsCondition struct {

	// - URL path patterns (regular expressions) of the condition
	// - Must be specified the unique string in all path patterns belongs to the same policy
	// - Must be specified as PCRE (Perl Compatible Regular Expressions) format
	//   - Capturing groups and backreferences are not supported
	PathPatterns []string `json:"path_patterns,omitempty"`
}

CreateStagedOptsCondition represents condition information in the rule configurations creation.

type CreateStagedResult

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

CreateStagedResult represents the result of a CreateStaged operation. Call its Extract method to interpret it as a Rule.

func CreateStaged

func CreateStaged(c *eclcloud.ServiceClient, id string, opts CreateStagedOptsBuilder) (r CreateStagedResult)

CreateStaged accepts a CreateStagedOpts struct and creates new rule configurations using the values provided.

func (CreateStagedResult) Extract

func (r CreateStagedResult) Extract() (*Rule, error)

Extract is a function that accepts a result and extracts a Rule resource.

func (CreateStagedResult) ExtractInto

func (r CreateStagedResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a rule, if possible.

type DeleteResult

type DeleteResult struct {
	eclcloud.ErrResult
}

DeleteResult represents the result of a Delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(c *eclcloud.ServiceClient, id string) (r DeleteResult)

Delete accepts a unique ID and deletes the rule associated with it.

type ListOpts

type ListOpts struct {

	// - ID of the resource
	ID string `q:"id"`

	// - Name of the resource
	Name string `q:"name"`

	// - Description of the resource
	Description string `q:"description"`

	// - Configuration status of the resource
	ConfigurationStatus string `q:"configuration_status"`

	// - Operation status of the resource
	OperationStatus string `q:"operation_status"`

	// - Priority of the rule
	Priority int `q:"priority"`

	// - ID of the target group that assigned to the rule
	TargetGroupID string `q:"target_group_id"`

	// - ID of the policy which the rule belongs to
	PolicyID string `q:"policy_id"`

	// - ID of the load balancer which the resource belongs to
	LoadBalancerID string `q:"load_balancer_id"`

	// - ID of the owner tenant of the resource
	TenantID string `q:"tenant_id"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the rule attributes you want to see returned.

func (ListOpts) ToRuleListQuery

func (opts ListOpts) ToRuleListQuery() (string, error)

ToRuleListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToRuleListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Rule

type Rule struct {

	// - ID of the rule
	ID string `json:"id"`

	// - Name of the rule
	Name string `json:"name"`

	// - Description of the rule
	Description string `json:"description"`

	// - Tags of the rule (JSON object format)
	Tags map[string]string `json:"tags"`

	// - Configuration status of the rule
	//   - `"ACTIVE"`
	//     - There are no configurations of the rule that waiting to be applied
	//   - `"CREATE_STAGED"`
	//     - The rule has been added and waiting to be applied
	//   - `"UPDATE_STAGED"`
	//     - Changed configurations of the rule exists that waiting to be applied
	//   - `"DELETE_STAGED"`
	//     - The rule has been removed and waiting to be applied
	ConfigurationStatus string `json:"configuration_status"`

	// - Operation status of the load balancer which the rule belongs to
	//   - `"NONE"` :
	//     - There are no operations of the load balancer
	//     - The load balancer and related resources can be operated
	//   - `"PROCESSING"`
	//     - The latest operation of the load balancer is processing
	//     - The load balancer and related resources cannot be operated
	//   - `"COMPLETE"`
	//     - The latest operation of the load balancer has been succeeded
	//     - The load balancer and related resources can be operated
	//   - `"STUCK"`
	//     - The latest operation of the load balancer has been stopped
	//     - Operators of NTT Communications will investigate the operation
	//     - The load balancer and related resources cannot be operated
	//   - `"ERROR"`
	//     - The latest operation of the load balancer has been failed
	//     - The operation was roll backed normally
	//     - The load balancer and related resources can be operated
	OperationStatus string `json:"operation_status"`

	// - ID of the policy which the rule belongs to
	PolicyID string `json:"policy_id"`

	// - ID of the load balancer which the rule belongs to
	LoadBalancerID string `json:"load_balancer_id"`

	// - ID of the owner tenant of the rule
	TenantID string `json:"tenant_id"`

	// - Priority of the rule
	Priority int `json:"priority,omitempty"`

	// - ID of the target group that assigned to the rule
	TargetGroupID string `json:"target_group_id,omitempty"`

	// - Conditions of the rules to distribute accesses to the target groups
	Conditions ConditionInResponse `json:"conditions"`

	// - Running configurations of the rule
	// - Return object when `changes` is `true`
	// - Return `null` when current configuration does not exist
	Current ConfigurationInResponse `json:"current"`

	// - Added or changed configurations of the rule that waiting to be applied
	// - Return object when `changes` is `true`
	// - Return `null` when staged configuration does not exist
	Staged ConfigurationInResponse `json:"staged"`
}

Rule represents a rule.

func ExtractRules

func ExtractRules(r pagination.Page) ([]Rule, error)

ExtractRules accepts a Page struct, specifically a NetworkPage struct, and extracts the elements into a slice of Rule structs. In other words, a generic collection is mapped into a relevant slice.

type RulePage

type RulePage struct {
	pagination.LinkedPageBase
}

RulePage is the page returned by a pager when traversing over a collection of rule.

func (RulePage) IsEmpty

func (r RulePage) IsEmpty() (bool, error)

IsEmpty checks whether a RulePage struct is empty.

type ShowOpts

type ShowOpts struct {

	// - When `true` is specified, `current` and `staged` are returned in response body
	Changes bool `q:"changes"`
}

ShowOpts represents options used to show a rule.

func (ShowOpts) ToRuleShowQuery

func (opts ShowOpts) ToRuleShowQuery() (string, error)

ToRuleShowQuery formats a ShowOpts into a query string.

type ShowOptsBuilder

type ShowOptsBuilder interface {
	ToRuleShowQuery() (string, error)
}

ShowOptsBuilder allows extensions to add additional parameters to the Show request.

type ShowResult

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

ShowResult represents the result of a Show operation. Call its Extract method to interpret it as a Rule.

func Show

func Show(c *eclcloud.ServiceClient, id string, opts ShowOptsBuilder) (r ShowResult)

Show retrieves a specific rule based on its unique ID.

func (ShowResult) Extract

func (r ShowResult) Extract() (*Rule, error)

Extract is a function that accepts a result and extracts a Rule resource.

func (ShowResult) ExtractInto

func (r ShowResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a rule, if possible.

type ShowStagedResult

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

ShowStagedResult represents the result of a ShowStaged operation. Call its Extract method to interpret it as a Rule.

func ShowStaged

func ShowStaged(c *eclcloud.ServiceClient, id string) (r ShowStagedResult)

ShowStaged retrieves specific rule configurations based on its unique ID.

func (ShowStagedResult) Extract

func (r ShowStagedResult) Extract() (*Rule, error)

Extract is a function that accepts a result and extracts a Rule resource.

func (ShowStagedResult) ExtractInto

func (r ShowStagedResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a rule, if possible.

type UpdateOpts

type UpdateOpts struct {

	// - Name of the rule
	Name *string `json:"name,omitempty"`

	// - Description of the rule
	Description *string `json:"description,omitempty"`

	// - Tags of the rule
	// - Must be specified as JSON object
	Tags *map[string]string `json:"tags,omitempty"`
}

UpdateOpts represents options used to update a existing rule.

func (UpdateOpts) ToRuleUpdateMap

func (opts UpdateOpts) ToRuleUpdateMap() (map[string]interface{}, error)

ToRuleUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToRuleUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

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

UpdateResult represents the result of a Update operation. Call its Extract method to interpret it as a Rule.

func Update

func Update(c *eclcloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts a UpdateOpts struct and updates a existing rule using the values provided.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Rule, error)

Extract is a function that accepts a result and extracts a Rule resource.

func (UpdateResult) ExtractInto

func (r UpdateResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a rule, if possible.

type UpdateStagedOpts

type UpdateStagedOpts struct {

	// - Priority of the rule
	// - Must be specified the unique number in all rules belongs to the same policy
	Priority *int `json:"priority,omitempty"`

	// - ID of the target group that assigned to the rule
	// - Must be specified the different target group from `"default_target_group_id"` of the policy
	TargetGroupID *string `json:"target_group_id,omitempty"`

	// - Conditions of the rules to distribute accesses to the target groups
	// - Must be specified one or more condition
	Conditions *UpdateStagedOptsCondition `json:"conditions,omitempty"`
}

UpdateStagedOpts represents options used to update existing Rule configurations.

func (UpdateStagedOpts) ToRuleUpdateStagedMap

func (opts UpdateStagedOpts) ToRuleUpdateStagedMap() (map[string]interface{}, error)

ToRuleUpdateStagedMap builds a request body from UpdateStagedOpts.

type UpdateStagedOptsBuilder

type UpdateStagedOptsBuilder interface {
	ToRuleUpdateStagedMap() (map[string]interface{}, error)
}

UpdateStagedOptsBuilder allows extensions to add additional parameters to the UpdateStaged request.

type UpdateStagedOptsCondition

type UpdateStagedOptsCondition struct {

	// - URL path patterns (regular expressions) of the condition
	// - Must be specified the unique string in all path patterns belongs to the same policy
	// - Must be specified as PCRE (Perl Compatible Regular Expressions) format
	//   - Capturing groups and backreferences are not supported
	PathPatterns *[]string `json:"path_patterns,omitempty"`
}

UpdateStagedOptsCondition represents condition information in rule configurations updation.

type UpdateStagedResult

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

UpdateStagedResult represents the result of a UpdateStaged operation. Call its Extract method to interpret it as a Rule.

func UpdateStaged

func UpdateStaged(c *eclcloud.ServiceClient, id string, opts UpdateStagedOptsBuilder) (r UpdateStagedResult)

UpdateStaged accepts a UpdateStagedOpts struct and updates existing Rule configurations using the values provided.

func (UpdateStagedResult) Extract

func (r UpdateStagedResult) Extract() (*Rule, error)

Extract is a function that accepts a result and extracts a Rule resource.

func (UpdateStagedResult) ExtractInto

func (r UpdateStagedResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a rule, if possible.

Directories

Path Synopsis
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Jump to

Keyboard shortcuts

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