python - boto3 的 API 文档在哪里?

标签 python amazon-web-services boto3

user guide对于 boto3指高级别资源和低级别客户端。通过将服务名称分别传递给 boto3.resourceboto3.client 来访问它们。

这可能看起来有点迂腐 - 我可能可以对每个资源或客户端的名称做出合理的猜测 - 但是在哪里我可以找到可用资源的列表?除非我错过了什么,否则它似乎不会出现在用户指南中。而且我在任何地方都找不到更详细的 API 引用。

一旦我有了资源(例如 EC2),我在哪里可以找到关于我可以用它做什么的文档?有一些例子here in the user guide ,但它们似乎是一个子集。

这让我感觉我唯一的选择就是检查 REPL 上的对象以获取看似合理的方法名称。

我在这里遗漏了什么吗?人们实际上如何使用这个库?

最佳答案

API 文档在这里:

https://boto3.readthedocs.io/en/stable/index.html

可用资源是动态生成的。如果您只是尝试创建一个伪造的资源,您应该能够在错误消息中看到哪些顶级资源当前可用:

>>> boto3.resource('potato')
ResourceNotExistsError: The 'potato' resource does not exist.
The available resources are:
   - cloudformation
   - cloudwatch
   - dynamodb
   - ec2
   - glacier
   - iam
   - opsworks
   - s3
   - sns
   - sqs

>>> boto3.client('bogus')
UnknownServiceError: Unknown service: 'bogus'. Valid service names are: acm, apigateway, application-autoscaling, appstream, autoscaling, batch, budgets, clouddirectory, cloudformation, cloudfront, cloudhsm, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, codebuild, codecommit, codedeploy, codepipeline, codestar, cognito-identity, cognito-idp, cognito-sync, config, cur, datapipeline, devicefarm, directconnect, discovery, dms, ds, dynamodb, dynamodbstreams, ec2, ecr, ecs, efs, elasticache, elasticbeanstalk, elastictranscoder, elb, elbv2, emr, es, events, firehose, gamelift, glacier, health, iam, importexport, inspector, iot, iot-data, kinesis, kinesisanalytics, kms, lambda, lex-models, lex-runtime, lightsail, logs, machinelearning, marketplacecommerceanalytics, meteringmarketplace, mturk, opsworks, opsworkscm, organizations, pinpoint, polly, rds, redshift, rekognition, resourcegroupstaggingapi, route53, route53domains, s3, sdb, servicecatalog, ses, shield, sms, snowball, sns, sqs, ssm, stepfunctions, storagegateway, sts, support, swf, waf, waf-regional, workdocs, workspaces, xray

您实际上可以对客户端执行的操作也是 generated dynamically, from json files 。例如,这里是 Amazon Glacier 的服务描述。

客户端还可以使用以下方法告诉您可用的子资源:

>>> glacier = boto3.resource('glacier')
>>> glacier.get_available_subresources()
['Account', 'Archive', 'Job', 'MultipartUpload', 'Notification', 'Vault']

例如,实例化glacier.Archive()所需的参数为 clearly documented 。这些文档非常好,但通过阅读 service description 也很容易辨别出相同的信息。直接文件。

关于python - boto3 的 API 文档在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44008633/

相关文章:

python - 将字符串中的单个单词与字典键匹配

amazon-web-services - 设置一个aws账户拥有的s3对另一个aws账户拥有的firehose流的写访问权限

ios - iOS AWS SDK Cloudfront图像下载和视频流

amazon-web-services - 现在有办法在 boto3 中获取 "AWS region names"吗?

python - findall 内的正则表达式 vs 计数内的正则表达式

python - SQLAlchemy 告诉我 "AttributeError: type object ' User' 没有属性 'columns' "

Python 指数衰减 curve_fit 给我一个线性拟合

amazon-web-services - 如何获取AWS中IAM角色的ARN值

python-3.x - 使用 boto3 使用 create_hit 和 externalQuestion 创建的 HIT,在请求者的帐户中不可见

amazon-web-services - boto3 找不到配置文件