Reputation: 1708
The user guide for boto3 refers high-level Resources and low-level clients. They are accessed by passing the name of the service to boto3.resource
and boto3.client
, respectively.
This might seem kind of pedantic - I could probably make reasonable guesses as to the names of each resource or client - but where do I find a list of available resources? Unless I missed something, it doesn't appear to be in the User Guide. And I'm not finding a more detailed API reference anywhere.
Once I do have a resource (like EC2) - where do I find documentation on what I can do with it? There are some examples here in the user guide, but they appear to be a subset.
This leaves me feeling like my only option is to inspect objects on the REPL for plausible looking method names.
Am I missing something here? How do people actually use this library?
Upvotes: 3
Views: 3291
Reputation: 362836
The API documentation is here:
https://boto3.readthedocs.io/en/stable/index.html
Available resources are generated dynamically. If you just try to create a bogus one, you should be able to see which top-level resources are currently available in the error message:
>>> 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
What you can actually do with a client is also generated dynamically, from json files. For example here is the service description for Amazon Glacier.
A client can also tell you the available subresources, using this method:
>>> glacier = boto3.resource('glacier')
>>> glacier.get_available_subresources()
['Account', 'Archive', 'Job', 'MultipartUpload', 'Notification', 'Vault']
The parameters necessary to instantiate a glacier.Archive()
, for example, are clearly documented. The docs are quite good, but it is also pretty easy to discern the same information from reading the service description files directly.
Upvotes: 2