ロールの詳細の取得

最終更新日: 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文字列応答は、演算子と指定された値に従ってフィルター処理されます。
  • 複数の文字と一致するにはアスタリスク (*) を使用します
  • オブジェクト内の値をフィルターするには、ドット (.) 文字を使用します (例 – custom properties)
  • 複数のフィルターを区切るにはカンマ (,) を使用します。

演算子は次のとおりです。
  • 以上: >:
  • 以下: <:
  • 大なり記号: >
  • 未満: <
  • 等しい: :
  • 等しくない: !:
  • 以下の構成です: ~
  • 含まれていません: !~

例– /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の3

次の Python スクリプトは、api.logicmonitor.com ポータル内のロールのリストを返します。 nameassociatedUserCountprivileges 結果ごとに返され、結果は次に従って降順で並べ替えられます。 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)
Pythonの3

特定の役割の詳細の取得

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)
Pythonの3
記事上で