├── .travis.yml ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── LICENSE ├── README.md ├── UPGRADING.md ├── acceptance ├── README.md ├── openstack │ ├── blockstorage │ │ ├── v1 │ │ │ ├── pkg.go │ │ │ ├── snapshots_test.go │ │ │ ├── volumes_test.go │ │ │ └── volumetypes_test.go │ │ └── v2 │ │ │ ├── extensions │ │ │ ├── pkg.go │ │ │ └── volumeactions_test.go │ │ │ ├── pkg.go │ │ │ └── volumes_test.go │ ├── client_test.go │ ├── compute │ │ └── v2 │ │ │ ├── bootfromvolume_test.go │ │ │ ├── compute_test.go │ │ │ ├── extension_test.go │ │ │ ├── flavors_test.go │ │ │ ├── floatingip_test.go │ │ │ ├── images_test.go │ │ │ ├── keypairs_test.go │ │ │ ├── network_test.go │ │ │ ├── pkg.go │ │ │ ├── quotaset_test.go │ │ │ ├── secdefrules_test.go │ │ │ ├── secgroup_test.go │ │ │ ├── servergroup_test.go │ │ │ ├── servers_test.go │ │ │ ├── tenantnetworks_test.go │ │ │ └── volumeattach_test.go │ ├── db │ │ └── v1 │ │ │ ├── common.go │ │ │ ├── database_test.go │ │ │ ├── flavor_test.go │ │ │ ├── instance_test.go │ │ │ ├── pkg.go │ │ │ └── user_test.go │ ├── identity │ │ ├── v2 │ │ │ ├── extension_test.go │ │ │ ├── identity_test.go │ │ │ ├── pkg.go │ │ │ ├── role_test.go │ │ │ ├── tenant_test.go │ │ │ ├── token_test.go │ │ │ └── user_test.go │ │ └── v3 │ │ │ ├── endpoint_test.go │ │ │ ├── identity_test.go │ │ │ ├── pkg.go │ │ │ ├── service_test.go │ │ │ └── token_test.go │ ├── imageservice │ │ └── v2 │ │ │ ├── README.md │ │ │ ├── common.go │ │ │ ├── imageservice_test.go │ │ │ ├── members_test.go │ │ │ └── pkg.go │ ├── networking │ │ └── v2 │ │ │ ├── apiversion_test.go │ │ │ ├── common.go │ │ │ ├── extension_test.go │ │ │ ├── extensions │ │ │ ├── fwaas │ │ │ │ ├── firewall_test.go │ │ │ │ ├── pkg.go │ │ │ │ ├── policy_test.go │ │ │ │ └── rule_test.go │ │ │ ├── layer3_test.go │ │ │ ├── lbaas │ │ │ │ ├── common.go │ │ │ │ ├── member_test.go │ │ │ │ ├── monitor_test.go │ │ │ │ ├── pkg.go │ │ │ │ ├── pool_test.go │ │ │ │ └── vip_test.go │ │ │ ├── lbaas_v2 │ │ │ │ ├── loadbalancer_test.go │ │ │ │ └── pkg.go │ │ │ ├── pkg.go │ │ │ ├── portsbinding │ │ │ │ ├── pkg.go │ │ │ │ └── portsbinding_test.go │ │ │ ├── provider_test.go │ │ │ └── security_test.go │ │ │ ├── network_test.go │ │ │ ├── pkg.go │ │ │ ├── port_test.go │ │ │ └── subnet_test.go │ ├── objectstorage │ │ └── v1 │ │ │ ├── accounts_test.go │ │ │ ├── common.go │ │ │ ├── containers_test.go │ │ │ └── objects_test.go │ ├── orchestration │ │ └── v1 │ │ │ ├── common.go │ │ │ ├── hello-compute.json │ │ │ ├── stackevents_test.go │ │ │ ├── stackresources_test.go │ │ │ ├── stacks_test.go │ │ │ └── stacktemplates_test.go │ └── pkg.go ├── rackspace │ ├── blockstorage │ │ └── v1 │ │ │ ├── common.go │ │ │ ├── snapshot_test.go │ │ │ ├── volume_test.go │ │ │ └── volume_type_test.go │ ├── cdn │ │ └── v1 │ │ │ ├── base_test.go │ │ │ ├── common.go │ │ │ ├── flavor_test.go │ │ │ ├── service_test.go │ │ │ └── serviceasset_test.go │ ├── client_test.go │ ├── compute │ │ └── v2 │ │ │ ├── bootfromvolume_test.go │ │ │ ├── compute_test.go │ │ │ ├── flavors_test.go │ │ │ ├── images_test.go │ │ │ ├── keypairs_test.go │ │ │ ├── networks_test.go │ │ │ ├── pkg.go │ │ │ ├── servers_test.go │ │ │ ├── virtualinterfaces_test.go │ │ │ └── volumeattach_test.go │ ├── db │ │ └── v1 │ │ │ ├── backup_test.go │ │ │ ├── common.go │ │ │ ├── config_group_test.go │ │ │ ├── database_test.go │ │ │ ├── flavor_test.go │ │ │ ├── instance_test.go │ │ │ ├── pkg.go │ │ │ ├── replica_test.go │ │ │ └── user_test.go │ ├── identity │ │ └── v2 │ │ │ ├── extension_test.go │ │ │ ├── identity_test.go │ │ │ ├── pkg.go │ │ │ ├── role_test.go │ │ │ ├── tenant_test.go │ │ │ ├── tokens_test.go │ │ │ └── user_test.go │ ├── lb │ │ └── v1 │ │ │ ├── acl_test.go │ │ │ ├── common.go │ │ │ ├── lb_test.go │ │ │ ├── monitor_test.go │ │ │ ├── node_test.go │ │ │ ├── session_test.go │ │ │ ├── throttle_test.go │ │ │ └── vip_test.go │ ├── networking │ │ └── v2 │ │ │ ├── common.go │ │ │ ├── network_test.go │ │ │ ├── port_test.go │ │ │ ├── security_test.go │ │ │ └── subnet_test.go │ ├── objectstorage │ │ └── v1 │ │ │ ├── accounts_test.go │ │ │ ├── bulk_test.go │ │ │ ├── cdncontainers_test.go │ │ │ ├── cdnobjects_test.go │ │ │ ├── common.go │ │ │ ├── containers_test.go │ │ │ └── objects_test.go │ ├── orchestration │ │ └── v1 │ │ │ ├── buildinfo_test.go │ │ │ ├── common.go │ │ │ ├── stackevents_test.go │ │ │ ├── stackresources_test.go │ │ │ ├── stacks_test.go │ │ │ └── stacktemplates_test.go │ ├── pkg.go │ └── rackconnect │ │ └── v3 │ │ ├── cloudnetworks_test.go │ │ ├── common.go │ │ ├── lbpools_test.go │ │ └── publicips_test.go └── tools │ ├── pkg.go │ └── tools.go ├── auth_options.go ├── auth_results.go ├── doc.go ├── endpoint_search.go ├── endpoint_search_test.go ├── openstack ├── auth_env.go ├── blockstorage │ ├── v1 │ │ ├── apiversions │ │ │ ├── doc.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── snapshots │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ ├── urls_test.go │ │ │ └── util.go │ │ ├── volumes │ │ │ ├── doc.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── testing │ │ │ │ ├── doc.go │ │ │ │ └── fixtures.go │ │ │ ├── urls.go │ │ │ ├── urls_test.go │ │ │ └── util.go │ │ └── volumetypes │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ └── v2 │ │ ├── extensions │ │ └── volumeactions │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ └── volumes │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ ├── urls_test.go │ │ └── util.go ├── cdn │ └── v1 │ │ ├── base │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── flavors │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── serviceassets │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ └── services │ │ ├── doc.go │ │ ├── errors.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go ├── client.go ├── client_test.go ├── common │ ├── README.md │ └── extensions │ │ ├── doc.go │ │ ├── errors.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go ├── compute │ └── v2 │ │ ├── extensions │ │ ├── adminactions │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ └── requests_test.go │ │ ├── bootfromvolume │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── defsecrules │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ └── urls.go │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── diskconfig │ │ │ ├── doc.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ └── results_test.go │ │ ├── doc.go │ │ ├── floatingip │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── keypairs │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── networks │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── quotasets │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── schedulerhints │ │ │ ├── doc.go │ │ │ ├── requests.go │ │ │ └── requests_test.go │ │ ├── secgroups │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ └── urls.go │ │ ├── servergroups │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── startstop │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ └── requests_test.go │ │ ├── tenantnetworks │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ └── volumeattach │ │ │ ├── doc.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── testing │ │ │ ├── doc.go │ │ │ └── fixtures.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── flavors │ │ ├── doc.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── images │ │ ├── doc.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ └── servers │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── results_test.go │ │ ├── urls.go │ │ ├── urls_test.go │ │ └── util.go ├── db │ └── v1 │ │ ├── configurations │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── databases │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── datastores │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── flavors │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── instances │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ └── users │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go ├── endpoint_location.go ├── endpoint_location_test.go ├── identity │ ├── v2 │ │ ├── extensions │ │ │ ├── admin │ │ │ │ └── roles │ │ │ │ │ ├── docs.go │ │ │ │ │ ├── fixtures.go │ │ │ │ │ ├── requests.go │ │ │ │ │ ├── requests_test.go │ │ │ │ │ ├── results.go │ │ │ │ │ └── urls.go │ │ │ ├── delegate.go │ │ │ ├── delegate_test.go │ │ │ ├── doc.go │ │ │ └── fixtures.go │ │ ├── tenants │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ └── urls.go │ │ ├── tokens │ │ │ ├── doc.go │ │ │ ├── errors.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ └── urls.go │ │ └── users │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ └── urls.go │ └── v3 │ │ ├── endpoints │ │ ├── doc.go │ │ ├── errors.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── extensions │ │ ├── doc.go │ │ └── trust │ │ │ ├── request.go │ │ │ └── request_test.go │ │ ├── roles │ │ ├── doc.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── services │ │ ├── doc.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ └── tokens │ │ ├── doc.go │ │ ├── errors.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go ├── imageservice │ └── v2 │ │ ├── README.md │ │ ├── images │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── types.go │ │ ├── urls.go │ │ └── urls_test.go │ │ └── members │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go ├── networking │ └── v2 │ │ ├── apiversions │ │ ├── doc.go │ │ ├── errors.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── common │ │ └── common_tests.go │ │ ├── extensions │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── external │ │ │ ├── doc.go │ │ │ ├── requests.go │ │ │ ├── results.go │ │ │ └── results_test.go │ │ ├── fwaas │ │ │ ├── doc.go │ │ │ ├── firewalls │ │ │ │ ├── errors.go │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ ├── policies │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ └── rules │ │ │ │ ├── errors.go │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ ├── layer3 │ │ │ ├── doc.go │ │ │ ├── floatingips │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ └── routers │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ ├── lbaas │ │ │ ├── doc.go │ │ │ ├── members │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ ├── monitors │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ ├── pools │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ └── vips │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ ├── lbaas_v2 │ │ │ ├── doc.go │ │ │ ├── listeners │ │ │ │ ├── fixtures.go │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ ├── loadbalancers │ │ │ │ ├── fixtures.go │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ ├── monitors │ │ │ │ ├── fixtures.go │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ │ └── pools │ │ │ │ ├── fixtures.go │ │ │ │ ├── requests.go │ │ │ │ ├── requests_test.go │ │ │ │ ├── results.go │ │ │ │ └── urls.go │ │ ├── portsbinding │ │ │ ├── doc.go │ │ │ ├── fixtures.go │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ ├── urls.go │ │ │ └── urls_test.go │ │ ├── provider │ │ │ ├── doc.go │ │ │ ├── results.go │ │ │ └── results_test.go │ │ └── security │ │ │ ├── doc.go │ │ │ ├── groups │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ └── urls.go │ │ │ └── rules │ │ │ ├── requests.go │ │ │ ├── requests_test.go │ │ │ ├── results.go │ │ │ └── urls.go │ │ ├── networks │ │ ├── doc.go │ │ ├── errors.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── ports │ │ ├── doc.go │ │ ├── errors.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ └── subnets │ │ ├── doc.go │ │ ├── errors.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── results_test.go │ │ ├── urls.go │ │ └── urls_test.go ├── objectstorage │ └── v1 │ │ ├── accounts │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── containers │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ └── objects │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go ├── orchestration │ └── v1 │ │ ├── apiversions │ │ ├── doc.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── buildinfo │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── stackevents │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── stackresources │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── stacks │ │ ├── doc.go │ │ ├── environment.go │ │ ├── environment_test.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── template.go │ │ ├── template_test.go │ │ ├── urls.go │ │ ├── utils.go │ │ └── utils_test.go │ │ └── stacktemplates │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go ├── telemetry │ └── v2 │ │ └── meters │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go └── utils │ ├── choose_version.go │ └── choose_version_test.go ├── pagination ├── http.go ├── linked.go ├── linked_test.go ├── marker.go ├── marker_test.go ├── null.go ├── pager.go ├── pagination_test.go ├── pkg.go ├── single.go └── single_test.go ├── params.go ├── params_test.go ├── provider_client.go ├── provider_client_test.go ├── rackspace ├── auth_env.go ├── autoscale │ └── v1 │ │ ├── policies │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ └── webhooks │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go ├── blockstorage │ └── v1 │ │ ├── snapshots │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ └── results.go │ │ ├── volumes │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ └── results.go │ │ └── volumetypes │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ └── results.go ├── cdn │ └── v1 │ │ ├── base │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── flavors │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── serviceassets │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ └── services │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go ├── client.go ├── client_test.go ├── compute │ └── v2 │ │ ├── bootfromvolume │ │ ├── delegate.go │ │ └── delegate_test.go │ │ ├── flavors │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── results.go │ │ └── urls.go │ │ ├── images │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ └── fixtures.go │ │ ├── keypairs │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── networks │ │ ├── doc.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── servers │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ └── requests_test.go │ │ ├── virtualinterfaces │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ └── volumeattach │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go ├── db │ └── v1 │ │ ├── backups │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── configurations │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ └── fixtures.go │ │ ├── databases │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ └── urls.go │ │ ├── datastores │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── flavors │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── instances │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ └── users │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go ├── identity │ └── v2 │ │ ├── extensions │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── roles │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── fixtures.go │ │ ├── tenants │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── tokens │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ └── users │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── fixtures.go │ │ ├── results.go │ │ └── urls.go ├── lb │ └── v1 │ │ ├── acl │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── lbs │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── monitors │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── nodes │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── sessions │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── ssl │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ ├── throttle │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go │ │ └── vips │ │ ├── doc.go │ │ ├── fixtures.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ └── urls.go ├── networking │ └── v2 │ │ ├── common │ │ └── common_tests.go │ │ ├── networks │ │ ├── delegate.go │ │ └── delegate_test.go │ │ ├── ports │ │ ├── delegate.go │ │ └── delegate_test.go │ │ ├── security │ │ ├── doc.go │ │ ├── groups │ │ │ ├── delegate.go │ │ │ └── delegate_test.go │ │ └── rules │ │ │ ├── delegate.go │ │ │ └── delegate_test.go │ │ └── subnets │ │ ├── delegate.go │ │ └── delegate_test.go ├── objectstorage │ └── v1 │ │ ├── accounts │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── bulk │ │ ├── doc.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── cdncontainers │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ ├── requests.go │ │ ├── requests_test.go │ │ ├── results.go │ │ ├── urls.go │ │ └── urls_test.go │ │ ├── cdnobjects │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ └── request.go │ │ ├── containers │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ └── objects │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go ├── orchestration │ └── v1 │ │ ├── buildinfo │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── stackevents │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── stackresources │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go │ │ ├── stacks │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ ├── doc.go │ │ └── fixtures.go │ │ └── stacktemplates │ │ ├── delegate.go │ │ ├── delegate_test.go │ │ └── doc.go └── rackconnect │ └── v3 │ ├── cloudnetworks │ ├── requests.go │ ├── requests_test.go │ ├── results.go │ └── urls.go │ ├── doc.go │ ├── lbpools │ ├── doc.go │ ├── requests.go │ ├── requests_test.go │ ├── results.go │ └── urls.go │ └── publicips │ ├── requests.go │ ├── requests_test.go │ ├── results.go │ └── urls.go ├── results.go ├── script ├── acceptancetest ├── bootstrap ├── cibuild ├── test └── unittest ├── service_client.go ├── service_client_test.go ├── testhelper ├── client │ └── fake.go ├── convenience.go ├── doc.go ├── fixture │ └── helper.go └── http_responses.go ├── util.go └── util_test.go /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | install: 4 | - go get golang.org/x/crypto/ssh 5 | - go get -v -tags 'fixtures acceptance' ./... 6 | go: 7 | - 1.4 8 | - 1.5 9 | - tip 10 | env: 11 | - COVERALLS_TOKEN=2k7PTU3xa474Hymwgdj6XjqenNfGTNkO8 12 | before_install: 13 | - go get github.com/axw/gocov/gocov 14 | - go get github.com/mattn/goveralls 15 | - go get github.com/pierrre/gotestcover 16 | - if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi 17 | script: 18 | - $HOME/gopath/bin/gotestcover -v -tags=fixtures -coverprofile=cover.out ./... 19 | after_success: 20 | - $HOME/gopath/bin/goveralls -service=travis-ci -coverprofile=cover.out 21 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | Contributors 2 | ============ 3 | 4 | | Name | Email | 5 | | ---- | ----- | 6 | | Samuel A. Falvo II | 7 | | Glen Campbell | 8 | | Jesse Noller | 9 | | Jon Perritt | 10 | | Ash Wilson | 11 | | Jamie Hannaford | 12 | | Don Schenck | don.schenck@rackspace.com> 13 | | Joe Topjian | 14 | -------------------------------------------------------------------------------- /acceptance/openstack/blockstorage/v1/pkg.go: -------------------------------------------------------------------------------- 1 | // The v1 package contains acceptance tests for the Openstack Cinder V1 service. 2 | 3 | package v1 4 | -------------------------------------------------------------------------------- /acceptance/openstack/blockstorage/v2/extensions/pkg.go: -------------------------------------------------------------------------------- 1 | // The extensions package contains acceptance tests for the Openstack Cinder V2 extensions service. 2 | 3 | package extensions 4 | -------------------------------------------------------------------------------- /acceptance/openstack/blockstorage/v2/pkg.go: -------------------------------------------------------------------------------- 1 | // The v2 package contains acceptance tests for the Openstack Cinder V2 service. 2 | 3 | package v2 4 | -------------------------------------------------------------------------------- /acceptance/openstack/compute/v2/images_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance compute images 2 | 3 | package v2 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud/openstack/compute/v2/images" 9 | "github.com/rackspace/gophercloud/pagination" 10 | ) 11 | 12 | func TestListImages(t *testing.T) { 13 | client, err := newClient() 14 | if err != nil { 15 | t.Fatalf("Unable to create a compute: client: %v", err) 16 | } 17 | 18 | t.Logf("ID\tRegion\tName\tStatus\tCreated") 19 | 20 | pager := images.ListDetail(client, nil) 21 | count, pages := 0, 0 22 | pager.EachPage(func(page pagination.Page) (bool, error) { 23 | pages++ 24 | images, err := images.ExtractImages(page) 25 | if err != nil { 26 | return false, err 27 | } 28 | 29 | for _, i := range images { 30 | t.Logf("%s\t%s\t%s\t%s", i.ID, i.Name, i.Status, i.Created) 31 | } 32 | 33 | return true, nil 34 | }) 35 | 36 | t.Logf("--------\n%d images listed on %d pages.", count, pages) 37 | } 38 | -------------------------------------------------------------------------------- /acceptance/openstack/compute/v2/pkg.go: -------------------------------------------------------------------------------- 1 | // The v2 package contains acceptance tests for the Openstack Compute V2 service. 2 | 3 | package v2 4 | -------------------------------------------------------------------------------- /acceptance/openstack/db/v1/flavor_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance db 2 | 3 | package v1 4 | 5 | import ( 6 | "github.com/rackspace/gophercloud/openstack/db/v1/flavors" 7 | "github.com/rackspace/gophercloud/pagination" 8 | ) 9 | 10 | func (c context) listFlavors() { 11 | c.Logf("Listing flavors") 12 | 13 | err := flavors.List(c.client).EachPage(func(page pagination.Page) (bool, error) { 14 | flavorList, err := flavors.ExtractFlavors(page) 15 | c.AssertNoErr(err) 16 | 17 | for _, f := range flavorList { 18 | c.Logf("Flavor: ID [%s] Name [%s] RAM [%d]", f.ID, f.Name, f.RAM) 19 | } 20 | 21 | return true, nil 22 | }) 23 | 24 | c.AssertNoErr(err) 25 | } 26 | 27 | func (c context) getFlavor() { 28 | flavor, err := flavors.Get(c.client, "1").Extract() 29 | c.Logf("Getting flavor %s", flavor.ID) 30 | c.AssertNoErr(err) 31 | } 32 | -------------------------------------------------------------------------------- /acceptance/openstack/db/v1/pkg.go: -------------------------------------------------------------------------------- 1 | package v1 2 | -------------------------------------------------------------------------------- /acceptance/openstack/identity/v2/pkg.go: -------------------------------------------------------------------------------- 1 | package v2 2 | -------------------------------------------------------------------------------- /acceptance/openstack/identity/v2/tenant_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance identity 2 | 3 | package v2 4 | 5 | import ( 6 | "testing" 7 | 8 | tenants2 "github.com/rackspace/gophercloud/openstack/identity/v2/tenants" 9 | "github.com/rackspace/gophercloud/pagination" 10 | th "github.com/rackspace/gophercloud/testhelper" 11 | ) 12 | 13 | func TestEnumerateTenants(t *testing.T) { 14 | service := authenticatedClient(t) 15 | 16 | t.Logf("Tenants to which your current token grants access:") 17 | count := 0 18 | err := tenants2.List(service, nil).EachPage(func(page pagination.Page) (bool, error) { 19 | t.Logf("--- Page %02d ---", count) 20 | 21 | tenants, err := tenants2.ExtractTenants(page) 22 | th.AssertNoErr(t, err) 23 | for i, tenant := range tenants { 24 | t.Logf("[%02d] name=[%s] id=[%s] description=[%s] enabled=[%v]", 25 | i, tenant.Name, tenant.ID, tenant.Description, tenant.Enabled) 26 | } 27 | 28 | count++ 29 | return true, nil 30 | }) 31 | th.AssertNoErr(t, err) 32 | } 33 | -------------------------------------------------------------------------------- /acceptance/openstack/identity/v3/pkg.go: -------------------------------------------------------------------------------- 1 | package v3 2 | -------------------------------------------------------------------------------- /acceptance/openstack/identity/v3/service_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v3 4 | 5 | import ( 6 | "testing" 7 | 8 | services3 "github.com/rackspace/gophercloud/openstack/identity/v3/services" 9 | "github.com/rackspace/gophercloud/pagination" 10 | ) 11 | 12 | func TestListServices(t *testing.T) { 13 | // Create a service client. 14 | serviceClient := createAuthenticatedClient(t) 15 | if serviceClient == nil { 16 | return 17 | } 18 | 19 | // Use the client to list all available services. 20 | pager := services3.List(serviceClient, services3.ListOpts{}) 21 | err := pager.EachPage(func(page pagination.Page) (bool, error) { 22 | parts, err := services3.ExtractServices(page) 23 | if err != nil { 24 | return false, err 25 | } 26 | 27 | t.Logf("--- Page ---") 28 | for _, service := range parts { 29 | t.Logf("Service: %32s %15s %10s %s", service.ID, service.Type, service.Name, *service.Description) 30 | } 31 | return true, nil 32 | }) 33 | if err != nil { 34 | t.Errorf("Unexpected error traversing pages: %v", err) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /acceptance/openstack/imageservice/v2/README.md: -------------------------------------------------------------------------------- 1 | Here be acceptance tests for the image service API. 2 | -------------------------------------------------------------------------------- /acceptance/openstack/imageservice/v2/pkg.go: -------------------------------------------------------------------------------- 1 | package v2 2 | -------------------------------------------------------------------------------- /acceptance/openstack/networking/v2/common.go: -------------------------------------------------------------------------------- 1 | package v2 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/rackspace/gophercloud" 8 | "github.com/rackspace/gophercloud/openstack" 9 | th "github.com/rackspace/gophercloud/testhelper" 10 | ) 11 | 12 | var Client *gophercloud.ServiceClient 13 | 14 | func NewClient() (*gophercloud.ServiceClient, error) { 15 | opts, err := openstack.AuthOptionsFromEnv() 16 | if err != nil { 17 | return nil, err 18 | } 19 | 20 | provider, err := openstack.AuthenticatedClient(opts) 21 | if err != nil { 22 | return nil, err 23 | } 24 | 25 | return openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{ 26 | Name: "neutron", 27 | Region: os.Getenv("OS_REGION_NAME"), 28 | }) 29 | } 30 | 31 | func Setup(t *testing.T) { 32 | client, err := NewClient() 33 | th.AssertNoErr(t, err) 34 | Client = client 35 | } 36 | 37 | func Teardown() { 38 | Client = nil 39 | } 40 | -------------------------------------------------------------------------------- /acceptance/openstack/networking/v2/extensions/fwaas/pkg.go: -------------------------------------------------------------------------------- 1 | package fwaas 2 | -------------------------------------------------------------------------------- /acceptance/openstack/networking/v2/extensions/lbaas/pkg.go: -------------------------------------------------------------------------------- 1 | package lbaas 2 | -------------------------------------------------------------------------------- /acceptance/openstack/networking/v2/extensions/lbaas_v2/pkg.go: -------------------------------------------------------------------------------- 1 | package lbaas_v2 2 | -------------------------------------------------------------------------------- /acceptance/openstack/networking/v2/extensions/pkg.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | -------------------------------------------------------------------------------- /acceptance/openstack/networking/v2/extensions/portsbinding/pkg.go: -------------------------------------------------------------------------------- 1 | package portsbinding 2 | -------------------------------------------------------------------------------- /acceptance/openstack/networking/v2/pkg.go: -------------------------------------------------------------------------------- 1 | package v2 2 | -------------------------------------------------------------------------------- /acceptance/openstack/objectstorage/v1/common.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v1 4 | 5 | import ( 6 | "os" 7 | "testing" 8 | 9 | "github.com/rackspace/gophercloud" 10 | "github.com/rackspace/gophercloud/openstack" 11 | th "github.com/rackspace/gophercloud/testhelper" 12 | ) 13 | 14 | var metadata = map[string]string{"gopher": "cloud"} 15 | 16 | func newClient(t *testing.T) *gophercloud.ServiceClient { 17 | ao, err := openstack.AuthOptionsFromEnv() 18 | th.AssertNoErr(t, err) 19 | 20 | client, err := openstack.AuthenticatedClient(ao) 21 | th.AssertNoErr(t, err) 22 | 23 | c, err := openstack.NewObjectStorageV1(client, gophercloud.EndpointOpts{ 24 | Region: os.Getenv("OS_REGION_NAME"), 25 | }) 26 | th.AssertNoErr(t, err) 27 | return c 28 | } 29 | -------------------------------------------------------------------------------- /acceptance/openstack/orchestration/v1/hello-compute.json: -------------------------------------------------------------------------------- 1 | { 2 | "heat_template_version": "2013-05-23", 3 | "resources": { 4 | "compute_instance": { 5 | "type": "OS::Nova::Server", 6 | "properties": { 7 | "flavor": "m1.small", 8 | "image": "cirros-0.3.2-x86_64-disk", 9 | "name": "Single Compute Instance" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /acceptance/openstack/pkg.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package openstack 4 | 5 | -------------------------------------------------------------------------------- /acceptance/rackspace/blockstorage/v1/common.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v1 4 | 5 | import ( 6 | "os" 7 | "testing" 8 | 9 | "github.com/rackspace/gophercloud" 10 | "github.com/rackspace/gophercloud/acceptance/tools" 11 | "github.com/rackspace/gophercloud/rackspace" 12 | th "github.com/rackspace/gophercloud/testhelper" 13 | ) 14 | 15 | func newClient() (*gophercloud.ServiceClient, error) { 16 | opts, err := rackspace.AuthOptionsFromEnv() 17 | if err != nil { 18 | return nil, err 19 | } 20 | opts = tools.OnlyRS(opts) 21 | region := os.Getenv("RS_REGION") 22 | 23 | provider, err := rackspace.AuthenticatedClient(opts) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | return rackspace.NewBlockStorageV1(provider, gophercloud.EndpointOpts{ 29 | Region: region, 30 | }) 31 | } 32 | 33 | func setup(t *testing.T) *gophercloud.ServiceClient { 34 | client, err := newClient() 35 | th.AssertNoErr(t, err) 36 | 37 | return client 38 | } 39 | -------------------------------------------------------------------------------- /acceptance/rackspace/cdn/v1/base_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v1 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud" 9 | "github.com/rackspace/gophercloud/rackspace/cdn/v1/base" 10 | th "github.com/rackspace/gophercloud/testhelper" 11 | ) 12 | 13 | func TestBaseOps(t *testing.T) { 14 | client := newClient(t) 15 | t.Log("Retrieving Home Document") 16 | testHomeDocumentGet(t, client) 17 | 18 | t.Log("Pinging root URL") 19 | testPing(t, client) 20 | } 21 | 22 | func testHomeDocumentGet(t *testing.T, client *gophercloud.ServiceClient) { 23 | hd, err := base.Get(client).Extract() 24 | th.AssertNoErr(t, err) 25 | t.Logf("Retrieved home document: %+v", *hd) 26 | } 27 | 28 | func testPing(t *testing.T, client *gophercloud.ServiceClient) { 29 | err := base.Ping(client).ExtractErr() 30 | th.AssertNoErr(t, err) 31 | t.Logf("Successfully pinged root URL") 32 | } 33 | -------------------------------------------------------------------------------- /acceptance/rackspace/cdn/v1/common.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v1 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud" 9 | "github.com/rackspace/gophercloud/rackspace" 10 | th "github.com/rackspace/gophercloud/testhelper" 11 | ) 12 | 13 | func newClient(t *testing.T) *gophercloud.ServiceClient { 14 | ao, err := rackspace.AuthOptionsFromEnv() 15 | th.AssertNoErr(t, err) 16 | 17 | client, err := rackspace.AuthenticatedClient(ao) 18 | th.AssertNoErr(t, err) 19 | 20 | c, err := rackspace.NewCDNV1(client, gophercloud.EndpointOpts{}) 21 | th.AssertNoErr(t, err) 22 | return c 23 | } 24 | -------------------------------------------------------------------------------- /acceptance/rackspace/cdn/v1/serviceasset_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v1 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud" 9 | osServiceAssets "github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets" 10 | "github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets" 11 | th "github.com/rackspace/gophercloud/testhelper" 12 | ) 13 | 14 | func TestServiceAsset(t *testing.T) { 15 | client := newClient(t) 16 | 17 | t.Log("Creating Service") 18 | loc := testServiceCreate(t, client, "test-site-2") 19 | t.Logf("Created service at location: %s", loc) 20 | 21 | t.Log("Deleting Service Assets") 22 | testServiceAssetDelete(t, client, loc) 23 | } 24 | 25 | func testServiceAssetDelete(t *testing.T, client *gophercloud.ServiceClient, url string) { 26 | deleteOpts := osServiceAssets.DeleteOpts{ 27 | All: true, 28 | } 29 | err := serviceassets.Delete(client, url, deleteOpts).ExtractErr() 30 | th.AssertNoErr(t, err) 31 | t.Log("Successfully deleted all Service Assets") 32 | } 33 | -------------------------------------------------------------------------------- /acceptance/rackspace/client_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package rackspace 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud/acceptance/tools" 9 | "github.com/rackspace/gophercloud/rackspace" 10 | th "github.com/rackspace/gophercloud/testhelper" 11 | ) 12 | 13 | func TestAuthenticatedClient(t *testing.T) { 14 | // Obtain credentials from the environment. 15 | ao, err := rackspace.AuthOptionsFromEnv() 16 | th.AssertNoErr(t, err) 17 | 18 | client, err := rackspace.AuthenticatedClient(tools.OnlyRS(ao)) 19 | if err != nil { 20 | t.Fatalf("Unable to authenticate: %v", err) 21 | } 22 | 23 | if client.TokenID == "" { 24 | t.Errorf("No token ID assigned to the client") 25 | } 26 | 27 | t.Logf("Client successfully acquired a token: %v", client.TokenID) 28 | } 29 | -------------------------------------------------------------------------------- /acceptance/rackspace/compute/v2/pkg.go: -------------------------------------------------------------------------------- 1 | package v2 2 | -------------------------------------------------------------------------------- /acceptance/rackspace/db/v1/flavor_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance db rackspace 2 | 3 | package v1 4 | 5 | import ( 6 | os "github.com/rackspace/gophercloud/openstack/db/v1/flavors" 7 | "github.com/rackspace/gophercloud/pagination" 8 | "github.com/rackspace/gophercloud/rackspace/db/v1/flavors" 9 | ) 10 | 11 | func (c context) listFlavors() { 12 | c.Logf("Listing flavors") 13 | 14 | err := flavors.List(c.client).EachPage(func(page pagination.Page) (bool, error) { 15 | flavorList, err := os.ExtractFlavors(page) 16 | c.AssertNoErr(err) 17 | 18 | for _, f := range flavorList { 19 | c.Logf("Flavor: ID [%s] Name [%s] RAM [%d]", f.ID, f.Name, f.RAM) 20 | } 21 | 22 | return true, nil 23 | }) 24 | 25 | c.AssertNoErr(err) 26 | } 27 | 28 | func (c context) getFlavor() { 29 | flavor, err := flavors.Get(c.client, "1").Extract() 30 | c.Logf("Getting flavor %s", flavor.ID) 31 | c.AssertNoErr(err) 32 | } 33 | -------------------------------------------------------------------------------- /acceptance/rackspace/db/v1/pkg.go: -------------------------------------------------------------------------------- 1 | package v1 2 | -------------------------------------------------------------------------------- /acceptance/rackspace/db/v1/replica_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance db rackspace 2 | 3 | package v1 4 | 5 | import ( 6 | "github.com/rackspace/gophercloud/acceptance/tools" 7 | "github.com/rackspace/gophercloud/rackspace/db/v1/instances" 8 | th "github.com/rackspace/gophercloud/testhelper" 9 | ) 10 | 11 | func (c *context) createReplica() { 12 | opts := instances.CreateOpts{ 13 | FlavorRef: "2", 14 | Size: 1, 15 | Name: tools.RandomString("gopher_db", 5), 16 | ReplicaOf: c.instanceID, 17 | } 18 | 19 | repl, err := instances.Create(c.client, opts).Extract() 20 | th.AssertNoErr(c.test, err) 21 | 22 | c.Logf("Creating replica of %s. Waiting...", c.instanceID) 23 | c.WaitUntilActive(repl.ID) 24 | c.Logf("Created replica %#v", repl) 25 | 26 | c.replicaID = repl.ID 27 | } 28 | 29 | func (c *context) detachReplica() { 30 | err := instances.DetachReplica(c.client, c.replicaID).ExtractErr() 31 | c.Logf("Detached replica %s", c.replicaID) 32 | c.AssertNoErr(err) 33 | } 34 | -------------------------------------------------------------------------------- /acceptance/rackspace/identity/v2/pkg.go: -------------------------------------------------------------------------------- 1 | package v2 2 | -------------------------------------------------------------------------------- /acceptance/rackspace/identity/v2/tenant_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v2 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud/pagination" 9 | rstenants "github.com/rackspace/gophercloud/rackspace/identity/v2/tenants" 10 | th "github.com/rackspace/gophercloud/testhelper" 11 | ) 12 | 13 | func TestTenants(t *testing.T) { 14 | service := authenticatedClient(t) 15 | 16 | t.Logf("Tenants available to the currently issued token:") 17 | count := 0 18 | err := rstenants.List(service, nil).EachPage(func(page pagination.Page) (bool, error) { 19 | t.Logf("--- Page %02d ---", count) 20 | 21 | tenants, err := rstenants.ExtractTenants(page) 22 | th.AssertNoErr(t, err) 23 | 24 | for i, tenant := range tenants { 25 | t.Logf("[%02d] id=[%s]", i, tenant.ID) 26 | t.Logf(" name=[%s] enabled=[%v]", i, tenant.Name, tenant.Enabled) 27 | t.Logf(" description=[%s]", tenant.Description) 28 | } 29 | 30 | count++ 31 | return true, nil 32 | }) 33 | th.AssertNoErr(t, err) 34 | if count == 0 { 35 | t.Errorf("No tenants listed for your current token.") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /acceptance/rackspace/identity/v2/tokens_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v2 4 | 5 | import ( 6 | "os" 7 | "testing" 8 | 9 | "github.com/rackspace/gophercloud/rackspace/identity/v2/tokens" 10 | th "github.com/rackspace/gophercloud/testhelper" 11 | ) 12 | 13 | func TestTokenAuth(t *testing.T) { 14 | authedClient := createClient(t, true) 15 | token := authedClient.TokenID 16 | 17 | tenantID := os.Getenv("RS_TENANT_ID") 18 | if tenantID == "" { 19 | t.Skip("You must set RS_TENANT_ID environment variable to run this test") 20 | } 21 | 22 | authOpts := tokens.AuthOptions{} 23 | authOpts.TenantID = tenantID 24 | authOpts.TokenID = token 25 | 26 | _, err := tokens.Create(authedClient, authOpts).ExtractToken() 27 | th.AssertNoErr(t, err) 28 | } 29 | -------------------------------------------------------------------------------- /acceptance/rackspace/networking/v2/common.go: -------------------------------------------------------------------------------- 1 | package v2 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/rackspace/gophercloud" 8 | "github.com/rackspace/gophercloud/rackspace" 9 | th "github.com/rackspace/gophercloud/testhelper" 10 | ) 11 | 12 | var Client *gophercloud.ServiceClient 13 | 14 | func NewClient() (*gophercloud.ServiceClient, error) { 15 | opts, err := rackspace.AuthOptionsFromEnv() 16 | if err != nil { 17 | return nil, err 18 | } 19 | 20 | provider, err := rackspace.AuthenticatedClient(opts) 21 | if err != nil { 22 | return nil, err 23 | } 24 | 25 | return rackspace.NewNetworkV2(provider, gophercloud.EndpointOpts{ 26 | Name: "cloudNetworks", 27 | Region: os.Getenv("RS_REGION"), 28 | }) 29 | } 30 | 31 | func Setup(t *testing.T) { 32 | client, err := NewClient() 33 | th.AssertNoErr(t, err) 34 | Client = client 35 | } 36 | 37 | func Teardown() { 38 | Client = nil 39 | } 40 | -------------------------------------------------------------------------------- /acceptance/rackspace/objectstorage/v1/bulk_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance rackspace objectstorage v1 2 | 3 | package v1 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk" 9 | th "github.com/rackspace/gophercloud/testhelper" 10 | ) 11 | 12 | func TestBulk(t *testing.T) { 13 | c, err := createClient(t, false) 14 | th.AssertNoErr(t, err) 15 | 16 | var options bulk.DeleteOpts 17 | options = append(options, "container/object1") 18 | res := bulk.Delete(c, options) 19 | th.AssertNoErr(t, res.Err) 20 | body, err := res.ExtractBody() 21 | th.AssertNoErr(t, err) 22 | t.Logf("Response body from Bulk Delete Request: %+v\n", body) 23 | } 24 | -------------------------------------------------------------------------------- /acceptance/rackspace/orchestration/v1/buildinfo_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v1 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo" 9 | th "github.com/rackspace/gophercloud/testhelper" 10 | ) 11 | 12 | func TestBuildInfo(t *testing.T) { 13 | // Create a provider client for making the HTTP requests. 14 | // See common.go in this directory for more information. 15 | client := newClient(t) 16 | 17 | bi, err := buildinfo.Get(client).Extract() 18 | th.AssertNoErr(t, err) 19 | t.Logf("retrieved build info: %+v\n", bi) 20 | } 21 | -------------------------------------------------------------------------------- /acceptance/rackspace/pkg.go: -------------------------------------------------------------------------------- 1 | package rackspace 2 | -------------------------------------------------------------------------------- /acceptance/rackspace/rackconnect/v3/cloudnetworks_test.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v3 4 | 5 | import ( 6 | "fmt" 7 | "testing" 8 | 9 | "github.com/rackspace/gophercloud" 10 | "github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks" 11 | th "github.com/rackspace/gophercloud/testhelper" 12 | ) 13 | 14 | func TestCloudNetworks(t *testing.T) { 15 | c := newClient(t) 16 | cnID := testListNetworks(t, c) 17 | testGetNetworks(t, c, cnID) 18 | } 19 | 20 | func testListNetworks(t *testing.T, c *gophercloud.ServiceClient) string { 21 | allPages, err := cloudnetworks.List(c).AllPages() 22 | th.AssertNoErr(t, err) 23 | allcn, err := cloudnetworks.ExtractCloudNetworks(allPages) 24 | fmt.Printf("Listing all cloud networks: %+v\n\n", allcn) 25 | var cnID string 26 | if len(allcn) > 0 { 27 | cnID = allcn[0].ID 28 | } 29 | return cnID 30 | } 31 | 32 | func testGetNetworks(t *testing.T, c *gophercloud.ServiceClient, id string) { 33 | cn, err := cloudnetworks.Get(c, id).Extract() 34 | th.AssertNoErr(t, err) 35 | fmt.Printf("Retrieved cloud network: %+v\n\n", cn) 36 | } 37 | -------------------------------------------------------------------------------- /acceptance/rackspace/rackconnect/v3/common.go: -------------------------------------------------------------------------------- 1 | // +build acceptance 2 | 3 | package v3 4 | 5 | import ( 6 | "os" 7 | "testing" 8 | 9 | "github.com/rackspace/gophercloud" 10 | "github.com/rackspace/gophercloud/rackspace" 11 | th "github.com/rackspace/gophercloud/testhelper" 12 | ) 13 | 14 | func newClient(t *testing.T) *gophercloud.ServiceClient { 15 | ao, err := rackspace.AuthOptionsFromEnv() 16 | th.AssertNoErr(t, err) 17 | 18 | client, err := rackspace.AuthenticatedClient(ao) 19 | th.AssertNoErr(t, err) 20 | 21 | c, err := rackspace.NewRackConnectV3(client, gophercloud.EndpointOpts{ 22 | Region: os.Getenv("RS_REGION_NAME"), 23 | }) 24 | th.AssertNoErr(t, err) 25 | return c 26 | } 27 | -------------------------------------------------------------------------------- /acceptance/tools/pkg.go: -------------------------------------------------------------------------------- 1 | package tools 2 | -------------------------------------------------------------------------------- /auth_results.go: -------------------------------------------------------------------------------- 1 | package gophercloud 2 | 3 | import "time" 4 | 5 | // AuthResults [deprecated] is a leftover type from the v0.x days. It was 6 | // intended to describe common functionality among identity service results, but 7 | // is not actually used anywhere. 8 | type AuthResults interface { 9 | // TokenID returns the token's ID value from the authentication response. 10 | TokenID() (string, error) 11 | 12 | // ExpiresAt retrieves the token's expiration time. 13 | ExpiresAt() (time.Time, error) 14 | } 15 | -------------------------------------------------------------------------------- /endpoint_search_test.go: -------------------------------------------------------------------------------- 1 | package gophercloud 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | ) 8 | 9 | func TestApplyDefaultsToEndpointOpts(t *testing.T) { 10 | eo := EndpointOpts{Availability: AvailabilityPublic} 11 | eo.ApplyDefaults("compute") 12 | expected := EndpointOpts{Availability: AvailabilityPublic, Type: "compute"} 13 | th.CheckDeepEquals(t, expected, eo) 14 | 15 | eo = EndpointOpts{Type: "compute"} 16 | eo.ApplyDefaults("object-store") 17 | expected = EndpointOpts{Availability: AvailabilityPublic, Type: "compute"} 18 | th.CheckDeepEquals(t, expected, eo) 19 | } 20 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/apiversions/doc.go: -------------------------------------------------------------------------------- 1 | // Package apiversions provides information and interaction with the different 2 | // API versions for the OpenStack Block Storage service, code-named Cinder. 3 | package apiversions 4 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/apiversions/requests.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // List lists all the Cinder API versions available to end-users. 9 | func List(c *gophercloud.ServiceClient) pagination.Pager { 10 | return pagination.NewPager(c, listURL(c), func(r pagination.PageResult) pagination.Page { 11 | return APIVersionPage{pagination.SinglePageBase(r)} 12 | }) 13 | } 14 | 15 | // Get will retrieve the volume type with the provided ID. To extract the volume 16 | // type from the result, call the Extract method on the GetResult. 17 | func Get(client *gophercloud.ServiceClient, v string) GetResult { 18 | var res GetResult 19 | _, res.Err = client.Get(getURL(client, v), &res.Body, nil) 20 | return res 21 | } 22 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/apiversions/urls.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | 3 | import ( 4 | "strings" 5 | "net/url" 6 | 7 | "github.com/rackspace/gophercloud" 8 | ) 9 | 10 | func getURL(c *gophercloud.ServiceClient, version string) string { 11 | return c.ServiceURL(strings.TrimRight(version, "/") + "/") 12 | } 13 | 14 | func listURL(c *gophercloud.ServiceClient) string { 15 | u, _ := url.Parse(c.ServiceURL("")) 16 | u.Path = "/" 17 | return u.String() 18 | } 19 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/apiversions/urls_test.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | const endpoint2 = "http://localhost:57909/v1/3a02ee0b5cf14816b41b17e851d29a94" 12 | 13 | func endpointClient() *gophercloud.ServiceClient { 14 | return &gophercloud.ServiceClient{Endpoint: endpoint} 15 | } 16 | 17 | func endpointClient2() *gophercloud.ServiceClient { 18 | return &gophercloud.ServiceClient{Endpoint: endpoint2} 19 | } 20 | 21 | func TestGetURL(t *testing.T) { 22 | actual := getURL(endpointClient(), "v1") 23 | expected := endpoint + "v1/" 24 | th.AssertEquals(t, expected, actual) 25 | } 26 | 27 | func TestListURL(t *testing.T) { 28 | actual := listURL(endpointClient2()) 29 | expected := endpoint 30 | th.AssertEquals(t, expected, actual) 31 | } 32 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/snapshots/doc.go: -------------------------------------------------------------------------------- 1 | // Package snapshots provides information and interaction with snapshots in the 2 | // OpenStack Block Storage service. A snapshot is a point in time copy of the 3 | // data contained in an external storage volume, and can be controlled 4 | // programmatically. 5 | package snapshots 6 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/snapshots/urls.go: -------------------------------------------------------------------------------- 1 | package snapshots 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func createURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("snapshots") 7 | } 8 | 9 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 10 | return c.ServiceURL("snapshots", id) 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, id string) string { 14 | return deleteURL(c, id) 15 | } 16 | 17 | func listURL(c *gophercloud.ServiceClient) string { 18 | return createURL(c) 19 | } 20 | 21 | func metadataURL(c *gophercloud.ServiceClient, id string) string { 22 | return c.ServiceURL("snapshots", id, "metadata") 23 | } 24 | 25 | func updateMetadataURL(c *gophercloud.ServiceClient, id string) string { 26 | return metadataURL(c, id) 27 | } 28 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/snapshots/util.go: -------------------------------------------------------------------------------- 1 | package snapshots 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | ) 6 | 7 | // WaitForStatus will continually poll the resource, checking for a particular 8 | // status. It will do this for the amount of seconds defined. 9 | func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { 10 | return gophercloud.WaitFor(secs, func() (bool, error) { 11 | current, err := Get(c, id).Extract() 12 | if err != nil { 13 | return false, err 14 | } 15 | 16 | if current.Status == status { 17 | return true, nil 18 | } 19 | 20 | return false, nil 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/volumes/doc.go: -------------------------------------------------------------------------------- 1 | // Package volumes provides information and interaction with volumes in the 2 | // OpenStack Block Storage service. A volume is a detachable block storage 3 | // device, akin to a USB hard drive. It can only be attached to one instance at 4 | // a time. 5 | package volumes 6 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/volumes/testing/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | This is package created is to hold fixtures (which imports testing), 3 | so that importing volumes package does not inadvertently import testing into production code 4 | More information here: 5 | https://github.com/rackspace/gophercloud/issues/473 6 | */ 7 | package testing 8 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/volumes/urls.go: -------------------------------------------------------------------------------- 1 | package volumes 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func createURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("volumes") 7 | } 8 | 9 | func listURL(c *gophercloud.ServiceClient) string { 10 | return createURL(c) 11 | } 12 | 13 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 14 | return c.ServiceURL("volumes", id) 15 | } 16 | 17 | func getURL(c *gophercloud.ServiceClient, id string) string { 18 | return deleteURL(c, id) 19 | } 20 | 21 | func updateURL(c *gophercloud.ServiceClient, id string) string { 22 | return deleteURL(c, id) 23 | } 24 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/volumes/util.go: -------------------------------------------------------------------------------- 1 | package volumes 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | ) 6 | 7 | // WaitForStatus will continually poll the resource, checking for a particular 8 | // status. It will do this for the amount of seconds defined. 9 | func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { 10 | return gophercloud.WaitFor(secs, func() (bool, error) { 11 | current, err := Get(c, id).Extract() 12 | if err != nil { 13 | return false, err 14 | } 15 | 16 | if current.Status == status { 17 | return true, nil 18 | } 19 | 20 | return false, nil 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/volumetypes/doc.go: -------------------------------------------------------------------------------- 1 | // Package volumetypes provides information and interaction with volume types 2 | // in the OpenStack Block Storage service. A volume type indicates the type of 3 | // a block storage volume, such as SATA, SCSCI, SSD, etc. These can be 4 | // customized or defined by the OpenStack admin. 5 | // 6 | // You can also define extra_specs associated with your volume types. For 7 | // instance, you could have a VolumeType=SATA, with extra_specs (RPM=10000, 8 | // RAID-Level=5) . Extra_specs are defined and customized by the admin. 9 | package volumetypes 10 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/volumetypes/urls.go: -------------------------------------------------------------------------------- 1 | package volumetypes 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("types") 7 | } 8 | 9 | func createURL(c *gophercloud.ServiceClient) string { 10 | return listURL(c) 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, id string) string { 14 | return c.ServiceURL("types", id) 15 | } 16 | 17 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 18 | return getURL(c, id) 19 | } 20 | -------------------------------------------------------------------------------- /openstack/blockstorage/v1/volumetypes/urls_test.go: -------------------------------------------------------------------------------- 1 | package volumetypes 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestListURL(t *testing.T) { 17 | actual := listURL(endpointClient()) 18 | expected := endpoint + "types" 19 | th.AssertEquals(t, expected, actual) 20 | } 21 | 22 | func TestCreateURL(t *testing.T) { 23 | actual := createURL(endpointClient()) 24 | expected := endpoint + "types" 25 | th.AssertEquals(t, expected, actual) 26 | } 27 | 28 | func TestGetURL(t *testing.T) { 29 | actual := getURL(endpointClient(), "foo") 30 | expected := endpoint + "types/foo" 31 | th.AssertEquals(t, expected, actual) 32 | } 33 | 34 | func TestDeleteURL(t *testing.T) { 35 | actual := deleteURL(endpointClient(), "foo") 36 | expected := endpoint + "types/foo" 37 | th.AssertEquals(t, expected, actual) 38 | } 39 | -------------------------------------------------------------------------------- /openstack/blockstorage/v2/extensions/volumeactions/doc.go: -------------------------------------------------------------------------------- 1 | // Package volumeactions provides information and interaction with volumes in the 2 | // OpenStack Block Storage service. A volume is a detachable block storage 3 | // device, akin to a USB hard drive. It can only be attached to one instance at 4 | // a time. 5 | package volumeactions 6 | -------------------------------------------------------------------------------- /openstack/blockstorage/v2/extensions/volumeactions/urls.go: -------------------------------------------------------------------------------- 1 | package volumeactions 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func attachURL(c *gophercloud.ServiceClient, id string) string { 6 | return c.ServiceURL("volumes", id, "action") 7 | } 8 | 9 | func detachURL(c *gophercloud.ServiceClient, id string) string { 10 | return attachURL(c, id) 11 | } 12 | 13 | func reserveURL(c *gophercloud.ServiceClient, id string) string { 14 | return attachURL(c, id) 15 | } 16 | 17 | func unreserveURL(c *gophercloud.ServiceClient, id string) string { 18 | return attachURL(c, id) 19 | } 20 | 21 | func initializeConnectionURL(c *gophercloud.ServiceClient, id string) string { 22 | return attachURL(c, id) 23 | } 24 | 25 | func teminateConnectionURL(c *gophercloud.ServiceClient, id string) string { 26 | return attachURL(c, id) 27 | } 28 | -------------------------------------------------------------------------------- /openstack/blockstorage/v2/volumes/doc.go: -------------------------------------------------------------------------------- 1 | // Package volumes provides information and interaction with volumes in the 2 | // OpenStack Block Storage service. A volume is a detachable block storage 3 | // device, akin to a USB hard drive. It can only be attached to one instance at 4 | // a time. 5 | package volumes 6 | -------------------------------------------------------------------------------- /openstack/blockstorage/v2/volumes/urls.go: -------------------------------------------------------------------------------- 1 | package volumes 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func createURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("volumes") 7 | } 8 | 9 | func listURL(c *gophercloud.ServiceClient) string { 10 | return c.ServiceURL("volumes", "detail") 11 | } 12 | 13 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 14 | return c.ServiceURL("volumes", id) 15 | } 16 | 17 | func getURL(c *gophercloud.ServiceClient, id string) string { 18 | return deleteURL(c, id) 19 | } 20 | 21 | func updateURL(c *gophercloud.ServiceClient, id string) string { 22 | return deleteURL(c, id) 23 | } 24 | -------------------------------------------------------------------------------- /openstack/blockstorage/v2/volumes/util.go: -------------------------------------------------------------------------------- 1 | package volumes 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | ) 6 | 7 | // WaitForStatus will continually poll the resource, checking for a particular 8 | // status. It will do this for the amount of seconds defined. 9 | func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { 10 | return gophercloud.WaitFor(secs, func() (bool, error) { 11 | current, err := Get(c, id).Extract() 12 | if err != nil { 13 | return false, err 14 | } 15 | 16 | if current.Status == status { 17 | return true, nil 18 | } 19 | 20 | return false, nil 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /openstack/cdn/v1/base/doc.go: -------------------------------------------------------------------------------- 1 | // Package base provides information and interaction with the base API 2 | // resource in the OpenStack CDN service. This API resource allows for 3 | // retrieving the Home Document and pinging the root URL. 4 | package base 5 | -------------------------------------------------------------------------------- /openstack/cdn/v1/base/requests.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | // Get retrieves the home document, allowing the user to discover the 6 | // entire API. 7 | func Get(c *gophercloud.ServiceClient) GetResult { 8 | var res GetResult 9 | _, res.Err = c.Get(getURL(c), &res.Body, nil) 10 | return res 11 | } 12 | 13 | // Ping retrieves a ping to the server. 14 | func Ping(c *gophercloud.ServiceClient) PingResult { 15 | var res PingResult 16 | _, res.Err = c.Get(pingURL(c), nil, &gophercloud.RequestOpts{ 17 | OkCodes: []int{204}, 18 | MoreHeaders: map[string]string{"Accept": ""}, 19 | }) 20 | return res 21 | } 22 | -------------------------------------------------------------------------------- /openstack/cdn/v1/base/results.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | // HomeDocument is a resource that contains all the resources for the CDN API. 10 | type HomeDocument map[string]interface{} 11 | 12 | // GetResult represents the result of a Get operation. 13 | type GetResult struct { 14 | gophercloud.Result 15 | } 16 | 17 | // Extract is a function that accepts a result and extracts a home document resource. 18 | func (r GetResult) Extract() (*HomeDocument, error) { 19 | if r.Err != nil { 20 | return nil, r.Err 21 | } 22 | 23 | submap, ok := r.Body.(map[string]interface{})["resources"] 24 | if !ok { 25 | return nil, errors.New("Unexpected HomeDocument structure") 26 | } 27 | casted := HomeDocument(submap.(map[string]interface{})) 28 | 29 | return &casted, nil 30 | } 31 | 32 | // PingResult represents the result of a Ping operation. 33 | type PingResult struct { 34 | gophercloud.ErrResult 35 | } 36 | -------------------------------------------------------------------------------- /openstack/cdn/v1/base/urls.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func getURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL() 7 | } 8 | 9 | func pingURL(c *gophercloud.ServiceClient) string { 10 | return c.ServiceURL("ping") 11 | } 12 | -------------------------------------------------------------------------------- /openstack/cdn/v1/flavors/doc.go: -------------------------------------------------------------------------------- 1 | // Package flavors provides information and interaction with the flavors API 2 | // resource in the OpenStack CDN service. This API resource allows for 3 | // listing flavors and retrieving a specific flavor. 4 | // 5 | // A flavor is a mapping configuration to a CDN provider. 6 | package flavors 7 | -------------------------------------------------------------------------------- /openstack/cdn/v1/flavors/requests.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // List returns a single page of CDN flavors. 9 | func List(c *gophercloud.ServiceClient) pagination.Pager { 10 | url := listURL(c) 11 | createPage := func(r pagination.PageResult) pagination.Page { 12 | return FlavorPage{pagination.SinglePageBase(r)} 13 | } 14 | return pagination.NewPager(c, url, createPage) 15 | } 16 | 17 | // Get retrieves a specific flavor based on its unique ID. 18 | func Get(c *gophercloud.ServiceClient, id string) GetResult { 19 | var res GetResult 20 | _, res.Err = c.Get(getURL(c, id), &res.Body, nil) 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /openstack/cdn/v1/flavors/urls.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("flavors") 7 | } 8 | 9 | func getURL(c *gophercloud.ServiceClient, id string) string { 10 | return c.ServiceURL("flavors", id) 11 | } 12 | -------------------------------------------------------------------------------- /openstack/cdn/v1/serviceassets/doc.go: -------------------------------------------------------------------------------- 1 | // Package serviceassets provides information and interaction with the 2 | // serviceassets API resource in the OpenStack CDN service. This API resource 3 | // allows for deleting cached assets. 4 | // 5 | // A service distributes assets across the network. Service assets let you 6 | // interrogate properties about these assets and perform certain actions on them. 7 | package serviceassets 8 | -------------------------------------------------------------------------------- /openstack/cdn/v1/serviceassets/fixtures.go: -------------------------------------------------------------------------------- 1 | // +build fixtures 2 | 3 | package serviceassets 4 | 5 | import ( 6 | "net/http" 7 | "testing" 8 | 9 | th "github.com/rackspace/gophercloud/testhelper" 10 | fake "github.com/rackspace/gophercloud/testhelper/client" 11 | ) 12 | 13 | // HandleDeleteCDNAssetSuccessfully creates an HTTP handler at `/services/{id}/assets` on the test handler mux 14 | // that responds with a `Delete` response. 15 | func HandleDeleteCDNAssetSuccessfully(t *testing.T) { 16 | th.Mux.HandleFunc("/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0/assets", func(w http.ResponseWriter, r *http.Request) { 17 | th.TestMethod(t, r, "DELETE") 18 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 19 | w.WriteHeader(http.StatusAccepted) 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /openstack/cdn/v1/serviceassets/requests_test.go: -------------------------------------------------------------------------------- 1 | package serviceassets 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | fake "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestDelete(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | 14 | HandleDeleteCDNAssetSuccessfully(t) 15 | 16 | err := Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", nil).ExtractErr() 17 | th.AssertNoErr(t, err) 18 | } 19 | -------------------------------------------------------------------------------- /openstack/cdn/v1/serviceassets/results.go: -------------------------------------------------------------------------------- 1 | package serviceassets 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | // DeleteResult represents the result of a Delete operation. 6 | type DeleteResult struct { 7 | gophercloud.ErrResult 8 | } 9 | -------------------------------------------------------------------------------- /openstack/cdn/v1/serviceassets/urls.go: -------------------------------------------------------------------------------- 1 | package serviceassets 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 6 | return c.ServiceURL("services", id, "assets") 7 | } 8 | -------------------------------------------------------------------------------- /openstack/cdn/v1/services/doc.go: -------------------------------------------------------------------------------- 1 | // Package services provides information and interaction with the services API 2 | // resource in the OpenStack CDN service. This API resource allows for 3 | // listing, creating, updating, retrieving, and deleting services. 4 | // 5 | // A service represents an application that has its content cached to the edge 6 | // nodes. 7 | package services 8 | -------------------------------------------------------------------------------- /openstack/cdn/v1/services/errors.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import "fmt" 4 | 5 | func no(str string) error { 6 | return fmt.Errorf("Required parameter %s not provided", str) 7 | } 8 | -------------------------------------------------------------------------------- /openstack/cdn/v1/services/urls.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("services") 7 | } 8 | 9 | func createURL(c *gophercloud.ServiceClient) string { 10 | return listURL(c) 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, id string) string { 14 | return c.ServiceURL("services", id) 15 | } 16 | 17 | func updateURL(c *gophercloud.ServiceClient, id string) string { 18 | return getURL(c, id) 19 | } 20 | 21 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 22 | return getURL(c, id) 23 | } 24 | -------------------------------------------------------------------------------- /openstack/common/README.md: -------------------------------------------------------------------------------- 1 | # Common Resources 2 | 3 | This directory is for resources that are shared by multiple services. 4 | -------------------------------------------------------------------------------- /openstack/common/extensions/doc.go: -------------------------------------------------------------------------------- 1 | // Package extensions provides information and interaction with the different extensions available 2 | // for an OpenStack service. 3 | // 4 | // The purpose of OpenStack API extensions is to: 5 | // 6 | // - Introduce new features in the API without requiring a version change. 7 | // - Introduce vendor-specific niche functionality. 8 | // - Act as a proving ground for experimental functionalities that might be included in a future 9 | // version of the API. 10 | // 11 | // Extensions usually have tags that prevent conflicts with other extensions that define attributes 12 | // or resources with the same names, and with core resources and attributes. 13 | // Because an extension might not be supported by all plug-ins, its availability varies with deployments 14 | // and the specific plug-in. 15 | package extensions 16 | -------------------------------------------------------------------------------- /openstack/common/extensions/errors.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | -------------------------------------------------------------------------------- /openstack/common/extensions/requests.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // Get retrieves information for a specific extension using its alias. 9 | func Get(c *gophercloud.ServiceClient, alias string) GetResult { 10 | var res GetResult 11 | _, res.Err = c.Get(ExtensionURL(c, alias), &res.Body, nil) 12 | return res 13 | } 14 | 15 | // List returns a Pager which allows you to iterate over the full collection of extensions. 16 | // It does not accept query parameters. 17 | func List(c *gophercloud.ServiceClient) pagination.Pager { 18 | return pagination.NewPager(c, ListExtensionURL(c), func(r pagination.PageResult) pagination.Page { 19 | return ExtensionPage{pagination.SinglePageBase(r)} 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /openstack/common/extensions/requests_test.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud/pagination" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestList(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | HandleListExtensionsSuccessfully(t) 15 | 16 | count := 0 17 | 18 | List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { 19 | count++ 20 | actual, err := ExtractExtensions(page) 21 | th.AssertNoErr(t, err) 22 | th.AssertDeepEquals(t, ExpectedExtensions, actual) 23 | 24 | return true, nil 25 | }) 26 | 27 | th.CheckEquals(t, 1, count) 28 | } 29 | 30 | func TestGet(t *testing.T) { 31 | th.SetupHTTP() 32 | defer th.TeardownHTTP() 33 | HandleGetExtensionSuccessfully(t) 34 | 35 | actual, err := Get(client.ServiceClient(), "agent").Extract() 36 | th.AssertNoErr(t, err) 37 | th.CheckDeepEquals(t, SingleExtension, actual) 38 | } 39 | -------------------------------------------------------------------------------- /openstack/common/extensions/urls.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | // ExtensionURL generates the URL for an extension resource by name. 6 | func ExtensionURL(c *gophercloud.ServiceClient, name string) string { 7 | return c.ServiceURL("extensions", name) 8 | } 9 | 10 | // ListExtensionURL generates the URL for the extensions resource collection. 11 | func ListExtensionURL(c *gophercloud.ServiceClient) string { 12 | return c.ServiceURL("extensions") 13 | } 14 | -------------------------------------------------------------------------------- /openstack/common/extensions/urls_test.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestExtensionURL(t *testing.T) { 17 | actual := ExtensionURL(endpointClient(), "agent") 18 | expected := endpoint + "extensions/agent" 19 | th.AssertEquals(t, expected, actual) 20 | } 21 | 22 | func TestListExtensionURL(t *testing.T) { 23 | actual := ListExtensionURL(endpointClient()) 24 | expected := endpoint + "extensions" 25 | th.AssertEquals(t, expected, actual) 26 | } 27 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/adminactions/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package provides access to the "Admin Actions" of the Compute API, 3 | including migrations, live-migrations, reset-state, etc. 4 | */ 5 | package adminactions 6 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/bootfromvolume/results.go: -------------------------------------------------------------------------------- 1 | package bootfromvolume 2 | 3 | import ( 4 | os "github.com/rackspace/gophercloud/openstack/compute/v2/servers" 5 | ) 6 | 7 | // CreateResult temporarily contains the response from a Create call. 8 | type CreateResult struct { 9 | os.CreateResult 10 | } 11 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/bootfromvolume/urls.go: -------------------------------------------------------------------------------- 1 | package bootfromvolume 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func createURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("os-volumes_boot") 7 | } 8 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/bootfromvolume/urls_test.go: -------------------------------------------------------------------------------- 1 | package bootfromvolume 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestCreateURL(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | c := client.ServiceClient() 14 | 15 | th.CheckEquals(t, c.Endpoint+"os-volumes_boot", createURL(c)) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/defsecrules/doc.go: -------------------------------------------------------------------------------- 1 | package defsecrules 2 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/defsecrules/urls.go: -------------------------------------------------------------------------------- 1 | package defsecrules 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const rulepath = "os-security-group-default-rules" 6 | 7 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 8 | return c.ServiceURL(rulepath, id) 9 | } 10 | 11 | func rootURL(c *gophercloud.ServiceClient) string { 12 | return c.ServiceURL(rulepath) 13 | } 14 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/delegate.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | common "github.com/rackspace/gophercloud/openstack/common/extensions" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | // ExtractExtensions interprets a Page as a slice of Extensions. 10 | func ExtractExtensions(page pagination.Page) ([]common.Extension, error) { 11 | return common.ExtractExtensions(page) 12 | } 13 | 14 | // Get retrieves information for a specific extension using its alias. 15 | func Get(c *gophercloud.ServiceClient, alias string) common.GetResult { 16 | return common.Get(c, alias) 17 | } 18 | 19 | // List returns a Pager which allows you to iterate over the full collection of extensions. 20 | // It does not accept query parameters. 21 | func List(c *gophercloud.ServiceClient) pagination.Pager { 22 | return common.List(c) 23 | } 24 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/diskconfig/doc.go: -------------------------------------------------------------------------------- 1 | // Package diskconfig provides information and interaction with the Disk 2 | // Config extension that works with the OpenStack Compute service. 3 | package diskconfig 4 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/doc.go: -------------------------------------------------------------------------------- 1 | // Package extensions provides information and interaction with the 2 | // different extensions available for the OpenStack Compute service. 3 | package extensions 4 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/floatingip/doc.go: -------------------------------------------------------------------------------- 1 | // Package floatingip provides the ability to manage floating ips through 2 | // nova-network 3 | package floatingip 4 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/floatingip/urls.go: -------------------------------------------------------------------------------- 1 | package floatingip 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "os-floating-ips" 6 | 7 | func resourceURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(resourcePath) 9 | } 10 | 11 | func listURL(c *gophercloud.ServiceClient) string { 12 | return resourceURL(c) 13 | } 14 | 15 | func createURL(c *gophercloud.ServiceClient) string { 16 | return resourceURL(c) 17 | } 18 | 19 | func getURL(c *gophercloud.ServiceClient, id string) string { 20 | return c.ServiceURL(resourcePath, id) 21 | } 22 | 23 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 24 | return getURL(c, id) 25 | } 26 | 27 | func serverURL(c *gophercloud.ServiceClient, serverId string) string { 28 | return c.ServiceURL("servers/" + serverId + "/action") 29 | } 30 | 31 | func associateURL(c *gophercloud.ServiceClient, serverId string) string { 32 | return serverURL(c, serverId) 33 | } 34 | 35 | func disassociateURL(c *gophercloud.ServiceClient, serverId string) string { 36 | return serverURL(c, serverId) 37 | } 38 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/keypairs/doc.go: -------------------------------------------------------------------------------- 1 | // Package keypairs provides information and interaction with the Keypairs 2 | // extension for the OpenStack Compute service. 3 | package keypairs 4 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/keypairs/urls.go: -------------------------------------------------------------------------------- 1 | package keypairs 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "os-keypairs" 6 | 7 | func resourceURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(resourcePath) 9 | } 10 | 11 | func listURL(c *gophercloud.ServiceClient) string { 12 | return resourceURL(c) 13 | } 14 | 15 | func createURL(c *gophercloud.ServiceClient) string { 16 | return resourceURL(c) 17 | } 18 | 19 | func getURL(c *gophercloud.ServiceClient, name string) string { 20 | return c.ServiceURL(resourcePath, name) 21 | } 22 | 23 | func deleteURL(c *gophercloud.ServiceClient, name string) string { 24 | return getURL(c, name) 25 | } 26 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/keypairs/urls_test.go: -------------------------------------------------------------------------------- 1 | package keypairs 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestListURL(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | c := client.ServiceClient() 14 | 15 | th.CheckEquals(t, c.Endpoint+"os-keypairs", listURL(c)) 16 | } 17 | 18 | func TestCreateURL(t *testing.T) { 19 | th.SetupHTTP() 20 | defer th.TeardownHTTP() 21 | c := client.ServiceClient() 22 | 23 | th.CheckEquals(t, c.Endpoint+"os-keypairs", createURL(c)) 24 | } 25 | 26 | func TestGetURL(t *testing.T) { 27 | th.SetupHTTP() 28 | defer th.TeardownHTTP() 29 | c := client.ServiceClient() 30 | 31 | th.CheckEquals(t, c.Endpoint+"os-keypairs/wat", getURL(c, "wat")) 32 | } 33 | 34 | func TestDeleteURL(t *testing.T) { 35 | th.SetupHTTP() 36 | defer th.TeardownHTTP() 37 | c := client.ServiceClient() 38 | 39 | th.CheckEquals(t, c.Endpoint+"os-keypairs/wat", deleteURL(c, "wat")) 40 | } 41 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/networks/doc.go: -------------------------------------------------------------------------------- 1 | // Package network provides the ability to manage nova-networks 2 | package networks 3 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/networks/requests.go: -------------------------------------------------------------------------------- 1 | package networks 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // List returns a Pager that allows you to iterate over a collection of Network. 9 | func List(client *gophercloud.ServiceClient) pagination.Pager { 10 | url := listURL(client) 11 | createPage := func(r pagination.PageResult) pagination.Page { 12 | return NetworkPage{pagination.SinglePageBase(r)} 13 | } 14 | return pagination.NewPager(client, url, createPage) 15 | } 16 | 17 | // Get returns data about a previously created Network. 18 | func Get(client *gophercloud.ServiceClient, id string) GetResult { 19 | var res GetResult 20 | _, res.Err = client.Get(getURL(client, id), &res.Body, nil) 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/networks/requests_test.go: -------------------------------------------------------------------------------- 1 | package networks 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud/pagination" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestList(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | HandleListSuccessfully(t) 15 | 16 | count := 0 17 | err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { 18 | count++ 19 | actual, err := ExtractNetworks(page) 20 | th.AssertNoErr(t, err) 21 | th.CheckDeepEquals(t, ExpectedNetworkSlice, actual) 22 | 23 | return true, nil 24 | }) 25 | th.AssertNoErr(t, err) 26 | th.CheckEquals(t, 1, count) 27 | } 28 | 29 | func TestGet(t *testing.T) { 30 | th.SetupHTTP() 31 | defer th.TeardownHTTP() 32 | HandleGetSuccessfully(t) 33 | 34 | actual, err := Get(client.ServiceClient(), "20c8acc0-f747-4d71-a389-46d078ebf000").Extract() 35 | th.AssertNoErr(t, err) 36 | th.CheckDeepEquals(t, &SecondNetwork, actual) 37 | } 38 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/networks/urls.go: -------------------------------------------------------------------------------- 1 | package networks 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "os-networks" 6 | 7 | func resourceURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(resourcePath) 9 | } 10 | 11 | func listURL(c *gophercloud.ServiceClient) string { 12 | return resourceURL(c) 13 | } 14 | 15 | func getURL(c *gophercloud.ServiceClient, id string) string { 16 | return c.ServiceURL(resourcePath, id) 17 | } 18 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/networks/urls_test.go: -------------------------------------------------------------------------------- 1 | package networks 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestListURL(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | c := client.ServiceClient() 14 | 15 | th.CheckEquals(t, c.Endpoint+"os-networks", listURL(c)) 16 | } 17 | 18 | func TestGetURL(t *testing.T) { 19 | th.SetupHTTP() 20 | defer th.TeardownHTTP() 21 | c := client.ServiceClient() 22 | id := "1" 23 | 24 | th.CheckEquals(t, c.Endpoint+"os-networks/"+id, getURL(c, id)) 25 | } 26 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/quotasets/doc.go: -------------------------------------------------------------------------------- 1 | // Package quotasets provides information and interaction with QuotaSet 2 | // extension for the OpenStack Compute service. 3 | package quotasets 4 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/quotasets/requests.go: -------------------------------------------------------------------------------- 1 | package quotasets 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | ) 6 | 7 | // Get returns public data about a previously created QuotaSet. 8 | func Get(client *gophercloud.ServiceClient, tenantID string) GetResult { 9 | var res GetResult 10 | _, res.Err = client.Get(getURL(client, tenantID), &res.Body, nil) 11 | return res 12 | } 13 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/quotasets/requests_test.go: -------------------------------------------------------------------------------- 1 | package quotasets 2 | 3 | import ( 4 | th "github.com/rackspace/gophercloud/testhelper" 5 | "github.com/rackspace/gophercloud/testhelper/client" 6 | "testing" 7 | ) 8 | 9 | func TestGet(t *testing.T) { 10 | th.SetupHTTP() 11 | defer th.TeardownHTTP() 12 | HandleGetSuccessfully(t) 13 | actual, err := Get(client.ServiceClient(), FirstTenantID).Extract() 14 | th.AssertNoErr(t, err) 15 | th.CheckDeepEquals(t, &FirstQuotaSet, actual) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/quotasets/urls.go: -------------------------------------------------------------------------------- 1 | package quotasets 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "os-quota-sets" 6 | 7 | func resourceURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(resourcePath) 9 | } 10 | 11 | func getURL(c *gophercloud.ServiceClient, tenantID string) string { 12 | return c.ServiceURL(resourcePath, tenantID) 13 | } 14 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/quotasets/urls_test.go: -------------------------------------------------------------------------------- 1 | package quotasets 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestGetURL(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | c := client.ServiceClient() 14 | 15 | th.CheckEquals(t, c.Endpoint+"os-quota-sets/wat", getURL(c, "wat")) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/schedulerhints/doc.go: -------------------------------------------------------------------------------- 1 | // Package schedulerhints enables instances to provide the OpenStack scheduler 2 | // hints about where they should be placed in the cloud. 3 | package schedulerhints 4 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/secgroups/doc.go: -------------------------------------------------------------------------------- 1 | package secgroups 2 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/secgroups/urls.go: -------------------------------------------------------------------------------- 1 | package secgroups 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | secgrouppath = "os-security-groups" 7 | rulepath = "os-security-group-rules" 8 | ) 9 | 10 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 11 | return c.ServiceURL(secgrouppath, id) 12 | } 13 | 14 | func rootURL(c *gophercloud.ServiceClient) string { 15 | return c.ServiceURL(secgrouppath) 16 | } 17 | 18 | func listByServerURL(c *gophercloud.ServiceClient, serverID string) string { 19 | return c.ServiceURL("servers", serverID, secgrouppath) 20 | } 21 | 22 | func rootRuleURL(c *gophercloud.ServiceClient) string { 23 | return c.ServiceURL(rulepath) 24 | } 25 | 26 | func resourceRuleURL(c *gophercloud.ServiceClient, id string) string { 27 | return c.ServiceURL(rulepath, id) 28 | } 29 | 30 | func serverActionURL(c *gophercloud.ServiceClient, id string) string { 31 | return c.ServiceURL("servers", id, "action") 32 | } 33 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/servergroups/doc.go: -------------------------------------------------------------------------------- 1 | // Package servergroups provides the ability to manage server groups 2 | package servergroups 3 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/servergroups/urls.go: -------------------------------------------------------------------------------- 1 | package servergroups 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "os-server-groups" 6 | 7 | func resourceURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(resourcePath) 9 | } 10 | 11 | func listURL(c *gophercloud.ServiceClient) string { 12 | return resourceURL(c) 13 | } 14 | 15 | func createURL(c *gophercloud.ServiceClient) string { 16 | return resourceURL(c) 17 | } 18 | 19 | func getURL(c *gophercloud.ServiceClient, id string) string { 20 | return c.ServiceURL(resourcePath, id) 21 | } 22 | 23 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 24 | return getURL(c, id) 25 | } 26 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/servergroups/urls_test.go: -------------------------------------------------------------------------------- 1 | package servergroups 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestListURL(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | c := client.ServiceClient() 14 | 15 | th.CheckEquals(t, c.Endpoint+"os-server-groups", listURL(c)) 16 | } 17 | 18 | func TestCreateURL(t *testing.T) { 19 | th.SetupHTTP() 20 | defer th.TeardownHTTP() 21 | c := client.ServiceClient() 22 | 23 | th.CheckEquals(t, c.Endpoint+"os-server-groups", createURL(c)) 24 | } 25 | 26 | func TestGetURL(t *testing.T) { 27 | th.SetupHTTP() 28 | defer th.TeardownHTTP() 29 | c := client.ServiceClient() 30 | id := "1" 31 | 32 | th.CheckEquals(t, c.Endpoint+"os-server-groups/"+id, getURL(c, id)) 33 | } 34 | 35 | func TestDeleteURL(t *testing.T) { 36 | th.SetupHTTP() 37 | defer th.TeardownHTTP() 38 | c := client.ServiceClient() 39 | id := "1" 40 | 41 | th.CheckEquals(t, c.Endpoint+"os-server-groups/"+id, deleteURL(c, id)) 42 | } 43 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/startstop/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package startstop provides functionality to start and stop servers that have 3 | been provisioned by the OpenStack Compute service. 4 | */ 5 | package startstop 6 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/startstop/fixtures.go: -------------------------------------------------------------------------------- 1 | // +build fixtures 2 | 3 | package startstop 4 | 5 | import ( 6 | "net/http" 7 | "testing" 8 | 9 | th "github.com/rackspace/gophercloud/testhelper" 10 | "github.com/rackspace/gophercloud/testhelper/client" 11 | ) 12 | 13 | func mockStartServerResponse(t *testing.T, id string) { 14 | th.Mux.HandleFunc("/servers/"+id+"/action", func(w http.ResponseWriter, r *http.Request) { 15 | th.TestMethod(t, r, "POST") 16 | th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 17 | th.TestJSONRequest(t, r, `{"os-start": null}`) 18 | w.WriteHeader(http.StatusAccepted) 19 | }) 20 | } 21 | 22 | func mockStopServerResponse(t *testing.T, id string) { 23 | th.Mux.HandleFunc("/servers/"+id+"/action", func(w http.ResponseWriter, r *http.Request) { 24 | th.TestMethod(t, r, "POST") 25 | th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 26 | th.TestJSONRequest(t, r, `{"os-stop": null}`) 27 | w.WriteHeader(http.StatusAccepted) 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/startstop/requests.go: -------------------------------------------------------------------------------- 1 | package startstop 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func actionURL(client *gophercloud.ServiceClient, id string) string { 6 | return client.ServiceURL("servers", id, "action") 7 | } 8 | 9 | // Start is the operation responsible for starting a Compute server. 10 | func Start(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { 11 | var res gophercloud.ErrResult 12 | reqBody := map[string]interface{}{"os-start": nil} 13 | _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil) 14 | return res 15 | } 16 | 17 | // Stop is the operation responsible for stopping a Compute server. 18 | func Stop(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { 19 | var res gophercloud.ErrResult 20 | reqBody := map[string]interface{}{"os-stop": nil} 21 | _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil) 22 | return res 23 | } 24 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/startstop/requests_test.go: -------------------------------------------------------------------------------- 1 | package startstop 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | const serverID = "{serverId}" 11 | 12 | func TestStart(t *testing.T) { 13 | th.SetupHTTP() 14 | defer th.TeardownHTTP() 15 | 16 | mockStartServerResponse(t, serverID) 17 | 18 | err := Start(client.ServiceClient(), serverID).ExtractErr() 19 | th.AssertNoErr(t, err) 20 | } 21 | 22 | func TestStop(t *testing.T) { 23 | th.SetupHTTP() 24 | defer th.TeardownHTTP() 25 | 26 | mockStopServerResponse(t, serverID) 27 | 28 | err := Stop(client.ServiceClient(), serverID).ExtractErr() 29 | th.AssertNoErr(t, err) 30 | } 31 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/tenantnetworks/doc.go: -------------------------------------------------------------------------------- 1 | // Package tenantnetworks provides the ability for tenants to see information about the networks they have access to 2 | package tenantnetworks 3 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/tenantnetworks/requests.go: -------------------------------------------------------------------------------- 1 | package tenantnetworks 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // List returns a Pager that allows you to iterate over a collection of Network. 9 | func List(client *gophercloud.ServiceClient) pagination.Pager { 10 | url := listURL(client) 11 | createPage := func(r pagination.PageResult) pagination.Page { 12 | return NetworkPage{pagination.SinglePageBase(r)} 13 | } 14 | return pagination.NewPager(client, url, createPage) 15 | } 16 | 17 | // Get returns data about a previously created Network. 18 | func Get(client *gophercloud.ServiceClient, id string) GetResult { 19 | var res GetResult 20 | _, res.Err = client.Get(getURL(client, id), &res.Body, nil) 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/tenantnetworks/requests_test.go: -------------------------------------------------------------------------------- 1 | package tenantnetworks 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud/pagination" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestList(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | HandleListSuccessfully(t) 15 | 16 | count := 0 17 | err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { 18 | count++ 19 | actual, err := ExtractNetworks(page) 20 | th.AssertNoErr(t, err) 21 | th.CheckDeepEquals(t, ExpectedNetworkSlice, actual) 22 | 23 | return true, nil 24 | }) 25 | th.AssertNoErr(t, err) 26 | th.CheckEquals(t, 1, count) 27 | } 28 | 29 | func TestGet(t *testing.T) { 30 | th.SetupHTTP() 31 | defer th.TeardownHTTP() 32 | HandleGetSuccessfully(t) 33 | 34 | actual, err := Get(client.ServiceClient(), "20c8acc0-f747-4d71-a389-46d078ebf000").Extract() 35 | th.AssertNoErr(t, err) 36 | th.CheckDeepEquals(t, &SecondNetwork, actual) 37 | } 38 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/tenantnetworks/urls.go: -------------------------------------------------------------------------------- 1 | package tenantnetworks 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "os-tenant-networks" 6 | 7 | func resourceURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(resourcePath) 9 | } 10 | 11 | func listURL(c *gophercloud.ServiceClient) string { 12 | return resourceURL(c) 13 | } 14 | 15 | func getURL(c *gophercloud.ServiceClient, id string) string { 16 | return c.ServiceURL(resourcePath, id) 17 | } 18 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/tenantnetworks/urls_test.go: -------------------------------------------------------------------------------- 1 | package tenantnetworks 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestListURL(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | c := client.ServiceClient() 14 | 15 | th.CheckEquals(t, c.Endpoint+"os-tenant-networks", listURL(c)) 16 | } 17 | 18 | func TestGetURL(t *testing.T) { 19 | th.SetupHTTP() 20 | defer th.TeardownHTTP() 21 | c := client.ServiceClient() 22 | id := "1" 23 | 24 | th.CheckEquals(t, c.Endpoint+"os-tenant-networks/"+id, getURL(c, id)) 25 | } 26 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/volumeattach/doc.go: -------------------------------------------------------------------------------- 1 | // Package volumeattach provides the ability to attach and detach volumes 2 | // to instances 3 | package volumeattach 4 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/volumeattach/testing/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | This is package created is to hold fixtures (which imports testing), 3 | so that importing volumeattach package does not inadvertently import testing into production code 4 | More information here: 5 | https://github.com/rackspace/gophercloud/issues/473 6 | */ 7 | package testing 8 | -------------------------------------------------------------------------------- /openstack/compute/v2/extensions/volumeattach/urls.go: -------------------------------------------------------------------------------- 1 | package volumeattach 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "os-volume_attachments" 6 | 7 | func resourceURL(c *gophercloud.ServiceClient, serverId string) string { 8 | return c.ServiceURL("servers", serverId, resourcePath) 9 | } 10 | 11 | func listURL(c *gophercloud.ServiceClient, serverId string) string { 12 | return resourceURL(c, serverId) 13 | } 14 | 15 | func createURL(c *gophercloud.ServiceClient, serverId string) string { 16 | return resourceURL(c, serverId) 17 | } 18 | 19 | func getURL(c *gophercloud.ServiceClient, serverId, aId string) string { 20 | return c.ServiceURL("servers", serverId, resourcePath, aId) 21 | } 22 | 23 | func deleteURL(c *gophercloud.ServiceClient, serverId, aId string) string { 24 | return getURL(c, serverId, aId) 25 | } 26 | -------------------------------------------------------------------------------- /openstack/compute/v2/flavors/doc.go: -------------------------------------------------------------------------------- 1 | // Package flavors provides information and interaction with the flavor API 2 | // resource in the OpenStack Compute service. 3 | // 4 | // A flavor is an available hardware configuration for a server. Each flavor 5 | // has a unique combination of disk space, memory capacity and priority for CPU 6 | // time. 7 | package flavors 8 | -------------------------------------------------------------------------------- /openstack/compute/v2/flavors/urls.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | ) 6 | 7 | func getURL(client *gophercloud.ServiceClient, id string) string { 8 | return client.ServiceURL("flavors", id) 9 | } 10 | 11 | func listURL(client *gophercloud.ServiceClient) string { 12 | return client.ServiceURL("flavors", "detail") 13 | } 14 | -------------------------------------------------------------------------------- /openstack/compute/v2/flavors/urls_test.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestGetURL(t *testing.T) { 17 | actual := getURL(endpointClient(), "foo") 18 | expected := endpoint + "flavors/foo" 19 | th.CheckEquals(t, expected, actual) 20 | } 21 | 22 | func TestListURL(t *testing.T) { 23 | actual := listURL(endpointClient()) 24 | expected := endpoint + "flavors/detail" 25 | th.CheckEquals(t, expected, actual) 26 | } 27 | -------------------------------------------------------------------------------- /openstack/compute/v2/images/doc.go: -------------------------------------------------------------------------------- 1 | // Package images provides information and interaction with the image API 2 | // resource in the OpenStack Compute service. 3 | // 4 | // An image is a collection of files used to create or rebuild a server. 5 | // Operators provide a number of pre-built OS images by default. You may also 6 | // create custom images from cloud servers you have launched. 7 | package images 8 | -------------------------------------------------------------------------------- /openstack/compute/v2/images/urls.go: -------------------------------------------------------------------------------- 1 | package images 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listDetailURL(client *gophercloud.ServiceClient) string { 6 | return client.ServiceURL("images", "detail") 7 | } 8 | 9 | func getURL(client *gophercloud.ServiceClient, id string) string { 10 | return client.ServiceURL("images", id) 11 | } 12 | 13 | func deleteURL(client *gophercloud.ServiceClient, id string) string { 14 | return client.ServiceURL("images", id) 15 | } 16 | -------------------------------------------------------------------------------- /openstack/compute/v2/images/urls_test.go: -------------------------------------------------------------------------------- 1 | package images 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestGetURL(t *testing.T) { 17 | actual := getURL(endpointClient(), "foo") 18 | expected := endpoint + "images/foo" 19 | th.CheckEquals(t, expected, actual) 20 | } 21 | 22 | func TestListDetailURL(t *testing.T) { 23 | actual := listDetailURL(endpointClient()) 24 | expected := endpoint + "images/detail" 25 | th.CheckEquals(t, expected, actual) 26 | } 27 | -------------------------------------------------------------------------------- /openstack/compute/v2/servers/doc.go: -------------------------------------------------------------------------------- 1 | // Package servers provides information and interaction with the server API 2 | // resource in the OpenStack Compute service. 3 | // 4 | // A server is a virtual machine instance in the compute system. In order for 5 | // one to be provisioned, a valid flavor and image are required. 6 | package servers 7 | -------------------------------------------------------------------------------- /openstack/compute/v2/servers/util.go: -------------------------------------------------------------------------------- 1 | package servers 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | // WaitForStatus will continually poll a server until it successfully transitions to a specified 6 | // status. It will do this for at most the number of seconds specified. 7 | func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { 8 | return gophercloud.WaitFor(secs, func() (bool, error) { 9 | current, err := Get(c, id).Extract() 10 | if err != nil { 11 | return false, err 12 | } 13 | 14 | if current.Status == status { 15 | return true, nil 16 | } 17 | 18 | return false, nil 19 | }) 20 | } 21 | -------------------------------------------------------------------------------- /openstack/db/v1/configurations/doc.go: -------------------------------------------------------------------------------- 1 | // Package configurations provides information and interaction with the 2 | // configuration API resource in the Rackspace Database service. 3 | // 4 | // A configuration group is a collection of key/value pairs which define how a 5 | // particular database operates. These key/value pairs are specific to each 6 | // datastore type and serve like settings. Some directives are capable of being 7 | // applied dynamically, while other directives require a server restart to take 8 | // effect. The configuration group can be applied to an instance at creation or 9 | // applied to an existing instance to modify the behavior of the running 10 | // datastore on the instance. 11 | package configurations 12 | -------------------------------------------------------------------------------- /openstack/db/v1/databases/doc.go: -------------------------------------------------------------------------------- 1 | // Package flavors provides information and interaction with the database API 2 | // resource in the OpenStack Database service. 3 | // 4 | // A database, when referred to here, refers to the database engine running on 5 | // an instance. 6 | package databases 7 | -------------------------------------------------------------------------------- /openstack/db/v1/databases/urls.go: -------------------------------------------------------------------------------- 1 | package databases 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func baseURL(c *gophercloud.ServiceClient, instanceID string) string { 6 | return c.ServiceURL("instances", instanceID, "databases") 7 | } 8 | 9 | func dbURL(c *gophercloud.ServiceClient, instanceID, dbName string) string { 10 | return c.ServiceURL("instances", instanceID, "databases", dbName) 11 | } 12 | -------------------------------------------------------------------------------- /openstack/db/v1/datastores/doc.go: -------------------------------------------------------------------------------- 1 | // Package datastores provides information and interaction with the datastore 2 | // API resource in the Rackspace Database service. 3 | package datastores 4 | -------------------------------------------------------------------------------- /openstack/db/v1/datastores/urls.go: -------------------------------------------------------------------------------- 1 | package datastores 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func baseURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("datastores") 7 | } 8 | 9 | func resourceURL(c *gophercloud.ServiceClient, dsID string) string { 10 | return c.ServiceURL("datastores", dsID) 11 | } 12 | 13 | func versionsURL(c *gophercloud.ServiceClient, dsID string) string { 14 | return c.ServiceURL("datastores", dsID, "versions") 15 | } 16 | 17 | func versionURL(c *gophercloud.ServiceClient, dsID, versionID string) string { 18 | return c.ServiceURL("datastores", dsID, "versions", versionID) 19 | } 20 | -------------------------------------------------------------------------------- /openstack/db/v1/flavors/doc.go: -------------------------------------------------------------------------------- 1 | // Package flavors provides information and interaction with the flavor API 2 | // resource in the OpenStack Database service. 3 | // 4 | // A flavor is an available hardware configuration for a database instance. 5 | // Each flavor has a unique combination of disk space, memory capacity and 6 | // priority for CPU time. 7 | package flavors 8 | -------------------------------------------------------------------------------- /openstack/db/v1/flavors/requests.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // List will list all available hardware flavors that an instance can use. The 9 | // operation is identical to the one supported by the Nova API, but without the 10 | // "disk" property. 11 | func List(client *gophercloud.ServiceClient) pagination.Pager { 12 | createPage := func(r pagination.PageResult) pagination.Page { 13 | return FlavorPage{pagination.LinkedPageBase{PageResult: r}} 14 | } 15 | 16 | return pagination.NewPager(client, listURL(client), createPage) 17 | } 18 | 19 | // Get will retrieve information for a specified hardware flavor. 20 | func Get(client *gophercloud.ServiceClient, id string) GetResult { 21 | var gr GetResult 22 | 23 | _, gr.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{ 24 | JSONResponse: &gr.Body, 25 | OkCodes: []int{200}, 26 | }) 27 | 28 | return gr 29 | } 30 | -------------------------------------------------------------------------------- /openstack/db/v1/flavors/urls.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func getURL(client *gophercloud.ServiceClient, id string) string { 6 | return client.ServiceURL("flavors", id) 7 | } 8 | 9 | func listURL(client *gophercloud.ServiceClient) string { 10 | return client.ServiceURL("flavors") 11 | } 12 | -------------------------------------------------------------------------------- /openstack/db/v1/instances/doc.go: -------------------------------------------------------------------------------- 1 | // Package instances provides information and interaction with the instance API 2 | // resource in the OpenStack Database service. 3 | // 4 | // A database instance is an isolated database environment with compute and 5 | // storage resources in a single tenant environment on a shared physical host 6 | // machine. 7 | package instances 8 | -------------------------------------------------------------------------------- /openstack/db/v1/instances/urls.go: -------------------------------------------------------------------------------- 1 | package instances 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func baseURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("instances") 7 | } 8 | 9 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 10 | return c.ServiceURL("instances", id) 11 | } 12 | 13 | func userRootURL(c *gophercloud.ServiceClient, id string) string { 14 | return c.ServiceURL("instances", id, "root") 15 | } 16 | 17 | func actionURL(c *gophercloud.ServiceClient, id string) string { 18 | return c.ServiceURL("instances", id, "action") 19 | } 20 | -------------------------------------------------------------------------------- /openstack/db/v1/users/doc.go: -------------------------------------------------------------------------------- 1 | // Package users provides information and interaction with the user API 2 | // resource in the OpenStack Database service. 3 | package users 4 | -------------------------------------------------------------------------------- /openstack/db/v1/users/urls.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func baseURL(c *gophercloud.ServiceClient, instanceID string) string { 6 | return c.ServiceURL("instances", instanceID, "users") 7 | } 8 | 9 | func userURL(c *gophercloud.ServiceClient, instanceID, userName string) string { 10 | return c.ServiceURL("instances", instanceID, "users", userName) 11 | } 12 | -------------------------------------------------------------------------------- /openstack/identity/v2/extensions/admin/roles/docs.go: -------------------------------------------------------------------------------- 1 | // Package roles provides functionality to interact with and control roles on 2 | // the API. 3 | // 4 | // A role represents a personality that a user can assume when performing a 5 | // specific set of operations. If a role includes a set of rights and 6 | // privileges, a user assuming that role inherits those rights and privileges. 7 | // 8 | // When a token is generated, the list of roles that user can assume is returned 9 | // back to them. Services that are being called by that user determine how they 10 | // interpret the set of roles a user has and to which operations or resources 11 | // each role grants access. 12 | // 13 | // It is up to individual services such as Compute or Image to assign meaning 14 | // to these roles. As far as the Identity service is concerned, a role is an 15 | // arbitrary name assigned by the user. 16 | package roles 17 | -------------------------------------------------------------------------------- /openstack/identity/v2/extensions/admin/roles/urls.go: -------------------------------------------------------------------------------- 1 | package roles 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | ExtPath = "OS-KSADM" 7 | RolePath = "roles" 8 | UserPath = "users" 9 | ) 10 | 11 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 12 | return c.ServiceURL(ExtPath, RolePath, id) 13 | } 14 | 15 | func rootURL(c *gophercloud.ServiceClient) string { 16 | return c.ServiceURL(ExtPath, RolePath) 17 | } 18 | 19 | func userRoleURL(c *gophercloud.ServiceClient, tenantID, userID, roleID string) string { 20 | return c.ServiceURL("tenants", tenantID, UserPath, userID, RolePath, ExtPath, roleID) 21 | } 22 | -------------------------------------------------------------------------------- /openstack/identity/v2/extensions/delegate_test.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | 3 | import ( 4 | "testing" 5 | 6 | common "github.com/rackspace/gophercloud/openstack/common/extensions" 7 | "github.com/rackspace/gophercloud/pagination" 8 | th "github.com/rackspace/gophercloud/testhelper" 9 | "github.com/rackspace/gophercloud/testhelper/client" 10 | ) 11 | 12 | func TestList(t *testing.T) { 13 | th.SetupHTTP() 14 | defer th.TeardownHTTP() 15 | HandleListExtensionsSuccessfully(t) 16 | 17 | count := 0 18 | err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { 19 | count++ 20 | actual, err := ExtractExtensions(page) 21 | th.AssertNoErr(t, err) 22 | th.CheckDeepEquals(t, common.ExpectedExtensions, actual) 23 | 24 | return true, nil 25 | }) 26 | th.AssertNoErr(t, err) 27 | th.CheckEquals(t, 1, count) 28 | } 29 | 30 | func TestGet(t *testing.T) { 31 | th.SetupHTTP() 32 | defer th.TeardownHTTP() 33 | common.HandleGetExtensionSuccessfully(t) 34 | 35 | actual, err := Get(client.ServiceClient(), "agent").Extract() 36 | th.AssertNoErr(t, err) 37 | th.CheckDeepEquals(t, common.SingleExtension, actual) 38 | } 39 | -------------------------------------------------------------------------------- /openstack/identity/v2/extensions/doc.go: -------------------------------------------------------------------------------- 1 | // Package extensions provides information and interaction with the 2 | // different extensions available for the OpenStack Identity service. 3 | package extensions 4 | -------------------------------------------------------------------------------- /openstack/identity/v2/tenants/doc.go: -------------------------------------------------------------------------------- 1 | // Package tenants provides information and interaction with the 2 | // tenants API resource for the OpenStack Identity service. 3 | // 4 | // See http://developer.openstack.org/api-ref-identity-v2.html#identity-auth-v2 5 | // and http://developer.openstack.org/api-ref-identity-v2.html#admin-tenants 6 | // for more information. 7 | package tenants 8 | -------------------------------------------------------------------------------- /openstack/identity/v2/tenants/requests.go: -------------------------------------------------------------------------------- 1 | package tenants 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // ListOpts filters the Tenants that are returned by the List call. 9 | type ListOpts struct { 10 | // Marker is the ID of the last Tenant on the previous page. 11 | Marker string `q:"marker"` 12 | 13 | // Limit specifies the page size. 14 | Limit int `q:"limit"` 15 | } 16 | 17 | // List enumerates the Tenants to which the current token has access. 18 | func List(client *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager { 19 | createPage := func(r pagination.PageResult) pagination.Page { 20 | return TenantPage{pagination.LinkedPageBase{PageResult: r}} 21 | } 22 | 23 | url := listURL(client) 24 | if opts != nil { 25 | q, err := gophercloud.BuildQueryString(opts) 26 | if err != nil { 27 | return pagination.Pager{Err: err} 28 | } 29 | url += q.String() 30 | } 31 | 32 | return pagination.NewPager(client, url, createPage) 33 | } 34 | -------------------------------------------------------------------------------- /openstack/identity/v2/tenants/requests_test.go: -------------------------------------------------------------------------------- 1 | package tenants 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud/pagination" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestListTenants(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | HandleListTenantsSuccessfully(t) 15 | 16 | count := 0 17 | err := List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) { 18 | count++ 19 | 20 | actual, err := ExtractTenants(page) 21 | th.AssertNoErr(t, err) 22 | 23 | th.CheckDeepEquals(t, ExpectedTenantSlice, actual) 24 | 25 | return true, nil 26 | }) 27 | th.AssertNoErr(t, err) 28 | th.CheckEquals(t, count, 1) 29 | } 30 | -------------------------------------------------------------------------------- /openstack/identity/v2/tenants/urls.go: -------------------------------------------------------------------------------- 1 | package tenants 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(client *gophercloud.ServiceClient) string { 6 | return client.ServiceURL("tenants") 7 | } 8 | -------------------------------------------------------------------------------- /openstack/identity/v2/tokens/doc.go: -------------------------------------------------------------------------------- 1 | // Package tokens provides information and interaction with the token API 2 | // resource for the OpenStack Identity service. 3 | // For more information, see: 4 | // http://developer.openstack.org/api-ref-identity-v2.html#identity-auth-v2 5 | package tokens 6 | -------------------------------------------------------------------------------- /openstack/identity/v2/tokens/urls.go: -------------------------------------------------------------------------------- 1 | package tokens 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | // CreateURL generates the URL used to create new Tokens. 6 | func CreateURL(client *gophercloud.ServiceClient) string { 7 | return client.ServiceURL("tokens") 8 | } 9 | 10 | // GetURL generates the URL used to Validate Tokens. 11 | func GetURL(client *gophercloud.ServiceClient, token string) string { 12 | return client.ServiceURL("tokens", token) 13 | } 14 | -------------------------------------------------------------------------------- /openstack/identity/v2/users/doc.go: -------------------------------------------------------------------------------- 1 | package users 2 | -------------------------------------------------------------------------------- /openstack/identity/v2/users/urls.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | tenantPath = "tenants" 7 | userPath = "users" 8 | rolePath = "roles" 9 | ) 10 | 11 | func ResourceURL(c *gophercloud.ServiceClient, id string) string { 12 | return c.ServiceURL(userPath, id) 13 | } 14 | 15 | func rootURL(c *gophercloud.ServiceClient) string { 16 | return c.ServiceURL(userPath) 17 | } 18 | 19 | func listRolesURL(c *gophercloud.ServiceClient, tenantID, userID string) string { 20 | return c.ServiceURL(tenantPath, tenantID, userPath, userID, rolePath) 21 | } 22 | -------------------------------------------------------------------------------- /openstack/identity/v3/endpoints/doc.go: -------------------------------------------------------------------------------- 1 | // Package endpoints provides information and interaction with the service 2 | // endpoints API resource in the OpenStack Identity service. 3 | // 4 | // For more information, see: 5 | // http://developer.openstack.org/api-ref-identity-v3.html#endpoints-v3 6 | package endpoints 7 | -------------------------------------------------------------------------------- /openstack/identity/v3/endpoints/errors.go: -------------------------------------------------------------------------------- 1 | package endpoints 2 | 3 | import "fmt" 4 | 5 | func requiredAttribute(attribute string) error { 6 | return fmt.Errorf("You must specify %s for this endpoint.", attribute) 7 | } 8 | 9 | var ( 10 | // ErrAvailabilityRequired is reported if an Endpoint is created without an Availability. 11 | ErrAvailabilityRequired = requiredAttribute("an availability") 12 | 13 | // ErrNameRequired is reported if an Endpoint is created without a Name. 14 | ErrNameRequired = requiredAttribute("a name") 15 | 16 | // ErrURLRequired is reported if an Endpoint is created without a URL. 17 | ErrURLRequired = requiredAttribute("a URL") 18 | 19 | // ErrServiceIDRequired is reported if an Endpoint is created without a ServiceID. 20 | ErrServiceIDRequired = requiredAttribute("a serviceID") 21 | ) 22 | -------------------------------------------------------------------------------- /openstack/identity/v3/endpoints/urls.go: -------------------------------------------------------------------------------- 1 | package endpoints 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(client *gophercloud.ServiceClient) string { 6 | return client.ServiceURL("endpoints") 7 | } 8 | 9 | func endpointURL(client *gophercloud.ServiceClient, endpointID string) string { 10 | return client.ServiceURL("endpoints", endpointID) 11 | } 12 | -------------------------------------------------------------------------------- /openstack/identity/v3/endpoints/urls_test.go: -------------------------------------------------------------------------------- 1 | package endpoints 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | func TestGetListURL(t *testing.T) { 10 | client := gophercloud.ServiceClient{Endpoint: "http://localhost:5000/v3/"} 11 | url := listURL(&client) 12 | if url != "http://localhost:5000/v3/endpoints" { 13 | t.Errorf("Unexpected list URL generated: [%s]", url) 14 | } 15 | } 16 | 17 | func TestGetEndpointURL(t *testing.T) { 18 | client := gophercloud.ServiceClient{Endpoint: "http://localhost:5000/v3/"} 19 | url := endpointURL(&client, "1234") 20 | if url != "http://localhost:5000/v3/endpoints/1234" { 21 | t.Errorf("Unexpected service URL generated: [%s]", url) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /openstack/identity/v3/extensions/doc.go: -------------------------------------------------------------------------------- 1 | // Package extensions provides information and interaction with the 2 | // different extensions available for the OpenStack Identity v3 service. 3 | package extensions 4 | -------------------------------------------------------------------------------- /openstack/identity/v3/roles/doc.go: -------------------------------------------------------------------------------- 1 | // Package roles provides information and interaction with the roles API 2 | // resource for the OpenStack Identity service. 3 | package roles 4 | -------------------------------------------------------------------------------- /openstack/identity/v3/roles/urls.go: -------------------------------------------------------------------------------- 1 | package roles 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listAssignmentsURL(client *gophercloud.ServiceClient) string { 6 | return client.ServiceURL("role_assignments") 7 | } 8 | -------------------------------------------------------------------------------- /openstack/identity/v3/roles/urls_test.go: -------------------------------------------------------------------------------- 1 | package roles 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | func TestListAssignmentsURL(t *testing.T) { 10 | client := gophercloud.ServiceClient{Endpoint: "http://localhost:5000/v3/"} 11 | url := listAssignmentsURL(&client) 12 | if url != "http://localhost:5000/v3/role_assignments" { 13 | t.Errorf("Unexpected list URL generated: [%s]", url) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /openstack/identity/v3/services/doc.go: -------------------------------------------------------------------------------- 1 | // Package services provides information and interaction with the services API 2 | // resource for the OpenStack Identity service. 3 | package services 4 | -------------------------------------------------------------------------------- /openstack/identity/v3/services/urls.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(client *gophercloud.ServiceClient) string { 6 | return client.ServiceURL("services") 7 | } 8 | 9 | func serviceURL(client *gophercloud.ServiceClient, serviceID string) string { 10 | return client.ServiceURL("services", serviceID) 11 | } 12 | -------------------------------------------------------------------------------- /openstack/identity/v3/services/urls_test.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | func TestListURL(t *testing.T) { 10 | client := gophercloud.ServiceClient{Endpoint: "http://localhost:5000/v3/"} 11 | url := listURL(&client) 12 | if url != "http://localhost:5000/v3/services" { 13 | t.Errorf("Unexpected list URL generated: [%s]", url) 14 | } 15 | } 16 | 17 | func TestServiceURL(t *testing.T) { 18 | client := gophercloud.ServiceClient{Endpoint: "http://localhost:5000/v3/"} 19 | url := serviceURL(&client, "1234") 20 | if url != "http://localhost:5000/v3/services/1234" { 21 | t.Errorf("Unexpected service URL generated: [%s]", url) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /openstack/identity/v3/tokens/doc.go: -------------------------------------------------------------------------------- 1 | // Package tokens provides information and interaction with the token API 2 | // resource for the OpenStack Identity service. 3 | // 4 | // For more information, see: 5 | // http://developer.openstack.org/api-ref-identity-v3.html#tokens-v3 6 | package tokens 7 | -------------------------------------------------------------------------------- /openstack/identity/v3/tokens/urls.go: -------------------------------------------------------------------------------- 1 | package tokens 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func tokenURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("auth", "tokens") 7 | } 8 | -------------------------------------------------------------------------------- /openstack/identity/v3/tokens/urls_test.go: -------------------------------------------------------------------------------- 1 | package tokens 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | func TestTokenURL(t *testing.T) { 11 | testhelper.SetupHTTP() 12 | defer testhelper.TeardownHTTP() 13 | 14 | client := gophercloud.ServiceClient{Endpoint: testhelper.Endpoint()} 15 | 16 | expected := testhelper.Endpoint() + "auth/tokens" 17 | actual := tokenURL(&client) 18 | if actual != expected { 19 | t.Errorf("Expected URL %s, but was %s", expected, actual) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /openstack/imageservice/v2/README.md: -------------------------------------------------------------------------------- 1 | This provides a Go API which wraps any service implementing the [OpenStack Image Service API, version 2](http://developer.openstack.org/api-ref-image-v2.html). 2 | -------------------------------------------------------------------------------- /openstack/imageservice/v2/images/urls_test.go: -------------------------------------------------------------------------------- 1 | package images 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/v2/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestListURL(t *testing.T) { 17 | th.AssertEquals(t, endpoint+"images", listURL(endpointClient())) 18 | } 19 | -------------------------------------------------------------------------------- /openstack/networking/v2/apiversions/doc.go: -------------------------------------------------------------------------------- 1 | // Package apiversions provides information and interaction with the different 2 | // API versions for the OpenStack Neutron service. This functionality is not 3 | // restricted to this particular version. 4 | package apiversions 5 | -------------------------------------------------------------------------------- /openstack/networking/v2/apiversions/errors.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | -------------------------------------------------------------------------------- /openstack/networking/v2/apiversions/requests.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // ListVersions lists all the Neutron API versions available to end-users 9 | func ListVersions(c *gophercloud.ServiceClient) pagination.Pager { 10 | return pagination.NewPager(c, apiVersionsURL(c), func(r pagination.PageResult) pagination.Page { 11 | return APIVersionPage{pagination.SinglePageBase(r)} 12 | }) 13 | } 14 | 15 | // ListVersionResources lists all of the different API resources for a particular 16 | // API versions. Typical resources for Neutron might be: networks, subnets, etc. 17 | func ListVersionResources(c *gophercloud.ServiceClient, v string) pagination.Pager { 18 | return pagination.NewPager(c, apiInfoURL(c, v), func(r pagination.PageResult) pagination.Page { 19 | return APIVersionResourcePage{pagination.SinglePageBase(r)} 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /openstack/networking/v2/apiversions/urls.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | func apiVersionsURL(c *gophercloud.ServiceClient) string { 10 | return c.Endpoint 11 | } 12 | 13 | func apiInfoURL(c *gophercloud.ServiceClient, version string) string { 14 | return c.Endpoint + strings.TrimRight(version, "/") + "/" 15 | } 16 | -------------------------------------------------------------------------------- /openstack/networking/v2/apiversions/urls_test.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestAPIVersionsURL(t *testing.T) { 17 | actual := apiVersionsURL(endpointClient()) 18 | expected := endpoint 19 | th.AssertEquals(t, expected, actual) 20 | } 21 | 22 | func TestAPIInfoURL(t *testing.T) { 23 | actual := apiInfoURL(endpointClient(), "v2.0") 24 | expected := endpoint + "v2.0/" 25 | th.AssertEquals(t, expected, actual) 26 | } 27 | -------------------------------------------------------------------------------- /openstack/networking/v2/common/common_tests.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/testhelper/client" 6 | ) 7 | 8 | const TokenID = client.TokenID 9 | 10 | func ServiceClient() *gophercloud.ServiceClient { 11 | sc := client.ServiceClient() 12 | sc.ResourceBase = sc.Endpoint + "v2.0/" 13 | return sc 14 | } 15 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/external/doc.go: -------------------------------------------------------------------------------- 1 | // Package external provides information and interaction with the external 2 | // extension for the OpenStack Networking service. 3 | package external 4 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/fwaas/doc.go: -------------------------------------------------------------------------------- 1 | // Package fwaas provides information and interaction with the Firewall 2 | // as a Service extension for the OpenStack Networking service. 3 | package fwaas 4 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/fwaas/firewalls/errors.go: -------------------------------------------------------------------------------- 1 | package firewalls 2 | 3 | import "fmt" 4 | 5 | func err(str string) error { 6 | return fmt.Errorf("%s", str) 7 | } 8 | 9 | var ( 10 | errPolicyRequired = err("A policy ID is required") 11 | ) 12 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/fwaas/firewalls/urls.go: -------------------------------------------------------------------------------- 1 | package firewalls 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "fw" 7 | resourcePath = "firewalls" 8 | ) 9 | 10 | func rootURL(c *gophercloud.ServiceClient) string { 11 | return c.ServiceURL(rootPath, resourcePath) 12 | } 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 15 | return c.ServiceURL(rootPath, resourcePath, id) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/fwaas/policies/urls.go: -------------------------------------------------------------------------------- 1 | package policies 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "fw" 7 | resourcePath = "firewall_policies" 8 | insertPath = "insert_rule" 9 | removePath = "remove_rule" 10 | ) 11 | 12 | func rootURL(c *gophercloud.ServiceClient) string { 13 | return c.ServiceURL(rootPath, resourcePath) 14 | } 15 | 16 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 17 | return c.ServiceURL(rootPath, resourcePath, id) 18 | } 19 | 20 | func insertURL(c *gophercloud.ServiceClient, id string) string { 21 | return c.ServiceURL(rootPath, resourcePath, id, insertPath) 22 | } 23 | 24 | func removeURL(c *gophercloud.ServiceClient, id string) string { 25 | return c.ServiceURL(rootPath, resourcePath, id, removePath) 26 | } 27 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/fwaas/rules/errors.go: -------------------------------------------------------------------------------- 1 | package rules 2 | 3 | import "fmt" 4 | 5 | func err(str string) error { 6 | return fmt.Errorf("%s", str) 7 | } 8 | 9 | var ( 10 | errProtocolRequired = err("A protocol is required (tcp, udp, icmp or any)") 11 | errActionRequired = err("An action is required (allow or deny)") 12 | ) 13 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/fwaas/rules/urls.go: -------------------------------------------------------------------------------- 1 | package rules 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "fw" 7 | resourcePath = "firewall_rules" 8 | ) 9 | 10 | func rootURL(c *gophercloud.ServiceClient) string { 11 | return c.ServiceURL(rootPath, resourcePath) 12 | } 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 15 | return c.ServiceURL(rootPath, resourcePath, id) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/layer3/doc.go: -------------------------------------------------------------------------------- 1 | // Package layer3 provides access to the Layer-3 networking extension for the 2 | // OpenStack Neutron service. This extension allows API users to route packets 3 | // between subnets, forward packets from internal networks to external ones, 4 | // and access instances from external networks through floating IPs. 5 | package layer3 6 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/layer3/floatingips/urls.go: -------------------------------------------------------------------------------- 1 | package floatingips 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "floatingips" 6 | 7 | func rootURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(resourcePath) 9 | } 10 | 11 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 12 | return c.ServiceURL(resourcePath, id) 13 | } 14 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/layer3/routers/urls.go: -------------------------------------------------------------------------------- 1 | package routers 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const resourcePath = "routers" 6 | 7 | func rootURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(resourcePath) 9 | } 10 | 11 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 12 | return c.ServiceURL(resourcePath, id) 13 | } 14 | 15 | func addInterfaceURL(c *gophercloud.ServiceClient, id string) string { 16 | return c.ServiceURL(resourcePath, id, "add_router_interface") 17 | } 18 | 19 | func removeInterfaceURL(c *gophercloud.ServiceClient, id string) string { 20 | return c.ServiceURL(resourcePath, id, "remove_router_interface") 21 | } 22 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas/doc.go: -------------------------------------------------------------------------------- 1 | // Package lbaas provides information and interaction with the Load Balancer 2 | // as a Service extension for the OpenStack Networking service. 3 | package lbaas 4 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas/members/urls.go: -------------------------------------------------------------------------------- 1 | package members 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "lb" 7 | resourcePath = "members" 8 | ) 9 | 10 | func rootURL(c *gophercloud.ServiceClient) string { 11 | return c.ServiceURL(rootPath, resourcePath) 12 | } 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 15 | return c.ServiceURL(rootPath, resourcePath, id) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas/monitors/urls.go: -------------------------------------------------------------------------------- 1 | package monitors 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "lb" 7 | resourcePath = "health_monitors" 8 | ) 9 | 10 | func rootURL(c *gophercloud.ServiceClient) string { 11 | return c.ServiceURL(rootPath, resourcePath) 12 | } 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 15 | return c.ServiceURL(rootPath, resourcePath, id) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas/pools/urls.go: -------------------------------------------------------------------------------- 1 | package pools 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "lb" 7 | resourcePath = "pools" 8 | monitorPath = "health_monitors" 9 | ) 10 | 11 | func rootURL(c *gophercloud.ServiceClient) string { 12 | return c.ServiceURL(rootPath, resourcePath) 13 | } 14 | 15 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 16 | return c.ServiceURL(rootPath, resourcePath, id) 17 | } 18 | 19 | func associateURL(c *gophercloud.ServiceClient, id string) string { 20 | return c.ServiceURL(rootPath, resourcePath, id, monitorPath) 21 | } 22 | 23 | func disassociateURL(c *gophercloud.ServiceClient, poolID, monitorID string) string { 24 | return c.ServiceURL(rootPath, resourcePath, poolID, monitorPath, monitorID) 25 | } 26 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas/vips/urls.go: -------------------------------------------------------------------------------- 1 | package vips 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "lb" 7 | resourcePath = "vips" 8 | ) 9 | 10 | func rootURL(c *gophercloud.ServiceClient) string { 11 | return c.ServiceURL(rootPath, resourcePath) 12 | } 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 15 | return c.ServiceURL(rootPath, resourcePath, id) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas_v2/doc.go: -------------------------------------------------------------------------------- 1 | // Package lbaas_v2 provides information and interaction with the Load Balancer 2 | // as a Service v2 extension for the OpenStack Networking service. 3 | // lbaas v2 api docs: http://developer.openstack.org/api-ref-networking-v2-ext.html#lbaas-v2.0 4 | // lbaas v2 api schema: https://github.com/openstack/neutron-lbaas/blob/master/neutron_lbaas/extensions/loadbalancerv2.py 5 | package lbaas_v2 6 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas_v2/listeners/urls.go: -------------------------------------------------------------------------------- 1 | package listeners 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "lbaas" 7 | resourcePath = "listeners" 8 | ) 9 | 10 | func rootURL(c *gophercloud.ServiceClient) string { 11 | return c.ServiceURL(rootPath, resourcePath) 12 | } 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 15 | return c.ServiceURL(rootPath, resourcePath, id) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas_v2/loadbalancers/urls.go: -------------------------------------------------------------------------------- 1 | package loadbalancers 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "lbaas" 7 | resourcePath = "loadbalancers" 8 | statusPath = "statuses" 9 | ) 10 | 11 | func rootURL(c *gophercloud.ServiceClient) string { 12 | return c.ServiceURL(rootPath, resourcePath) 13 | } 14 | 15 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 16 | return c.ServiceURL(rootPath, resourcePath, id) 17 | } 18 | 19 | func statusRootURL(c *gophercloud.ServiceClient, id string) string { 20 | return c.ServiceURL(rootPath, resourcePath, id, statusPath) 21 | } 22 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas_v2/monitors/urls.go: -------------------------------------------------------------------------------- 1 | package monitors 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "lbaas" 7 | resourcePath = "healthmonitors" 8 | ) 9 | 10 | func rootURL(c *gophercloud.ServiceClient) string { 11 | return c.ServiceURL(rootPath, resourcePath) 12 | } 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 15 | return c.ServiceURL(rootPath, resourcePath, id) 16 | } 17 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/lbaas_v2/pools/urls.go: -------------------------------------------------------------------------------- 1 | package pools 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const ( 6 | rootPath = "lbaas" 7 | resourcePath = "pools" 8 | memberPath = "members" 9 | ) 10 | 11 | func rootURL(c *gophercloud.ServiceClient) string { 12 | return c.ServiceURL(rootPath, resourcePath) 13 | } 14 | 15 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 16 | return c.ServiceURL(rootPath, resourcePath, id) 17 | } 18 | 19 | func memberRootURL(c *gophercloud.ServiceClient, poolId string) string { 20 | return c.ServiceURL(rootPath, resourcePath, poolId, memberPath) 21 | } 22 | 23 | func memberResourceURL(c *gophercloud.ServiceClient, poolID string, memeberID string) string { 24 | return c.ServiceURL(rootPath, resourcePath, poolID, memberPath, memeberID) 25 | } 26 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/portsbinding/doc.go: -------------------------------------------------------------------------------- 1 | // Package portsbinding provides information and interaction with the port 2 | // binding extension for the OpenStack Networking service. 3 | package portsbinding 4 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/portsbinding/urls.go: -------------------------------------------------------------------------------- 1 | package portsbinding 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 6 | return c.ServiceURL("ports", id) 7 | } 8 | 9 | func rootURL(c *gophercloud.ServiceClient) string { 10 | return c.ServiceURL("ports") 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, id string) string { 14 | return resourceURL(c, id) 15 | } 16 | 17 | func createURL(c *gophercloud.ServiceClient) string { 18 | return rootURL(c) 19 | } 20 | 21 | func updateURL(c *gophercloud.ServiceClient, id string) string { 22 | return resourceURL(c, id) 23 | } 24 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/portsbinding/urls_test.go: -------------------------------------------------------------------------------- 1 | package portsbinding 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint, ResourceBase: endpoint + "v2.0/"} 14 | } 15 | 16 | func TestGetURL(t *testing.T) { 17 | actual := getURL(endpointClient(), "foo") 18 | expected := endpoint + "v2.0/ports/foo" 19 | th.AssertEquals(t, expected, actual) 20 | } 21 | 22 | func TestCreateURL(t *testing.T) { 23 | actual := createURL(endpointClient()) 24 | expected := endpoint + "v2.0/ports" 25 | th.AssertEquals(t, expected, actual) 26 | } 27 | 28 | func TestUpdateURL(t *testing.T) { 29 | actual := updateURL(endpointClient(), "foo") 30 | expected := endpoint + "v2.0/ports/foo" 31 | th.AssertEquals(t, expected, actual) 32 | } 33 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/security/groups/urls.go: -------------------------------------------------------------------------------- 1 | package groups 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const rootPath = "security-groups" 6 | 7 | func rootURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(rootPath) 9 | } 10 | 11 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 12 | return c.ServiceURL(rootPath, id) 13 | } 14 | -------------------------------------------------------------------------------- /openstack/networking/v2/extensions/security/rules/urls.go: -------------------------------------------------------------------------------- 1 | package rules 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | const rootPath = "security-group-rules" 6 | 7 | func rootURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(rootPath) 9 | } 10 | 11 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 12 | return c.ServiceURL(rootPath, id) 13 | } 14 | -------------------------------------------------------------------------------- /openstack/networking/v2/networks/doc.go: -------------------------------------------------------------------------------- 1 | // Package networks contains functionality for working with Neutron network 2 | // resources. A network is an isolated virtual layer-2 broadcast domain that is 3 | // typically reserved for the tenant who created it (unless you configure the 4 | // network to be shared). Tenants can create multiple networks until the 5 | // thresholds per-tenant quota is reached. 6 | // 7 | // In the v2.0 Networking API, the network is the main entity. Ports and subnets 8 | // are always associated with a network. 9 | package networks 10 | -------------------------------------------------------------------------------- /openstack/networking/v2/networks/errors.go: -------------------------------------------------------------------------------- 1 | package networks 2 | -------------------------------------------------------------------------------- /openstack/networking/v2/networks/urls.go: -------------------------------------------------------------------------------- 1 | package networks 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 6 | return c.ServiceURL("networks", id) 7 | } 8 | 9 | func rootURL(c *gophercloud.ServiceClient) string { 10 | return c.ServiceURL("networks") 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, id string) string { 14 | return resourceURL(c, id) 15 | } 16 | 17 | func listURL(c *gophercloud.ServiceClient) string { 18 | return rootURL(c) 19 | } 20 | 21 | func createURL(c *gophercloud.ServiceClient) string { 22 | return rootURL(c) 23 | } 24 | 25 | func updateURL(c *gophercloud.ServiceClient, id string) string { 26 | return resourceURL(c, id) 27 | } 28 | 29 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 30 | return resourceURL(c, id) 31 | } 32 | -------------------------------------------------------------------------------- /openstack/networking/v2/ports/doc.go: -------------------------------------------------------------------------------- 1 | // Package ports contains functionality for working with Neutron port resources. 2 | // A port represents a virtual switch port on a logical network switch. Virtual 3 | // instances attach their interfaces into ports. The logical port also defines 4 | // the MAC address and the IP address(es) to be assigned to the interfaces 5 | // plugged into them. When IP addresses are associated to a port, this also 6 | // implies the port is associated with a subnet, as the IP address was taken 7 | // from the allocation pool for a specific subnet. 8 | package ports 9 | -------------------------------------------------------------------------------- /openstack/networking/v2/ports/errors.go: -------------------------------------------------------------------------------- 1 | package ports 2 | 3 | import "fmt" 4 | 5 | func err(str string) error { 6 | return fmt.Errorf("%s", str) 7 | } 8 | 9 | var ( 10 | errNetworkIDRequired = err("A Network ID is required") 11 | ) 12 | -------------------------------------------------------------------------------- /openstack/networking/v2/ports/urls.go: -------------------------------------------------------------------------------- 1 | package ports 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 6 | return c.ServiceURL("ports", id) 7 | } 8 | 9 | func rootURL(c *gophercloud.ServiceClient) string { 10 | return c.ServiceURL("ports") 11 | } 12 | 13 | func listURL(c *gophercloud.ServiceClient) string { 14 | return rootURL(c) 15 | } 16 | 17 | func getURL(c *gophercloud.ServiceClient, id string) string { 18 | return resourceURL(c, id) 19 | } 20 | 21 | func createURL(c *gophercloud.ServiceClient) string { 22 | return rootURL(c) 23 | } 24 | 25 | func updateURL(c *gophercloud.ServiceClient, id string) string { 26 | return resourceURL(c, id) 27 | } 28 | 29 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 30 | return resourceURL(c, id) 31 | } 32 | -------------------------------------------------------------------------------- /openstack/networking/v2/subnets/doc.go: -------------------------------------------------------------------------------- 1 | // Package subnets contains functionality for working with Neutron subnet 2 | // resources. A subnet represents an IP address block that can be used to 3 | // assign IP addresses to virtual instances. Each subnet must have a CIDR and 4 | // must be associated with a network. IPs can either be selected from the whole 5 | // subnet CIDR or from allocation pools specified by the user. 6 | // 7 | // A subnet can also have a gateway, a list of DNS name servers, and host routes. 8 | // This information is pushed to instances whose interfaces are associated with 9 | // the subnet. 10 | package subnets 11 | -------------------------------------------------------------------------------- /openstack/networking/v2/subnets/errors.go: -------------------------------------------------------------------------------- 1 | package subnets 2 | 3 | import "fmt" 4 | 5 | func err(str string) error { 6 | return fmt.Errorf("%s", str) 7 | } 8 | 9 | var ( 10 | errNetworkIDRequired = err("A network ID is required") 11 | errCIDRRequired = err("A valid CIDR is required") 12 | errInvalidIPType = err("An IP type must either be 4 or 6") 13 | errInvalidGatewayConfig = err("Both disabling the gateway and specifying a gateway is not allowed") 14 | ) 15 | -------------------------------------------------------------------------------- /openstack/networking/v2/subnets/urls.go: -------------------------------------------------------------------------------- 1 | package subnets 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 6 | return c.ServiceURL("subnets", id) 7 | } 8 | 9 | func rootURL(c *gophercloud.ServiceClient) string { 10 | return c.ServiceURL("subnets") 11 | } 12 | 13 | func listURL(c *gophercloud.ServiceClient) string { 14 | return rootURL(c) 15 | } 16 | 17 | func getURL(c *gophercloud.ServiceClient, id string) string { 18 | return resourceURL(c, id) 19 | } 20 | 21 | func createURL(c *gophercloud.ServiceClient) string { 22 | return rootURL(c) 23 | } 24 | 25 | func updateURL(c *gophercloud.ServiceClient, id string) string { 26 | return resourceURL(c, id) 27 | } 28 | 29 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 30 | return resourceURL(c, id) 31 | } 32 | -------------------------------------------------------------------------------- /openstack/objectstorage/v1/accounts/doc.go: -------------------------------------------------------------------------------- 1 | // Package accounts contains functionality for working with Object Storage 2 | // account resources. An account is the top-level resource the object storage 3 | // hierarchy: containers belong to accounts, objects belong to containers. 4 | // 5 | // Another way of thinking of an account is like a namespace for all your 6 | // resources. It is synonymous with a project or tenant in other OpenStack 7 | // services. 8 | package accounts 9 | -------------------------------------------------------------------------------- /openstack/objectstorage/v1/accounts/requests_test.go: -------------------------------------------------------------------------------- 1 | package accounts 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | fake "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestUpdateAccount(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | HandleUpdateAccountSuccessfully(t) 14 | 15 | options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}} 16 | res := Update(fake.ServiceClient(), options) 17 | th.AssertNoErr(t, res.Err) 18 | } 19 | 20 | func TestGetAccount(t *testing.T) { 21 | th.SetupHTTP() 22 | defer th.TeardownHTTP() 23 | HandleGetAccountSuccessfully(t) 24 | 25 | expectedMetadata := map[string]string{"Subject": "books"} 26 | res := Get(fake.ServiceClient(), &GetOpts{}) 27 | th.AssertNoErr(t, res.Err) 28 | actualMetadata, _ := res.ExtractMetadata() 29 | th.CheckDeepEquals(t, expectedMetadata, actualMetadata) 30 | //headers, err := res.Extract() 31 | //th.AssertNoErr(t, err) 32 | } 33 | -------------------------------------------------------------------------------- /openstack/objectstorage/v1/accounts/urls.go: -------------------------------------------------------------------------------- 1 | package accounts 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func getURL(c *gophercloud.ServiceClient) string { 6 | return c.Endpoint 7 | } 8 | 9 | func updateURL(c *gophercloud.ServiceClient) string { 10 | return getURL(c) 11 | } 12 | -------------------------------------------------------------------------------- /openstack/objectstorage/v1/accounts/urls_test.go: -------------------------------------------------------------------------------- 1 | package accounts 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestGetURL(t *testing.T) { 17 | actual := getURL(endpointClient()) 18 | expected := endpoint 19 | th.CheckEquals(t, expected, actual) 20 | } 21 | 22 | func TestUpdateURL(t *testing.T) { 23 | actual := updateURL(endpointClient()) 24 | expected := endpoint 25 | th.CheckEquals(t, expected, actual) 26 | } 27 | -------------------------------------------------------------------------------- /openstack/objectstorage/v1/containers/doc.go: -------------------------------------------------------------------------------- 1 | // Package containers contains functionality for working with Object Storage 2 | // container resources. A container serves as a logical namespace for objects 3 | // that are placed inside it - an object with the same name in two different 4 | // containers represents two different objects. 5 | // 6 | // In addition to containing objects, you can also use the container to control 7 | // access to objects by using an access control list (ACL). 8 | package containers 9 | -------------------------------------------------------------------------------- /openstack/objectstorage/v1/containers/urls.go: -------------------------------------------------------------------------------- 1 | package containers 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(c *gophercloud.ServiceClient) string { 6 | return c.Endpoint 7 | } 8 | 9 | func createURL(c *gophercloud.ServiceClient, container string) string { 10 | return c.ServiceURL(container) 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, container string) string { 14 | return createURL(c, container) 15 | } 16 | 17 | func deleteURL(c *gophercloud.ServiceClient, container string) string { 18 | return createURL(c, container) 19 | } 20 | 21 | func updateURL(c *gophercloud.ServiceClient, container string) string { 22 | return createURL(c, container) 23 | } 24 | -------------------------------------------------------------------------------- /openstack/objectstorage/v1/objects/doc.go: -------------------------------------------------------------------------------- 1 | // Package objects contains functionality for working with Object Storage 2 | // object resources. An object is a resource that represents and contains data 3 | // - such as documents, images, and so on. You can also store custom metadata 4 | // with an object. 5 | package objects 6 | -------------------------------------------------------------------------------- /openstack/objectstorage/v1/objects/urls.go: -------------------------------------------------------------------------------- 1 | package objects 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | ) 6 | 7 | func listURL(c *gophercloud.ServiceClient, container string) string { 8 | return c.ServiceURL(container) 9 | } 10 | 11 | func copyURL(c *gophercloud.ServiceClient, container, object string) string { 12 | return c.ServiceURL(container, object) 13 | } 14 | 15 | func createURL(c *gophercloud.ServiceClient, container, object string) string { 16 | return copyURL(c, container, object) 17 | } 18 | 19 | func getURL(c *gophercloud.ServiceClient, container, object string) string { 20 | return copyURL(c, container, object) 21 | } 22 | 23 | func deleteURL(c *gophercloud.ServiceClient, container, object string) string { 24 | return copyURL(c, container, object) 25 | } 26 | 27 | func downloadURL(c *gophercloud.ServiceClient, container, object string) string { 28 | return copyURL(c, container, object) 29 | } 30 | 31 | func updateURL(c *gophercloud.ServiceClient, container, object string) string { 32 | return copyURL(c, container, object) 33 | } 34 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/apiversions/doc.go: -------------------------------------------------------------------------------- 1 | // Package apiversions provides information and interaction with the different 2 | // API versions for the OpenStack Heat service. This functionality is not 3 | // restricted to this particular version. 4 | package apiversions 5 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/apiversions/requests.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // ListVersions lists all the Neutron API versions available to end-users 9 | func ListVersions(c *gophercloud.ServiceClient) pagination.Pager { 10 | return pagination.NewPager(c, apiVersionsURL(c), func(r pagination.PageResult) pagination.Page { 11 | return APIVersionPage{pagination.SinglePageBase(r)} 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/apiversions/urls.go: -------------------------------------------------------------------------------- 1 | package apiversions 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func apiVersionsURL(c *gophercloud.ServiceClient) string { 6 | return c.Endpoint 7 | } 8 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/buildinfo/doc.go: -------------------------------------------------------------------------------- 1 | // Package buildinfo provides build information about heat deployments. 2 | package buildinfo 3 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/buildinfo/requests.go: -------------------------------------------------------------------------------- 1 | package buildinfo 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | // Get retreives data for the given stack template. 6 | func Get(c *gophercloud.ServiceClient) GetResult { 7 | var res GetResult 8 | _, res.Err = c.Get(getURL(c), &res.Body, nil) 9 | return res 10 | } 11 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/buildinfo/requests_test.go: -------------------------------------------------------------------------------- 1 | package buildinfo 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | fake "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | func TestGetTemplate(t *testing.T) { 11 | th.SetupHTTP() 12 | defer th.TeardownHTTP() 13 | HandleGetSuccessfully(t, GetOutput) 14 | 15 | actual, err := Get(fake.ServiceClient()).Extract() 16 | th.AssertNoErr(t, err) 17 | 18 | expected := GetExpected 19 | th.AssertDeepEquals(t, expected, actual) 20 | } 21 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/buildinfo/results.go: -------------------------------------------------------------------------------- 1 | package buildinfo 2 | 3 | import ( 4 | "github.com/mitchellh/mapstructure" 5 | "github.com/rackspace/gophercloud" 6 | ) 7 | 8 | // Revision represents the API/Engine revision of a Heat deployment. 9 | type Revision struct { 10 | Revision string `mapstructure:"revision"` 11 | } 12 | 13 | // BuildInfo represents the build information for a Heat deployment. 14 | type BuildInfo struct { 15 | API Revision `mapstructure:"api"` 16 | Engine Revision `mapstructure:"engine"` 17 | } 18 | 19 | // GetResult represents the result of a Get operation. 20 | type GetResult struct { 21 | gophercloud.Result 22 | } 23 | 24 | // Extract returns a pointer to a BuildInfo object and is called after a 25 | // Get operation. 26 | func (r GetResult) Extract() (*BuildInfo, error) { 27 | if r.Err != nil { 28 | return nil, r.Err 29 | } 30 | 31 | var res BuildInfo 32 | if err := mapstructure.Decode(r.Body, &res); err != nil { 33 | return nil, err 34 | } 35 | 36 | return &res, nil 37 | } 38 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/buildinfo/urls.go: -------------------------------------------------------------------------------- 1 | package buildinfo 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func getURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("build_info") 7 | } 8 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/stackevents/doc.go: -------------------------------------------------------------------------------- 1 | // Package stackevents provides operations for finding, listing, and retrieving 2 | // stack events. Stack events are events that take place on stacks such as 3 | // updating and abandoning. 4 | package stackevents 5 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/stackevents/urls.go: -------------------------------------------------------------------------------- 1 | package stackevents 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func findURL(c *gophercloud.ServiceClient, stackName string) string { 6 | return c.ServiceURL("stacks", stackName, "events") 7 | } 8 | 9 | func listURL(c *gophercloud.ServiceClient, stackName, stackID string) string { 10 | return c.ServiceURL("stacks", stackName, stackID, "events") 11 | } 12 | 13 | func listResourceEventsURL(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) string { 14 | return c.ServiceURL("stacks", stackName, stackID, "resources", resourceName, "events") 15 | } 16 | 17 | func getURL(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) string { 18 | return c.ServiceURL("stacks", stackName, stackID, "resources", resourceName, "events", eventID) 19 | } 20 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/stackresources/doc.go: -------------------------------------------------------------------------------- 1 | // Package stackresources provides operations for working with stack resources. 2 | // A resource is a template artifact that represents some component of your 3 | // desired architecture (a Cloud Server, a group of scaled Cloud Servers, a load 4 | // balancer, some configuration management system, and so forth). 5 | package stackresources 6 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/stacks/doc.go: -------------------------------------------------------------------------------- 1 | // Package stacks provides operation for working with Heat stacks. A stack is a 2 | // group of resources (servers, load balancers, databases, and so forth) 3 | // combined to fulfill a useful purpose. Based on a template, Heat orchestration 4 | // engine creates an instantiated set of resources (a stack) to run the 5 | // application framework or component specified (in the template). A stack is a 6 | // running instance of a template. The result of creating a stack is a deployment 7 | // of the application framework or component. 8 | package stacks 9 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/stacks/urls.go: -------------------------------------------------------------------------------- 1 | package stacks 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func createURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("stacks") 7 | } 8 | 9 | func adoptURL(c *gophercloud.ServiceClient) string { 10 | return createURL(c) 11 | } 12 | 13 | func listURL(c *gophercloud.ServiceClient) string { 14 | return createURL(c) 15 | } 16 | 17 | func getURL(c *gophercloud.ServiceClient, name, id string) string { 18 | return c.ServiceURL("stacks", name, id) 19 | } 20 | 21 | func updateURL(c *gophercloud.ServiceClient, name, id string) string { 22 | return getURL(c, name, id) 23 | } 24 | 25 | func deleteURL(c *gophercloud.ServiceClient, name, id string) string { 26 | return getURL(c, name, id) 27 | } 28 | 29 | func previewURL(c *gophercloud.ServiceClient) string { 30 | return c.ServiceURL("stacks", "preview") 31 | } 32 | 33 | func abandonURL(c *gophercloud.ServiceClient, name, id string) string { 34 | return c.ServiceURL("stacks", name, id, "abandon") 35 | } 36 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/stacktemplates/doc.go: -------------------------------------------------------------------------------- 1 | // Package stacktemplates provides operations for working with Heat templates. 2 | // A Cloud Orchestration template is a portable file, written in a user-readable 3 | // language, that describes how a set of resources should be assembled and what 4 | // software should be installed in order to produce a working stack. The template 5 | // specifies what resources should be used, what attributes can be set, and other 6 | // parameters that are critical to the successful, repeatable automation of a 7 | // specific application stack. 8 | package stacktemplates 9 | -------------------------------------------------------------------------------- /openstack/orchestration/v1/stacktemplates/urls.go: -------------------------------------------------------------------------------- 1 | package stacktemplates 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func getURL(c *gophercloud.ServiceClient, stackName, stackID string) string { 6 | return c.ServiceURL("stacks", stackName, stackID, "template") 7 | } 8 | 9 | func validateURL(c *gophercloud.ServiceClient) string { 10 | return c.ServiceURL("validate") 11 | } 12 | -------------------------------------------------------------------------------- /openstack/telemetry/v2/meters/doc.go: -------------------------------------------------------------------------------- 1 | package meters 2 | -------------------------------------------------------------------------------- /openstack/telemetry/v2/meters/urls.go: -------------------------------------------------------------------------------- 1 | package meters 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(client *gophercloud.ServiceClient) string { 6 | return client.ServiceURL("v2", "meters") 7 | } 8 | 9 | func showURL(client *gophercloud.ServiceClient, name string) string { 10 | return client.ServiceURL("v2", "meters", name) 11 | } 12 | 13 | func createURL(client *gophercloud.ServiceClient, name string) string { 14 | return client.ServiceURL("v2", "meters", name) 15 | } 16 | 17 | func statisticsURL(client *gophercloud.ServiceClient, name string) string { 18 | return client.ServiceURL("v2", "meters", name, "statistics") 19 | } 20 | -------------------------------------------------------------------------------- /pagination/null.go: -------------------------------------------------------------------------------- 1 | package pagination 2 | 3 | // nullPage is an always-empty page that trivially satisfies all Page interfacts. 4 | // It's useful to be returned along with an error. 5 | type nullPage struct{} 6 | 7 | // NextPageURL always returns "" to indicate that there are no more pages to return. 8 | func (p nullPage) NextPageURL() (string, error) { 9 | return "", nil 10 | } 11 | 12 | // IsEmpty always returns true to prevent iteration over nullPages. 13 | func (p nullPage) IsEmpty() (bool, error) { 14 | return true, nil 15 | } 16 | 17 | // LastMark always returns "" because the nullPage contains no items to have a mark. 18 | func (p nullPage) LastMark() (string, error) { 19 | return "", nil 20 | } 21 | -------------------------------------------------------------------------------- /pagination/pagination_test.go: -------------------------------------------------------------------------------- 1 | package pagination 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/testhelper" 6 | ) 7 | 8 | func createClient() *gophercloud.ServiceClient { 9 | return &gophercloud.ServiceClient{ 10 | ProviderClient: &gophercloud.ProviderClient{TokenID: "abc123"}, 11 | Endpoint: testhelper.Endpoint(), 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /pagination/pkg.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package pagination contains utilities and convenience structs that implement common pagination idioms within OpenStack APIs. 3 | */ 4 | package pagination 5 | -------------------------------------------------------------------------------- /pagination/single.go: -------------------------------------------------------------------------------- 1 | package pagination 2 | 3 | // SinglePageBase may be embedded in a Page that contains all of the results from an operation at once. 4 | type SinglePageBase PageResult 5 | 6 | // NextPageURL always returns "" to indicate that there are no more pages to return. 7 | func (current SinglePageBase) NextPageURL() (string, error) { 8 | return "", nil 9 | } 10 | 11 | // GetBody returns the single page's body. This method is needed to satisfy the 12 | // Page interface. 13 | func (current SinglePageBase) GetBody() interface{} { 14 | return current.Body 15 | } 16 | -------------------------------------------------------------------------------- /provider_client_test.go: -------------------------------------------------------------------------------- 1 | package gophercloud 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | ) 8 | 9 | func TestAuthenticatedHeaders(t *testing.T) { 10 | p := &ProviderClient{ 11 | TokenID: "1234", 12 | } 13 | expected := map[string]string{"X-Auth-Token": "1234"} 14 | actual := p.AuthenticatedHeaders() 15 | th.CheckDeepEquals(t, expected, actual) 16 | } 17 | 18 | func TestUserAgent(t *testing.T) { 19 | p := &ProviderClient{} 20 | 21 | p.UserAgent.Prepend("custom-user-agent/2.4.0") 22 | expected := "custom-user-agent/2.4.0 gophercloud/1.0.0" 23 | actual := p.UserAgent.Join() 24 | th.CheckEquals(t, expected, actual) 25 | 26 | p.UserAgent.Prepend("another-custom-user-agent/0.3.0", "a-third-ua/5.9.0") 27 | expected = "another-custom-user-agent/0.3.0 a-third-ua/5.9.0 custom-user-agent/2.4.0 gophercloud/1.0.0" 28 | actual = p.UserAgent.Join() 29 | th.CheckEquals(t, expected, actual) 30 | 31 | p.UserAgent = UserAgent{} 32 | expected = "gophercloud/1.0.0" 33 | actual = p.UserAgent.Join() 34 | th.CheckEquals(t, expected, actual) 35 | } 36 | -------------------------------------------------------------------------------- /rackspace/autoscale/v1/policies/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package policies provides information and interaction with the policy API 3 | resource in the Rackspace Auto Scale service. 4 | 5 | Auto Scale uses policies to define when and how scaling activity will take 6 | place. Scaling policies specify how to modify the scaling group and its 7 | behavior. You can specify multiple policies to manage a scaling group. 8 | */ 9 | package policies 10 | -------------------------------------------------------------------------------- /rackspace/autoscale/v1/policies/urls.go: -------------------------------------------------------------------------------- 1 | package policies 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(c *gophercloud.ServiceClient, groupID string) string { 6 | return c.ServiceURL("groups", groupID, "policies") 7 | } 8 | 9 | func createURL(c *gophercloud.ServiceClient, groupID string) string { 10 | return c.ServiceURL("groups", groupID, "policies") 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, groupID, policyID string) string { 14 | return c.ServiceURL("groups", groupID, "policies", policyID) 15 | } 16 | 17 | func updateURL(c *gophercloud.ServiceClient, groupID, policyID string) string { 18 | return getURL(c, groupID, policyID) 19 | } 20 | 21 | func deleteURL(c *gophercloud.ServiceClient, groupID, policyID string) string { 22 | return getURL(c, groupID, policyID) 23 | } 24 | 25 | func executeURL(c *gophercloud.ServiceClient, groupID, policyID string) string { 26 | return c.ServiceURL("groups", groupID, "policies", policyID, "execute") 27 | } 28 | -------------------------------------------------------------------------------- /rackspace/autoscale/v1/webhooks/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package webhooks provides information and interaction with the webhook API resource 3 | in the Rackspace Auto Scale service. 4 | 5 | Auto Scale uses webhooks to initiate scaling events. Webhooks are associated 6 | with scaling policies and provide capability URLs which can be accessed 7 | anonymously to trigger execution of those policies. The Auto Scale webhook 8 | architecture allows Auto Scale to be integrated with other systems, for example, 9 | monitoring systems. 10 | */ 11 | package webhooks 12 | -------------------------------------------------------------------------------- /rackspace/autoscale/v1/webhooks/urls.go: -------------------------------------------------------------------------------- 1 | package webhooks 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(c *gophercloud.ServiceClient, groupID, policyID string) string { 6 | return c.ServiceURL("groups", groupID, "policies", policyID, "webhooks") 7 | } 8 | 9 | func createURL(c *gophercloud.ServiceClient, groupID, policyID string) string { 10 | return c.ServiceURL("groups", groupID, "policies", policyID, "webhooks") 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, groupID, policyID, webhookID string) string { 14 | return c.ServiceURL("groups", groupID, "policies", policyID, "webhooks", webhookID) 15 | } 16 | 17 | func updateURL(c *gophercloud.ServiceClient, groupID, policyID, webhookID string) string { 18 | return getURL(c, groupID, policyID, webhookID) 19 | } 20 | 21 | func deleteURL(c *gophercloud.ServiceClient, groupID, policyID, webhookID string) string { 22 | return getURL(c, groupID, policyID, webhookID) 23 | } 24 | -------------------------------------------------------------------------------- /rackspace/blockstorage/v1/snapshots/doc.go: -------------------------------------------------------------------------------- 1 | // Package snapshots provides information and interaction with the snapshot 2 | // API resource for the Rackspace Block Storage service. 3 | package snapshots 4 | -------------------------------------------------------------------------------- /rackspace/blockstorage/v1/volumes/doc.go: -------------------------------------------------------------------------------- 1 | // Package volumes provides information and interaction with the volume 2 | // API resource for the Rackspace Block Storage service. 3 | package volumes 4 | -------------------------------------------------------------------------------- /rackspace/blockstorage/v1/volumetypes/delegate.go: -------------------------------------------------------------------------------- 1 | package volumetypes 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | // List returns all volume types. 10 | func List(client *gophercloud.ServiceClient) pagination.Pager { 11 | return os.List(client) 12 | } 13 | 14 | // Get will retrieve the volume type with the provided ID. To extract the volume 15 | // type from the result, call the Extract method on the GetResult. 16 | func Get(client *gophercloud.ServiceClient, id string) GetResult { 17 | return GetResult{os.Get(client, id)} 18 | } 19 | -------------------------------------------------------------------------------- /rackspace/blockstorage/v1/volumetypes/doc.go: -------------------------------------------------------------------------------- 1 | // Package volumetypes provides information and interaction with the volume type 2 | // API resource for the Rackspace Block Storage service. 3 | package volumetypes 4 | -------------------------------------------------------------------------------- /rackspace/blockstorage/v1/volumetypes/results.go: -------------------------------------------------------------------------------- 1 | package volumetypes 2 | 3 | import ( 4 | "github.com/mitchellh/mapstructure" 5 | os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | type VolumeType os.VolumeType 10 | 11 | type GetResult struct { 12 | os.GetResult 13 | } 14 | 15 | // Extract will get the Volume Type struct out of the response. 16 | func (r GetResult) Extract() (*VolumeType, error) { 17 | if r.Err != nil { 18 | return nil, r.Err 19 | } 20 | 21 | var res struct { 22 | VolumeType *VolumeType `json:"volume_type" mapstructure:"volume_type"` 23 | } 24 | 25 | err := mapstructure.Decode(r.Body, &res) 26 | 27 | return res.VolumeType, err 28 | } 29 | 30 | func ExtractVolumeTypes(page pagination.Page) ([]VolumeType, error) { 31 | var response struct { 32 | VolumeTypes []VolumeType `mapstructure:"volume_types"` 33 | } 34 | 35 | err := mapstructure.Decode(page.(os.ListResult).Body, &response) 36 | return response.VolumeTypes, err 37 | } 38 | -------------------------------------------------------------------------------- /rackspace/cdn/v1/base/delegate.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | 6 | os "github.com/rackspace/gophercloud/openstack/cdn/v1/base" 7 | ) 8 | 9 | // Get retrieves the home document, allowing the user to discover the 10 | // entire API. 11 | func Get(c *gophercloud.ServiceClient) os.GetResult { 12 | return os.Get(c) 13 | } 14 | 15 | // Ping retrieves a ping to the server. 16 | func Ping(c *gophercloud.ServiceClient) os.PingResult { 17 | return os.Ping(c) 18 | } 19 | -------------------------------------------------------------------------------- /rackspace/cdn/v1/base/doc.go: -------------------------------------------------------------------------------- 1 | // Package base provides information and interaction with the base API 2 | // resource in the Rackspace CDN service. This API resource allows for 3 | // retrieving the Home Document and pinging the root URL. 4 | package base 5 | -------------------------------------------------------------------------------- /rackspace/cdn/v1/flavors/delegate.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | 6 | os "github.com/rackspace/gophercloud/openstack/cdn/v1/flavors" 7 | "github.com/rackspace/gophercloud/pagination" 8 | ) 9 | 10 | // List returns a single page of CDN flavors. 11 | func List(c *gophercloud.ServiceClient) pagination.Pager { 12 | return os.List(c) 13 | } 14 | 15 | // Get retrieves a specific flavor based on its unique ID. 16 | func Get(c *gophercloud.ServiceClient, id string) os.GetResult { 17 | return os.Get(c, id) 18 | } 19 | -------------------------------------------------------------------------------- /rackspace/cdn/v1/flavors/doc.go: -------------------------------------------------------------------------------- 1 | // Package flavors provides information and interaction with the flavors API 2 | // resource in the Rackspace CDN service. This API resource allows for 3 | // listing flavors and retrieving a specific flavor. 4 | // 5 | // A flavor is a mapping configuration to a CDN provider. 6 | package flavors 7 | -------------------------------------------------------------------------------- /rackspace/cdn/v1/serviceassets/delegate.go: -------------------------------------------------------------------------------- 1 | package serviceassets 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | 6 | os "github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets" 7 | ) 8 | 9 | // Delete accepts a unique ID and deletes the CDN service asset associated with 10 | // it. 11 | func Delete(c *gophercloud.ServiceClient, id string, opts os.DeleteOptsBuilder) os.DeleteResult { 12 | return os.Delete(c, id, opts) 13 | } 14 | -------------------------------------------------------------------------------- /rackspace/cdn/v1/serviceassets/delegate_test.go: -------------------------------------------------------------------------------- 1 | package serviceassets 2 | 3 | import ( 4 | "testing" 5 | 6 | os "github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | fake "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestDelete(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | 15 | os.HandleDeleteCDNAssetSuccessfully(t) 16 | 17 | err := Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", nil).ExtractErr() 18 | th.AssertNoErr(t, err) 19 | } 20 | -------------------------------------------------------------------------------- /rackspace/cdn/v1/serviceassets/doc.go: -------------------------------------------------------------------------------- 1 | // Package serviceassets provides information and interaction with the 2 | // serviceassets API resource in the Rackspace CDN service. This API resource 3 | // allows for deleting cached assets. 4 | // 5 | // A service distributes assets across the network. Service assets let you 6 | // interrogate properties about these assets and perform certain actions on them. 7 | package serviceassets 8 | -------------------------------------------------------------------------------- /rackspace/cdn/v1/services/doc.go: -------------------------------------------------------------------------------- 1 | // Package services provides information and interaction with the services API 2 | // resource in the Rackspace CDN service. This API resource allows for 3 | // listing, creating, updating, retrieving, and deleting services. 4 | // 5 | // A service represents an application that has its content cached to the edge 6 | // nodes. 7 | package services 8 | -------------------------------------------------------------------------------- /rackspace/client_test.go: -------------------------------------------------------------------------------- 1 | package rackspace 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "testing" 7 | 8 | "github.com/rackspace/gophercloud" 9 | th "github.com/rackspace/gophercloud/testhelper" 10 | ) 11 | 12 | func TestAuthenticatedClientV2(t *testing.T) { 13 | th.SetupHTTP() 14 | defer th.TeardownHTTP() 15 | 16 | th.Mux.HandleFunc("/v2.0/tokens", func(w http.ResponseWriter, r *http.Request) { 17 | fmt.Fprintf(w, ` 18 | { 19 | "access": { 20 | "token": { 21 | "id": "01234567890", 22 | "expires": "2014-10-01T10:00:00.000000Z" 23 | }, 24 | "serviceCatalog": [] 25 | } 26 | } 27 | `) 28 | }) 29 | 30 | options := gophercloud.AuthOptions{ 31 | Username: "me", 32 | APIKey: "09876543210", 33 | IdentityEndpoint: th.Endpoint() + "v2.0/", 34 | } 35 | client, err := AuthenticatedClient(options) 36 | th.AssertNoErr(t, err) 37 | th.CheckEquals(t, "01234567890", client.TokenID) 38 | } 39 | -------------------------------------------------------------------------------- /rackspace/compute/v2/bootfromvolume/delegate.go: -------------------------------------------------------------------------------- 1 | package bootfromvolume 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume" 6 | osServers "github.com/rackspace/gophercloud/openstack/compute/v2/servers" 7 | ) 8 | 9 | // Create requests the creation of a server from the given block device mapping. 10 | func Create(client *gophercloud.ServiceClient, opts osServers.CreateOptsBuilder) osServers.CreateResult { 11 | return osBFV.Create(client, opts) 12 | } 13 | -------------------------------------------------------------------------------- /rackspace/compute/v2/flavors/doc.go: -------------------------------------------------------------------------------- 1 | // Package flavors provides information and interaction with the flavor 2 | // API resource for the Rackspace Cloud Servers service. 3 | package flavors 4 | -------------------------------------------------------------------------------- /rackspace/compute/v2/flavors/urls.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | ) 6 | 7 | func getURL(client *gophercloud.ServiceClient, id string) string { 8 | return client.ServiceURL("flavors", id) 9 | } 10 | -------------------------------------------------------------------------------- /rackspace/compute/v2/images/delegate.go: -------------------------------------------------------------------------------- 1 | package images 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/compute/v2/images" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | // ListDetail enumerates the available server images. 10 | func ListDetail(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { 11 | return os.ListDetail(client, opts) 12 | } 13 | 14 | // Get acquires additional detail about a specific image by ID. 15 | func Get(client *gophercloud.ServiceClient, id string) os.GetResult { 16 | return os.Get(client, id) 17 | } 18 | 19 | // ExtractImages interprets a page as a collection of server images. 20 | func ExtractImages(page pagination.Page) ([]os.Image, error) { 21 | return os.ExtractImages(page) 22 | } 23 | -------------------------------------------------------------------------------- /rackspace/compute/v2/images/doc.go: -------------------------------------------------------------------------------- 1 | // Package images provides information and interaction with the image 2 | // API resource for the Rackspace Cloud Servers service. 3 | package images 4 | -------------------------------------------------------------------------------- /rackspace/compute/v2/keypairs/doc.go: -------------------------------------------------------------------------------- 1 | // Package keypairs provides information and interaction with the keypair 2 | // API resource for the Rackspace Cloud Servers service. 3 | package keypairs 4 | -------------------------------------------------------------------------------- /rackspace/compute/v2/networks/doc.go: -------------------------------------------------------------------------------- 1 | // Package networks provides information and interaction with the network 2 | // API resource for the Rackspace Cloud Servers service. 3 | package networks 4 | -------------------------------------------------------------------------------- /rackspace/compute/v2/networks/urls.go: -------------------------------------------------------------------------------- 1 | package networks 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 6 | return c.ServiceURL("os-networksv2", id) 7 | } 8 | 9 | func rootURL(c *gophercloud.ServiceClient) string { 10 | return c.ServiceURL("os-networksv2") 11 | } 12 | 13 | func getURL(c *gophercloud.ServiceClient, id string) string { 14 | return resourceURL(c, id) 15 | } 16 | 17 | func listURL(c *gophercloud.ServiceClient) string { 18 | return rootURL(c) 19 | } 20 | 21 | func createURL(c *gophercloud.ServiceClient) string { 22 | return rootURL(c) 23 | } 24 | 25 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 26 | return resourceURL(c, id) 27 | } 28 | -------------------------------------------------------------------------------- /rackspace/compute/v2/networks/urls_test.go: -------------------------------------------------------------------------------- 1 | package networks 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestGetURL(t *testing.T) { 17 | actual := getURL(endpointClient(), "foo") 18 | expected := endpoint + "os-networksv2/foo" 19 | th.AssertEquals(t, expected, actual) 20 | } 21 | 22 | func TestCreateURL(t *testing.T) { 23 | actual := createURL(endpointClient()) 24 | expected := endpoint + "os-networksv2" 25 | th.AssertEquals(t, expected, actual) 26 | } 27 | 28 | func TestListURL(t *testing.T) { 29 | actual := createURL(endpointClient()) 30 | expected := endpoint + "os-networksv2" 31 | th.AssertEquals(t, expected, actual) 32 | } 33 | 34 | func TestDeleteURL(t *testing.T) { 35 | actual := deleteURL(endpointClient(), "foo") 36 | expected := endpoint + "os-networksv2/foo" 37 | th.AssertEquals(t, expected, actual) 38 | } 39 | -------------------------------------------------------------------------------- /rackspace/compute/v2/servers/doc.go: -------------------------------------------------------------------------------- 1 | // Package servers provides information and interaction with the server 2 | // API resource for the Rackspace Cloud Servers service. 3 | package servers 4 | -------------------------------------------------------------------------------- /rackspace/compute/v2/virtualinterfaces/urls.go: -------------------------------------------------------------------------------- 1 | package virtualinterfaces 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(c *gophercloud.ServiceClient, instanceID string) string { 6 | return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2") 7 | } 8 | 9 | func createURL(c *gophercloud.ServiceClient, instanceID string) string { 10 | return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2") 11 | } 12 | 13 | func deleteURL(c *gophercloud.ServiceClient, instanceID, interfaceID string) string { 14 | return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2", interfaceID) 15 | } 16 | -------------------------------------------------------------------------------- /rackspace/compute/v2/virtualinterfaces/urls_test.go: -------------------------------------------------------------------------------- 1 | package virtualinterfaces 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestCreateURL(t *testing.T) { 17 | actual := createURL(endpointClient(), "12345") 18 | expected := endpoint + "servers/12345/os-virtual-interfacesv2" 19 | th.AssertEquals(t, expected, actual) 20 | } 21 | 22 | func TestListURL(t *testing.T) { 23 | actual := createURL(endpointClient(), "12345") 24 | expected := endpoint + "servers/12345/os-virtual-interfacesv2" 25 | th.AssertEquals(t, expected, actual) 26 | } 27 | 28 | func TestDeleteURL(t *testing.T) { 29 | actual := deleteURL(endpointClient(), "12345", "6789") 30 | expected := endpoint + "servers/12345/os-virtual-interfacesv2/6789" 31 | th.AssertEquals(t, expected, actual) 32 | } 33 | -------------------------------------------------------------------------------- /rackspace/compute/v2/volumeattach/doc.go: -------------------------------------------------------------------------------- 1 | // Package volumeattach provides the ability to attach and detach volume 2 | // to instances to Rackspace servers 3 | package volumeattach 4 | -------------------------------------------------------------------------------- /rackspace/db/v1/backups/doc.go: -------------------------------------------------------------------------------- 1 | // Package backups provides information and interaction with the backup API 2 | // resource in the Rackspace Database service. 3 | // 4 | // A backup is a copy of a database instance that can be used to restore it to 5 | // some defined point in history. 6 | package backups 7 | -------------------------------------------------------------------------------- /rackspace/db/v1/backups/urls.go: -------------------------------------------------------------------------------- 1 | package backups 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func baseURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("backups") 7 | } 8 | 9 | func resourceURL(c *gophercloud.ServiceClient, backupID string) string { 10 | return c.ServiceURL("backups", backupID) 11 | } 12 | -------------------------------------------------------------------------------- /rackspace/db/v1/configurations/doc.go: -------------------------------------------------------------------------------- 1 | package configurations 2 | -------------------------------------------------------------------------------- /rackspace/db/v1/databases/delegate.go: -------------------------------------------------------------------------------- 1 | package databases 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/db/v1/databases" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | func Create(client *gophercloud.ServiceClient, instanceID string, opts os.CreateOptsBuilder) os.CreateResult { 10 | return os.Create(client, instanceID, opts) 11 | } 12 | 13 | func List(client *gophercloud.ServiceClient, instanceID string) pagination.Pager { 14 | return os.List(client, instanceID) 15 | } 16 | 17 | func Delete(client *gophercloud.ServiceClient, instanceID, dbName string) os.DeleteResult { 18 | return os.Delete(client, instanceID, dbName) 19 | } 20 | -------------------------------------------------------------------------------- /rackspace/db/v1/databases/doc.go: -------------------------------------------------------------------------------- 1 | // Package databases provides information and interaction with the database API 2 | // resource in the Rackspace Database service. 3 | package databases 4 | -------------------------------------------------------------------------------- /rackspace/db/v1/databases/urls.go: -------------------------------------------------------------------------------- 1 | package databases 2 | -------------------------------------------------------------------------------- /rackspace/db/v1/datastores/delegate.go: -------------------------------------------------------------------------------- 1 | package datastores 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/db/v1/datastores" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | // List will list all available flavors. 10 | func List(client *gophercloud.ServiceClient) pagination.Pager { 11 | return os.List(client) 12 | } 13 | 14 | // Get retrieves the details for a particular flavor. 15 | func Get(client *gophercloud.ServiceClient, flavorID string) os.GetResult { 16 | return os.Get(client, flavorID) 17 | } 18 | 19 | // ListVersions will list all of the available versions for a specified 20 | // datastore type. 21 | func ListVersions(client *gophercloud.ServiceClient, datastoreID string) pagination.Pager { 22 | return os.ListVersions(client, datastoreID) 23 | } 24 | 25 | // GetVersion will retrieve the details of a specified datastore version. 26 | func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) os.GetVersionResult { 27 | return os.GetVersion(client, datastoreID, versionID) 28 | } 29 | -------------------------------------------------------------------------------- /rackspace/db/v1/datastores/doc.go: -------------------------------------------------------------------------------- 1 | package datastores 2 | -------------------------------------------------------------------------------- /rackspace/db/v1/flavors/delegate.go: -------------------------------------------------------------------------------- 1 | package flavors 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/db/v1/flavors" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | // List will list all available flavors. 10 | func List(client *gophercloud.ServiceClient) pagination.Pager { 11 | return os.List(client) 12 | } 13 | 14 | // Get retrieves the details for a particular flavor. 15 | func Get(client *gophercloud.ServiceClient, flavorID string) os.GetResult { 16 | return os.Get(client, flavorID) 17 | } 18 | -------------------------------------------------------------------------------- /rackspace/db/v1/flavors/doc.go: -------------------------------------------------------------------------------- 1 | // Package flavors provides information and interaction with the flavor API 2 | // resource in the Rackspace Database service. 3 | package flavors 4 | -------------------------------------------------------------------------------- /rackspace/db/v1/instances/doc.go: -------------------------------------------------------------------------------- 1 | // Package instances provides information and interaction with the instance API 2 | // resource in the Rackspace Database service. 3 | package instances 4 | -------------------------------------------------------------------------------- /rackspace/db/v1/instances/urls.go: -------------------------------------------------------------------------------- 1 | package instances 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func baseURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("instances") 7 | } 8 | 9 | func createURL(c *gophercloud.ServiceClient) string { 10 | return baseURL(c) 11 | } 12 | 13 | func resourceURL(c *gophercloud.ServiceClient, id string) string { 14 | return c.ServiceURL("instances", id) 15 | } 16 | 17 | func configURL(c *gophercloud.ServiceClient, id string) string { 18 | return c.ServiceURL("instances", id, "configuration") 19 | } 20 | 21 | func backupsURL(c *gophercloud.ServiceClient, id string) string { 22 | return c.ServiceURL("instances", id, "backups") 23 | } 24 | -------------------------------------------------------------------------------- /rackspace/db/v1/users/delegate.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/db/v1/users" 6 | ) 7 | 8 | // Create will create a new database user for the specified database instance. 9 | func Create(client *gophercloud.ServiceClient, instanceID string, opts os.CreateOptsBuilder) os.CreateResult { 10 | return os.Create(client, instanceID, opts) 11 | } 12 | 13 | // Delete will permanently remove a user from a specified database instance. 14 | func Delete(client *gophercloud.ServiceClient, instanceID, userName string) os.DeleteResult { 15 | return os.Delete(client, instanceID, userName) 16 | } 17 | -------------------------------------------------------------------------------- /rackspace/db/v1/users/doc.go: -------------------------------------------------------------------------------- 1 | // Package users provides information and interaction with the user API 2 | // resource in the Rackspace Database service. 3 | package users 4 | -------------------------------------------------------------------------------- /rackspace/db/v1/users/urls.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func baseURL(c *gophercloud.ServiceClient, instanceID string) string { 6 | return c.ServiceURL("instances", instanceID, "users") 7 | } 8 | 9 | func userURL(c *gophercloud.ServiceClient, instanceID, userName string) string { 10 | return c.ServiceURL("instances", instanceID, "users", userName) 11 | } 12 | 13 | func dbsURL(c *gophercloud.ServiceClient, instanceID, userName string) string { 14 | return c.ServiceURL("instances", instanceID, "users", userName, "databases") 15 | } 16 | 17 | func dbURL(c *gophercloud.ServiceClient, instanceID, userName, dbName string) string { 18 | return c.ServiceURL("instances", instanceID, "users", userName, "databases", dbName) 19 | } 20 | -------------------------------------------------------------------------------- /rackspace/identity/v2/extensions/delegate.go: -------------------------------------------------------------------------------- 1 | package extensions 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | common "github.com/rackspace/gophercloud/openstack/common/extensions" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | // ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the 10 | // elements into a slice of os.Extension structs. 11 | func ExtractExtensions(page pagination.Page) ([]common.Extension, error) { 12 | return common.ExtractExtensions(page) 13 | } 14 | 15 | // Get retrieves information for a specific extension using its alias. 16 | func Get(c *gophercloud.ServiceClient, alias string) common.GetResult { 17 | return common.Get(c, alias) 18 | } 19 | 20 | // List returns a Pager which allows you to iterate over the full collection of extensions. 21 | // It does not accept query parameters. 22 | func List(c *gophercloud.ServiceClient) pagination.Pager { 23 | return common.List(c) 24 | } 25 | -------------------------------------------------------------------------------- /rackspace/identity/v2/extensions/doc.go: -------------------------------------------------------------------------------- 1 | // Package extensions provides information and interaction with the all the 2 | // extensions available for the Rackspace Identity service. 3 | package extensions 4 | -------------------------------------------------------------------------------- /rackspace/identity/v2/tenants/delegate.go: -------------------------------------------------------------------------------- 1 | package tenants 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/identity/v2/tenants" 6 | "github.com/rackspace/gophercloud/pagination" 7 | ) 8 | 9 | // ExtractTenants interprets a page of List results as a more usable slice of Tenant structs. 10 | func ExtractTenants(page pagination.Page) ([]os.Tenant, error) { 11 | return os.ExtractTenants(page) 12 | } 13 | 14 | // List enumerates the tenants to which the current token grants access. 15 | func List(client *gophercloud.ServiceClient, opts *os.ListOpts) pagination.Pager { 16 | return os.List(client, opts) 17 | } 18 | -------------------------------------------------------------------------------- /rackspace/identity/v2/tenants/delegate_test.go: -------------------------------------------------------------------------------- 1 | package tenants 2 | 3 | import ( 4 | "testing" 5 | 6 | os "github.com/rackspace/gophercloud/openstack/identity/v2/tenants" 7 | "github.com/rackspace/gophercloud/pagination" 8 | th "github.com/rackspace/gophercloud/testhelper" 9 | fake "github.com/rackspace/gophercloud/testhelper/client" 10 | ) 11 | 12 | func TestListTenants(t *testing.T) { 13 | th.SetupHTTP() 14 | defer th.TeardownHTTP() 15 | os.HandleListTenantsSuccessfully(t) 16 | 17 | count := 0 18 | err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) { 19 | actual, err := ExtractTenants(page) 20 | th.AssertNoErr(t, err) 21 | th.CheckDeepEquals(t, os.ExpectedTenantSlice, actual) 22 | 23 | count++ 24 | return true, nil 25 | }) 26 | th.AssertNoErr(t, err) 27 | th.CheckEquals(t, 1, count) 28 | } 29 | -------------------------------------------------------------------------------- /rackspace/identity/v2/tenants/doc.go: -------------------------------------------------------------------------------- 1 | // Package tenants provides information and interaction with the tenant 2 | // API resource for the Rackspace Identity service. 3 | package tenants 4 | -------------------------------------------------------------------------------- /rackspace/identity/v2/tokens/delegate_test.go: -------------------------------------------------------------------------------- 1 | package tokens 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | os "github.com/rackspace/gophercloud/openstack/identity/v2/tokens" 8 | th "github.com/rackspace/gophercloud/testhelper" 9 | "github.com/rackspace/gophercloud/testhelper/client" 10 | ) 11 | 12 | func tokenPost(t *testing.T, options gophercloud.AuthOptions, requestJSON string) os.CreateResult { 13 | th.SetupHTTP() 14 | defer th.TeardownHTTP() 15 | os.HandleTokenPost(t, requestJSON) 16 | 17 | return Create(client.ServiceClient(), WrapOptions(options)) 18 | } 19 | 20 | func TestCreateTokenWithAPIKey(t *testing.T) { 21 | options := gophercloud.AuthOptions{ 22 | Username: "me", 23 | APIKey: "1234567890abcdef", 24 | } 25 | 26 | os.IsSuccessful(t, tokenPost(t, options, ` 27 | { 28 | "auth": { 29 | "RAX-KSKEY:apiKeyCredentials": { 30 | "username": "me", 31 | "apiKey": "1234567890abcdef" 32 | } 33 | } 34 | } 35 | `)) 36 | } 37 | -------------------------------------------------------------------------------- /rackspace/identity/v2/tokens/doc.go: -------------------------------------------------------------------------------- 1 | // Package tokens provides information and interaction with the token 2 | // API resource for the Rackspace Identity service. 3 | package tokens 4 | -------------------------------------------------------------------------------- /rackspace/identity/v2/users/urls.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func resetAPIKeyURL(client *gophercloud.ServiceClient, id string) string { 6 | return client.ServiceURL("users", id, "OS-KSADM", "credentials", "RAX-KSKEY:apiKeyCredentials", "RAX-AUTH", "reset") 7 | } 8 | -------------------------------------------------------------------------------- /rackspace/lb/v1/acl/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package acl provides information and interaction with the access lists feature 3 | of the Rackspace Cloud Load Balancer service. 4 | 5 | The access list management feature allows fine-grained network access controls 6 | to be applied to the load balancer's virtual IP address. A single IP address, 7 | multiple IP addresses, or entire network subnets can be added. Items that are 8 | configured with the ALLOW type always takes precedence over items with the DENY 9 | type. To reject traffic from all items except for those with the ALLOW type, 10 | add a networkItem with an address of "0.0.0.0/0" and a DENY type. 11 | */ 12 | package acl 13 | -------------------------------------------------------------------------------- /rackspace/lb/v1/acl/urls.go: -------------------------------------------------------------------------------- 1 | package acl 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | const ( 10 | path = "loadbalancers" 11 | aclPath = "accesslist" 12 | ) 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, lbID, networkID int) string { 15 | return c.ServiceURL(path, strconv.Itoa(lbID), aclPath, strconv.Itoa(networkID)) 16 | } 17 | 18 | func rootURL(c *gophercloud.ServiceClient, lbID int) string { 19 | return c.ServiceURL(path, strconv.Itoa(lbID), aclPath) 20 | } 21 | -------------------------------------------------------------------------------- /rackspace/lb/v1/monitors/urls.go: -------------------------------------------------------------------------------- 1 | package monitors 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | const ( 10 | path = "loadbalancers" 11 | monitorPath = "healthmonitor" 12 | ) 13 | 14 | func rootURL(c *gophercloud.ServiceClient, lbID int) string { 15 | return c.ServiceURL(path, strconv.Itoa(lbID), monitorPath) 16 | } 17 | -------------------------------------------------------------------------------- /rackspace/lb/v1/nodes/urls.go: -------------------------------------------------------------------------------- 1 | package nodes 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | const ( 10 | lbPath = "loadbalancers" 11 | nodePath = "nodes" 12 | eventPath = "events" 13 | ) 14 | 15 | func resourceURL(c *gophercloud.ServiceClient, lbID, nodeID int) string { 16 | return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath, strconv.Itoa(nodeID)) 17 | } 18 | 19 | func rootURL(c *gophercloud.ServiceClient, lbID int) string { 20 | return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath) 21 | } 22 | 23 | func eventsURL(c *gophercloud.ServiceClient, lbID int) string { 24 | return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath, eventPath) 25 | } 26 | -------------------------------------------------------------------------------- /rackspace/lb/v1/sessions/requests_test.go: -------------------------------------------------------------------------------- 1 | package sessions 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | const lbID = 12345 11 | 12 | func TestEnable(t *testing.T) { 13 | th.SetupHTTP() 14 | defer th.TeardownHTTP() 15 | 16 | mockEnableResponse(t, lbID) 17 | 18 | opts := CreateOpts{Type: HTTPCOOKIE} 19 | err := Enable(client.ServiceClient(), lbID, opts).ExtractErr() 20 | th.AssertNoErr(t, err) 21 | } 22 | 23 | func TestGet(t *testing.T) { 24 | th.SetupHTTP() 25 | defer th.TeardownHTTP() 26 | 27 | mockGetResponse(t, lbID) 28 | 29 | sp, err := Get(client.ServiceClient(), lbID).Extract() 30 | th.AssertNoErr(t, err) 31 | 32 | expected := &SessionPersistence{Type: HTTPCOOKIE} 33 | th.AssertDeepEquals(t, expected, sp) 34 | } 35 | 36 | func TestDisable(t *testing.T) { 37 | th.SetupHTTP() 38 | defer th.TeardownHTTP() 39 | 40 | mockDisableResponse(t, lbID) 41 | 42 | err := Disable(client.ServiceClient(), lbID).ExtractErr() 43 | th.AssertNoErr(t, err) 44 | } 45 | -------------------------------------------------------------------------------- /rackspace/lb/v1/sessions/urls.go: -------------------------------------------------------------------------------- 1 | package sessions 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | const ( 10 | path = "loadbalancers" 11 | spPath = "sessionpersistence" 12 | ) 13 | 14 | func rootURL(c *gophercloud.ServiceClient, id int) string { 15 | return c.ServiceURL(path, strconv.Itoa(id), spPath) 16 | } 17 | -------------------------------------------------------------------------------- /rackspace/lb/v1/ssl/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package ssl provides information and interaction with the SSL Termination 3 | feature of the Rackspace Cloud Load Balancer service. 4 | 5 | You may only enable and configure SSL termination on load balancers with 6 | non-secure protocols, such as HTTP, but not HTTPS. 7 | 8 | SSL-terminated load balancers decrypt the traffic at the traffic manager and 9 | pass unencrypted traffic to the back-end node. Because of this, the customer's 10 | back-end nodes don't know what protocol the client requested. For this reason, 11 | the X-Forwarded-Proto (XFP) header has been added for identifying the 12 | originating protocol of an HTTP request as "http" or "https" depending on what 13 | protocol the client requested. 14 | 15 | Not every service returns certificates in the proper order. Please verify that 16 | your chain of certificates matches that of walking up the chain from the domain 17 | to the CA root. 18 | 19 | If used for HTTP to HTTPS redirection, the LoadBalancer's securePort attribute 20 | must be set to 443, and its secureTrafficOnly attribute must be true. 21 | */ 22 | package ssl 23 | -------------------------------------------------------------------------------- /rackspace/lb/v1/ssl/urls.go: -------------------------------------------------------------------------------- 1 | package ssl 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | const ( 10 | path = "loadbalancers" 11 | sslPath = "ssltermination" 12 | certPath = "certificatemappings" 13 | ) 14 | 15 | func rootURL(c *gophercloud.ServiceClient, id int) string { 16 | return c.ServiceURL(path, strconv.Itoa(id), sslPath) 17 | } 18 | 19 | func certURL(c *gophercloud.ServiceClient, id int) string { 20 | return c.ServiceURL(path, strconv.Itoa(id), sslPath, certPath) 21 | } 22 | 23 | func certResourceURL(c *gophercloud.ServiceClient, id, certID int) string { 24 | return c.ServiceURL(path, strconv.Itoa(id), sslPath, certPath, strconv.Itoa(certID)) 25 | } 26 | -------------------------------------------------------------------------------- /rackspace/lb/v1/throttle/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package throttle provides information and interaction with the Connection 3 | Throttling feature of the Rackspace Cloud Load Balancer service. 4 | */ 5 | package throttle 6 | -------------------------------------------------------------------------------- /rackspace/lb/v1/throttle/requests_test.go: -------------------------------------------------------------------------------- 1 | package throttle 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | "github.com/rackspace/gophercloud/testhelper/client" 8 | ) 9 | 10 | const lbID = 12345 11 | 12 | func TestCreate(t *testing.T) { 13 | th.SetupHTTP() 14 | defer th.TeardownHTTP() 15 | 16 | mockCreateResponse(t, lbID) 17 | 18 | opts := CreateOpts{MaxConnections: 200} 19 | err := Create(client.ServiceClient(), lbID, opts).ExtractErr() 20 | th.AssertNoErr(t, err) 21 | } 22 | 23 | func TestGet(t *testing.T) { 24 | th.SetupHTTP() 25 | defer th.TeardownHTTP() 26 | 27 | mockGetResponse(t, lbID) 28 | 29 | sp, err := Get(client.ServiceClient(), lbID).Extract() 30 | th.AssertNoErr(t, err) 31 | 32 | expected := &ConnectionThrottle{MaxConnections: 100} 33 | th.AssertDeepEquals(t, expected, sp) 34 | } 35 | 36 | func TestDelete(t *testing.T) { 37 | th.SetupHTTP() 38 | defer th.TeardownHTTP() 39 | 40 | mockDeleteResponse(t, lbID) 41 | 42 | err := Delete(client.ServiceClient(), lbID).ExtractErr() 43 | th.AssertNoErr(t, err) 44 | } 45 | -------------------------------------------------------------------------------- /rackspace/lb/v1/throttle/results.go: -------------------------------------------------------------------------------- 1 | package throttle 2 | 3 | import ( 4 | "github.com/mitchellh/mapstructure" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | // ConnectionThrottle represents the connection throttle configuration for a 10 | // particular load balancer. 11 | type ConnectionThrottle struct { 12 | MaxConnections int 13 | } 14 | 15 | // CreateResult represents the result of a create operation. 16 | type CreateResult struct { 17 | gophercloud.ErrResult 18 | } 19 | 20 | // DeleteResult represents the result of a delete operation. 21 | type DeleteResult struct { 22 | gophercloud.ErrResult 23 | } 24 | 25 | // GetResult represents the result of a get operation. 26 | type GetResult struct { 27 | gophercloud.Result 28 | } 29 | 30 | // Extract interprets a GetResult as a SP, if possible. 31 | func (r GetResult) Extract() (*ConnectionThrottle, error) { 32 | if r.Err != nil { 33 | return nil, r.Err 34 | } 35 | 36 | var response struct { 37 | CT ConnectionThrottle `mapstructure:"connectionThrottle"` 38 | } 39 | 40 | err := mapstructure.Decode(r.Body, &response) 41 | 42 | return &response.CT, err 43 | } 44 | -------------------------------------------------------------------------------- /rackspace/lb/v1/throttle/urls.go: -------------------------------------------------------------------------------- 1 | package throttle 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | const ( 10 | path = "loadbalancers" 11 | ctPath = "connectionthrottle" 12 | ) 13 | 14 | func rootURL(c *gophercloud.ServiceClient, id int) string { 15 | return c.ServiceURL(path, strconv.Itoa(id), ctPath) 16 | } 17 | -------------------------------------------------------------------------------- /rackspace/lb/v1/vips/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package vips provides information and interaction with the Virtual IP API 3 | resource for the Rackspace Cloud Load Balancer service. 4 | 5 | A virtual IP (VIP) makes a load balancer accessible by clients. The load 6 | balancing service supports either a public VIP, routable on the public Internet, 7 | or a ServiceNet address, routable only within the region in which the load 8 | balancer resides. 9 | 10 | All load balancers must have at least one virtual IP associated with them at 11 | all times. 12 | */ 13 | package vips 14 | -------------------------------------------------------------------------------- /rackspace/lb/v1/vips/urls.go: -------------------------------------------------------------------------------- 1 | package vips 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/rackspace/gophercloud" 7 | ) 8 | 9 | const ( 10 | lbPath = "loadbalancers" 11 | vipPath = "virtualips" 12 | ) 13 | 14 | func resourceURL(c *gophercloud.ServiceClient, lbID, nodeID int) string { 15 | return c.ServiceURL(lbPath, strconv.Itoa(lbID), vipPath, strconv.Itoa(nodeID)) 16 | } 17 | 18 | func rootURL(c *gophercloud.ServiceClient, lbID int) string { 19 | return c.ServiceURL(lbPath, strconv.Itoa(lbID), vipPath) 20 | } 21 | -------------------------------------------------------------------------------- /rackspace/networking/v2/common/common_tests.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/testhelper/client" 6 | ) 7 | 8 | const TokenID = client.TokenID 9 | 10 | func ServiceClient() *gophercloud.ServiceClient { 11 | return client.ServiceClient() 12 | } 13 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/accounts/delegate_test.go: -------------------------------------------------------------------------------- 1 | package accounts 2 | 3 | import ( 4 | "testing" 5 | 6 | os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | fake "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestUpdateAccounts(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | 15 | os.HandleUpdateAccountSuccessfully(t) 16 | 17 | options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}} 18 | res := Update(fake.ServiceClient(), options) 19 | th.CheckNoErr(t, res.Err) 20 | } 21 | 22 | func TestGetAccounts(t *testing.T) { 23 | th.SetupHTTP() 24 | defer th.TeardownHTTP() 25 | 26 | os.HandleGetAccountSuccessfully(t) 27 | 28 | expected := map[string]string{"Foo": "bar"} 29 | actual, err := Get(fake.ServiceClient()).ExtractMetadata() 30 | th.CheckNoErr(t, err) 31 | th.CheckDeepEquals(t, expected, actual) 32 | } 33 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/accounts/doc.go: -------------------------------------------------------------------------------- 1 | // Package accounts provides information and interaction with the account 2 | // API resource for the Rackspace Cloud Files service. 3 | package accounts 4 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/bulk/doc.go: -------------------------------------------------------------------------------- 1 | // Package bulk provides functionality for working with bulk operations in the 2 | // Rackspace Cloud Files service. 3 | package bulk 4 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/bulk/requests_test.go: -------------------------------------------------------------------------------- 1 | package bulk 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "testing" 7 | 8 | th "github.com/rackspace/gophercloud/testhelper" 9 | fake "github.com/rackspace/gophercloud/testhelper/client" 10 | ) 11 | 12 | func TestBulkDelete(t *testing.T) { 13 | th.SetupHTTP() 14 | defer th.TeardownHTTP() 15 | th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 16 | th.TestMethod(t, r, "DELETE") 17 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 18 | th.AssertEquals(t, r.URL.RawQuery, "bulk-delete") 19 | 20 | w.WriteHeader(http.StatusOK) 21 | fmt.Fprintf(w, ` 22 | { 23 | "Number Not Found": 1, 24 | "Response Status": "200 OK", 25 | "Errors": [], 26 | "Number Deleted": 1, 27 | "Response Body": "" 28 | } 29 | `) 30 | }) 31 | 32 | options := DeleteOpts{"gophercloud-testcontainer1", "gophercloud-testcontainer2"} 33 | actual, err := Delete(fake.ServiceClient(), options).ExtractBody() 34 | th.AssertNoErr(t, err) 35 | th.AssertEquals(t, actual.NumberDeleted, 1) 36 | } 37 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/bulk/results.go: -------------------------------------------------------------------------------- 1 | package bulk 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | 6 | "github.com/mitchellh/mapstructure" 7 | ) 8 | 9 | // DeleteResult represents the result of a bulk delete operation. 10 | type DeleteResult struct { 11 | gophercloud.Result 12 | } 13 | 14 | // DeleteRespBody is the form of the response body returned by a bulk delete request. 15 | type DeleteRespBody struct { 16 | NumberNotFound int `mapstructure:"Number Not Found"` 17 | ResponseStatus string `mapstructure:"Response Status"` 18 | Errors []string `mapstructure:"Errors"` 19 | NumberDeleted int `mapstructure:"Number Deleted"` 20 | ResponseBody string `mapstructure:"Response Body"` 21 | } 22 | 23 | // ExtractBody will extract the body returned by the bulk extract request. 24 | func (dr DeleteResult) ExtractBody() (DeleteRespBody, error) { 25 | var resp DeleteRespBody 26 | err := mapstructure.Decode(dr.Body, &resp) 27 | return resp, err 28 | } 29 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/bulk/urls.go: -------------------------------------------------------------------------------- 1 | package bulk 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func deleteURL(c *gophercloud.ServiceClient) string { 6 | return c.Endpoint + "?bulk-delete" 7 | } 8 | 9 | func extractURL(c *gophercloud.ServiceClient, ext string) string { 10 | return c.Endpoint + "?extract-archive=" + ext 11 | } 12 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/bulk/urls_test.go: -------------------------------------------------------------------------------- 1 | package bulk 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestDeleteURL(t *testing.T) { 17 | actual := deleteURL(endpointClient()) 18 | expected := endpoint + "?bulk-delete" 19 | th.CheckEquals(t, expected, actual) 20 | } 21 | 22 | func TestExtractURL(t *testing.T) { 23 | actual := extractURL(endpointClient(), "tar") 24 | expected := endpoint + "?extract-archive=tar" 25 | th.CheckEquals(t, expected, actual) 26 | } 27 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/cdncontainers/doc.go: -------------------------------------------------------------------------------- 1 | // Package cdncontainers provides information and interaction with the CDN 2 | // Container API resource for the Rackspace Cloud Files service. 3 | package cdncontainers 4 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/cdncontainers/requests_test.go: -------------------------------------------------------------------------------- 1 | package cdncontainers 2 | 3 | import ( 4 | "net/http" 5 | "testing" 6 | 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | fake "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestEnableCDNContainer(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) { 15 | th.TestMethod(t, r, "PUT") 16 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 17 | th.TestHeader(t, r, "Accept", "application/json") 18 | 19 | w.Header().Add("X-Ttl", "259200") 20 | w.Header().Add("X-Cdn-Enabled", "True") 21 | w.WriteHeader(http.StatusNoContent) 22 | }) 23 | 24 | options := &EnableOpts{CDNEnabled: true, TTL: 259200} 25 | actual := Enable(fake.ServiceClient(), "testContainer", options) 26 | th.AssertNoErr(t, actual.Err) 27 | th.CheckEquals(t, actual.Header["X-Ttl"][0], "259200") 28 | th.CheckEquals(t, actual.Header["X-Cdn-Enabled"][0], "True") 29 | } 30 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/cdncontainers/urls.go: -------------------------------------------------------------------------------- 1 | package cdncontainers 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func enableURL(c *gophercloud.ServiceClient, containerName string) string { 6 | return c.ServiceURL(containerName) 7 | } 8 | 9 | func getURL(c *gophercloud.ServiceClient, container string) string { 10 | return c.ServiceURL(container) 11 | } 12 | 13 | func updateURL(c *gophercloud.ServiceClient, container string) string { 14 | return getURL(c, container) 15 | } 16 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/cdncontainers/urls_test.go: -------------------------------------------------------------------------------- 1 | package cdncontainers 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/rackspace/gophercloud" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | ) 9 | 10 | const endpoint = "http://localhost:57909/" 11 | 12 | func endpointClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} 14 | } 15 | 16 | func TestEnableURL(t *testing.T) { 17 | actual := enableURL(endpointClient(), "foo") 18 | expected := endpoint + "foo" 19 | th.CheckEquals(t, expected, actual) 20 | } 21 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/cdnobjects/delegate.go: -------------------------------------------------------------------------------- 1 | package cdnobjects 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects" 6 | ) 7 | 8 | // Delete is a function that deletes an object from the CDN. 9 | func Delete(c *gophercloud.ServiceClient, containerName, objectName string, opts os.DeleteOptsBuilder) os.DeleteResult { 10 | return os.Delete(c, containerName, objectName, nil) 11 | } 12 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/cdnobjects/delegate_test.go: -------------------------------------------------------------------------------- 1 | package cdnobjects 2 | 3 | import ( 4 | "testing" 5 | 6 | os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | fake "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestDeleteCDNObject(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | os.HandleDeleteObjectSuccessfully(t) 15 | 16 | res := Delete(fake.ServiceClient(), "testContainer", "testObject", nil) 17 | th.AssertNoErr(t, res.Err) 18 | 19 | } 20 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/cdnobjects/doc.go: -------------------------------------------------------------------------------- 1 | // Package cdnobjects provides information and interaction with the CDN 2 | // Object API resource for the Rackspace Cloud Files service. 3 | package cdnobjects 4 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/cdnobjects/request.go: -------------------------------------------------------------------------------- 1 | package cdnobjects 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers" 6 | ) 7 | 8 | // CDNURL returns the unique CDN URI for the given container and object. 9 | func CDNURL(c *gophercloud.ServiceClient, containerName, objectName string) (string, error) { 10 | h, err := cdncontainers.Get(c, containerName).Extract() 11 | if err != nil { 12 | return "", err 13 | } 14 | return h.CDNUri + "/" + objectName, nil 15 | } 16 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/containers/doc.go: -------------------------------------------------------------------------------- 1 | // Package containers provides information and interaction with the Container 2 | // API resource for the Rackspace Cloud Files service. 3 | package containers 4 | -------------------------------------------------------------------------------- /rackspace/objectstorage/v1/objects/doc.go: -------------------------------------------------------------------------------- 1 | // Package objects provides information and interaction with the Object 2 | // API resource for the Rackspace Cloud Files service. 3 | package objects 4 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/buildinfo/delegate.go: -------------------------------------------------------------------------------- 1 | package buildinfo 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo" 6 | ) 7 | 8 | // Get retreives build info data for the Heat deployment. 9 | func Get(c *gophercloud.ServiceClient) os.GetResult { 10 | return os.Get(c) 11 | } 12 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/buildinfo/delegate_test.go: -------------------------------------------------------------------------------- 1 | package buildinfo 2 | 3 | import ( 4 | "testing" 5 | 6 | os "github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo" 7 | th "github.com/rackspace/gophercloud/testhelper" 8 | fake "github.com/rackspace/gophercloud/testhelper/client" 9 | ) 10 | 11 | func TestGetTemplate(t *testing.T) { 12 | th.SetupHTTP() 13 | defer th.TeardownHTTP() 14 | os.HandleGetSuccessfully(t, os.GetOutput) 15 | 16 | actual, err := Get(fake.ServiceClient()).Extract() 17 | th.AssertNoErr(t, err) 18 | 19 | expected := os.GetExpected 20 | th.AssertDeepEquals(t, expected, actual) 21 | } 22 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/buildinfo/doc.go: -------------------------------------------------------------------------------- 1 | // Package buildinfo provides build information about heat deployments. 2 | package buildinfo 3 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/stackevents/doc.go: -------------------------------------------------------------------------------- 1 | // Package stackevents provides operations for finding, listing, and retrieving 2 | // stack events. 3 | package stackevents 4 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/stackresources/doc.go: -------------------------------------------------------------------------------- 1 | // Package stackresources provides operations for working with stack resources. 2 | // A resource is a template artifact that represents some component of your 3 | // desired architecture (a Cloud Server, a group of scaled Cloud Servers, a load 4 | // balancer, some configuration management system, and so forth). 5 | package stackresources 6 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/stacks/doc.go: -------------------------------------------------------------------------------- 1 | // Package stacks provides operation for working with Heat stacks. A stack is a 2 | // group of resources (servers, load balancers, databases, and so forth) 3 | // combined to fulfill a useful purpose. Based on a template, Heat orchestration 4 | // engine creates an instantiated set of resources (a stack) to run the 5 | // application framework or component specified (in the template). A stack is a 6 | // running instance of a template. The result of creating a stack is a deployment 7 | // of the application framework or component. 8 | package stacks 9 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/stacks/fixtures.go: -------------------------------------------------------------------------------- 1 | // +build fixtures 2 | 3 | package stacks 4 | 5 | import ( 6 | "github.com/rackspace/gophercloud" 7 | os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks" 8 | ) 9 | 10 | // CreateExpected represents the expected object from a Create request. 11 | var CreateExpected = &os.CreatedStack{ 12 | ID: "b663e18a-4767-4cdf-9db5-9c8cc13cc38a", 13 | Links: []gophercloud.Link{ 14 | gophercloud.Link{ 15 | Href: "https://ord.orchestration.api.rackspacecloud.com/v1/864477/stacks/stackcreated/b663e18a-4767-4cdf-9db5-9c8cc13cc38a", 16 | Rel: "self", 17 | }, 18 | }, 19 | } 20 | 21 | // CreateOutput represents the response body from a Create request. 22 | const CreateOutput = ` 23 | { 24 | "stack": { 25 | "id": "b663e18a-4767-4cdf-9db5-9c8cc13cc38a", 26 | "links": [ 27 | { 28 | "href": "https://ord.orchestration.api.rackspacecloud.com/v1/864477/stacks/stackcreated/b663e18a-4767-4cdf-9db5-9c8cc13cc38a", 29 | "rel": "self" 30 | } 31 | ] 32 | } 33 | } 34 | ` 35 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/stacktemplates/delegate.go: -------------------------------------------------------------------------------- 1 | package stacktemplates 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates" 6 | ) 7 | 8 | // Get retreives data for the given stack template. 9 | func Get(c *gophercloud.ServiceClient, stackName, stackID string) os.GetResult { 10 | return os.Get(c, stackName, stackID) 11 | } 12 | 13 | // Validate validates the given stack template. 14 | func Validate(c *gophercloud.ServiceClient, opts os.ValidateOptsBuilder) os.ValidateResult { 15 | return os.Validate(c, opts) 16 | } 17 | -------------------------------------------------------------------------------- /rackspace/orchestration/v1/stacktemplates/doc.go: -------------------------------------------------------------------------------- 1 | // Package stacktemplates provides operations for working with Heat templates. 2 | // A Cloud Orchestration template is a portable file, written in a user-readable 3 | // language, that describes how a set of resources should be assembled and what 4 | // software should be installed in order to produce a working stack. The template 5 | // specifies what resources should be used, what attributes can be set, and other 6 | // parameters that are critical to the successful, repeatable automation of a 7 | // specific application stack. 8 | package stacktemplates 9 | -------------------------------------------------------------------------------- /rackspace/rackconnect/v3/cloudnetworks/requests.go: -------------------------------------------------------------------------------- 1 | package cloudnetworks 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/pagination" 6 | ) 7 | 8 | // List returns all cloud networks that are associated with RackConnect. The ID 9 | // returned for each network is the same as the ID returned by the networks package. 10 | func List(c *gophercloud.ServiceClient) pagination.Pager { 11 | url := listURL(c) 12 | createPage := func(r pagination.PageResult) pagination.Page { 13 | return CloudNetworkPage{pagination.SinglePageBase(r)} 14 | } 15 | return pagination.NewPager(c, url, createPage) 16 | } 17 | 18 | // Get retrieves a specific cloud network (that is associated with RackConnect) 19 | // based on its unique ID. 20 | func Get(c *gophercloud.ServiceClient, id string) GetResult { 21 | var res GetResult 22 | _, res.Err = c.Get(getURL(c, id), &res.Body, nil) 23 | return res 24 | } 25 | -------------------------------------------------------------------------------- /rackspace/rackconnect/v3/cloudnetworks/urls.go: -------------------------------------------------------------------------------- 1 | package cloudnetworks 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | func listURL(c *gophercloud.ServiceClient) string { 6 | return c.ServiceURL("cloud_networks") 7 | } 8 | 9 | func getURL(c *gophercloud.ServiceClient, id string) string { 10 | return c.ServiceURL("cloud_networks", id) 11 | } 12 | -------------------------------------------------------------------------------- /rackspace/rackconnect/v3/doc.go: -------------------------------------------------------------------------------- 1 | // Package rackconnect allows Rackspace cloud accounts to leverage version 3 of 2 | // RackConnect, Rackspace's hybrid connectivity solution connecting dedicated 3 | // and cloud servers. 4 | package rackconnect 5 | -------------------------------------------------------------------------------- /rackspace/rackconnect/v3/lbpools/doc.go: -------------------------------------------------------------------------------- 1 | // Package lbpools provides access to load balancer pools associated with a 2 | // RackConnect configuration. Load Balancer Pools must be configured in advance 3 | // by your Network Security team to be eligible for use with RackConnect. 4 | // If you do not see a pool that you expect to see, contact your Support team 5 | // for further assistance. The Load Balancer Pool id returned by these calls is 6 | // automatically generated by the RackConnect automation and will remain constant 7 | // unless the Load Balancer Pool is renamed on your hardware load balancer. 8 | // All Load Balancer Pools will currently return a status of ACTIVE. Future 9 | // features may introduce additional statuses. 10 | // Node status values are ADDING, ACTIVE, REMOVING, ADD_FAILED, and REMOVE_FAILED. 11 | // The cloud_servers node count will only include Cloud Servers from the specified 12 | // cloud account. Any dedicated servers or cloud servers from another cloud account 13 | // on the same RackConnect Configuration will be counted as external nodes. 14 | package lbpools 15 | -------------------------------------------------------------------------------- /rackspace/rackconnect/v3/publicips/urls.go: -------------------------------------------------------------------------------- 1 | package publicips 2 | 3 | import "github.com/rackspace/gophercloud" 4 | 5 | var root = "public_ips" 6 | 7 | func listURL(c *gophercloud.ServiceClient) string { 8 | return c.ServiceURL(root) 9 | } 10 | 11 | func createURL(c *gophercloud.ServiceClient) string { 12 | return c.ServiceURL(root) 13 | } 14 | 15 | func listForServerURL(c *gophercloud.ServiceClient, serverID string) string { 16 | return c.ServiceURL(root + "?cloud_server_id=" + serverID) 17 | } 18 | 19 | func getURL(c *gophercloud.ServiceClient, id string) string { 20 | return c.ServiceURL(root, id) 21 | } 22 | 23 | func deleteURL(c *gophercloud.ServiceClient, id string) string { 24 | return getURL(c, id) 25 | } 26 | -------------------------------------------------------------------------------- /script/acceptancetest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run the acceptance tests. 4 | 5 | exec go test -p=1 -tags 'acceptance fixtures' github.com/rackspace/gophercloud/acceptance/... $@ 6 | -------------------------------------------------------------------------------- /script/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script helps new contributors set up their local workstation for 4 | # gophercloud development and contributions. 5 | 6 | # Create the environment 7 | export GOPATH=$HOME/go/gophercloud 8 | mkdir -p $GOPATH 9 | 10 | # Download gophercloud into that environment 11 | go get github.com/rackspace/gophercloud 12 | cd $GOPATH/src/github.com/rackspace/gophercloud 13 | git checkout master 14 | 15 | # Write out the env.sh convenience file. 16 | cd $GOPATH 17 | cat <env.sh 18 | #!/bin/bash 19 | export GOPATH=$(pwd) 20 | export GOPHERCLOUD=$GOPATH/src/github.com/rackspace/gophercloud 21 | EOF 22 | chmod a+x env.sh 23 | 24 | # Make changes immediately available as a convenience. 25 | . ./env.sh 26 | 27 | -------------------------------------------------------------------------------- /script/cibuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test script to be invoked by Travis. 4 | 5 | exec script/unittest -v 6 | -------------------------------------------------------------------------------- /script/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run all the tests. 4 | 5 | exec go test -tags 'acceptance fixtures' ./... $@ 6 | -------------------------------------------------------------------------------- /script/unittest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run the unit tests. 4 | 5 | exec go test -tags fixtures ./... $@ 6 | -------------------------------------------------------------------------------- /service_client_test.go: -------------------------------------------------------------------------------- 1 | package gophercloud 2 | 3 | import ( 4 | "testing" 5 | 6 | th "github.com/rackspace/gophercloud/testhelper" 7 | ) 8 | 9 | func TestServiceURL(t *testing.T) { 10 | c := &ServiceClient{Endpoint: "http://123.45.67.8/"} 11 | expected := "http://123.45.67.8/more/parts/here" 12 | actual := c.ServiceURL("more", "parts", "here") 13 | th.CheckEquals(t, expected, actual) 14 | } 15 | -------------------------------------------------------------------------------- /testhelper/client/fake.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/rackspace/gophercloud" 5 | "github.com/rackspace/gophercloud/testhelper" 6 | ) 7 | 8 | // Fake token to use. 9 | const TokenID = "cbc36478b0bd8e67e89469c7749d4127" 10 | 11 | // ServiceClient returns a generic service client for use in tests. 12 | func ServiceClient() *gophercloud.ServiceClient { 13 | return &gophercloud.ServiceClient{ 14 | ProviderClient: &gophercloud.ProviderClient{TokenID: TokenID}, 15 | Endpoint: testhelper.Endpoint(), 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testhelper/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package testhelper container methods that are useful for writing unit tests. 3 | */ 4 | package testhelper 5 | -------------------------------------------------------------------------------- /testhelper/fixture/helper.go: -------------------------------------------------------------------------------- 1 | package fixture 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "testing" 7 | 8 | th "github.com/rackspace/gophercloud/testhelper" 9 | "github.com/rackspace/gophercloud/testhelper/client" 10 | ) 11 | 12 | func SetupHandler(t *testing.T, url, method, requestBody, responseBody string, status int) { 13 | th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { 14 | th.TestMethod(t, r, method) 15 | th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 16 | 17 | if requestBody != "" { 18 | th.TestJSONRequest(t, r, requestBody) 19 | } 20 | 21 | if responseBody != "" { 22 | w.Header().Add("Content-Type", "application/json") 23 | } 24 | 25 | w.WriteHeader(status) 26 | 27 | if responseBody != "" { 28 | fmt.Fprintf(w, responseBody) 29 | } 30 | }) 31 | } 32 | --------------------------------------------------------------------------------