3.7. 在集合中更新资源
要更新资源,您必须从它所在的集合中检索它,修改所需的参数,然后调用资源的
update
方法来保存更改。参数修改通过使用检索到的资源的 set_*
方法执行。
例 3.7. 更新资源
在本例中,名为
DemoDataCenter
的数据中心已更新其描述。
dc = api.datacenters.get("DemoDataCenter") dc.set_description("This data center description provided using the Python SDK") dc.update()
dc = api.datacenters.get("DemoDataCenter")
dc.set_description("This data center description provided using the Python SDK")
dc.update()