هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Cloud Data Center
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
Domain Name Service
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
DataArts Fabric
Cloud Transformation
Cloud Adoption Framework
Well-Architected Framework
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
Blockchain
Blockchain Service
Web3 Node Engine Service
MacroVerse aPaaS
CloudDevice
KooDrive
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
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 (CCI)
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
Meeting
IoT
IoT Device Access
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
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Industry Video Management Service
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
Huawei Cloud Astro Canvas
Huawei Cloud Astro Zero
CodeArts Governance
Help Center/ Log Tank Service/ API Reference/ APIs/ Log Transfer/ Creating a Log Transfer Task (New Version)

Creating a Log Transfer Task (New Version)

Function

This API is used to transfer logs to OBS, DIS, and DMS.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/transfers

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. It can be obtained by calling an API or from the console. For details, see Obtaining a Project ID.

Minimum: 32

Maximum: 32

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

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

Constraints

N/A

Range

N/A

Default Value

N/A

Content-Type

Yes

String

Definition

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

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

log_group_id

Yes

String

Log group ID.

log_streams

Yes

Array of LogStreams objects

Log stream ID list.

log_transfer_info

Yes

log_transfer_info object

Log transfer information.

Table 4 LogStreams

Parameter

Mandatory

Type

Description

log_stream_id

Yes

String

Log stream ID.

log_stream_name

No

String

Log stream name.

Table 5 log_transfer_info

Parameter

Mandatory

Type

Description

log_transfer_type

Yes

String

Log transfer type. You can transfer logs to OBS, DIS, and DMS.

log_transfer_mode

Yes

String

Log transfer mode. cycle indicates periodical transfer, and realTime indicates real-time transfer. cycle is available to OBS transfer tasks and realTime is available to DIS and DMS transfer tasks.

log_storage_format

Yes

String

Log transfer format. The value can be RAW or JSON. RAW indicates the raw log format, and JSON indicates the JSON format.

log_transfer_status

Yes

String

Log transfer status. The value can be ENABLE (log transfer is enabled), DISABLE (log transfer is disabled), or EXCEPTION (log transfer is abnormal).

log_agency_transfer

No

log_agency_transfer object

Information about delegated log transfer. This parameter is required if you transfer logs for another account.

log_transfer_detail

Yes

log_transfer_detail object

Log transfer details.

Table 6 log_agency_transfer

Parameter

Mandatory

Type

Description

agency_domain_id

Yes

String

Definition

Account ID of the delegator.

Range

N/A

agency_domain_name

Yes

String

Definition

Account name of the delegator.

Range

N/A

agency_name

Yes

String

Definition

Name of the agency created by the delegator.

Range

N/A

agency_project_id

Yes

String

Definition

Project ID of the delegator.

Range

N/A

be_agency_domain_id

Yes

String

Definition

Account ID of the delegated party (ID of the account that created the log transfer task).

Range

N/A

be_agency_project_id

Yes

String

Definition

Project ID of the delegated party (ID of the project for which the transfer task is created).

Range

N/A

Table 7 log_transfer_detail

Parameter

Mandatory

Type

Description

obs_period

Yes

Integer

Definition

Length of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2min, 5min, 30min, 1hour, 3hour, 6hour, or 12hour.

Constraints

N/A

Range

1,2,3,5,6,12,30

obs_period_unit

Yes

String

Definition

Unit of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2min, 5min, 30min, 1hour, 3hour, 6hour, or 12hour.

Constraints

N/A

Range

min or hour

obs_bucket_name

Yes

String

Definition

OBS bucket name. This parameter is required when you create an OBS transfer task.

Constraints

N/A

obs_encrypted_id

No

String

Definition

KMS key ID for an OBS transfer task. This parameter is required if encryption is enabled for the target OBS bucket.

Constraints

N/A

obs_dir_pre_fix_name

No

String

Definition

Custom transfer path of an OBS transfer task. This parameter is optional.

Constraints

N/A

obs_prefix_name

No

String

Definition

Transfer file prefix of an OBS transfer task. This parameter is optional.

Constraints

N/A

obs_time_zone

No

String

Definition

Time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer. If this parameter is specified, obs_time_zone_id must also be specified.

Constraints

N/A

obs_time_zone_id

No

String

Definition

ID of the time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer. If this parameter is specified, obs_time_zone must also be specified.

Constraints

N/A

dis_id

No

String

Definition

DIS stream ID. This parameter is required when you create a DIS transfer task.

Constraints

N/A

dis_name

No

String

Definition

DIS stream name. This parameter is required when you create a DIS transfer task.

Constraints

N/A

kafka_id

No

String

Definition

Kafka ID of a DMS transfer task. This parameter is required when you create a DMS transfer task. Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first. For details, see section "Registering a DMS Kafka Instance."

Constraints

N/A

kafka_topic

No

String

Definition

Kafka topic of a DMS transfer task. This parameter is required when you create a DMS transfer task. Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first. For details, see section "Registering a DMS Kafka Instance."

Constraints

N/A

obs_eps_id

No

String

Definition

Enterprise project ID of an OBS transfer task.

Constraints

N/A

obs_encrypted_enable

No

Boolean

Definition

Whether OBS bucket encryption is enabled.

Constraints

N/A

tags

No

Array of strings

Definition

If tag delivery is enabled, this field must contain the following host information: hostIP, hostId, hostName, pathFile, and collectTime.

The public fields are logStreamName, regionName, logGroupName, and projectId, which are optional. The field for enabling tag transfer is streamTag, which is optional.

Constraints

N/A

lts_tags

No

Array of strings

Definition

