cfw

package
v0.9.208 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

* Copyright 2022 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language governing permissions * and limitations under the License.

* Copyright 2022 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language governing permissions * and limitations under the License.

Index

Constants

View Source
const (
	DEFAULT_SERVICE_DOMAIN = "http://cfw.baidubce.com"
	DEFAULT_MAX_PARALLEL   = 10
	MULTIPART_ALIGN        = 1 << 20        // 1MB
	MIN_MULTIPART_SIZE     = 1 << 20        // 1MB
	DEFAULT_MULTIPART_SIZE = 12 * (1 << 20) // 12MB
	MAX_PART_NUMBER        = 10000
)

Variables

This section is empty.

Functions

func BindCfw

func BindCfw(cli *Client, cfwId string, body *BindCfwRequest) error

BindCfw - 批量实例绑定CFW策略。 - 没有规则的CFW不能绑定到实例

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id
  • body:

RETURNS:

  • error: the return error if any occurs

func CreateCfwRule

func CreateCfwRule(cli *Client, cfwId string, body *CreateCfwRuleRequest) error

CreateCfwRule - 批量创建CFW中防护规则。 - 五元组(protocol/sourceAddress/destAddress/sourcePort/destPort) + 方向(direction)不能全部相同。 - 一次最多创建100条规则。

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id
  • body:

RETURNS:

  • error: the return error if any occurs

func DeleteCfw

func DeleteCfw(cli *Client, cfwId string) error

DeleteCfw - 删除指定CFW策略。 - CFW存在绑定关系时不允许删除

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id

RETURNS:

  • error: the return error if any occurs

func DeleteCfwRule

func DeleteCfwRule(cli *Client, cfwId string, body *DeleteCfwRuleRequest) error

DeleteCfwRule - 批量删除指定CFW中某些规则。 - CFW已绑定到实例时,至少保留一条规则。

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id
  • body:

RETURNS:

  • error: the return error if any occurs

func DisableCfw

func DisableCfw(cli *Client, cfwId string, body *DisableCfwRequest) error

DisableCfw - 已绑定CFW的实例,使用该接口临时关闭CFW的防护功能。

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id
  • body:

RETURNS:

  • error: the return error if any occurs

func EnableCfw

func EnableCfw(cli *Client, cfwId string, body *EnableCfwRequest) error

EnableCfw - 已绑定CFW并且临时关闭了防护功能的实例,使用该接口恢复CFW的防护功能。

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id
  • body:

RETURNS:

  • error: the return error if any occurs

func UnbindCfw

func UnbindCfw(cli *Client, cfwId string, body *UnbindCfwRequest) error

UnbindCfw - 实例批量解绑CFW。

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id
  • body:

RETURNS:

  • error: the return error if any occurs

func UpdateCfw

func UpdateCfw(cli *Client, cfwId string, body *UpdateCfwRequest) error

UpdateCfw - 更新CFW策略的基本信息。

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id
  • body:

RETURNS:

  • error: the return error if any occurs

func UpdateCfwRule

func UpdateCfwRule(cli *Client, cfwId string, cfwRuleId string,
	body *UpdateCfwRuleRequest) error

UpdateCfwRule - 修改指定CFW规则。 - 五元组(protocol/sourceAddress/destAddress/sourcePort/destPort) + 方向(direction)不能全部相同。

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW策略的id
  • cfwRuleId: CFW规则的id
  • body:

RETURNS:

  • error: the return error if any occurs

Types

type BindCfwRequest

type BindCfwRequest struct {
	InstanceType string    `json:"instanceType"`
	Instances    []CfwBind `json:"instances"`
}

type BindCfwRequestInstances

type BindCfwRequestInstances struct {
}

type Cfw

type Cfw struct {
	CfwId           string    `json:"cfwId"`
	Name            string    `json:"name"`
	Description     string    `json:"description"`
	CreatedTime     string    `json:"createdTime"`
	BindInstanceNum int32     `json:"bindInstanceNum"`
	Type            int32     `json:"type"`
	Border          int32     `json:"border"`
	CfwRules        []CfwRule `json:"cfwRules"`
}

type CfwBind

type CfwBind struct {
	Region     string `json:"region"`
	InstanceId string `json:"instanceId"`
	Role       string `json:"role"`
	MemberId   string `json:"memberId"`
}

type CfwRule

type CfwRule struct {
	IpVersion     int32  `json:"ipVersion"`
	Priority      int32  `json:"priority"`
	Protocol      string `json:"protocol"`
	Direction     string `json:"direction"`
	SourceAddress string `json:"sourceAddress"`
	DestAddress   string `json:"destAddress"`
	SourcePort    string `json:"sourcePort"`
	DestPort      string `json:"destPort"`
	Action        string `json:"action"`
	Description   string `json:"description"`
	CfwId         string `json:"cfwId"`
	CfwRuleId     string `json:"cfwRuleId"`
}

type Client

type Client struct {
	*bce.BceClient

	// Fileds that used in parallel operation for BOS service
	MaxParallel   int64
	MultipartSize int64
}

Client of bcd service is a kind of BceClient, so derived from BceClient

func NewClient

func NewClient(ak, sk, endpoint string) (*Client, error)

NewClient make the bcd service client with default configuration. Use `cli.Config.xxx` to access the config or change it to non-default value.

func (*Client) BindCfw

func (c *Client) BindCfw(cfwId string, body *BindCfwRequest) error

BindCfw - 批量实例绑定CFW策略。 - 没有规则的CFW不能绑定到实例

PARAMS:

  • cfwId: CFW的id
  • body: body参数

RETURNS:

  • error: the return error if any occurs

func (*Client) CreateCfw

func (c *Client) CreateCfw(body *CreateCfwRequest) (
	*CreateCfwResponse, error)

CreateCfw - 创建CFW策略。

PARAMS:

  • body: body参数

RETURNS:

  • *CreateCfwResponse:
  • error: the return error if any occurs

func (*Client) CreateCfwRule

func (c *Client) CreateCfwRule(cfwId string, body *CreateCfwRuleRequest) error

CreateCfwRule - 批量创建CFW中防护规则。 - 五元组(protocol/sourceAddress/destAddress/sourcePort/destPort) + 方向(direction)不能全部相同。 - 一次最多创建100条规则。

PARAMS:

  • cfwId: CFW的id
  • body: body参数

RETURNS:

  • error: the return error if any occurs

func (*Client) DeleteCfw

func (c *Client) DeleteCfw(cfwId string) error

DeleteCfw - 删除指定CFW策略。 - CFW存在绑定关系时不允许删除

PARAMS:

  • cfwId: CFW的id

RETURNS:

  • error: the return error if any occurs

func (*Client) DeleteCfwRule

func (c *Client) DeleteCfwRule(cfwId string, body *DeleteCfwRuleRequest) error

DeleteCfwRule - 批量删除指定CFW中某些规则。 - CFW已绑定到实例时,至少保留一条规则。

PARAMS:

  • cfwId: CFW的id
  • body: body参数

RETURNS:

  • error: the return error if any occurs

func (*Client) DisableCfw

func (c *Client) DisableCfw(cfwId string, body *DisableCfwRequest) error

DisableCfw - 已绑定CFW的实例,使用该接口临时关闭CFW的防护功能。

PARAMS:

  • cfwId: CFW的id
  • body: body参数

RETURNS:

  • error: the return error if any occurs

func (*Client) EnableCfw

func (c *Client) EnableCfw(cfwId string, body *EnableCfwRequest) error

EnableCfw - 已绑定CFW并且临时关闭了防护功能的实例,使用该接口恢复CFW的防护功能。

PARAMS:

  • cfwId: CFW的id
  • body: body参数

RETURNS:

  • error: the return error if any occurs

func (*Client) GetCfw

func (c *Client) GetCfw(cfwId string) (*GetCfwResponse, error)

GetCfw - 查询指定CFW策略的详情信息。

PARAMS:

  • cfwId: CFW的id

RETURNS:

  • *GetCfwResponse:
  • error: the return error if any occurs

func (*Client) ListCfw

func (c *Client) ListCfw(listCfwArgs *ListCfwArgs) (
	*ListCfwResponse, error)

ListCfw - 查询CFW策略列表信息。

PARAMS:

  • marker: 批量获取列表查询的起始位置,是一个由系统生成的字符串
  • maxKeys: 每页包含的最大数量,最大数量通常不超过1000,缺省值为1000

RETURNS:

  • *ListCfwResponse:
  • error: the return error if any occurs

func (*Client) ListInstance

func (c *Client) ListInstance(body *ListInstanceRequest) (*ListInstanceResponse, error)

ListInstance - 查询防护边界实例的列表。

PARAMS:

  • instanceType: 实例类型,取值[ eip | nat | etGateway | peerconn | csn | ipv6Gateway ]
  • marker: 批量获取列表的查询的起始位置,是一个由系统生成的字符串
  • maxKeys: 每页包含的最大数量,最大数量通常不超过1000,缺省值为1000
  • status: 防护状态,取值 [ unbound | protected | unprotected ]
  • region: 地域信息,取值 [ bj | gz | su | fsh | hkg | bd | fwh | sin ]
  • body: body参数

RETURNS:

  • *ListInstanceResponse:
  • error: the return error if any occurs

func (*Client) UnbindCfw

func (c *Client) UnbindCfw(cfwId string, body *UnbindCfwRequest) error

UnbindCfw - 实例批量解绑CFW。

PARAMS:

  • cfwId: CFW的id
  • body: body参数

RETURNS:

  • error: the return error if any occurs

func (*Client) UpdateCfw

func (c *Client) UpdateCfw(cfwId string, body *UpdateCfwRequest) error

UpdateCfw - 更新CFW策略的基本信息。

PARAMS:

  • cfwId: CFW的id
  • body: body参数

RETURNS:

  • error: the return error if any occurs

func (*Client) UpdateCfwRule

func (c *Client) UpdateCfwRule(cfwId string, cfwRuleId string,
	body *UpdateCfwRuleRequest) error

UpdateCfwRule - 修改指定CFW规则。 - 五元组(protocol/sourceAddress/destAddress/sourcePort/destPort) + 方向(direction)不能全部相同。

PARAMS:

  • cfwId: CFW策略的id
  • cfwRuleId: CFW规则的id
  • body: body参数

RETURNS:

  • error: the return error if any occurs

type CreateCfwRequest

type CreateCfwRequest struct {
	Name        string       `json:"name"`
	Description string       `json:"description"`
	Type        int32        `json:"type"`
	Border      int32        `json:"border"`
	CfwRules    []CreateRule `json:"cfwRules"`
}

type CreateCfwRequestCfwRules

type CreateCfwRequestCfwRules struct {
}

type CreateCfwResponse

type CreateCfwResponse struct {
	CfwId string `json:"cfwId"`
}

func CreateCfw

func CreateCfw(cli *Client, body *CreateCfwRequest) (*CreateCfwResponse, error)

CreateCfw - 创建CFW策略。

PARAMS:

  • cli: the client agent which can perform sending request
  • body:

RETURNS:

  • *api.CreateCfwResponse:
  • error: the return error if any occurs

type CreateCfwRuleRequest

type CreateCfwRuleRequest struct {
	CfwRules []CreateRule `json:"cfwRules"`
}

type CreateCfwRuleRequestCfwRules

type CreateCfwRuleRequestCfwRules struct {
}

type CreateRule

type CreateRule struct {
	IpVersion     int32  `json:"ipVersion"`
	Priority      int32  `json:"priority"`
	Protocol      string `json:"protocol"`
	Direction     string `json:"direction"`
	SourceAddress string `json:"sourceAddress"`
	DestAddress   string `json:"destAddress"`
	SourcePort    string `json:"sourcePort"`
	DestPort      string `json:"destPort"`
	Action        string `json:"action"`
	Description   string `json:"description"`
}

type DeleteCfwRuleRequest

type DeleteCfwRuleRequest struct {
	CfwRuleIds []string `json:"cfwRuleIds"`
}

type DeleteCfwRuleRequestCfwRuleIds

type DeleteCfwRuleRequestCfwRuleIds struct {
}

type DisableCfwRequest

type DisableCfwRequest struct {
	InstanceId string `json:"instanceId"`
	Role       string `json:"role"`
	MemberId   string `json:"memberId"`
}

type EnableCfwRequest

type EnableCfwRequest struct {
	InstanceId string `json:"instanceId"`
	Role       string `json:"role"`
	MemberId   string `json:"memberId"`
}

type GetCfwResponse

type GetCfwResponse struct {
	CfwId           string    `json:"cfwId"`
	Name            string    `json:"name"`
	Description     string    `json:"description"`
	CreatedTime     string    `json:"createdTime"`
	BindInstanceNum int32     `json:"bindInstanceNum"`
	Type            int32     `json:"type"`
	Border          int32     `json:"border"`
	CfwRules        []CfwRule `json:"cfwRules"`
}

