Skip to content

Commit

Permalink
Updates features in bls
Browse files Browse the repository at this point in the history
  • Loading branch information
duanliguo committed Sep 13, 2024
1 parent b93d8c5 commit cbdec3c
Show file tree
Hide file tree
Showing 19 changed files with 1,975 additions and 154 deletions.
2 changes: 1 addition & 1 deletion bce/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

// Constants and default values for the package bce
const (
SDK_VERSION = "0.9.190"
SDK_VERSION = "0.9.133"
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
DEFAULT_DOMAIN = "baidubce.com"
DEFAULT_PROTOCOL = "http"
Expand Down
16 changes: 10 additions & 6 deletions doc/BLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@

在确认您使用SDK时配置的Endpoint时,可先阅读开发人员指南中关于[BLS访问域名](https://cloud.baidu.com/doc/BLS/s/4k8qysj2z)的部分,理解Endpoint相关的概念。百度云目前开放了多区域支持,请参考[区域选择说明](https://cloud.baidu.com/doc/Reference/s/2jwvz23xx)

目前支持“华北-北京”和“华南-广州”两个区域。北京区域:`bls-log.bj.baidubce.com`广州区域:`bls-log.gz.baidubce.com`。对应信息为:

| 访问区域 | 对应Endpoint | Protocol |
| --------- | ----------------------- | ---------- |
| 华北-北京 | bls-log.bj.baidubce.com | HTTP/HTTPS |
| 华南-广州 | bls-log.gz.baidubce.com | HTTP/HTTPS |
目前支持“华北-北京”、“华南-广州”、“华东-苏州”、“华北-保定”、“华中金融-武汉”、“华北-阳泉”六个区域。对应信息为:

| 访问区域 | 对应Endpoint | Protocol |
| --------- |--------------------------| ---------- |
| 华北-北京 | bls-log.bj.baidubce.com | HTTP/HTTPS |
| 华南-广州 | bls-log.gz.baidubce.com | HTTP/HTTPS |
| 华东-苏州 | bls-log.su.baidubce.com | HTTP/HTTPS |
| 华北-保定 | bls-log.bd.baidubce.com | HTTP/HTTPS |
| 华中金融-武汉 | bls-log.fwh.baidubce.com | HTTP/HTTPS |
| 华北-阳泉 | bls-log.yq.baidubce.com | HTTP/HTTPS |

## 获取密钥

Expand Down
51 changes: 32 additions & 19 deletions services/bls/api/fastquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import (
// CreateFastQuery - create a fastQuery
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - body: the fastQuery body
// - cli: the client agent which can perform sending request
// - body: the fastQuery body
//
// RETURNS:
// - error: nil if success otherwise the specific error
// - error: nil if success otherwise the specific error
func CreateFastQuery(cli bce.Client, body *bce.Body) error {
req := &bce.BceRequest{}
req.SetUri(FASTQUERY_PREFIX)
Expand All @@ -49,11 +50,12 @@ func CreateFastQuery(cli bce.Client, body *bce.Body) error {
// DescribeFastQuery - get specific fastQuery info
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - fastQueryName: fastQuery name to get
// - cli: the client agent which can perform sending request
// - fastQueryName: fastQuery name to get
//
// RETURNS:
// - *FastQuery: target fastQuery info
// - error: nil if success otherwise the specific error
// - *FastQuery: target fastQuery info
// - error: nil if success otherwise the specific error
func DescribeFastQuery(cli bce.Client, fastQueryName string) (*FastQuery, error) {
req := &bce.BceRequest{}
req.SetUri(getFastQueryUri(fastQueryName))
Expand All @@ -75,11 +77,12 @@ func DescribeFastQuery(cli bce.Client, fastQueryName string) (*FastQuery, error)
// UpdateFastQuery - update specific fastQuery info
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - body: update fastQuery body
// - fastQueryName: fastQuery to update
// - cli: the client agent which can perform sending request
// - body: update fastQuery body
// - fastQueryName: fastQuery to update
//
// RETURNS:
// - error: nil if success otherwise the specific error
// - error: nil if success otherwise the specific error
func UpdateFastQuery(cli bce.Client, body *bce.Body, fastQueryName string) error {
req := &bce.BceRequest{}
req.SetUri(getFastQueryUri(fastQueryName))
Expand All @@ -99,10 +102,11 @@ func UpdateFastQuery(cli bce.Client, body *bce.Body, fastQueryName string) error
// DeleteFastQuery - delete specific fastQuery
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - fastQueryName: fastQuery name to delete
// - cli: the client agent which can perform sending request
// - fastQueryName: fastQuery name to delete
//
// RETURNS:
// - error: nil if success otherwise the specific error
// - error: nil if success otherwise the specific error
func DeleteFastQuery(cli bce.Client, fastQueryName string) error {
req := &bce.BceRequest{}
req.SetUri(getFastQueryUri(fastQueryName))
Expand All @@ -121,15 +125,24 @@ func DeleteFastQuery(cli bce.Client, fastQueryName string) error {
// ListFastQuery - get all fastQuery info
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - args: query args to get pattern-match fastQuery
// - cli: the client agent which can perform sending request
// - project: logstore project
// - logStore: logStore to parse
// - args: query args to get pattern-match fastQuery
//
// RETURNS:
// - *ListFastQueryResult: pattern-match fastQuery result
// - error: nil if success otherwise the specific error
func ListFastQuery(cli bce.Client, args *QueryConditions) (*ListFastQueryResult, error) {
// - *ListFastQueryResult: pattern-match fastQuery result
// - error: nil if success otherwise the specific error
func ListFastQuery(cli bce.Client, project string, logStore string, args *QueryConditions) (*ListFastQueryResult, error) {
req := &bce.BceRequest{}
req.SetUri(FASTQUERY_PREFIX)
req.SetMethod(http.GET)
if project != "" {
req.SetParam("project", project)
}
if logStore != "" {
req.SetParam("logStoreName", logStore)
}
// Set optional args
if args != nil {
if args.NamePattern != "" {
Expand Down
50 changes: 31 additions & 19 deletions services/bls/api/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ import (
// CreateIndex - create index for logStore
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - logStoreName: logStore needs to be indexed
// - body: index mappings body
// - cli: the client agent which can perform sending request
// - project: logstore project
// - logStoreName: logStore needs to be indexed
// - body: index mappings body
//
// RETURNS:
// - error: nil if success otherwise the specific error
func CreateIndex(cli bce.Client, logStoreName string, body *bce.Body) error {
// - error: nil if success otherwise the specific error
func CreateIndex(cli bce.Client, project string, logStoreName string, body *bce.Body) error {
req := &bce.BceRequest{}
req.SetUri(getIndexUri(logStoreName))
req.SetParam("project", project)
req.SetMethod(http.POST)
req.SetBody(body)
resp := &bce.BceResponse{}
Expand All @@ -48,14 +51,17 @@ func CreateIndex(cli bce.Client, logStoreName string, body *bce.Body) error {
// UpdateIndex - update index info
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - logStoreName: logStore needs to be updated
// - body: index mappings body
// - cli: the client agent which can perform sending request
// - project: logstore project
// - logStoreName: logStore needs to be updated
// - body: index mappings body
//
// RETURNS:
// - error: nil if success otherwise the specific error
func UpdateIndex(cli bce.Client, logStoreName string, body *bce.Body) error {
// - error: nil if success otherwise the specific error
func UpdateIndex(cli bce.Client, project string, logStoreName string, body *bce.Body) error {
req := &bce.BceRequest{}
req.SetUri(getIndexUri(logStoreName))
req.SetParam("project", project)
req.SetMethod(http.PUT)
req.SetBody(body)
resp := &bce.BceResponse{}
Expand All @@ -72,13 +78,16 @@ func UpdateIndex(cli bce.Client, logStoreName string, body *bce.Body) error {
// DeleteIndex - delete index for logStore
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - logStoreName: logStore to be deleted
// - cli: the client agent which can perform sending request
// - project: logstore project
// - logStoreName: logStore to be deleted
//
// RETURNS:
// - error: nil if success otherwise the specific error
func DeleteIndex(cli bce.Client, logStoreName string) error {
// - error: nil if success otherwise the specific error
func DeleteIndex(cli bce.Client, project string, logStoreName string) error {
req := &bce.BceRequest{}
req.SetUri(getIndexUri(logStoreName))
req.SetParam("project", project)
req.SetMethod(http.DELETE)
resp := &bce.BceResponse{}
if err := cli.SendRequest(req, resp); err != nil {
Expand All @@ -94,14 +103,17 @@ func DeleteIndex(cli bce.Client, logStoreName string) error {
// DescribeIndex - get specific logStore index info
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - logStoreName: logStore needs to be get
// - cli: the client agent which can perform sending request
// - project: logstore project
// - logStoreName: logStore needs to be get
//
// RETURNS:
// - *IndexFields: index mappings info
// - error: nil if success otherwise the specific error
func DescribeIndex(cli bce.Client, logStoreName string) (*IndexFields, error) {
// - *IndexFields: index mappings info
// - error: nil if success otherwise the specific error
func DescribeIndex(cli bce.Client, project, logStoreName string) (*IndexFields, error) {
req := &bce.BceRequest{}
req.SetUri(getIndexUri(logStoreName))
req.SetParam("project", project)
req.SetMethod(http.GET)
resp := &bce.BceResponse{}
if err := cli.SendRequest(req, resp); err != nil {
Expand Down
43 changes: 26 additions & 17 deletions services/bls/api/logrecord.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ import (
// PushLogRecord - push logRecords into logStore
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - logStore: target logStore to store logRecords
// - body: logRecord body
// - cli: the client agent which can perform sending request
// - project: logstore project
// - logStore: target logStore to store logRecords
// - body: logRecord body
//
// RETURNS:
// - error: nil if success otherwise the specific error
func PushLogRecord(cli bce.Client, logStore string, body *bce.Body) error {
// - error: nil if success otherwise the specific error
func PushLogRecord(cli bce.Client, project string, logStore string, body *bce.Body) error {
req := &bce.BceRequest{}
req.SetUri(getLogRecordUri(logStore))
req.SetParam("project", project)
req.SetMethod(http.POST)
req.SetBody(body)
resp := &bce.BceResponse{}
Expand All @@ -50,15 +53,18 @@ func PushLogRecord(cli bce.Client, logStore string, body *bce.Body) error {
// PullLogRecord - get logRecords from logStore
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - logStore: target logStore to get logRecords
// - args: pull logRecords limitation args
// - cli: the client agent which can perform sending request
// - project: logstore project
// - logStore: target logStore to get logRecords
// - args: pull logRecords limitation args
//
// RETURNS:
// - *PullLogRecordResult: pull logRecord result set
// - error: nil if success otherwise the specific error
func PullLogRecord(cli bce.Client, logStore string, args *PullLogRecordArgs) (*PullLogRecordResult, error) {
// - *PullLogRecordResult: pull logRecord result set
// - error: nil if success otherwise the specific error
func PullLogRecord(cli bce.Client, project string, logStore string, args *PullLogRecordArgs) (*PullLogRecordResult, error) {
req := &bce.BceRequest{}
req.SetUri(getLogRecordUri(logStore))
req.SetParam("project", project)
req.SetMethod(http.GET)
if args != nil {
if args.LogStreamName != "" {
Expand Down Expand Up @@ -94,15 +100,18 @@ func PullLogRecord(cli bce.Client, logStore string, args *PullLogRecordArgs) (*P
// QueryLogRecord - retrieve logRecords from logStore
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - logStore: target logStore to retrieve logRecords
// - args: query logRecords conditions args
// - cli: the client agent which can perform sending request
// - project: logstore project
// - logStore: target logStore to retrieve logRecords
// - args: query logRecords conditions args
//
// RETURNS:
// - *QueryLogResult: query logRecord result set
// - error: nil if success otherwise the specific error
func QueryLogRecord(cli bce.Client, logStore string, args *QueryLogRecordArgs) (*QueryLogResult, error) {
// - *QueryLogResult: query logRecord result set
// - error: nil if success otherwise the specific error
func QueryLogRecord(cli bce.Client, project string, logStore string, args *QueryLogRecordArgs) (*QueryLogResult, error) {
req := &bce.BceRequest{}
req.SetUri(getLogRecordUri(logStore))
req.SetParam("project", project)
req.SetMethod(http.GET)
if args != nil {
req.SetParam("logStreamName", args.LogStreamName)
Expand Down
Loading

0 comments on commit cbdec3c

Please sign in to comment.