Whether to transfer the tag field. This parameter is optional when the JSON format is selected for DMS transfer.

Constraints

N/A

stream_tags

No

Array of strings

Definition

Whether to transfer the log stream tag field. This parameter is optional when the JSON format is selected for DMS transfer.

Constraints

N/A

struct_fields

No

Array of strings

Definition

Whether to transfer the structured fields. This parameter is optional when the JSON format is selected for DMS transfer.

Constraints

N/A

invalid_field_value

No

String

Definition

Whether to enable the invalid field fill function. This parameter is optional when the JSON format is selected for DMS transfer.

Constraints

N/A

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

log_group_id

String

Definition

ID of the created log group.

Range

N/A

log_group_name

String

Definition

Name of the created log group.

Range

N/A

log_streams

Array of log_streams objects

Definition

Details about log streams in the log group.

log_transfer_id

String

Definition

ID of the created log transfer task.

Range

N/A

log_transfer_info

log_transfer_info_RespBody object

Definition

Log transfer information.

Table 9 log_streams

Parameter

Type

Description

log_stream_id

String

Definition

Log stream ID.

Range

N/A

log_stream_name

String

Definition

Log stream name.

Range

N/A

Table 10 log_transfer_info_RespBody

Parameter

Type

Description

log_agency_transfer

log_agency_transfer object

Definition

Information about the transfer agency.

If the log source of transfer is another account, logs generated by the delegator account is transferred. Ensure that the delegator has created an agency for log transfer delegation in IAM.

log_create_time

Integer

Definition

Time when the log transfer task was created.

Range

0 to 2147483647

log_storage_format

String

Definition

Log transfer format. The value can be RAW (raw logs) or JSON.

The available format options depend on the selected transfer destination. When the transfer destination is OBS or DIS, JSON and RAM are supported. When the transfer destination is DMS, only RAW is supported.

Range

  • RAW

  • JSON

log_transfer_detail

TransferDetail object

Definition

Log transfer information.

log_transfer_mode

String

Definition

Log transfer mode. The value can be cycle (periodical transfer) and realTime (real-time transfer).

The available mode options depend on the selected transfer destination. If the transfer destination is OBS, the transfer mode can be cycle. If the transfer destination is DIS or DMS, the transfer mode can be realTime.

Range

  • cycle

  • realTime

log_transfer_status

String

Definition

Log transfer status.

Range

  • ENABLE: Log transfer is enabled.

  • DISABLE: Log transfer is disabled.

  • EXCEPTION: Log transfer is abnormal.

log_transfer_type

String

Definition

Log transfer type.

Range

  • OBS: Logs are transferred to OBS.

  • DIS: Logs are transferred to DIS.

  • DMS: Logs are transferred to DMS.

Table 11 log_agency_transfer

Parameter

Type

Description

agency_domain_id

String

Definition

Account ID of the delegator.

Range

N/A

agency_domain_name

String

Definition

Account name of the delegator.

Range

N/A

agency_name

String

Definition

Name of the agency created by the delegator.

Range

N/A

agency_project_id

String

Definition

Project ID of the delegator.

Range

N/A

be_agency_domain_id

String

Definition

Account ID of the delegated party (ID of the account that created the log transfer task).

Range

N/A

be_agency_project_id

String

Definition

Project ID of the delegated party (ID of the project for which the transfer task is created).

Range

N/A

Table 12 TransferDetail

Parameter

Type

Description

obs_period

Integer

Definition

Time for transferring logs to OBS. This parameter is returned when the transfer destination is OBS.

Range

1, 2, 3, 5, 6, 2, 30

obs_period_unit

String

Definition

Time unit for transferring data to OBS. This parameter is returned when the transfer destination is OBS.

Range

  • min

  • hour

obs_bucket_name

String

Definition

Name of the OBS bucket to which logs are transferred. This parameter is returned when the transfer destination is OBS.

Range

N/A

obs_encrypted_id

String

Definition

KMS key ID of the OBS bucket to which logs are transferred. This parameter is returned when logs are transferred to an encrypted OBS bucket.

Range

N/A

obs_dir_pre_fix_name

String

Definition

Custom transfer path to which logs are transferred to OBS. This parameter is returned when the transfer destination is OBS. Logs will be transferred to this custom path to separate log files from different log streams.

Range

N/A

obs_prefix_name

String

Definition

File name prefix of the log files transferred to an OBS bucket. This parameter is returned when the transfer destination is OBS.

Range

N/A

obs_time_zone

String

Definition

Time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer.

Range

N/A

obs_time_zone_id

String

Definition

Time zone ID for an OBS transfer task. For details, see Time Zone List for OBS Transfer.

Range

N/A

dis_id

String

Definition

ID of the DIS transfer channel to which logs are transferred. This parameter is returned when logs are transferred to DIS.

Range

N/A

dis_name

String

Definition

Name of the DIS transfer channel to which logs are transferred. This parameter is returned when logs are transferred to DIS.

Range

N/A

kafka_id

String

Definition

Kafka ID for transferring logs to DMS. This parameter is returned when logs are transferred to DMS.

Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first. For details, see Registering a DMS Kafka Instance.

Range

N/A

kafka_topic

String

Definition

Kafka topic for transferring logs to DMS. This parameter is returned when logs are transferred to DMS.

Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first. For details, see Registering a DMS Kafka Instance.

Range

N/A

obs_transfer_path

String

Definition

OBS bucket path, which is the log transfer destination.

Range

N/A

obs_encrypted_enable

Boolean

Definition

Whether OBS bucket encryption is enabled.

Range

  • true

  • false

tags

Array of strings

Definition

