Help Center/ Host Security Service/ API Reference/ API Description/ Ransomware Prevention/ Querying the Servers Protected Against Ransomware
Updated on 2025-08-15 GMT+08:00

Querying the Servers Protected Against Ransomware

Function

This API is used to query the list of servers protected against ransomware. This API needs to be used together with Cloud Backup and Recovery (CBR). Ensure the site has CBR before using ransomware-related APIs.

Calling Method

For details, see Calling APIs.

URI

GET /v5/{project_id}/ransomware/server

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID, which is used to specify the project that an asset belongs to. After the project ID is configured, you can query assets in the project using the project ID. For details about how to obtain it, see Obtaining a Project ID.

Constraints

N/A

Range

The value contains 1 to 256 characters.

Default Value

N/A

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

Definition

Enterprise project ID, which is used to filter assets in different enterprise projects. For details, see Obtaining an Enterprise Project ID.

To query assets in all enterprise projects, set this parameter to all_granted_eps.

Constraints

You need to set this parameter only after the enterprise project function is enabled.

Range

The value can contain 1 to 256 characters.

Default Value

0: default enterprise project.

offset

No

Integer

Definition

Start position of the record to be returned.

Constraints

N/A

Range

The value range is 0 to 2,000,000.

Default Value

0

limit

No

Integer

Definition

Number of records displayed on each page.

Constraints

N/A

Range

Value range: 10 to 200

Default Value

10

host_name

No

String

Definition

Server name.

Constraints

N/A

Range

The value can contain 1 to 256 characters.

Default Value

N/A

os_type

No

String

Definition

OS type.

Constraints

N/A

Range

The options are as follows:

  • Linux

  • Windows

You can enter 0 to 64 characters.

Default Value

N/A

host_ip

No

String

Definition

Server IP address.

Constraints

N/A

Range

The value contains 0 to 256 characters.

Default Value

N/A

host_status

No

String

Definition

Server status.

Constraints

N/A

Range

The options are as follows:

  • If no parameter is transferred, it indicates all items.

  • ACTIVE: running

  • SHUTOFF: shut down

Default Value

N/A

last_days

No

Integer

Definition

Query time range (days).

Constraints

N/A

Range

The value can contain 1 to 30 characters. If this parameter is left blank, the service queries the protection events and existing backups within the last day by default.

Default Value

N/A

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token, which contains user identity and permissions. The token can be used for identity authentication when an API is called. For details about how to obtain the token, see Obtaining a User Token.

Constraints

N/A

Range

The value can contain 1 to 32,768 characters.

Default Value

N/A

region

No

String

Definition

Region ID, which is used to query assets in the required region. For details about how to obtain a region ID, see Obtaining a Region ID.

Constraints

N/A

Range

The value can contain 0 to 128 characters.

Default Value

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

total_num

Integer

Definition

Total number.

Range

Value range: 0 to 65,535

data_list

Array of ProtectionServerInfo objects

Definition

Query the list of servers protected against ransomware.

Range

Value range: 0 to 65,535 ProtectionServerInfo objects

Table 5 ProtectionServerInfo

Parameter

Type

Description

project_id

String

Definition

Project ID.

Range

The value can contain 0 to 128 characters.

enterprise_project_id

String

Definition

Enterprise project ID.

Range

The value can contain 0 to 128 characters.

host_id

String

Definition

Server ID.

Range

The value can contain 0 to 128 characters.

agent_id

String

Definition

Agent ID

Range

The value can contain 0 to 128 characters.

host_name

String

Definition

Server name.

Range

The value can contain 0 to 128 characters.

host_ip

String

Definition

EIP.

Range

The value can contain 0 to 128 characters.

private_ip

String

Definition

Private IP address.

Range

The value can contain 0 to 128 characters.

os_type

String

Definition

OS type.

Range

The options are as follows:

  • Linux

  • Windows

os_name

String

Definition

System name.

Range

The value can contain 0 to 128 characters.

host_status

String

Definition

Server status.

Range

The options are as follows:

  • ACTIVE: running

  • SHUTOFF: shut down

ransom_protection_status

String

Definition

Ransomware prevention status.

Range

The options are as follows:

  • closed: protection disabled

  • opened: protected

  • opening: being enabled

  • closing: being disabled

  • protect_failed: protection failed

  • protect_degraded: protection degraded

ransom_protection_fail_reason

String

Definition

Ransomware protection failure cause.

Range

The options are as follows:

  • driver_load_failed: Driver loading failed.

  • protect_interrupted: Protection interrupted.

  • decoy_deploy_totally_failed: All honeypots failed to be deployed.

  • decoy_deploy_partially_failed: Some honeypots failed to be deployed.

failed_decoy_dir

String

Definition

Directory where honeypot protection failed. (This parameter has a value only if certain honeypots failed to be deployed.)

Range

The value can contain 0 to 512 characters.

agent_version

String

Definition

Agent version.

Range

The value can contain 1 to 128 characters.

protect_status

String

Definition

Protection status.

Range

The options are as follows:

  • closed: not protected

  • opened: protected

group_id

String

Definition

Server group ID.

Range

The value can contain 1 to 128 characters.

group_name

String

Definition

Server group name.

Range

The value can contain 1 to 128 characters.

protect_policy_id

String

Definition

Protection policy ID.

Range

The value can contain 1 to 128 characters.

protect_policy_name

String

Definition

Protection policy name.

Range

The value can contain 1 to 128 characters.

backup_error

backup_error object

Backup error message

backup_protection_status

String

Definition

Whether to enable backup.

Range

The options are as follows:

  • failed_to_turn_on_backup: Backup cannot be enabled.

  • closed

  • opened

count_protect_event

Integer

Definition

Number of protection events.

Range

Value range: 0 to 2,097,152

count_backuped

Integer

Definition

Number of existing backups.

Range

Value range: 0 to 2,097,152

agent_status

String

Definition

Agent status.

Range

The value can contain 1 to 128 characters.

version

String

Definition

Enabled HSS edition.

Range

The options are as follows:

  • hss.version.null: none

  • hss.version.basic: basic edition

  • hss.version.advanced: professional edition

  • hss.version.enterprise: enterprise edition

  • hss.version.premium: premium edition

  • hss.version.wtp: WTP edition

  • hss.version.container.enterprise: container edition

host_source

String

Definition

Server type.

Range

The options are as follows:

  • ecs: ECS

  • outside: on-premises server

  • workspace: cloud desktop

vault_id

String

Definition

Vault ID.

Range

The value can contain 0 to 128 characters.

vault_name

String

Definition

Vault name.

Range

The value can contain 0 to 128 characters.

vault_size

Integer

Definition

Total capacity, in GB

Range

Value range: 0 to 2,097,152

vault_used

Integer

Definition

Used capacity, in MB.

Range

Value range: 0 to 2,097,152

vault_allocated

Integer

Definition

Allocated bound server capacity, in GB.

Range

Value range: 0 to 2,097,152

vault_charging_mode

String

Definition

Vault creation mode.

Range

The options are as follows:

  • post_paid: pay-per-use

  • pre_paid: yearly/monthly

vault_status

String

Definition

Vault status.

Range

The options are as follows:

  • available

  • lock

  • frozen

  • deleting

  • error

backup_policy_id

String

Definition

Backup policy ID. If this parameter is left blank, the backup policy is not bound. If this parameter has a value, check whether the backup policy is enabled based on the backup_policy_enabled field.

Range

The value can contain 1 to 128 characters.

backup_policy_name

String

Definition

Backup policy name.

Range

The value can contain 1 to 128 characters.

backup_policy_enabled

Boolean

Definition

Whether the policy is enabled.

Range

The options are as follows:

  • true: The policy is enabled.

  • false: The policy is disabled.

resources_num

Integer

Definition

Number of bound servers.

Range

Value range: 0 to 2,097,152

Table 6 backup_error

Parameter

Type

Description

error_code

Integer

Definition

Error code.

Range

The options are as follows:

  • 0: No error information.

  • 1: Backup cannot be enabled because another vault has been bound.

  • 2: The number of backup vaults exceeds the upper limit.

  • 3: An exception occurs when the CBR API is called.

error_description

String

Definition

Error message.

Range

The value can contain 1 to 128 characters.

Example Requests

Query the list of ransomware protection servers. If the limit parameter is not set, 10 records are returned by default.

GET https://{endpoint}/v5/{project_id}/ransomware/server

Example Responses

Status code: 200

Request succeeded.

{
  "total_num" : 1,
  "data_list" : [ {
    "agent_id" : "2758d2a61598fd9144cfa6b201049e7c0af8c3f1280cd24e3ec95a2f0811a2a2",
    "agent_status" : "online",
    "backup_error" : {
      "error_code" : 1,
      "error_description" : "Backup cannot be enabled because another vault has been bound."
    },
    "ransom_protection_status" : "opened",
    "backup_protection_status" : "failed_to_turn_on_backup",
    "count_backuped" : 0,
    "count_protect_event" : 0,
    "group_id" : "7c659ea3-006f-4687-9f1c-6d975d955f37",
    "group_name" : "333",
    "host_id" : "caa958ad-a481-4d46-b51e-6861b8864515",
    "host_ip" : "100.85.119.68",
    "host_name" : "Euler",
    "host_status" : "ACTIVE",
    "os_name" : "EulerOS",
    "os_type" : "Linux",
    "private_ip" : "100.85.123.9",
    "protect_policy_id" : "0253edfd-30e7-439d-8f3f-17c54c99706",
    "protect_policy_name" : "tst",
    "protect_status" : "opened"
  } ]
}

SDK Sample Code

The SDK sample code is as follows.

 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
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.hss.v5.region.HssRegion;
import com.huaweicloud.sdk.hss.v5.*;
import com.huaweicloud.sdk.hss.v5.model.*;


public class ListProtectionServerSolution {

    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);

        HssClient client = HssClient.newBuilder()
                .withCredential(auth)
                .withRegion(HssRegion.valueOf("<YOUR REGION>"))
                .build();
        ListProtectionServerRequest request = new ListProtectionServerRequest();
        try {
            ListProtectionServerResponse response = client.listProtectionServer(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());
        }
    }
}
 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkhss.v5.region.hss_region import HssRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkhss.v5 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 = HssClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(HssRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListProtectionServerRequest()
        response = client.list_protection_server(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    hss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/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 := hss.NewHssClient(
        hss.HssClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListProtectionServerRequest{}
	response, err := client.ListProtectionServer(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.

Error Codes

See Error Codes.