百度智能云

All Product Document

          Log Service

          Download Task Operations

          Create download task

          Use the following code to create a download task.

          createDownloadTaskRequest := CreateDownloadTaskRequest{
              Name:           "sdk-download-task-test",
              Project:        "default",
              LogStoreName:   "test",
              LogStreamName:  "",
              Query:          "match *",
              QueryStartTime: time.Now().Add(-10 * time.Minute).UTC().Format("2006-01-02T15:04:05Z"),
              QueryEndTime:   time.Now().UTC().Format("2006-01-02T15:04:05Z"),
              Format:         "json",
              Limit:          100,
              Order:          "desc",
              FileDir:        "",
          }
          uuid, err := BLS_CLIENT.CreateDownloadTask(createDownloadTaskRequest)
          if err != nil {
            fmt.Println("Create downlaod task failed: %v", err)
          } else {
            fmt.Printf('Create download task success with uuid: %s\n', uuid)
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document CreateDownloadTask

          Obtain the specified download task

          With following codes, obtain the download task details of the specified UUID

          describeDownloadRequest := DescribeDownloadRequest{
              UUID: uuid,
          }
          dt, err := BLS_CLIENT.DescribeDownloadTask(describeDownloadRequest)
          if err != nil {
            fmt.Println("Get download task failed: %v", err)
          } else {
            fmt.Printf("get download task info: %v\n", dt)
          }

          Prompt:

          With following codes, obtain the logstore data file link generated by the download task, and download the file through this link

          getDownloadTaskLinkRequest := GetDownloadTaskLinkRequest{
              UUID: uuid,
          }
          lr, err := BLS_CLIENT.GetDownloadTaskLink(getDownloadTaskLinkRequest)
          if err != nil {
            fmt.Println("get download task link failed: %v", err)
          } else {
            fmt.Printf("get download task link success with %v\n", lr)
          }

          Prompt:

          Get download task list

          Use the following code to retrieve the list of download tasks created by the current user.

          //Optional parameter list
          listDownloadTaskRequest := ListDownloadTaskRequest{
              Project:      "default",
              LogStoreName: "test",
              Order:       "desc",
              OrderBy:     "",
              PageNo:      1,
              PageSize:    20,
          }
          res, err := BLS_CLIENT.ListDownloadTask(listDownloadTaskRequest)
          if err != nil {
            fmt.Println("List download task failed: %v", err)
          } else {
            fmt.Printf("Download task list: %v\n", res)
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document List Download Task

          Delete download task

          Use the following code to delete the download task specified by the UUID.

          deleteDownloadTaskRequest := DeleteDownloadTaskRequest{
              UUID: uuid,
          }
          err = BLS_CLIENT.DeleteDownloadTask(deleteDownloadTaskRequest)
          if err != nil {
            fmt.Println("Delete download task failed: %v", err)
          } else {
            fmt.Println("Delete download task success.")
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document Delete Download Task
          Previous
          LogStore Operations
          Next
          FastQuery Operations