ロールの詳細の取得
最終更新日: 10 年 2023 月 XNUMX 日LogicMonitor REST API v3 を使用してロールの詳細を取得できます。 API リクエストを行う前に、自分自身を認証する必要があります。
ロールのリストの取得
次のクエリ パラメーターを含めて、応答に含めるデータの種類とその形式を制御できます。
URI: 取得 /setting/roles
説明 | ||
fields | 文字列 | 応答はフィルター処理され、各オブジェクトの指定されたフィールドのみが含まれます。 プロパティのリストをカンマで区切って指定できます。 例– /setting/roles?fields=name,privileges |
size | 整数 | 表示する結果の数を指定します。 GET 呼び出しでは最大 1000 件の結果を要求できます。 このパラメータに値が指定されていない場合、デフォルトでは 50 のロールのリストが返されます。 例– /setting/roles?size=5 |
offset | 整数 | 表示される結果をオフセットする結果の数を指定します。 例– /setting/roles?offset=2 |
filter | 文字列 | 応答は、演算子と指定された値に従ってフィルター処理されます。
演算子は次のとおりです。
例– /setting/roles?filter=name:administrator |
例
次のPythonスクリプトは、api.logicmonitor.comポータル内のすべてのロールのリストを返します。
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'
#Request Info
httpVerb ='GET'
resourcePath = '/setting/roles'
queryParams = ''
data = ''
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath +queryParams
#Get current time in milliseconds
epoch = str(int(time.time() * 1000))
#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath
#Construct signature digest = hmac.new(
AccessKey.encode('utf-8'),
msg=requestVars.encode('utf-8'),
digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
#Make request
response = requests.get(url, data=data, headers=headers)
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
例
次の Python スクリプトは、api.logicmonitor.com ポータル内のロールのリストを返します。 name
, associatedUserCount
、 privileges
結果ごとに返され、結果は次に従って降順で並べ替えられます。 associatedUserCount
.
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'
#Request Info
httpVerb ='GET'
resourcePath = '/setting/roles'
queryParams = '?fields=name,associatedUserCount,privileges&sort=-associatedUserCount'
data = ''
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath +queryParams
#Get current time in milliseconds
epoch = str(int(time.time() * 1000))
#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath
#Construct signature digest = hmac.new(
AccessKey.encode('utf-8'),
msg=requestVars.encode('utf-8'),
digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
#Make request
response = requests.get(url, data=data, headers=headers)
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
特定の役割の詳細の取得
URI: 取得 /setting/roles/{id}
説明 | ||
id | 整数 | (必須の) 詳細を取得するロールの ID。 |
fields | 文字列 | 応答はフィルター処理され、各オブジェクトの指定されたフィールドのみが含まれます。 プロパティのリストをカンマで区切って指定できます。 例– /setting/roles/{id}?fields=name,associatedUserCount |
次の Python スクリプトは、ID 8 のロールの詳細を返します。
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'
#Request Info
httpVerb ='GET'
resourcePath = '/setting/roles/8'
queryParams = ''
data = ''
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath +queryParams
#Get current time in milliseconds
epoch = str(int(time.time() * 1000))
#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath
#Construct signature digest = hmac.new(
AccessKey.encode('utf-8'),
msg=requestVars.encode('utf-8'),
digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
#Make request
response = requests.get(url, data=data, headers=headers)
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)