ユーザー詳細の取得
最終更新日: 07 年 2024 月 XNUMX 日LogicMonitor REST API v3 を使用してユーザーの詳細を取得できます。 API リクエストを行う前に、自分自身を認証する必要があります。
ユーザーのリストの取得
デフォルトでは、50 人のユーザーのリストが返されます。次のクエリ パラメーターを含めて、応答に含めるデータの種類とその形式を制御できます。
ご注意: クエリ パラメーターはリソース パスの一部ではないため、LMv1 認証署名の計算中に含めるべきではありません。
URI: 取得 /setting/admins
種類 | 説明 | |
type | String | このクエリ パラメーターは、ベアラー トークンを使用してユーザーをフィルターするために使用されます。 例– url/setting/admins?type=bearer |
permission | String | このクエリ パラメータは、トレース権限を持つユーザーをフィルタリングするために使用されます。 例– url/setting/admins?permission=traces |
filterGroupString | String | このパラメーターは、次のフィルター値を複数のフィールドと照合するために使用されます。 * 管理者の名 * 管理者の姓 * 管理者のユーザー名 * 管理者に割り当てられた roleName * 管理者グループ名 * 管理者のステータス 例えば - url/setting/admins?filterGroupString=John ここでの値は、 John 上記のすべてのフィールドと照合されます。 |
fields | String | 応答はフィルター処理され、各オブジェクトの指定されたフィールドのみが含まれます。 プロパティのリストをカンマで区切って指定できます。 例– /setting/admins?fields=id,username |
size | 整数 | 表示する結果の数。 GET 呼び出しでは最大 1000 件の結果を要求できます。このパラメータに値が指定されていない場合、デフォルトでは 50 人のユーザーのリストが返されます。 例– /setting/admins?size=30 |
offset | 整数 | 表示された結果をオフセットする結果の数。 例– /setting/admins?offset=20 |
filter | String | 応答は、演算子と指定された値に従ってフィルタリングされます。 filter=property:value
|
次の 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/admins'
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)
特定のユーザーの詳細を取得する
URI: 取得 /setting/admins{ID}
種類 | 説明 | |
id | 整数 | (必須の) 詳細を取得するユーザーの ID。 |
fields | String | 応答はフィルター処理され、各オブジェクトの指定されたフィールドのみが含まれます。 プロパティのリストをカンマで区切って指定できます。 例– /setting/admins/id?fields=username,role |
次の Python スクリプトは、アカウント api.logicmonitor.com のユーザー 32 に関する情報を取得します。
#!/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/admins/32'
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)