Creating a Security Report
Function
This API is used to create a security report.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/workspaces/{workspace_id}/sa/reports
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition Project ID, which is used to specify the project that a resource belongs to. You can query the resources of a project by project ID. You can obtain the project ID from the API or console. Obtaining the Project ID Constraints N/A Range N/A Default Value N/A |
|
workspace_id |
Yes |
String |
Definition Workspace ID. Constraints N/A Range N/A Default Value N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
Region |
Yes |
String |
Region ID. |
|
X-Auth-Token |
Yes |
String |
Definition User token. You can obtain it by calling the IAM API for obtaining a user token. The user token is the value of X-Subject-Token in the response header. Obtaining a User Token Constraints N/A Range N/A Default Value N/A |
|
content-type |
Yes |
String |
Definition Content type. Constraints N/A Range Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
report_name |
Yes |
String |
Report name. |
|
report_period |
Yes |
String |
Report period. The options are weekly, daily, annual, and monthly. |
|
report_range |
Yes |
report_range object |
Data scope. |
|
language |
Yes |
String |
Language. |
|
notification_task |
No |
String |
Notification task ID. |
|
layout_id |
Yes |
String |
Layout ID. |
|
title |
No |
String |
Email subject. |
|
to |
No |
String |
Recipient email address. |
|
cc |
No |
String |
CC recipient email address. |
|
content |
No |
String |
Email content. |
|
report_file_type |
No |
String |
Report type. Image, PDF, and HTML are supported. |
|
frequency |
No |
String |
Report sending frequency. The options are daily, monthly, and weekly. |
|
binding_wizard |
Yes |
String |
Report content. |
|
timezone |
No |
String |
Information. |
|
report_rule_infos |
No |
Array of ReportRuleRequest objects |
Report sending rule. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
start |
Yes |
String |
Start time. |
|
end |
Yes |
String |
End time. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
rule |
No |
String |
Cron expression of the report sending task. |
|
rule_end |
No |
String |
End time for starting the report sending task. |
|
start_time |
No |
start_time object |
Start time of the report statistical period. |
|
end_time |
No |
end_time object |
End time of the report statistical period. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
day |
No |
Integer |
Date of the report statistical period. -1: the previous day; 0: the current day. |
|
week |
No |
Integer |
Date of the report statistical period. -1: the previous week; 0: the current week. |
|
month |
No |
Integer |
Date of the report statistical period. -1: the previous month; 0: the current month. |
|
time |
No |
String |
Start time of the report statistical period. The time is in the format of hour:minute:second. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
day |
No |
Integer |
Date of the report statistical period. -1: the previous day; 0: the current day. |
|
week |
No |
Integer |
Date of the report statistical period. -1: the previous week; 0: the current week. |
|
month |
No |
Integer |
Date of the report statistical period. -1: the previous month; 0: the current month. |
|
time |
No |
String |
End time of the report statistical period. The time is in the format of hour:minute:second. |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
X-request-id |
String |
Request ID. Format: request_uuid-timestamp-hostname. |
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Response Example |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
X-request-id |
String |
Request ID. Format: request_uuid-timestamp-hostname. |
|
Parameter |
Type |
Description |
|---|---|---|
|
code |
String |
Definition Error code. Range N/A |
|
message |
String |
Definition Error description. Range N/A |
Example Requests
Request body for creating a report.
{
"layout_id" : "b240d19f-7bdb-39cd-bfc2-0d4b86d8747f",
"report_period" : "weekly",
"notification_task" : "b6940c3beee4413381be3f257ab6fb2d",
"language" : "zh-CN",
"report_name" : "q6YSAc1KBy",
"binding_wizard" : "{\"binding_buttons\":[],\"boa_version\":\"v4\",\"create_time\":\"2025-11-20T10:51:40Z+0800\",\"creator_id\":\"b40b54b1f27a4224aa0c95ede5b5a46a\",\"creator_name\":\"l00644738\",\"workspace_id\":\"75645d0a-93b8-4a7f-a77c-e97009389445\"}",
"report_range" : {
"start" : "1662900406226",
"end" : "1662900406226"
}
}
Example Responses
Status code: 200
Request succeeded.
"success"
SDK Sample Code
The SDK sample code is as follows.
Request body for creating a report.
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 |
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.secmaster.v1.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v1.*; import com.huaweicloud.sdk.secmaster.v1.model.*; public class CreateReportSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("<YOUR REGION>")) .build(); CreateReportRequest request = new CreateReportRequest(); request.withWorkspaceId("{workspace_id}"); CreateReportRequestBody body = new CreateReportRequestBody(); CreateReportRequestBodyReportRange reportRangebody = new CreateReportRequestBodyReportRange(); reportRangebody.withStart("1662900406226") .withEnd("1662900406226"); body.withBindingWizard("{"binding_buttons":[],"boa_version":"v4","create_time":"2025-11-20T10:51:40Z+0800","creator_id":"b40b54b1f27a4224aa0c95ede5b5a46a","creator_name":"l00644738","workspace_id":"75645d0a-93b8-4a7f-a77c-e97009389445"}"); body.withLayoutId("b240d19f-7bdb-39cd-bfc2-0d4b86d8747f"); body.withNotificationTask("b6940c3beee4413381be3f257ab6fb2d"); body.withLanguage("zh-CN"); body.withReportRange(reportRangebody); body.withReportPeriod(CreateReportRequestBody.ReportPeriodEnum.fromValue("weekly")); body.withReportName("q6YSAc1KBy"); request.withBody(body); try { CreateReportResponse response = client.createReport(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()); } } } |
Request body for creating a report.
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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v1.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v1 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateReportRequest() request.workspace_id = "{workspace_id}" reportRangebody = CreateReportRequestBodyReportRange( start="1662900406226", end="1662900406226" ) request.body = CreateReportRequestBody( binding_wizard="{"binding_buttons":[],"boa_version":"v4","create_time":"2025-11-20T10:51:40Z+0800","creator_id":"b40b54b1f27a4224aa0c95ede5b5a46a","creator_name":"l00644738","workspace_id":"75645d0a-93b8-4a7f-a77c-e97009389445"}", layout_id="b240d19f-7bdb-39cd-bfc2-0d4b86d8747f", notification_task="b6940c3beee4413381be3f257ab6fb2d", language="zh-CN", report_range=reportRangebody, report_period="weekly", report_name="q6YSAc1KBy" ) response = client.create_report(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Request body for creating a report.
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateReportRequest{} request.WorkspaceId = "{workspace_id}" reportRangebody := &model.CreateReportRequestBodyReportRange{ Start: "1662900406226", End: "1662900406226", } notificationTaskCreateReportRequestBody:= "b6940c3beee4413381be3f257ab6fb2d" request.Body = &model.CreateReportRequestBody{ BindingWizard: "{"binding_buttons":[],"boa_version":"v4","create_time":"2025-11-20T10:51:40Z+0800","creator_id":"b40b54b1f27a4224aa0c95ede5b5a46a","creator_name":"l00644738","workspace_id":"75645d0a-93b8-4a7f-a77c-e97009389445"}", LayoutId: "b240d19f-7bdb-39cd-bfc2-0d4b86d8747f", NotificationTask: ¬ificationTaskCreateReportRequestBody, Language: "zh-CN", ReportRange: reportRangebody, ReportPeriod: model.GetCreateReportRequestBodyReportPeriodEnum().WEEKLY, ReportName: "q6YSAc1KBy", } response, err := client.CreateReport(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 |
Request succeeded. |
|
400 |
Request failed. |
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