Whether filtering by tag fields is enabled.

Range

N/A

Status code: 400

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Status code: 500

Table 14 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Example Requests

  • Transferring logs to OBS

    POST https://{endpoint}/v2/{project_id}/transfers
    
    {
      "log_group_id" : "8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx",
      "log_streams" : [ {
        "log_stream_id" : "c776e1a7-8548-430a-afe5-xxxxxxxxxxxx"
      } ],
      "log_transfer_info" : {
        "log_transfer_type" : "OBS",
        "log_transfer_mode" : "xxxxx",
        "log_storage_format" : "XXX",
        "log_transfer_status" : "XXXXX",
        "log_agency_transfer" : {
          "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "agency_domain_name" : "paas_apm_z004xxxxx_xx",
          "agency_name" : "test20210325",
          "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx",
          "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx"
        },
        "log_transfer_detail" : {
          "obs_period" : 2,
          "obs_period_unit" : "min",
          "obs_bucket_name" : "xxxxx",
          "obs_encrypted_id" : "1bd90032-1424-481f-8558-ba49854xxxxx",
          "obs_dir_pre_fix_name" : "/xx",
          "obs_prefix_name" : "xxxxx",
          "obs_time_zone" : "UTC+01:00",
          "obs_time_zone_id" : "Africa/Lagos"
        }
      }
    }
  • Creating a DIS transfer task

    POST https://{endpoint}/v2/{project_id}/transfers
    
    {
      "log_group_id" : "8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx",
      "log_streams" : [ {
        "log_stream_id" : "c776e1a7-8548-430a-afe5-xxxxxxxxxxxx"
      } ],
      "log_transfer_info" : {
        "log_transfer_type" : "DIS",
        "log_transfer_mode" : "xxxxx",
        "log_storage_format" : "XXX",
        "log_transfer_status" : "XXXXX",
        "log_agency_transfer" : {
          "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "agency_domain_name" : "paas_apm_z004xxxxx_xx",
          "agency_name" : "test20210325",
          "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx",
          "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx"
        },
        "log_transfer_detail" : {
          "dis_id" : "i1y8vfMTvf4LQzxxxxx",
          "dis_name" : "xxxxx"
        }
      }
    }

Example Responses

Status code: 200

The log transfer task is created.

  • The following parameters are returned for an OBS transfer task:

    {
      "log_group_id" : "9a7e2183-2d6d-4732-9a9b-e897fd4e49e0",
      "log_group_name" : "lts-group-kafka",
      "log_streams" : [ {
        "log_stream_id" : "839dac89-35af-4db2-ab4a-a7dda0d0d3f8",
        "log_stream_name" : "lts-topic-kafka"
      } ],
      "log_transfer_id" : "ddced522-233a-4181-a5fc-7b458c819afc",
      "log_transfer_info" : {
        "log_create_time" : 1634802241847,
        "log_storage_format" : "JSON",
        "log_agency_transfer" : {
          "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "agency_domain_name" : "paas_apm_z004xxxxx_xx",
          "agency_name" : "test20210325",
          "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx",
          "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx"
        },
        "log_transfer_detail" : {
          "obs_period" : 2,
          "obs_prefix_name" : "",
          "obs_period_unit" : "min",
          "obs_transfer_path" : "/0002/LogTanks/cn-north-7/",
          "obs_bucket_name" : "0002",
          "obs_encrypted_enable" : false,
          "obs_dir_pre_fix_name" : "",
          "obs_time_zone" : "UTC+01:00",
          "obs_time_zone_id" : "Africa/Lagos",
          "tags" : [ ]
        },
        "log_transfer_mode" : "cycle",
        "log_transfer_status" : "ENABLE",
        "log_transfer_type" : "OBS"
      }
    }
  • The following parameters are returned for a DIS transfer task:

    {
      "log_group_id" : "9a7e2183-2d6d-4732-9a9b-e897fd4e49e0",
      "log_group_name" : "lts-group-kafka",
      "log_streams" : [ {
        "log_stream_id" : "839dac89-35af-4db2-ab4a-a7dda0d0d3f8",
        "log_stream_name" : "lts-topic-kafka"
      } ],
      "log_transfer_id" : "ddced522-233a-4181-a5fc-7b458c819afc",
      "log_transfer_info" : {
        "log_create_time" : 1634802241847,
        "log_storage_format" : "JSON",
        "log_agency_transfer" : {
          "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "agency_domain_name" : "paas_apm_z004xxxxx_xx",
          "agency_name" : "test20210325",
          "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx",
          "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx"
        },
        "log_transfer_detail" : {
          "dis_id" : "xxxxx",
          "dis_name" : "xxxxxx",
          "tags" : [ ]
        },
        "log_transfer_mode" : "cycle",
        "log_transfer_status" : "ENABLE",
        "log_transfer_type" : "OBS"
      }
    }
  • The following parameters are returned for a DMS transfer task:

    {
      "log_group_id" : "9a7e2183-2d6d-4732-9a9b-e897fd4e49e0",
      "log_group_name" : "lts-group-kafka",
      "log_streams" : [ {
        "log_stream_id" : "839dac89-35af-4db2-ab4a-a7dda0d0d3f8",
        "log_stream_name" : "lts-topic-kafka"
      } ],
      "log_transfer_id" : "ddced522-233a-4181-a5fc-7b458c819afc",
      "log_transfer_info" : {
        "log_create_time" : 1634802241847,
        "log_storage_format" : "JSON",
        "log_agency_transfer" : {
          "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "agency_domain_name" : "paas_apm_z004xxxxx_xx",
          "agency_name" : "test20210325",
          "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx",
          "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
          "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx"
        },
        "log_transfer_detail" : {
          "kafka_id" : "xxxxxx",
          "kafka_topic" : "xxxxx",
          "tags" : [ ]
        },
        "log_transfer_mode" : "cycle",
        "log_transfer_status" : "ENABLE",
        "log_transfer_type" : "OBS"
      }
    }

