Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Log Tank Service/ API Reference/ APIs/ Log Ingestion/ Creating a cross-account log ingestion configuration.

Creating a cross-account log ingestion configuration.

Function

Creating a cross-account log ingestion configuration.

Calling Method

For details, see Calling APIs.

URI

POST /v2.0/{project_id}/lts/createAgencyAccess

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 1

Maximum: 64

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token.

Minimum: 1

Maximum: 10000

Content-Type

Yes

String

Set this parameter to application/json;charset=utf8.

Minimum: 30

Maximum: 30

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

preview_agency_list

Yes

Array of PreviewAgencyLogAccessReqBody objects

Preview of the proxy list.

Table 4 PreviewAgencyLogAccessReqBody

Parameter

Mandatory

Type

Description

agency_access_type

Yes

String

Log ingestion type.

Enumeration values:

  • AGENCYACCESS

agency_log_access

Yes

String

Cross-account log ingestion configuration name.

log_agencyStream_name

Yes

String

Delegator log stream name.

log_agencyStream_id

Yes

String

Delegator log stream ID.

log_agencyGroup_name

Yes

String

Delegator log group name.

log_agencyGroup_id

Yes

String

Delegator log group ID.

log_beAgencystream_name

Yes

String

Delegatee log stream name.

log_beAgencystream_id

Yes

String

Delegatee log stream ID.

log_beAgencygroup_name

Yes

String

Delegatee log group name.

log_beAgencygroup_id

Yes

String

Delegatee log group ID.

be_agency_project_id

Yes

String

Delegatee project ID.

agency_project_id

Yes

String

Delegator project ID.

agency_domain_name

Yes

String

Delegator account name.

agency_name

Yes

String

Agency name.

Response Parameters

Status code: 201

Table 5 Response body parameters

Parameter

Type

Description

[items]

Array of LTSAccessConfigInfoRespon200 objects

Table 6 LTSAccessConfigInfoRespon200

Parameter

Type

Description

access_config_id

String

Cross-account log ingestion ID.

project_id

String

Project ID.

access_config_name

String

Cross-account log ingestion name.

access_config_type

Object

Cross-account log ingestion type.

Enumeration values:

  • Agent

  • CRD

  • AGENCYACCESS

  • K8S_CCE

  • K8S_CUSTOM

  • CLOUD_STREAM_AGENCY

group_id

String

Log group ID.

log_group_name

String

Log group name.

log_stream_id

String

Log stream ID.

log_stream_name

String

Log stream name.

create_time

Long

Creation time.

agency_log_access

PreviewAgencyLogAccessReqBody object

Information of the delegated ingestion.

Table 7 PreviewAgencyLogAccessReqBody

Parameter

Type

Description

agency_access_type

String

Log ingestion type.

Enumeration values:

  • AGENCYACCESS

agency_log_access

String

Cross-account log ingestion configuration name.

log_agencyStream_name

String

Delegator log stream name.

log_agencyStream_id

String

Delegator log stream ID.

log_agencyGroup_name

String

Delegator log group name.

log_agencyGroup_id

String

Delegator log group ID.

log_beAgencystream_name

String

Delegatee log stream name.

log_beAgencystream_id

String

Delegatee log stream ID.

log_beAgencygroup_name

String

Delegatee log group name.

log_beAgencygroup_id

String

Delegatee log group ID.

be_agency_project_id

String

Delegatee project ID.

agency_project_id

String

Delegator project ID.

agency_domain_name

String

Delegator account name.

agency_name

String

Agency name.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

message

ErrorMessagebody object

Error message body.

Table 9 ErrorMessagebody

Parameter

Type

Description

code

String

Error code.

Minimum: 8

Maximum: 36

details

String

Error description.

Minimum: 2

Maximum: 512

Status code: 500

Table 10 Response body parameters

Parameter

Type

Description

message

ErrorMessagebody object

Error message body.

Table 11 ErrorMessagebody

Parameter

Type

Description

code

String

Error code.

Minimum: 8

Maximum: 36

details

String

Error description.

Minimum: 2

Maximum: 512

Example Requests

Creating a cross-account log ingestion configuration.

POST https://{endpoint}//v2.0/{project_id}/lts/createAgencyAccess

{
  "preview_agency_list" : [ {
    "agency_log_access" : "rule_lb30",
    "agency_access_type" : "AGENCYACCESS",
    "agency_name" : "wenshufeng",
    "agency_domain_name" : "paas_aom_z00418070_01",
    "agency_project_id" : "a0a12b069ab4491185d7cf26c3e86ada",
    "be_agency_project_id" : "2a473356cca5487f8373be891bffc1cf",
    "log_agencyStream_name" : "lts-topic-bug",
    "log_agencyStream_id" : "beb169ff-e6e9-4bea-8e77-50afdec74071",
    "log_agencyGroup_name" : "lts-group-sgq",
    "log_agencyGroup_id" : "f06cbfa0-7243-4031-9380-ae0465bd3997",
    "log_beAgencystream_name" : "lts-topic-ECS",
    "log_beAgencystream_id" : "36ce06b0-c6bf-436d-9abe-39de86da28bb",
    "log_beAgencygroup_name" : "lts-group-sgqECS",
    "log_beAgencygroup_id" : "1e749063-d9f5-474f-a537-00cad4e9a108"
  } ]
}

Example Responses

Status code: 201

The cross-account log ingestion configuration is created.

[ {
  "access_config_id" : "e929f40e-d1cf-4d59-b656-a2995cbd3229",
  "access_config_name" : "rule_lb30",
  "access_config_type" : "AGENCYACCESS",
  "agency_log_access" : {
    "agency_accessConfig_id" : "e929f40e-d1cf-4d59-b656-a2995cbd3229",
    "agency_access_type" : "AGENCYACCESS",
    "agency_domain_name" : "paas_aom_z00418070_01",
    "agency_log_access" : "rule_lb30",
    "agency_name" : "wenshufeng",
    "agency_project_id" : "a0a12b069ab4491185d7cf26c3e86ada",
    "be_agency_project_id" : "2a473356cca5487f8373be891bffc1cf",
    "log_agencyGroup_id" : "f06cbfa0-7243-4031-9380-ae0465bd3997",
    "log_agencyGroup_name" : "lts-group-sgq",
    "log_agencyStream_id" : "beb169ff-e6e9-4bea-8e77-50afdec74071",
    "log_agencyStream_name" : "lts-topic-bug",
    "log_beAgencygroup_id" : "1e749063-d9f5-474f-a537-00cad4e9a108",
    "log_beAgencygroup_name" : "lts-group-sgqECS",
    "log_beAgencystream_id" : "36ce06b0-c6bf-436d-9abe-39de86da28bb",
    "log_beAgencystream_name" : "lts-topic-ECS"
  },
  "binary_collect" : false,
  "create_time" : 1694400753168,
  "group_id" : "1e749063-d9f5-474f-a537-00cad4e9a108",
  "hostGroupNum" : 0,
  "hostNum" : 0,
  "host_group_info_list" : [ ],
  "host_rule_info" : {
    "black_paths" : [ ],
    "pathType" : "host_file",
    "paths" : [ ],
    "stderr" : false,
    "stdout" : false
  },
  "id" : "",
  "indexId" : "",
  "key" : "",
  "log_group_name" : "lts-group-sgqECS",
  "log_split" : false,
  "log_stream_id" : "36ce06b0-c6bf-436d-9abe-39de86da28bb",
  "log_stream_name" : "lts-topic-ECS",
  "pathNum" : 0,
  "project_id" : "2a473356cca5487f8373be891bffc1cf",
  "tag_list" : [ ]
} ]

Status code: 400

Failed to create cross-account log ingestion configuration.

{
  "message" : {
    "code" : "LTS.0420",
    "details" : "Agency not existed, check domain name and agency name"
  }
}

Status code: 500

Internal service error.

{
  "message" : {
    "code" : "LTS.0010",
    "details" : "The system encountered an internal error"
  }
}

SDK Sample Code

The SDK sample code is as follows.

Creating a cross-account log ingestion configuration.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.lts.v2.region.LtsRegion;
import com.huaweicloud.sdk.lts.v2.*;
import com.huaweicloud.sdk.lts.v2.model.*;

import java.util.List;
import java.util.ArrayList;

public class CreateAgencyAccessSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        LtsClient client = LtsClient.newBuilder()
                .withCredential(auth)
                .withRegion(LtsRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateAgencyAccessRequest request = new CreateAgencyAccessRequest();
        PreviewAgencyLogAccessReqListBody body = new PreviewAgencyLogAccessReqListBody();
        List<PreviewAgencyLogAccessReqBody> listbodyPreviewAgencyList = new ArrayList<>();
        listbodyPreviewAgencyList.add(
            new PreviewAgencyLogAccessReqBody()
                .withAgencyAccessType(PreviewAgencyLogAccessReqBody.AgencyAccessTypeEnum.fromValue("AGENCYACCESS"))
                .withAgencyLogAccess("rule_lb30")
                .withLogAgencyStreamName("lts-topic-bug")
                .withLogAgencyStreamId("beb169ff-e6e9-4bea-8e77-50afdec74071")
                .withLogAgencyGroupName("lts-group-sgq")
                .withLogAgencyGroupId("f06cbfa0-7243-4031-9380-ae0465bd3997")
                .withLogBeAgencystreamName("lts-topic-ECS")
                .withLogBeAgencystreamId("36ce06b0-c6bf-436d-9abe-39de86da28bb")
                .withLogBeAgencygroupName("lts-group-sgqECS")
                .withLogBeAgencygroupId("1e749063-d9f5-474f-a537-00cad4e9a108")
                .withBeAgencyProjectId("2a473356cca5487f8373be891bffc1cf")
                .withAgencyProjectId("a0a12b069ab4491185d7cf26c3e86ada")
                .withAgencyDomainName("paas_aom_z00418070_01")
                .withAgencyName("wenshufeng")
        );
        body.withPreviewAgencyList(listbodyPreviewAgencyList);
        request.withBody(body);
        try {
            CreateAgencyAccessResponse response = client.createAgencyAccess(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Creating a cross-account log ingestion configuration.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdklts.v2.region.lts_region import LtsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdklts.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = LtsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(LtsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateAgencyAccessRequest()
        listPreviewAgencyListbody = [
            PreviewAgencyLogAccessReqBody(
                agency_access_type="AGENCYACCESS",
                agency_log_access="rule_lb30",
                log_agency_stream_name="lts-topic-bug",
                log_agency_stream_id="beb169ff-e6e9-4bea-8e77-50afdec74071",
                log_agency_group_name="lts-group-sgq",
                log_agency_group_id="f06cbfa0-7243-4031-9380-ae0465bd3997",
                log_be_agencystream_name="lts-topic-ECS",
                log_be_agencystream_id="36ce06b0-c6bf-436d-9abe-39de86da28bb",
                log_be_agencygroup_name="lts-group-sgqECS",
                log_be_agencygroup_id="1e749063-d9f5-474f-a537-00cad4e9a108",
                be_agency_project_id="2a473356cca5487f8373be891bffc1cf",
                agency_project_id="a0a12b069ab4491185d7cf26c3e86ada",
                agency_domain_name="paas_aom_z00418070_01",
                agency_name="wenshufeng"
            )
        ]
        request.body = PreviewAgencyLogAccessReqListBody(
            preview_agency_list=listPreviewAgencyListbody
        )
        response = client.create_agency_access(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Creating a cross-account log ingestion configuration.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    lts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := lts.NewLtsClient(
        lts.LtsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.CreateAgencyAccessRequest{}
	var listPreviewAgencyListbody = []model.PreviewAgencyLogAccessReqBody{
        {
            AgencyAccessType: model.GetPreviewAgencyLogAccessReqBodyAgencyAccessTypeEnum().AGENCYACCESS,
            AgencyLogAccess: "rule_lb30",
            LogAgencyStreamName: "lts-topic-bug",
            LogAgencyStreamId: "beb169ff-e6e9-4bea-8e77-50afdec74071",
            LogAgencyGroupName: "lts-group-sgq",
            LogAgencyGroupId: "f06cbfa0-7243-4031-9380-ae0465bd3997",
            LogBeAgencystreamName: "lts-topic-ECS",
            LogBeAgencystreamId: "36ce06b0-c6bf-436d-9abe-39de86da28bb",
            LogBeAgencygroupName: "lts-group-sgqECS",
            LogBeAgencygroupId: "1e749063-d9f5-474f-a537-00cad4e9a108",
            BeAgencyProjectId: "2a473356cca5487f8373be891bffc1cf",
            AgencyProjectId: "a0a12b069ab4491185d7cf26c3e86ada",
            AgencyDomainName: "paas_aom_z00418070_01",
            AgencyName: "wenshufeng",
        },
    }
	request.Body = &model.PreviewAgencyLogAccessReqListBody{
		PreviewAgencyList: listPreviewAgencyListbody,
	}
	response, err := client.CreateAgencyAccess(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Creating a cross-account log ingestion configuration.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.lts.v2.region.LtsRegion;
import com.huaweicloud.sdk.lts.v2.*;
import com.huaweicloud.sdk.lts.v2.model.*;

import java.util.List;
import java.util.ArrayList;

public class CreateAgencyAccessSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        LtsClient client = LtsClient.newBuilder()
                .withCredential(auth)
                .withRegion(LtsRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateAgencyAccessRequest request = new CreateAgencyAccessRequest();
        PreviewAgencyLogAccessReqListBody body = new PreviewAgencyLogAccessReqListBody();
        List<PreviewAgencyLogAccessReqBody> listbodyPreviewAgencyList = new ArrayList<>();
        listbodyPreviewAgencyList.add(
            new PreviewAgencyLogAccessReqBody()
                .withAgencyAccessType(PreviewAgencyLogAccessReqBody.AgencyAccessTypeEnum.fromValue("AGENCYACCESS"))
                .withAgencyLogAccess("rule_lb30")
                .withLogAgencyStreamName("lts-topic-bug")
                .withLogAgencyStreamId("beb169ff-e6e9-4bea-8e77-50afdec74071")
                .withLogAgencyGroupName("lts-group-sgq")
                .withLogAgencyGroupId("f06cbfa0-7243-4031-9380-ae0465bd3997")
                .withLogBeAgencystreamName("lts-topic-ECS")
                .withLogBeAgencystreamId("36ce06b0-c6bf-436d-9abe-39de86da28bb")
                .withLogBeAgencygroupName("lts-group-sgqECS")
                .withLogBeAgencygroupId("1e749063-d9f5-474f-a537-00cad4e9a108")
                .withBeAgencyProjectId("2a473356cca5487f8373be891bffc1cf")
                .withAgencyProjectId("a0a12b069ab4491185d7cf26c3e86ada")
                .withAgencyDomainName("paas_aom_z00418070_01")
                .withAgencyName("wenshufeng")
        );
        body.withPreviewAgencyList(listbodyPreviewAgencyList);
        request.withBody(body);
        try {
            CreateAgencyAccessResponse response = client.createAgencyAccess(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Creating a cross-account log ingestion configuration.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdklts.v2.region.lts_region import LtsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdklts.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = LtsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(LtsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateAgencyAccessRequest()
        listPreviewAgencyListbody = [
            PreviewAgencyLogAccessReqBody(
                agency_access_type="AGENCYACCESS",
                agency_log_access="rule_lb30",
                log_agency_stream_name="lts-topic-bug",
                log_agency_stream_id="beb169ff-e6e9-4bea-8e77-50afdec74071",
                log_agency_group_name="lts-group-sgq",
                log_agency_group_id="f06cbfa0-7243-4031-9380-ae0465bd3997",
                log_be_agencystream_name="lts-topic-ECS",
                log_be_agencystream_id="36ce06b0-c6bf-436d-9abe-39de86da28bb",
                log_be_agencygroup_name="lts-group-sgqECS",
                log_be_agencygroup_id="1e749063-d9f5-474f-a537-00cad4e9a108",
                be_agency_project_id="2a473356cca5487f8373be891bffc1cf",
                agency_project_id="a0a12b069ab4491185d7cf26c3e86ada",
                agency_domain_name="paas_aom_z00418070_01",
                agency_name="wenshufeng"
            )
        ]
        request.body = PreviewAgencyLogAccessReqListBody(
            preview_agency_list=listPreviewAgencyListbody
        )
        response = client.create_agency_access(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Creating a cross-account log ingestion configuration.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    lts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := lts.NewLtsClient(
        lts.LtsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.CreateAgencyAccessRequest{}
	var listPreviewAgencyListbody = []model.PreviewAgencyLogAccessReqBody{
        {
            AgencyAccessType: model.GetPreviewAgencyLogAccessReqBodyAgencyAccessTypeEnum().AGENCYACCESS,
            AgencyLogAccess: "rule_lb30",
            LogAgencyStreamName: "lts-topic-bug",
            LogAgencyStreamId: "beb169ff-e6e9-4bea-8e77-50afdec74071",
            LogAgencyGroupName: "lts-group-sgq",
            LogAgencyGroupId: "f06cbfa0-7243-4031-9380-ae0465bd3997",
            LogBeAgencystreamName: "lts-topic-ECS",
            LogBeAgencystreamId: "36ce06b0-c6bf-436d-9abe-39de86da28bb",
            LogBeAgencygroupName: "lts-group-sgqECS",
            LogBeAgencygroupId: "1e749063-d9f5-474f-a537-00cad4e9a108",
            BeAgencyProjectId: "2a473356cca5487f8373be891bffc1cf",
            AgencyProjectId: "a0a12b069ab4491185d7cf26c3e86ada",
            AgencyDomainName: "paas_aom_z00418070_01",
            AgencyName: "wenshufeng",
        },
    }
	request.Body = &model.PreviewAgencyLogAccessReqListBody{
		PreviewAgencyList: listPreviewAgencyListbody,
	}
	response, err := client.CreateAgencyAccess(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

201

The cross-account log ingestion configuration is created.

400

Failed to create cross-account log ingestion configuration.

500

Internal service error.

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback