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
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. |
Request 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. |
Content-Type |
Yes |
String |
Set this parameter to application/json;charset=utf8. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
preview_agency_list |
Yes |
Array of PreviewAgencyLogAccessReqBody objects |
Preview of the proxy list. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
agency_access_type |
Yes |
String |
Log ingestion type. |
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
Parameter |
Type |
Description |
---|---|---|
[items] |
Array<Array<LTSAccessConfigInfoRespon200>> |
The cross-account log ingestion configuration is created. |
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. |
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 |
Information of the delegated ingestion. |
Parameter |
Type |
Description |
---|---|---|
agency_access_type |
String |
Log ingestion type. |
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
Parameter |
Type |
Description |
---|---|---|
message |
ErrorMessagebody object |
Error message body. |
Parameter |
Type |
Description |
---|---|---|
code |
String |
Error code. |
details |
String |
Error description. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
message |
ErrorMessagebody object |
Error message body. |
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.
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot