BcmClient

BCM

  • Function Release Records
  • Product Announcement
    • Site Monitor Billing Announcement
  • Product Description
    • Product Introduction
    • Core concepts
    • Product advantages
    • Product features
  • Product pricing
    • Product pricing
    • Site Monitor Pricing
  • Quick Start
  • Operation guide
    • Enter Cloud Monitor
    • Dashboard
      • Overview
      • Management Dashboard Charts
      • Management Dashboard
    • Alarm Service
      • Overview
      • Alarm strategy
      • Alarm history
      • Alarm Template
      • Alarm Notification Template
      • Alarm callback
    • Cloud product monitor
      • Instance monitor
      • Instance Group
      • View Metrics
    • Site Monitor
      • Timed Detection (Formerly Site Monitor)
        • Overview
        • Manage Timed Probe Tasks
        • Purchase Guide
        • View timed probe tasks
      • IP advanced fault diagnosis
        • Manage IP Advanced Fault Diagnosis Tasks
        • View IP Advanced Fault Diagnosis Tasks
      • Instant probe
        • Overview
        • Manage instant probe tasks
    • Event Monitor
    • Event Bus
      • Event Delivery History
      • Overview
      • Event summary
      • Event Set
      • Event Rules
        • Event Rules
        • Event content conversion
        • Event pattern
  • API Reference
    • Overview
    • Service domain
    • Error response
    • Query Monitoring Data for Partial Dimensions
    • Dashboard API
    • Common Request and Response Headers
    • Alarm Management API
    • Alarm Management Interface V2
    • Alarm history
    • Push Data API
    • Event Bus Push
    • Application Monitor
    • Dimension Value TopN and Monitoring Data Query Interface
    • Batch Query Monitoring Data Interface V2
    • Dimension Value TopN Query Interface
    • Instance Group Interface
    • Site Monitor
    • Query Latest Metric Data for Partial Dimensions
    • General Description
    • Query Data API
    • Event Monitor
    • Instant Probe
    • Event Alarm History
    • Notification Template
  • Java-SDK
    • Overview
    • Initialization
    • Install the SDK Package
    • BcmClient
    • Query Monitoring Data for Partial Dimensions
    • Dimension Value TopN and Monitoring Data Query Interface
    • Batch Query Monitoring Data Interface V2
    • Dimension Value TopN Query Interface
    • Query Latest Metric Data for Partial Dimensions
    • Query Data API
    • Alarm Strategy-related APIs
    • Batch Query Data Interface
    • Alarm History-related APIs
  • Python-SDK
    • Overview
    • Initialization
    • Install SDK
    • BcmClient
    • Query Monitoring Data for Partial Dimensions
    • Batch Query Monitoring Data Interface V2
    • Dimension Value TopN Query Interface
    • Query Latest Metric Data for Partial Dimensions
    • Query Data API
    • Alarm Strategy List API
    • Batch Data Query Interface
  • Go-SDK
    • Overview
    • Initialization
    • Install the SDK Package
    • BcmClient
    • Query Monitoring Data for Partial Dimensions
    • Dimension Value TopN and Monitoring Data Query Interface
    • Batch Query Monitoring Data Interface V2
    • Dimension Value TopN Query Interface
    • Query Latest Metric Data for Partial Dimensions
    • Query Data API
    • Alarm Strategy-related APIs
    • Alarm History-related APIs
    • Batch Data Query Interface
  • BCM-Agent
    • Functions
    • Monitoring Trend Chart
    • BCM-Agent-Frequently Asked Questions
    • Appendix
  • FAQs
    • Common Questions Overview
    • Fault-related questions
    • Configuration-related questions
    • Performance-related questions
  • Cloud Product Monitor List
    • Cloud Product Metric List (Legacy Version Hidden)
    • Cloud Product Monitor Object Type List
    • Cloud Product Event List
    • Cloud Product Metric List
      • Database
        • Cloud Database TableStorage
        • Cloud Database DocDB for MongoDB
        • Data transmission service (DTS)
        • Cloud native database GaiaDB
        • Vector Database (VectorDB)
        • Dedicated Database Cluster (DDC)
        • Cloud Database Redis
        • Cloud database RDS
        • Cloud Database HBase
      • Enterprise Application
        • Message Service for RabbitMQ
      • Network
        • Service Network Interface Card (SNIC)
        • Peering Connections
        • IPv6 gateway
        • NAT Gateway
        • Load Balancer Dedicated Cluster LBDC
        • Baidu Load Balance (BLB)
        • Network probe NP
        • Dedicated channel
        • Elastic IP EIP
        • Elastic Network Interface Card (ENIC)
        • Cloud Smart Network (CSN)
        • Dedicated gateway
        • Virtual Private Network (VPN) Gateway
        • Layer 2 Gateway LTGW
        • Physical dedicated line
      • Intelligent Big Data
        • MapReduce BMR
        • Message service for Kafka-dedicated
        • Message Service for RocketMQ
        • Baidu Stream Computing (BSC)
        • Baidu Elasticsearch
        • Log Service BLS
        • Data warehouse DORIS
      • Cloud native
        • Cloud Function Computing
        • Baidu container instance (BCI)
      • Compute
        • Baidu Cloud Compute (BCC)
        • Elastic Baremetal Compute BBC
      • Storage and CDN
        • Parallel Filesystem Service (PFS)
        • Cloud File System (CFS)
        • Content delivery network (CDN)
        • Baidu object storage (BOS)
        • Cloud Disk Server (CDS)
        • Baidu edge computing (BEC)
      • Website service
        • Baidu Cloud Virtual Host (BCH)
      • Large Model Platform
        • Qianfan Large Model Platform ModelBuilder
  • Typical Practices
    • Scenarios for Batch Creation of Alarm Strategies
    • Usage Scenarios for Different Notification Channels
  • Service Level Agreement (SLA)
    • Site Monitor Service Level Agreement SLA
  • BCM-Tool
    • Uninstallation Method
    • Installation method
    • BCM-Tool-Frequently Asked Questions
    • Functions
    • Multi-Region Service
    • Application method
All documents
menu
No results found, please re-enter

BCM

  • Function Release Records
  • Product Announcement
    • Site Monitor Billing Announcement
  • Product Description
    • Product Introduction
    • Core concepts
    • Product advantages
    • Product features
  • Product pricing
    • Product pricing
    • Site Monitor Pricing
  • Quick Start
  • Operation guide
    • Enter Cloud Monitor
    • Dashboard
      • Overview
      • Management Dashboard Charts
      • Management Dashboard
    • Alarm Service
      • Overview
      • Alarm strategy
      • Alarm history
      • Alarm Template
      • Alarm Notification Template
      • Alarm callback
    • Cloud product monitor
      • Instance monitor
      • Instance Group
      • View Metrics
    • Site Monitor
      • Timed Detection (Formerly Site Monitor)
        • Overview
        • Manage Timed Probe Tasks
        • Purchase Guide
        • View timed probe tasks
      • IP advanced fault diagnosis
        • Manage IP Advanced Fault Diagnosis Tasks
        • View IP Advanced Fault Diagnosis Tasks
      • Instant probe
        • Overview
        • Manage instant probe tasks
    • Event Monitor
    • Event Bus
      • Event Delivery History
      • Overview
      • Event summary
      • Event Set
      • Event Rules
        • Event Rules
        • Event content conversion
        • Event pattern
  • API Reference
    • Overview
    • Service domain
    • Error response
    • Query Monitoring Data for Partial Dimensions
    • Dashboard API
    • Common Request and Response Headers
    • Alarm Management API
    • Alarm Management Interface V2
    • Alarm history
    • Push Data API
    • Event Bus Push
    • Application Monitor
    • Dimension Value TopN and Monitoring Data Query Interface
    • Batch Query Monitoring Data Interface V2
    • Dimension Value TopN Query Interface
    • Instance Group Interface
    • Site Monitor
    • Query Latest Metric Data for Partial Dimensions
    • General Description
    • Query Data API
    • Event Monitor
    • Instant Probe
    • Event Alarm History
    • Notification Template
  • Java-SDK
    • Overview
    • Initialization
    • Install the SDK Package
    • BcmClient
    • Query Monitoring Data for Partial Dimensions
    • Dimension Value TopN and Monitoring Data Query Interface
    • Batch Query Monitoring Data Interface V2
    • Dimension Value TopN Query Interface
    • Query Latest Metric Data for Partial Dimensions
    • Query Data API
    • Alarm Strategy-related APIs
    • Batch Query Data Interface
    • Alarm History-related APIs
  • Python-SDK
    • Overview
    • Initialization
    • Install SDK
    • BcmClient
    • Query Monitoring Data for Partial Dimensions
    • Batch Query Monitoring Data Interface V2
    • Dimension Value TopN Query Interface
    • Query Latest Metric Data for Partial Dimensions
    • Query Data API
    • Alarm Strategy List API
    • Batch Data Query Interface
  • Go-SDK
    • Overview
    • Initialization
    • Install the SDK Package
    • BcmClient
    • Query Monitoring Data for Partial Dimensions
    • Dimension Value TopN and Monitoring Data Query Interface
    • Batch Query Monitoring Data Interface V2
    • Dimension Value TopN Query Interface
    • Query Latest Metric Data for Partial Dimensions
    • Query Data API
    • Alarm Strategy-related APIs
    • Alarm History-related APIs
    • Batch Data Query Interface
  • BCM-Agent
    • Functions
    • Monitoring Trend Chart
    • BCM-Agent-Frequently Asked Questions
    • Appendix
  • FAQs
    • Common Questions Overview
    • Fault-related questions
    • Configuration-related questions
    • Performance-related questions
  • Cloud Product Monitor List
    • Cloud Product Metric List (Legacy Version Hidden)
    • Cloud Product Monitor Object Type List
    • Cloud Product Event List
    • Cloud Product Metric List
      • Database
        • Cloud Database TableStorage
        • Cloud Database DocDB for MongoDB
        • Data transmission service (DTS)
        • Cloud native database GaiaDB
        • Vector Database (VectorDB)
        • Dedicated Database Cluster (DDC)
        • Cloud Database Redis
        • Cloud database RDS
        • Cloud Database HBase
      • Enterprise Application
        • Message Service for RabbitMQ
      • Network
        • Service Network Interface Card (SNIC)
        • Peering Connections
        • IPv6 gateway
        • NAT Gateway
        • Load Balancer Dedicated Cluster LBDC
        • Baidu Load Balance (BLB)
        • Network probe NP
        • Dedicated channel
        • Elastic IP EIP
        • Elastic Network Interface Card (ENIC)
        • Cloud Smart Network (CSN)
        • Dedicated gateway
        • Virtual Private Network (VPN) Gateway
        • Layer 2 Gateway LTGW
        • Physical dedicated line
      • Intelligent Big Data
        • MapReduce BMR
        • Message service for Kafka-dedicated
        • Message Service for RocketMQ
        • Baidu Stream Computing (BSC)
        • Baidu Elasticsearch
        • Log Service BLS
        • Data warehouse DORIS
      • Cloud native
        • Cloud Function Computing
        • Baidu container instance (BCI)
      • Compute
        • Baidu Cloud Compute (BCC)
        • Elastic Baremetal Compute BBC
      • Storage and CDN
        • Parallel Filesystem Service (PFS)
        • Cloud File System (CFS)
        • Content delivery network (CDN)
        • Baidu object storage (BOS)
        • Cloud Disk Server (CDS)
        • Baidu edge computing (BEC)
      • Website service
        • Baidu Cloud Virtual Host (BCH)
      • Large Model Platform
        • Qianfan Large Model Platform ModelBuilder
  • Typical Practices
    • Scenarios for Batch Creation of Alarm Strategies
    • Usage Scenarios for Different Notification Channels
  • Service Level Agreement (SLA)
    • Site Monitor Service Level Agreement SLA
  • BCM-Tool
    • Uninstallation Method
    • Installation method
    • BCM-Tool-Frequently Asked Questions
    • Functions
    • Multi-Region Service
    • Application method
  • Document center
  • arrow
  • BCM
  • arrow
  • Go-SDK
  • arrow
  • BcmClient
Table of contents on this page
  • Create a new BCM client
  • Create a new BCM client with AK/SK
  • Create a BCM client with STS
  • Configure HTTPS access to BCM
  • Configure the BCM client
  • Use a proxy
  • Set network parameters
  • Configure options for generating signature strings

BcmClient

Updated at:2025-11-03

Create a new BCM client

A BCM client acts as the client for BCM control plane services, offering developers various methods to interact with these services.

Create a new BCM client with AK/SK

Users can refer to the following code to create a new BCM Client to access BCC with AK/SK:

Go
1import (
2 "github.com/baidubce/bce-sdk-go/services/bcm"   //Import BCM service module
3)
4func main() {
5 // User’s Access Key ID and Secret Access Key
6	ACCESS_KEY_ID, SECRET_ACCESS_KEY := <your-access-key-id>, <your-secret-access-key>
7 // User-specified Endpoint
8	ENDPOINT := <domain-name>
9 // Initialize a BcmClient
10	bcmClient, err := bcm.NewClient(AK, SK, ENDPOINT)
11}

In the code above, ACCESS_KEY_ID corresponds to “Access Key ID” in the console. SECRET_ACCESS_KEY corresponds to “Access Key Secret” in the console. For the method to retrieve them, refer to the Guide - Manage ACCESSKEY. The third parameter ENDPOINT is a user-specified domain name. If left empty, the default domain name will be used as the BCM control plane service address.

Note:The endpoint parameter must be defined with the domain name of the specified region. For example, if the service is located in Beijing, the endpoint will be bcm.bj.baidubce.com.

Create a BCM client with STS

Request STS Token

BCM facilitates temporary third-party access authorization through the STS mechanism. STS (Security Token Service) is a temporary authorization service provided by Baidu AI Cloud. With STS, you can issue access credentials that have customized validity periods and permissions for third-party users. These users can then use the credentials to directly call Baidu AI Cloud APIs or SDKs to access cloud resources.

To access BCM via STS, users must first request an certification string through the STS client. For instructions on obtaining STS credentials, refer to Baidu AI Cloud STS Usage Guide.

Create BCM Client with STS Token

Once you have obtained the STS token, configure it in the BCM Client to enable client creation based on STS.

Code example

The GO SDK implements the STS service API. Below is a complete example for requesting an STS Token and creating an BCM Client object:

Go
1import (
2	"fmt"
3 "github.com/baidubce/bce-sdk-go/auth"                    //Import the authentication module
4 "github.com/baidubce/bce-sdk-go/services/bcm"   //Import BCM service module
5 "github.com/baidubce/bce-sdk-go/services/sts"            //Import the Baige service module
6)
7func main() {
8 //Create a Client object for the STS service, using the default Endpoint
9	AK, SK := <your-access-key-id>, <your-secret-access-key>
10	stsClient, err := sts.NewClient(AK, SK)
11	if err != nil {
12		fmt.Println("create sts client object :", err)
13		return
14	}
15 //Obtain a temporary authentication token with a validity period of 60 seconds and an empty ACL
16	stsObj, err := stsClient.GetSessionToken(60, "")
17	if err != nil {
18		fmt.Println("get session token failed:", err)
19		return
20    }
21	fmt.Println("GetSessionToken result:")
22	fmt.Println("  accessKeyId:", stsObj.AccessKeyId)
23	fmt.Println("  secretAccessKey:", stsObj.SecretAccessKey)
24	fmt.Println("  sessionToken:", stsObj.SessionToken)
25	fmt.Println("  createTime:", stsObj.CreateTime)
26	fmt.Println("  expiration:", stsObj.Expiration)
27	fmt.Println("  userId:", stsObj.UserId)
28 //Create a client object for BCM control plane services using the requested temporary STS, with the default endpoint
29	bcmClient, err := bcm.NewClient(stsObj.AccessKeyId, stsObj.SecretAccessKey, "")
30	if err != nil {
31		fmt.Println("create bcm client failed:", err)
32		return
33	}
34	stsCredential, err := auth.NewSessionBceCredentials(
35		stsObj.AccessKeyId,
36		stsObj.SecretAccessKey,
37		stsObj.SessionToken)
38	if err != nil {
39		fmt.Println("create sts credential object failed:", err)
40		return
41	}
42	bcmClient.Config.Credentials = stsCredential
43}

Note: Currently, when configuring a BCM client with STS, regardless of where the corresponding BCM service endpoint is located, the STS endpoint must be set to http://sts.bj.baidubce.com. This default is utilized when creating an STS object in the above code.

Configure HTTPS access to BCM

BCM supports the HTTPS transport protocol. To use HTTPS to access BCM services with the BCM Go SDK, specify HTTPS in the endpoint when creating the BCM client object.

