Where is the API documentation for boto3 resources?

≡放荡痞女 提交于 2019-12-21 17:22:55

问题


I have learned that boto3 offers two levels of abstraction: a low-level API called client that is a thin wrapper around the AWS HTTP API, and a high-level client called resource that offers real Python objects. My question is, where is the API documentation for the resource API?

I found this:

https://boto3.readthedocs.io/en/stable/reference/services/ec2.html#client

But that describes the client API, and there's not a 1-to-1 mapping to the resource API. For example, enumerating instances is called describe_instances() on the client object, and it is called instances.all() on the resource object.

Next I found this:

http://boto3.readthedocs.io/en/stable/reference/core/resources.html?highlight=resource

This describes a set of base classes and factory methods, but it doesn't describe the API for a specific service like EC2.

At runtime, I printed out an object of interest and found that it is a boto3.resources.factory.ec2.ServiceResource, but searching the boto3 documentation doesn't show me any human-readable documentation for this resource.

Is there an API document that explains what all of the different Python classes are, and what properties/methods they have? I can print this out at runtime, e.g. print(dir(ec2)) but this is a pretty tedious way to discover the API.


回答1:


Thanks @jordanm for answering in the comments. I'm expanding into a more detailed answer.

The client documentation contains a section called "Service Resource" that I had not noticed before.

Highlighted the service resource in the table of contents:

Clicking this heading shows me the methods and properties of an EC2 resource instance.




回答2:


Hope this answer is useful to some even though its late.

Use these two links accordingly

Consider the 1st one as the Main reference. This is the link provided in the other answer https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#service-resource

Main reference

The 2nd one provides a more detailed view on the methods and attributes available for a particular resource like instance,image,VPC etc

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html

^this is almost the same link -- all options below the service-resource provide detailed info on that particular resource such as instance,image etc.,

common resources



来源:https://stackoverflow.com/questions/49177491/where-is-the-api-documentation-for-boto3-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!