我正在使用亚马逊网络服务Boto3软件开发工具包进行一些自动化工作。我无法了解客户端(低级)和资源(高级)之间的区别
这里的低级(客户端)和高级(资源)有什么区别?
发布于 2018-05-07 17:17:14
根据我的理解,这里提到的是API编程中使用的低级和高级接口。它开始了,
high-level interface, are designed to enable the programmer to write code in shorter amount of time and to be less involved with the details of the software module or hardware device that is performing the required services. Which is in direct contrast with the other one.
low-level interface, are more detailed allowing the programmer to manipulate functions within a software module or within hardware at very granular level.在亚马逊网络服务中,当您使用Boto3进行API编程时,客户端提供与服务API一样紧密的低级接口。这意味着,所有服务操作都将由clients.Whereas支持,参考资料提供了一个高级别接口,这意味着与客户端提供的原始低级调用不同。
发布于 2022-01-14 16:37:50
检索现有存储桶列表
s3 = boto3.client("s3") response = s3.list_buckets()
输出存储桶名称
为响应‘buckets’中的bucket打印(“Existing buckets:"):print(f'{bucket"Name"}')
与客户端相比,
资源提供面向对象的接口,用于与各种AWS服务进行交互。资源可以按如下方式实例化:
# S3 bucket identifier
s3 = boto3.resource("s3")
bucket = s3.Bucket(name="my_bucket")总而言之,与客户端相比,资源是AWS服务的更高级别的抽象。资源是使用boto3的推荐模式,因为在与亚马逊网络服务交互时,您不必担心许多底层细节。因此,使用资源编写的代码往往更简单。
但是,并非所有AWS服务都提供资源。在这种情况下,除了使用客户端之外,没有其他选择。
https://stackoverflow.com/questions/50208090
复制相似问题