Go
1// import "github.com/baidubce/bce-sdk-go/services/bcm"
2 ENDPOINT := "https://bcm.bj.baidubce.com" //Specify the use of HTTPS protocol
3AK, SK := <your-access-key-id>, <your-secret-access-key>
4bcmClient, _ := bcm.NewClient(AK, SK, ENDPOINT)

Configure the BCM client

If users need to configure specific parameters for the BCM Client, they can customize the configuration using the exported Config field of the BCM Client object after its creation. This allows for configuring parameters such as proxy and maximum number of connections for the client.

Use a proxy

The following code snippet enables the client to access BCM service using a proxy:

Go
1// import "github.com/baidubce/bce-sdk-go/services/bcm"
2 // Create an BCM Client object
3AK, SK := <your-access-key-id>, <your-secret-access-key>
4ENDPOINT := "bcm.bj.baidubce.com
5client, _ := bcm.NewClient(AK, SK, ENDPOINT)
6 // Use the local port 8080 for the proxy
7client.Config.ProxyUrl = "127.0.0.1:8080"

Set network parameters

Users can configure network parameters using the following example code:

Go
1// import "github.com/baidubce/bce-sdk-go/services/bcm"
2AK, SK := <your-access-key-id>, <your-secret-access-key>
3ENDPOINT := "bcm.bj.baidubce.com"
4client, _ := bcm.NewClient(AK, SK, ENDPOINT)
5 // Configure to not retry, default: Back Off retry
6client.Config.Retry = bce.NewNoRetryPolicy()
7 // Configure connection timeout to 30 seconds
8client.Config.ConnectionTimeoutInMillis = 30 * 1000

Configure options for generating signature strings

Go
1// import "github.com/baidubce/bce-sdk-go/services/bcm"
2AK, SK := <your-access-key-id>, <your-secret-access-key>
3ENDPOINT := "bcm.bj.baidubce.com"
4client, _ := bcm.NewClient(AK, SK, ENDPOINT)
5 // Configure the HTTP request header Host for signing
6headersToSign := map[string]struct{}{"Host": struct{}{}}
7client.Config.SignOption.HeadersToSign = HeadersToSign
8 // Configure the validity period of the signature to 30 seconds
9client.Config.SignOption.ExpireSeconds = 30

Parameter description

When using the GO SDK to access BCM, the Config field of the created BCM Client object supports the following parameters, as shown in the table below:

ConfigMap name Types Meaning
Endpoint string Domain name for service requests
ProxyUrl string The proxy address for client requests
Region string Region for resource requests
UserAgent string User name, HTTP request’s User-Agent header
Credentials *auth.BceCredentials Authentication object for requests, divided into regular AK/SK and STS
SignOption *auth.SignOptions Options for authentication string signing
Retry RetryPolicy Retry policy for connections
ConnectionTimeoutInMillis int Connection timeout, in milliseconds, defaulting to 20 minutes

Description:

  1. The Credentials field is created using the auth.NewBceCredentials and auth.NewSessionBceCredentials functions. The former is used by default, while the latter is used for STS certification. See "Create a BCM client with STS" for details.
  2. The SignOption field represents options when generating a signature string, as detailed in the table below:
Name Types Meaning
HeadersToSign map[string]struct{} HTTP headers used when generating the signature string
Timestamp int64 Timestamp used in the generated signature string, defaulting to the value at the time of sending request
ExpireSeconds int Validity period of the signature string
Plain Text
1 Among configuration options, HeadersToSign defaults to `Host`, `Content-Type`, `Content-Length` and `Content-MD5`; TimeStamp is typically set to zero, indicating that the timestamp at the time of generating the certification string shall be used, and users generally shall not explicitly specify the value for this field; ExpireSeconds defaults to 1,800 seconds or 30 minutes.
  1. The Retry field specifies the retry policy, currently supporting two types: NoRetryPolicy and BackOffRetryPolicy. By default, the latter is used. This retry policy specifies the maximum number of retries, the maximum retry duration, and the retry base. Retries increase exponentially based on the retry base multiplied by 2 until the maximum number of retries or the maximum retry duration is reached.

Previous
Install the SDK Package
Next
Query Monitoring Data for Partial Dimensions