Home > Storage > PowerFlex > White Papers > PowerFlex REST API Introduction > Get compliance report
This use case prints the compliance report for a specified deployment. This example uses PowerFlex Manager 3.x, which uses three custom headers for authentication.
Custom headers
Authentication process:
import datetime
import hmac
import hashlib
import requests
import base64
import time
import sys
import getpass
# PFxM credentials
Usr = "admin"
Pwd = "password123"
Domain = "VXLOCAL"
# PFxM IP address
srv: str = "172.128.30.30"
loginUri = "https://{}/Api/V1/Authenticate".format(Srv)
# print("loginUri is: {}".format(loginUri))
hdr = {'content-type': 'application/json',
'Accept': 'application/json'}
Conn = requests.Session()
Conn.headers = hdr
Conn.verify = False
authCred = {
"username": Usr,
"domain": Domain,
"password": Pwd
}
# for item in authCred.items():
# print(item)
rAuth = Conn.post(loginUri, json=authCred)
# print(rAuth.text)
AuthJson = rAuth.json()
# for item in AuthJson:
# print(item)
fmApiKey = str.format(AuthJson.get('apiKey'))
fmApiKeyEnc = fmApiKey.encode()
print("the api key is : {}".format(fmApiKey))
# print(type(fmApiKey))
# print("the api keyenc is : {}".format(fmApiKeyEnc))
fmApiSecret = str.format(AuthJson.get('apiSecret'))
fmApiSecretEnc = fmApiSecret.encode()
print("the api secret is : {}".format(fmApiSecret))
# print(type(fmApiSecret))
# print("the api secret enc is : {}".format(fmApiSecretEnc))
timerightnow = str(int(datetime.datetime.now().timestamp()))
print("the time is : {}".format(timerightnow))
# print(type(timerightnow))
# uAgent = "PostmanRuntime/7.28.2"
uAgent = "My User Agent 1.0"
print("user agent is : {}".format(uAgent))
deployURI = "https://{}/Api/V1/Deployment/2c9e649e78d6b7c00178e2a59ff63f9a/firmware/compliancereport".format(Srv)
print("the uri is : {}".format(deployURI))
deployURIpath = "/Api/V1/Deployment/2c9e649e78d6b7c00178e2a59ff63f9a/firmware/compliancereport"
print("the uri path is : {}".format(deployURIpath))
reqString = fmApiKey + ":" + "GET" + ":" + deployURIpath + ":" + uAgent + ":" + timerightnow
reqStringEnc = reqString.encode()
print("reqString is : {}".format(reqString))
# print(type(reqString))
reqHeadHash = hmac.digest(fmApiSecretEnc, reqStringEnc, hashlib.sha256)
# print(type(reqHeadHash))
# print("the digest is : {}".format(reqHeadHash))
reqHeadHashb64 = base64.b64encode(reqHeadHash)
print("the base 64 encoded value is : {}".format(reqHeadHashb64))
reqHeaderNow = {
'content-type': 'application/json',
'Accept': 'application/json',
'User-Agent': uAgent,
'x-dell-auth-key': fmApiKey,
'x-dell-auth-signature': reqHeadHashb64,
'x-dell-auth-timestamp': timerightnow
}
Conn.headers = reqHeaderNow
rDeployments = Conn.get(deployURI)
print("status is : {}".format(rDeployments.status_code))
print(rDeployments.text)