boto3的API文档在哪里?

时间:2017-05-16 18:06:53

标签: python amazon-web-services boto3

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

这可能看起来很迂腐 - 我可能会对每个资源或客户端的名称做出合理的猜测 - 但是在哪里我找到了可用资源的列表?除非我遗漏了某些内容,否则它似乎不在用户指南中。而且我没有在任何地方找到更详细的API参考。

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

这让我觉得我唯一的选择就是检查REPL上的对象是否有合理的方法名称。

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

1 个答案:

答案 0 :(得分:2)

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文件也很容易识别相同的信息。