1
設置權限的一個特定的ID,我會自動工作創造的Nexus OSS私有倉庫。 現在,我正在考慮使用curl
這樣做。 在這裏,我想創建中的Nexus API
- 2個私有倉庫(快照,版本)
- 權限的每個倉庫(創建,讀取,更新,刪除)
- 角色添加權限的用
- 用戶角色集
我目前在向角色添加權限時遇到問題,因爲生成的權限ID看起來像一些隨機ID。
curl -s --user <user>:<password> -X POST -H 'Accept: application/json' -H 'Content-Type: application/json'\
-d '{"data":{"name":"<repo-name>-release","description":"<repo-name>-release","type":"target","repositoryTargetId":"any","repositoryId":"<repo-name>-release","repositoryGroupId":"","method":["create","read","update","delete"]}}'\
https://<my-nexus-server>/nexus/service/local/privileges_target
它返回
{"data":[{"id":"19de4d5c87506","resourceURI":"https://<my-nexus-server>/nexus/service/local/privileges_target/19de4d5c87506","name":"<repo-name>-release - (create)","description":"<repo-name>-release","type":"target","userManaged":true,"properties":[{"key":"repositoryTargetId","value":"any"},{"key":"method","value":"create,read"},{"key":"repositoryId","value":"<repo-name>-release"},{"key":"repositoryGroupId","value":""}]},{"id":"19de4d638eafd","resourceURI":"https://<my-nexus-server>/nexus/service/local/privileges_target/19de4d638eafd","name":"123-release - (read)","description":"<repo-name>-release","type":"target","userManaged":true,"properties":[{"key":"repositoryTargetId","value":"any"},{"key":"method","value":"read"},{"key":"repositoryId","value":"<repo-name>-release"},{"key":"repositoryGroupId","value":""}]},{"id":"19de4d6c197e0","resourceURI":"https://<my-nexus-server>/nexus/service/local/privileges_target/19de4d6c197e0","name":"<repo-name>-release - (update)","description":"<repo-name>-release","type":"target","userManaged":true,"properties":[{"key":"repositoryTargetId","value":"any"},{"key":"method","value":"update,read"},{"key":"repositoryId","value":"<repo-name>-release"},{"key":"repositoryGroupId","value":""}]},{"id":"19de4d756fde5","resourceURI":"https://<my-nexus-server>/nexus/service/local/privileges_target/19de4d756fde5","name":"<repo-name>-release - (delete)","description":"<repo-name>-release","type":"target","userManaged":true,"properties":[{"key":"repositoryTargetId","value":"any"},{"key":"method","value":"delete,read"},{"key":"repositoryId","value":"<repo-name>-release"},{"key":"repositoryGroupId","value":""}]}]}
我想這些生成的權限的添加到角色。
有沒有辦法來
- 產生通過REST API權限的時候設置ID?
或
- 添加這些生成的權限的(具有隨機ID)的一個作用?
無法設置這些ID,您需要在創建權限後解析結果並在下次調用中使用生成的ID。 – rseddon
@rseddon謝謝你的回覆。我想我會停止懶惰,並寫一點腳本來解析它們。 –