4.2. Satellite 6 API 提示


本节提供了一些常规提示,以帮助使用 Satellite 6 API 优化您的体验。

浏览 Satellite 6 API

如果您已经登录到 Satellite 6 web UI,您可以在 /api/v2/<API-NAME> 中看到 GET 请求的默认结果。例如:

在命令行中使用 Satellite 6 API 请求

您可以使用 curl 命令来与 Satellite 6 API 交互。例如:

例 4.1. GET 请求示例

列出 Satellite 6 中机构、主机和用户的 GET 请求示例。

# SATUSER=admin
# SATPASS='changeme'
# SATURL="https://localhost"

# curl -k -u $SATUSER:$SATPASS -X GET -H \
'Accept: application/json' $SATURL/api/v2/organizations | json_reformat
# curl -k -u $SATUSER:$SATPASS -X GET -H \
'Accept: application/json' $SATURL/api/v2/hosts | json_reformat
# curl -k -u $SATUSER:$SATPASS -X GET -H \
'Accept: application/json' $SATURL/api/v2/users | json_reformat
# curl -k -u $SATUSER:$SATPASS -X GET -H \
'Accept: application/json' $SATURL/api/v2/users/3 | json_reformat
Copy to Clipboard Toggle word wrap

例 4.2. DELETE 请求示例

基于之前用户列表删除已知 ID 为"9"的现有用户的 DELETE 请求示例。

# curl -k -u $SATUSER:$SATPASS -X DELETE -H \
'Accept: application/json' $SATURL/api/v2/users/9 | json_reformat
Copy to Clipboard Toggle word wrap

例 4.3. POST 请求示例

用于创建名为 example 的新用户的 POST 请求 示例,传递 true 标志来为用户启用管理员特权。

# curl -k -u $SATUSER:$SATPASS -X POST \
-d '{ "mail": "root@localhost", "firstname": "Example", \
"lastname": "User", "login": "example", "password": "redhat", \
"admin": 'true', "auth_source_id": 1 }' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
$SATURL/api/v2/users | json_reformat
Copy to Clipboard Toggle word wrap

例 4.4. PUT 请求示例

将已知 ID 为 "10" 的现有 示例 用户的电子邮件地址的 PUT 请求示例为 example@localhost

# curl -k -u $SATUSER:$SATPASS -X PUT \
-d '{ "id": 10, "mail": "example@localhost" }' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
$SATURL/api/v2/users/10 | json_reformat
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat