I have been working on a python script to retrieve security events from the Host Security Services(HSS) from Huawei Cloud. However, I have been getting error codes which is as below image. Referring the Huawei document, possibly could be Incorrect Access Key ID, Revoked or Expired Credentials, Region Mismatch, Incorrect Project ID.
However, I highly doubt it was because if the issues stated above as I have thoroughly verified the AK/SK values along with the project id. This action includes deleting and creating new AK/SK values.
Question 1: Could there be another issue causing this error.
Question 2: Is there another way around to achieve the same outcome which is to retrieve security events of HSS through API?
import json
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkhss.v5 import HssClient
from huaweicloudsdkhss.v5.region.hss_region import HssRegion
from huaweicloudsdkhss.v5.model.list_alarm_white_list_request import ListAlarmWhiteListRequest
from huaweicloudsdkhss.v5.model.list_security_events_request import ListSecurityEventsRequest
# Replace with your Huawei Cloud AK/SK and project information
ak = 'your_access_key'
sk = 'your_secret_key'
project_id = 'your_project_id'
region = HssRegion.MY_KUALALUMPUR_1 # e.g., 'cn-north-4'
endpoint = 'hss.my-kualalumpur-1.alphaedge.tmone.com.my'
# Initialize credentials and client
credentials = BasicCredentials(ak, sk, project_id)
client = HssClient.new_builder()
.with_credentials(credentials)
.with_region(HssRegion.MY_KUALALUMPUR_1)
.with_endpoint(endpoint)
.build()
# Create request object
request = ListSecurityEventsRequest()
try:
response = client.list_alarm_white_list(request)
print(json.dumps(response.to_dict(), indent=2))
except exceptions.ClientRequestException as e:
print(f"Exception: {e.status_code}, {e.request_id}, {e.error_msg}")
Click here to view the error message
Junior SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.