func GetCfw

func GetCfw(cli *Client, cfwId string) (*GetCfwResponse, error)

GetCfw - 查询指定CFW策略的详情信息。

PARAMS:

  • cli: the client agent which can perform sending request
  • cfwId: CFW的id

RETURNS:

  • *api.GetCfwResponse:
  • error: the return error if any occurs

type GetCfwResponseCfwRules

type GetCfwResponseCfwRules struct {
}

type Instance

type Instance struct {
	InstanceId      string `json:"instanceId"`
	InstanceName    string `json:"instanceName"`
	Status          string `json:"status"`
	Region          string `json:"region"`
	CfwId           string `json:"cfwId"`
	CfwName         string `json:"cfwName"`
	VpcId           string `json:"vpcId"`
	VpcName         string `json:"vpcName"`
	PublicIp        string `json:"publicIp"`
	Role            string `json:"role"`
	LocalIfId       string `json:"localIfId"`
	LocalIfName     string `json:"localIfName"`
	PeerRegion      string `json:"peerRegion"`
	PeerVpcId       string `json:"peerVpcId"`
	PeerVpcName     string `json:"peerVpcName"`
	MemberId        string `json:"memberId"`
	MemberName      string `json:"memberName"`
	MemberAccountId string `json:"memberAccountId"`
}

type ListCfwArgs

type ListCfwArgs struct {
	Marker  string `json:"marker"`
	MaxKeys int    `json:"maxKeys"`
}

type ListCfwResponse

type ListCfwResponse struct {
	Marker      string `json:"marker"`
	IsTruncated bool   `json:"isTruncated"`
	NextMarker  string `json:"nextMarker"`
	MaxKeys     int32  `json:"maxKeys"`
	Cfws        []Cfw  `json:"cfws"`
}

func ListCfw

func ListCfw(cli *Client, listCfwArgs *ListCfwArgs) (
	*ListCfwResponse, error)

ListCfw - 查询CFW策略列表信息。

PARAMS:

  • cli: the client agent which can perform sending request
  • listCfwArgs:

RETURNS:

  • *api.ListCfwResponse:
  • error: the return error if any occurs

type ListCfwResponseCfws

type ListCfwResponseCfws struct {
}

type ListInstanceRequest

type ListInstanceRequest struct {
	InstanceType string `json:"instanceType"`
	Marker       string `json:"marker"`
	MaxKeys      int    `json:"maxKeys"`
	Status       string `json:"status"`
	Region       string `json:"region"`
}

type ListInstanceRequestCfwRuleIds

type ListInstanceRequestCfwRuleIds struct {
}

type ListInstanceResponse

type ListInstanceResponse struct {
	Marker      string     `json:"marker"`
	IsTruncated bool       `json:"isTruncated"`
	NextMarker  string     `json:"nextMarker"`
	MaxKeys     int        `json:"maxKeys"`
	Instances   []Instance `json:"instances"`
}

func ListInstance

func ListInstance(cli *Client, listInstanceRequest *ListInstanceRequest) (*ListInstanceResponse, error)

ListInstance - 查询防护边界实例的列表。

PARAMS:

  • cli: the client agent which can perform sending request
  • listInstanceRequest:

RETURNS:

  • *api.ListInstanceResponse:
  • error: the return error if any occurs

type ListInstanceResponseInstances

type ListInstanceResponseInstances struct {
}

type UnbindCfwRequest

type UnbindCfwRequest struct {
	InstanceType string    `json:"instanceType"`
	Instances    []CfwBind `json:"instances"`
}

type UnbindCfwRequestInstances

type UnbindCfwRequestInstances struct {
}

type UpdateCfwRequest

type UpdateCfwRequest struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

type UpdateCfwRuleRequest

type UpdateCfwRuleRequest struct {
	IpVersion     int32  `json:"ipVersion"`
	Priority      int32  `json:"priority"`
	Protocol      string `json:"protocol"`
	Direction     string `json:"direction"`
	SourceAddress string `json:"sourceAddress"`
	DestAddress   string `json:"destAddress"`
	SourcePort    string `json:"sourcePort"`
	DestPort      string `json:"destPort"`
	Action        string `json:"action"`
	Description   string `json:"description"`
}

Jump to

Keyboard shortcuts

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