ユーザー詳細の更新
最終更新日: 07 年 2024 月 XNUMX 日LogicMonitor REST API v3 を使用してユーザーの詳細を更新できます。 API リクエストを行う前に、自分自身を認証する必要があります。
ユーザーに部分的な更新を行うには、 PATCH
リクエスト。ユーザーを完全に更新するには、 PUT
リクエストで詳細に指定された通りになります。
URI: パッチ /setting/admins{ID}
URI: 置く /setting/admins{ID}
ご注意:
- REST 標準に従って、PUT リクエストで指定されていないプロパティはデフォルト値に戻ります。
- パスワードを更新するには、リクエストでクエリ パラメータchangePassword=trueを設定します。
種類 | 説明 | |
id | 整数 | (必須の) 更新するユーザーの ID。 |
changePassword | ブーリアン | ユーザーのパスワードを変更するには、次のように設定します "changePassword": true 。 デフォルトでは、次のように設定されています false . |
lastName | String | ユーザーの姓。 例– "lastName": "Potter" |
note | String | ユーザーに関するメモを追加します。 例– "note": "Harry Potter has super admin role." |
viewPermission | JSONオブジェクト | この アカウント ユーザーに表示されるタブ。 例– { "Resources" : true, "Websites" : true, "Reports" : true, "Dashboards" : true, "Alerts" : true, "Settings" : true, "Maps" : true, "Logs" : true, "Traces" : true } |
timezone | String | ユーザーのタイムゾーン。 例– "timezone": "America/Los Angeles" |
roles | JSONオブジェクト | (必須の) ユーザーに割り当てられた役割。これには、ロールのアカウント権限が含まれます。アカウントの各領域のロールに権限を追加できます。ロールの名前、説明、およびグループ ID、このロールに 2 要素認証が必要な場合、ユーザーが EULA に同意する必要がある場合などは、ロールに指定されます。ユーザーに複数のロールが割り当てられている場合、ユーザーの権限は、割り当てられた各ロールの権限の合計となります。 たとえば、割り当てられた 1 つのロールがすべてのリソースに対して表示のみの権限を提供し、割り当てられた別のロールがすべてのリソースに対して管理権限を提供する場合、ユーザーはすべてのリソースに対して表示と管理の両方の権限を持ちます。さらに別の割り当てられたロールがすべてのダッシュボードに対する表示権限を提供するが、リソースに対する権限がない場合でも、ユーザーはすべてのリソースに対する管理権限を持ち、さらにすべてのダッシュボードに対する表示権限も持ちます。 |
smsEmailFormat | String | を示します sms or fullText フォーマット。 SMS の場合は 160 文字、フルテキストの場合はすべての文字が許可されます。 例– "smsEmailFormat": "sms" |
apionly | ブーリアン | ユーザーが API 専用ユーザーかどうかを示します。 例– "apionly": true API のみのユーザーは、LogicMonitor REST API にのみアクセスできます。これらに関連するフィールドは、ユーザー名、API トークン、ロール、ステータス、メモのみです。パスワードやその他のユーザー インターフェイス固有のフィールドがないため、API ベースの統合の専用ユーザーとしてより安全になります。 |
apiTokens | JSONオブジェクト | ユーザーの API トークン。の apiTokens で構成されてい
"apiTokens": [ { "note": "Harry Potter's API Token", "status": 2 } ], |
adminGroupIds | 整数 | 管理者がいるグループのグループ ID。複数のグループ ID はカンマで区切られます。 例– "adminGroupIds": 1,2,3 |
password | String | (必須の) ユーザーのパスワード。 例– "password": "hPo131" |
email | String | (必須の) ユーザーの電子メール アドレス。 例– "email": "[email protected]" |
contactMethod | String | ユーザーに連絡する方法。サポートされている連絡方法は次のとおりです。 email と smsemail . 例– "contactMethod": "email" |
smsEmail | String | ユーザーのSMS電子メールアドレス。 例– "smsEmail": [email protected] |
twoFAEnabled | ブーリアン | ユーザーに対して 2 要素認証が有効かどうかを示します。 例– "twoFAEnabled": true |
firstName | String | ユーザーの名。 例– "firstName": "Harry" |
phone | String | ユーザーの電話番号。 例– "phone": "9091929394" |
createdBy | String | ユーザーを作成したユーザーの詳細。別のユーザー、SAML、または LogicMonitor である可能性があります。 例– "createdBy": "Chief Admin" |
forcePasswordChange | ブーリアン | 次回のログイン時にユーザーにパスワードの変更を強制するかどうかを示します。 例– "forcePasswordChange": false |
acceptEULA | ブーリアン | ユーザーがエンドユーザー使用許諾契約 (EULA) に同意する必要があるかどうかを示します。 例– "acceptEULA": false |
username | String | (必須の) ユーザーのユーザー名。 例– "username": "Harry" |
status | String | ユーザーのステータス。サポートされている値は次のとおりです。 active と suspended . 例– "status": "active" |
次の Python スクリプトは、ユーザーのパスワードを含むユーザー Sara を更新します (したがって、 changePassword=true
リクエスト内) アカウント 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: ")
UserPassword = getpass.getpass("Enter password for user : ")
Company = 'apiAccount'
#Request Info
httpVerb ='PUT'
resourcePath = '/setting/admins/147'
queryParams ='?changePassword=true'
data = '{"roles":[{"name":"administrator"}],"email":"[email protected]","username":"sara","password":"%s","status":"active"} % (UserPassword)'
#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.put(url, data=data, headers=headers)
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)