Status code: 400

Invalid request. Modify the request based on the description in error_msg before a retry.

{
  "error_code" : "LTS.0207",
  "error_msg" : "The log stream is associated by transfer"
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "error_code" : "LTS.0207",
  "error_msg" : "The log stream is associated by transfer"
}

SDK Sample Code

The SDK sample code is as follows.

  • Transferring logs to OBS

     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
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    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 CreateTransferSolution {
    
        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();
            CreateTransferRequest request = new CreateTransferRequest();
            CreateTransferRequestBody body = new CreateTransferRequestBody();
            TransferDetail logTransferDetailLogTransferInfo = new TransferDetail();
            logTransferDetailLogTransferInfo.withObsPeriod(TransferDetail.ObsPeriodEnum.NUMBER_2)
                .withObsEncryptedId("1bd90032-1424-481f-8558-ba49854xxxxx")
                .withObsPrefixName("xxxxx")
                .withObsPeriodUnit("min")
                .withObsBucketName("xxxxx")
                .withObsDirPreFixName("/xx")
                .withObsTimeZone("UTC+01:00")
                .withObsTimeZoneId("Africa/Lagos");
            CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer logAgencyTransferLogTransferInfo = new CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer();
            logAgencyTransferLogTransferInfo.withAgencyDomainId("1d26cc8c86a840e28a4f8d0d078xxxxx")
                .withAgencyDomainName("paas_apm_z004xxxxx_xx")
                .withAgencyName("test20210325")
                .withAgencyProjectId("2a473356cca5487f8373be891bfxxxxx")
                .withBeAgencyDomainId("1d26cc8c86a840e28a4f8d0d078xxxxx")
                .withBeAgencyProjectId("2a473356cca5487f8373be891bfxxxxx");
            CreateTransferRequestBodyLogTransferInfo logTransferInfobody = new CreateTransferRequestBodyLogTransferInfo();
            logTransferInfobody.withLogTransferType("OBS")
                .withLogTransferMode(CreateTransferRequestBodyLogTransferInfo.LogTransferModeEnum.fromValue("xxxxx"))
                .withLogStorageFormat(CreateTransferRequestBodyLogTransferInfo.LogStorageFormatEnum.fromValue("XXX"))
                .withLogTransferStatus(CreateTransferRequestBodyLogTransferInfo.LogTransferStatusEnum.fromValue("XXXXX"))
                .withLogAgencyTransfer(logAgencyTransferLogTransferInfo)
                .withLogTransferDetail(logTransferDetailLogTransferInfo);
            List<CreateTransferRequestBodyLogStreams> listbodyLogStreams = new ArrayList<>();
            listbodyLogStreams.add(
                new CreateTransferRequestBodyLogStreams()
                    .withLogStreamId("c776e1a7-8548-430a-afe5-xxxxxxxxxxxx")
            );
            body.withLogTransferInfo(logTransferInfobody);
            body.withLogStreams(listbodyLogStreams);
            body.withLogGroupId("8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx");
            request.withBody(body);
            try {
                CreateTransferResponse response = client.createTransfer(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 DIS transfer task

     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
    71
    72
    73
    74
    75
    76
    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 CreateTransferSolution {
    
        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();
            CreateTransferRequest request = new CreateTransferRequest();
            CreateTransferRequestBody body = new CreateTransferRequestBody();
            TransferDetail logTransferDetailLogTransferInfo = new TransferDetail();
            logTransferDetailLogTransferInfo.withDisId("i1y8vfMTvf4LQzxxxxx")
                .withDisName("xxxxx");
            CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer logAgencyTransferLogTransferInfo = new CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer();
            logAgencyTransferLogTransferInfo.withAgencyDomainId("1d26cc8c86a840e28a4f8d0d078xxxxx")
                .withAgencyDomainName("paas_apm_z004xxxxx_xx")
                .withAgencyName("test20210325")
                .withAgencyProjectId("2a473356cca5487f8373be891bfxxxxx")
                .withBeAgencyDomainId("1d26cc8c86a840e28a4f8d0d078xxxxx")
                .withBeAgencyProjectId("2a473356cca5487f8373be891bfxxxxx");
            CreateTransferRequestBodyLogTransferInfo logTransferInfobody = new CreateTransferRequestBodyLogTransferInfo();
            logTransferInfobody.withLogTransferType("DIS")
                .withLogTransferMode(CreateTransferRequestBodyLogTransferInfo.LogTransferModeEnum.fromValue("xxxxx"))
                .withLogStorageFormat(CreateTransferRequestBodyLogTransferInfo.LogStorageFormatEnum.fromValue("XXX"))
                .withLogTransferStatus(CreateTransferRequestBodyLogTransferInfo.LogTransferStatusEnum.fromValue("XXXXX"))
                .withLogAgencyTransfer(logAgencyTransferLogTransferInfo)
                .withLogTransferDetail(logTransferDetailLogTransferInfo);
            List<CreateTransferRequestBodyLogStreams> listbodyLogStreams = new ArrayList<>();
            listbodyLogStreams.add(
                new CreateTransferRequestBodyLogStreams()
                    .withLogStreamId("c776e1a7-8548-430a-afe5-xxxxxxxxxxxx")
            );
            body.withLogTransferInfo(logTransferInfobody);
            body.withLogStreams(listbodyLogStreams);
            body.withLogGroupId("8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx");
            request.withBody(body);
            try {
                CreateTransferResponse response = client.createTransfer(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());
            }
        }
    }
    
  • Transferring logs to OBS

     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
    # 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 = CreateTransferRequest()
            logTransferDetailLogTransferInfo = TransferDetail(
                obs_period=2,
                obs_encrypted_id="1bd90032-1424-481f-8558-ba49854xxxxx",
                obs_prefix_name="xxxxx",
                obs_period_unit="min",
                obs_bucket_name="xxxxx",
                obs_dir_pre_fix_name="/xx",
                obs_time_zone="UTC+01:00",
                obs_time_zone_id="Africa/Lagos"
            )
            logAgencyTransferLogTransferInfo = CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer(
                agency_domain_id="1d26cc8c86a840e28a4f8d0d078xxxxx",
                agency_domain_name="paas_apm_z004xxxxx_xx",
                agency_name="test20210325",
                agency_project_id="2a473356cca5487f8373be891bfxxxxx",
                be_agency_domain_id="1d26cc8c86a840e28a4f8d0d078xxxxx",
                be_agency_project_id="2a473356cca5487f8373be891bfxxxxx"
            )
            logTransferInfobody = CreateTransferRequestBodyLogTransferInfo(
                log_transfer_type="OBS",
                log_transfer_mode="xxxxx",
                log_storage_format="XXX",
                log_transfer_status="XXXXX",
                log_agency_transfer=logAgencyTransferLogTransferInfo,
                log_transfer_detail=logTransferDetailLogTransferInfo
            )
            listLogStreamsbody = [
                CreateTransferRequestBodyLogStreams(
                    log_stream_id="c776e1a7-8548-430a-afe5-xxxxxxxxxxxx"
                )
            ]
            request.body = CreateTransferRequestBody(
                log_transfer_info=logTransferInfobody,
                log_streams=listLogStreamsbody,
                log_group_id="8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx"
            )
            response = client.create_transfer(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 DIS transfer task

     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
    # 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 = CreateTransferRequest()
            logTransferDetailLogTransferInfo = TransferDetail(
                dis_id="i1y8vfMTvf4LQzxxxxx",
                dis_name="xxxxx"
            )
            logAgencyTransferLogTransferInfo = CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer(
                agency_domain_id="1d26cc8c86a840e28a4f8d0d078xxxxx",
                agency_domain_name="paas_apm_z004xxxxx_xx",
                agency_name="test20210325",
                agency_project_id="2a473356cca5487f8373be891bfxxxxx",
                be_agency_domain_id="1d26cc8c86a840e28a4f8d0d078xxxxx",
                be_agency_project_id="2a473356cca5487f8373be891bfxxxxx"
            )
            logTransferInfobody = CreateTransferRequestBodyLogTransferInfo(
                log_transfer_type="DIS",
                log_transfer_mode="xxxxx",
                log_storage_format="XXX",
                log_transfer_status="XXXXX",
                log_agency_transfer=logAgencyTransferLogTransferInfo,
                log_transfer_detail=logTransferDetailLogTransferInfo
            )
            listLogStreamsbody = [
                CreateTransferRequestBodyLogStreams(
                    log_stream_id="c776e1a7-8548-430a-afe5-xxxxxxxxxxxx"
                )
            ]
            request.body = CreateTransferRequestBody(
                log_transfer_info=logTransferInfobody,
                log_streams=listLogStreamsbody,
                log_group_id="8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx"
            )
            response = client.create_transfer(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Transferring logs to OBS

     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
    71
    72
    73
    74
    75
    76
    77
    78
    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.CreateTransferRequest{}
    	obsEncryptedIdLogTransferDetail:= "1bd90032-1424-481f-8558-ba49854xxxxx"
    	obsPrefixNameLogTransferDetail:= "xxxxx"
    	obsDirPreFixNameLogTransferDetail:= "/xx"
    	obsTimeZoneLogTransferDetail:= "UTC+01:00"
    	obsTimeZoneIdLogTransferDetail:= "Africa/Lagos"
    	logTransferDetailLogTransferInfo := &model.TransferDetail{
    		ObsPeriod: model.GetTransferDetailObsPeriodEnum().E_2,
    		ObsEncryptedId: &obsEncryptedIdLogTransferDetail,
    		ObsPrefixName: &obsPrefixNameLogTransferDetail,
    		ObsPeriodUnit: "min",
    		ObsBucketName: "xxxxx",
    		ObsDirPreFixName: &obsDirPreFixNameLogTransferDetail,
    		ObsTimeZone: &obsTimeZoneLogTransferDetail,
    		ObsTimeZoneId: &obsTimeZoneIdLogTransferDetail,
    	}
    	logAgencyTransferLogTransferInfo := &model.CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer{
    		AgencyDomainId: "1d26cc8c86a840e28a4f8d0d078xxxxx",
    		AgencyDomainName: "paas_apm_z004xxxxx_xx",
    		AgencyName: "test20210325",
    		AgencyProjectId: "2a473356cca5487f8373be891bfxxxxx",
    		BeAgencyDomainId: "1d26cc8c86a840e28a4f8d0d078xxxxx",
    		BeAgencyProjectId: "2a473356cca5487f8373be891bfxxxxx",
    	}
    	logTransferInfobody := &model.CreateTransferRequestBodyLogTransferInfo{
    		LogTransferType: "OBS",
    		LogTransferMode: model.GetCreateTransferRequestBodyLogTransferInfoLogTransferModeEnum().XXXXX,
    		LogStorageFormat: model.GetCreateTransferRequestBodyLogTransferInfoLogStorageFormatEnum().XXX,
    		LogTransferStatus: model.GetCreateTransferRequestBodyLogTransferInfoLogTransferStatusEnum().XXXXX,
    		LogAgencyTransfer: logAgencyTransferLogTransferInfo,
    		LogTransferDetail: logTransferDetailLogTransferInfo,
    	}
    	var listLogStreamsbody = []model.CreateTransferRequestBodyLogStreams{
            {
                LogStreamId: "c776e1a7-8548-430a-afe5-xxxxxxxxxxxx",
            },
        }
    	request.Body = &model.CreateTransferRequestBody{
    		LogTransferInfo: logTransferInfobody,
    		LogStreams: listLogStreamsbody,
    		LogGroupId: "8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx",
    	}
    	response, err := client.CreateTransfer(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Creating a DIS transfer task

     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
    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.CreateTransferRequest{}
    	disIdLogTransferDetail:= "i1y8vfMTvf4LQzxxxxx"
    	disNameLogTransferDetail:= "xxxxx"
    	logTransferDetailLogTransferInfo := &model.TransferDetail{
    		DisId: &disIdLogTransferDetail,
    		DisName: &disNameLogTransferDetail,
    	}
    	logAgencyTransferLogTransferInfo := &model.CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer{
    		AgencyDomainId: "1d26cc8c86a840e28a4f8d0d078xxxxx",
    		AgencyDomainName: "paas_apm_z004xxxxx_xx",
    		AgencyName: "test20210325",
    		AgencyProjectId: "2a473356cca5487f8373be891bfxxxxx",
    		BeAgencyDomainId: "1d26cc8c86a840e28a4f8d0d078xxxxx",
    		BeAgencyProjectId: "2a473356cca5487f8373be891bfxxxxx",
    	}
    	logTransferInfobody := &model.CreateTransferRequestBodyLogTransferInfo{
    		LogTransferType: "DIS",
    		LogTransferMode: model.GetCreateTransferRequestBodyLogTransferInfoLogTransferModeEnum().XXXXX,
    		LogStorageFormat: model.GetCreateTransferRequestBodyLogTransferInfoLogStorageFormatEnum().XXX,
    		LogTransferStatus: model.GetCreateTransferRequestBodyLogTransferInfoLogTransferStatusEnum().XXXXX,
    		LogAgencyTransfer: logAgencyTransferLogTransferInfo,
    		LogTransferDetail: logTransferDetailLogTransferInfo,
    	}
    	var listLogStreamsbody = []model.CreateTransferRequestBodyLogStreams{
            {
                LogStreamId: "c776e1a7-8548-430a-afe5-xxxxxxxxxxxx",
            },
        }
    	request.Body = &model.CreateTransferRequestBody{
    		LogTransferInfo: logTransferInfobody,
    		LogStreams: listLogStreamsbody,
    		LogGroupId: "8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx",
    	}
    	response, err := client.CreateTransfer(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.

  • Transferring logs to OBS

     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
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    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 CreateTransferSolution {
    
        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();
            CreateTransferRequest request = new CreateTransferRequest();
            CreateTransferRequestBody body = new CreateTransferRequestBody();
            TransferDetail logTransferDetailLogTransferInfo = new TransferDetail();
            logTransferDetailLogTransferInfo.withObsPeriod(TransferDetail.ObsPeriodEnum.NUMBER_2)
                .withObsEncryptedId("1bd90032-1424-481f-8558-ba49854xxxxx")
                .withObsPrefixName("xxxxx")
                .withObsPeriodUnit("min")
                .withObsBucketName("xxxxx")
                .withObsDirPreFixName("/xx")
                .withObsTimeZone("UTC+01:00")
                .withObsTimeZoneId("Africa/Lagos");
            CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer logAgencyTransferLogTransferInfo = new CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer();
            logAgencyTransferLogTransferInfo.withAgencyDomainId("1d26cc8c86a840e28a4f8d0d078xxxxx")
                .withAgencyDomainName("paas_apm_z004xxxxx_xx")
                .withAgencyName("test20210325")
                .withAgencyProjectId("2a473356cca5487f8373be891bfxxxxx")
                .withBeAgencyDomainId("1d26cc8c86a840e28a4f8d0d078xxxxx")
                .withBeAgencyProjectId("2a473356cca5487f8373be891bfxxxxx");
            CreateTransferRequestBodyLogTransferInfo logTransferInfobody = new CreateTransferRequestBodyLogTransferInfo();
            logTransferInfobody.withLogTransferType("OBS")
                .withLogTransferMode(CreateTransferRequestBodyLogTransferInfo.LogTransferModeEnum.fromValue("xxxxx"))
                .withLogStorageFormat(CreateTransferRequestBodyLogTransferInfo.LogStorageFormatEnum.fromValue("XXX"))
                .withLogTransferStatus(CreateTransferRequestBodyLogTransferInfo.LogTransferStatusEnum.fromValue("XXXXX"))
                .withLogAgencyTransfer(logAgencyTransferLogTransferInfo)
                .withLogTransferDetail(logTransferDetailLogTransferInfo);
            List<CreateTransferRequestBodyLogStreams> listbodyLogStreams = new ArrayList<>();
            listbodyLogStreams.add(
                new CreateTransferRequestBodyLogStreams()
                    .withLogStreamId("c776e1a7-8548-430a-afe5-xxxxxxxxxxxx")
            );
            body.withLogTransferInfo(logTransferInfobody);
            body.withLogStreams(listbodyLogStreams);
            body.withLogGroupId("8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx");
            request.withBody(body);
            try {
                CreateTransferResponse response = client.createTransfer(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 DIS transfer task

     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
    71
    72
    73
    74
    75
    76
    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 CreateTransferSolution {
    
        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();
            CreateTransferRequest request = new CreateTransferRequest();
            CreateTransferRequestBody body = new CreateTransferRequestBody();
            TransferDetail logTransferDetailLogTransferInfo = new TransferDetail();
            logTransferDetailLogTransferInfo.withDisId("i1y8vfMTvf4LQzxxxxx")
                .withDisName("xxxxx");
            CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer logAgencyTransferLogTransferInfo = new CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer();
            logAgencyTransferLogTransferInfo.withAgencyDomainId("1d26cc8c86a840e28a4f8d0d078xxxxx")
                .withAgencyDomainName("paas_apm_z004xxxxx_xx")
                .withAgencyName("test20210325")
                .withAgencyProjectId("2a473356cca5487f8373be891bfxxxxx")
                .withBeAgencyDomainId("1d26cc8c86a840e28a4f8d0d078xxxxx")
                .withBeAgencyProjectId("2a473356cca5487f8373be891bfxxxxx");
            CreateTransferRequestBodyLogTransferInfo logTransferInfobody = new CreateTransferRequestBodyLogTransferInfo();
            logTransferInfobody.withLogTransferType("DIS")
                .withLogTransferMode(CreateTransferRequestBodyLogTransferInfo.LogTransferModeEnum.fromValue("xxxxx"))
                .withLogStorageFormat(CreateTransferRequestBodyLogTransferInfo.LogStorageFormatEnum.fromValue("XXX"))
                .withLogTransferStatus(CreateTransferRequestBodyLogTransferInfo.LogTransferStatusEnum.fromValue("XXXXX"))
                .withLogAgencyTransfer(logAgencyTransferLogTransferInfo)
                .withLogTransferDetail(logTransferDetailLogTransferInfo);
            List<CreateTransferRequestBodyLogStreams> listbodyLogStreams = new ArrayList<>();
            listbodyLogStreams.add(
                new CreateTransferRequestBodyLogStreams()
                    .withLogStreamId("c776e1a7-8548-430a-afe5-xxxxxxxxxxxx")
            );
            body.withLogTransferInfo(logTransferInfobody);
            body.withLogStreams(listbodyLogStreams);
            body.withLogGroupId("8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx");
            request.withBody(body);
            try {
                CreateTransferResponse response = client.createTransfer(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());
            }
        }
    }
    
  • Transferring logs to OBS

     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
    # 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 = CreateTransferRequest()
            logTransferDetailLogTransferInfo = TransferDetail(
                obs_period=2,
                obs_encrypted_id="1bd90032-1424-481f-8558-ba49854xxxxx",
                obs_prefix_name="xxxxx",
                obs_period_unit="min",
                obs_bucket_name="xxxxx",
                obs_dir_pre_fix_name="/xx",
                obs_time_zone="UTC+01:00",
                obs_time_zone_id="Africa/Lagos"
            )
            logAgencyTransferLogTransferInfo = CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer(
                agency_domain_id="1d26cc8c86a840e28a4f8d0d078xxxxx",
                agency_domain_name="paas_apm_z004xxxxx_xx",
                agency_name="test20210325",
                agency_project_id="2a473356cca5487f8373be891bfxxxxx",
                be_agency_domain_id="1d26cc8c86a840e28a4f8d0d078xxxxx",
                be_agency_project_id="2a473356cca5487f8373be891bfxxxxx"
            )
            logTransferInfobody = CreateTransferRequestBodyLogTransferInfo(
                log_transfer_type="OBS",
                log_transfer_mode="xxxxx",
                log_storage_format="XXX",
                log_transfer_status="XXXXX",
                log_agency_transfer=logAgencyTransferLogTransferInfo,
                log_transfer_detail=logTransferDetailLogTransferInfo
            )
            listLogStreamsbody = [
                CreateTransferRequestBodyLogStreams(
                    log_stream_id="c776e1a7-8548-430a-afe5-xxxxxxxxxxxx"
                )
            ]
            request.body = CreateTransferRequestBody(
                log_transfer_info=logTransferInfobody,
                log_streams=listLogStreamsbody,
                log_group_id="8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx"
            )
            response = client.create_transfer(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 DIS transfer task

     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
    # 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 = CreateTransferRequest()
            logTransferDetailLogTransferInfo = TransferDetail(
                dis_id="i1y8vfMTvf4LQzxxxxx",
                dis_name="xxxxx"
            )
            logAgencyTransferLogTransferInfo = CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer(
                agency_domain_id="1d26cc8c86a840e28a4f8d0d078xxxxx",
                agency_domain_name="paas_apm_z004xxxxx_xx",
                agency_name="test20210325",
                agency_project_id="2a473356cca5487f8373be891bfxxxxx",
                be_agency_domain_id="1d26cc8c86a840e28a4f8d0d078xxxxx",
                be_agency_project_id="2a473356cca5487f8373be891bfxxxxx"
            )
            logTransferInfobody = CreateTransferRequestBodyLogTransferInfo(
                log_transfer_type="DIS",
                log_transfer_mode="xxxxx",
                log_storage_format="XXX",
                log_transfer_status="XXXXX",
                log_agency_transfer=logAgencyTransferLogTransferInfo,
                log_transfer_detail=logTransferDetailLogTransferInfo
            )
            listLogStreamsbody = [
                CreateTransferRequestBodyLogStreams(
                    log_stream_id="c776e1a7-8548-430a-afe5-xxxxxxxxxxxx"
                )
            ]
            request.body = CreateTransferRequestBody(
                log_transfer_info=logTransferInfobody,
                log_streams=listLogStreamsbody,
                log_group_id="8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx"
            )
            response = client.create_transfer(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Transferring logs to OBS

     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
    71
    72
    73
    74
    75
    76
    77
    78
    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.CreateTransferRequest{}
    	obsEncryptedIdLogTransferDetail:= "1bd90032-1424-481f-8558-ba49854xxxxx"
    	obsPrefixNameLogTransferDetail:= "xxxxx"
    	obsDirPreFixNameLogTransferDetail:= "/xx"
    	obsTimeZoneLogTransferDetail:= "UTC+01:00"
    	obsTimeZoneIdLogTransferDetail:= "Africa/Lagos"
    	logTransferDetailLogTransferInfo := &model.TransferDetail{
    		ObsPeriod: model.GetTransferDetailObsPeriodEnum().E_2,
    		ObsEncryptedId: &obsEncryptedIdLogTransferDetail,
    		ObsPrefixName: &obsPrefixNameLogTransferDetail,
    		ObsPeriodUnit: "min",
    		ObsBucketName: "xxxxx",
    		ObsDirPreFixName: &obsDirPreFixNameLogTransferDetail,
    		ObsTimeZone: &obsTimeZoneLogTransferDetail,
    		ObsTimeZoneId: &obsTimeZoneIdLogTransferDetail,
    	}
    	logAgencyTransferLogTransferInfo := &model.CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer{
    		AgencyDomainId: "1d26cc8c86a840e28a4f8d0d078xxxxx",
    		AgencyDomainName: "paas_apm_z004xxxxx_xx",
    		AgencyName: "test20210325",
    		AgencyProjectId: "2a473356cca5487f8373be891bfxxxxx",
    		BeAgencyDomainId: "1d26cc8c86a840e28a4f8d0d078xxxxx",
    		BeAgencyProjectId: "2a473356cca5487f8373be891bfxxxxx",
    	}
    	logTransferInfobody := &model.CreateTransferRequestBodyLogTransferInfo{
    		LogTransferType: "OBS",
    		LogTransferMode: model.GetCreateTransferRequestBodyLogTransferInfoLogTransferModeEnum().XXXXX,
    		LogStorageFormat: model.GetCreateTransferRequestBodyLogTransferInfoLogStorageFormatEnum().XXX,
    		LogTransferStatus: model.GetCreateTransferRequestBodyLogTransferInfoLogTransferStatusEnum().XXXXX,
    		LogAgencyTransfer: logAgencyTransferLogTransferInfo,
    		LogTransferDetail: logTransferDetailLogTransferInfo,
    	}
    	var listLogStreamsbody = []model.CreateTransferRequestBodyLogStreams{
            {
                LogStreamId: "c776e1a7-8548-430a-afe5-xxxxxxxxxxxx",
            },
        }
    	request.Body = &model.CreateTransferRequestBody{
    		LogTransferInfo: logTransferInfobody,
    		LogStreams: listLogStreamsbody,
    		LogGroupId: "8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx",
    	}
    	response, err := client.CreateTransfer(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Creating a DIS transfer task

     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
    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.CreateTransferRequest{}
    	disIdLogTransferDetail:= "i1y8vfMTvf4LQzxxxxx"
    	disNameLogTransferDetail:= "xxxxx"
    	logTransferDetailLogTransferInfo := &model.TransferDetail{
    		DisId: &disIdLogTransferDetail,
    		DisName: &disNameLogTransferDetail,
    	}
    	logAgencyTransferLogTransferInfo := &model.CreateTransferRequestBodyLogTransferInfoLogAgencyTransfer{
    		AgencyDomainId: "1d26cc8c86a840e28a4f8d0d078xxxxx",
    		AgencyDomainName: "paas_apm_z004xxxxx_xx",
    		AgencyName: "test20210325",
    		AgencyProjectId: "2a473356cca5487f8373be891bfxxxxx",
    		BeAgencyDomainId: "1d26cc8c86a840e28a4f8d0d078xxxxx",
    		BeAgencyProjectId: "2a473356cca5487f8373be891bfxxxxx",
    	}
    	logTransferInfobody := &model.CreateTransferRequestBodyLogTransferInfo{
    		LogTransferType: "DIS",
    		LogTransferMode: model.GetCreateTransferRequestBodyLogTransferInfoLogTransferModeEnum().XXXXX,
    		LogStorageFormat: model.GetCreateTransferRequestBodyLogTransferInfoLogStorageFormatEnum().XXX,
    		LogTransferStatus: model.GetCreateTransferRequestBodyLogTransferInfoLogTransferStatusEnum().XXXXX,
    		LogAgencyTransfer: logAgencyTransferLogTransferInfo,
    		LogTransferDetail: logTransferDetailLogTransferInfo,
    	}
    	var listLogStreamsbody = []model.CreateTransferRequestBodyLogStreams{
            {
                LogStreamId: "c776e1a7-8548-430a-afe5-xxxxxxxxxxxx",
            },
        }
    	request.Body = &model.CreateTransferRequestBody{
    		LogTransferInfo: logTransferInfobody,
    		LogStreams: listLogStreamsbody,
    		LogGroupId: "8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx",
    	}
    	response, err := client.CreateTransfer(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

200

The log transfer task is created.

400

Invalid request. Modify the request based on the description in error_msg before a retry.

500

The server has received the request but encountered an internal 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
咨询盘古Doer

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback