gitlab-fog-google 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codecov.yml +2 -0
- data/.editorconfig +11 -0
- data/.fog.example +25 -0
- data/.gitignore +20 -0
- data/.gitlab-ci.yml +13 -0
- data/.hound.yml +2 -0
- data/.rubocop.yml +255 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +33 -0
- data/CHANGELOG.md +464 -0
- data/CONTRIBUTING.md +175 -0
- data/CONTRIBUTORS.md +95 -0
- data/Gemfile +13 -0
- data/LICENSE.md +20 -0
- data/MIGRATING.md +1 -0
- data/README.md +177 -0
- data/Rakefile +19 -0
- data/SECURITY.md +16 -0
- data/ci/.gitignore +1 -0
- data/ci/README.md +65 -0
- data/ci/build-head-pipeline.yml +173 -0
- data/ci/credentials.yml.template +28 -0
- data/ci/docker-image/Dockerfile +18 -0
- data/ci/integration-pipeline.yml +226 -0
- data/ci/pipeline-dev.yml +58 -0
- data/ci/tasks/run-int.sh +53 -0
- data/ci/tasks/run-int.yml +18 -0
- data/ci/tasks/utils.sh +10 -0
- data/examples/backend_services.rb +23 -0
- data/examples/bootstrap.rb +27 -0
- data/examples/create_instance.rb +73 -0
- data/examples/create_instance_with_attached_disk.rb +53 -0
- data/examples/dns/project.rb +7 -0
- data/examples/dns/zones.rb +43 -0
- data/examples/get_list_images.rb +42 -0
- data/examples/get_list_snapshots.rb +28 -0
- data/examples/image_create.rb +17 -0
- data/examples/l7_load_balance.rb +79 -0
- data/examples/load-balance.rb +116 -0
- data/examples/metadata.rb +40 -0
- data/examples/monitoring/metric_descriptors.rb +24 -0
- data/examples/monitoring/monitored_resource_descriptors.rb +24 -0
- data/examples/monitoring/timeseries_collection.rb +32 -0
- data/examples/network.rb +55 -0
- data/examples/precreated_client.rb +24 -0
- data/examples/pubsub/subscriptions.rb +54 -0
- data/examples/pubsub/topics.rb +33 -0
- data/examples/sql/flags.rb +11 -0
- data/examples/sql/instances.rb +38 -0
- data/examples/sql/operations.rb +24 -0
- data/examples/sql/ssl_certs.rb +32 -0
- data/examples/sql/tiers.rb +11 -0
- data/examples/storage.rb +49 -0
- data/examples/storage_json.rb +37 -0
- data/gitlab-fog-google.gemspec +44 -0
- data/lib/fog/bin/google.rb +97 -0
- data/lib/fog/compute/google.rb +304 -0
- data/lib/fog/compute/google/mock.rb +845 -0
- data/lib/fog/compute/google/models/address.rb +133 -0
- data/lib/fog/compute/google/models/addresses.rb +63 -0
- data/lib/fog/compute/google/models/backend_service.rb +86 -0
- data/lib/fog/compute/google/models/backend_services.rb +24 -0
- data/lib/fog/compute/google/models/disk.rb +155 -0
- data/lib/fog/compute/google/models/disk_type.rb +27 -0
- data/lib/fog/compute/google/models/disk_types.rb +42 -0
- data/lib/fog/compute/google/models/disks.rb +88 -0
- data/lib/fog/compute/google/models/firewall.rb +94 -0
- data/lib/fog/compute/google/models/firewalls.rb +24 -0
- data/lib/fog/compute/google/models/forwarding_rule.rb +79 -0
- data/lib/fog/compute/google/models/forwarding_rules.rb +44 -0
- data/lib/fog/compute/google/models/global_address.rb +58 -0
- data/lib/fog/compute/google/models/global_addresses.rb +46 -0
- data/lib/fog/compute/google/models/global_forwarding_rule.rb +78 -0
- data/lib/fog/compute/google/models/global_forwarding_rules.rb +24 -0
- data/lib/fog/compute/google/models/http_health_check.rb +104 -0
- data/lib/fog/compute/google/models/http_health_checks.rb +24 -0
- data/lib/fog/compute/google/models/image.rb +81 -0
- data/lib/fog/compute/google/models/images.rb +109 -0
- data/lib/fog/compute/google/models/instance_group.rb +90 -0
- data/lib/fog/compute/google/models/instance_group_manager.rb +51 -0
- data/lib/fog/compute/google/models/instance_group_managers.rb +45 -0
- data/lib/fog/compute/google/models/instance_groups.rb +63 -0
- data/lib/fog/compute/google/models/instance_template.rb +47 -0
- data/lib/fog/compute/google/models/instance_templates.rb +24 -0
- data/lib/fog/compute/google/models/machine_type.rb +23 -0
- data/lib/fog/compute/google/models/machine_types.rb +46 -0
- data/lib/fog/compute/google/models/network.rb +60 -0
- data/lib/fog/compute/google/models/networks.rb +24 -0
- data/lib/fog/compute/google/models/operation.rb +73 -0
- data/lib/fog/compute/google/models/operations.rb +45 -0
- data/lib/fog/compute/google/models/project.rb +28 -0
- data/lib/fog/compute/google/models/projects.rb +19 -0
- data/lib/fog/compute/google/models/region.rb +30 -0
- data/lib/fog/compute/google/models/regions.rb +24 -0
- data/lib/fog/compute/google/models/route.rb +49 -0
- data/lib/fog/compute/google/models/routes.rb +24 -0
- data/lib/fog/compute/google/models/server.rb +604 -0
- data/lib/fog/compute/google/models/servers.rb +120 -0
- data/lib/fog/compute/google/models/snapshot.rb +62 -0
- data/lib/fog/compute/google/models/snapshots.rb +32 -0
- data/lib/fog/compute/google/models/ssl_certificate.rb +42 -0
- data/lib/fog/compute/google/models/ssl_certificates.rb +24 -0
- data/lib/fog/compute/google/models/subnetwork.rb +83 -0
- data/lib/fog/compute/google/models/subnetworks.rb +43 -0
- data/lib/fog/compute/google/models/target_http_proxies.rb +24 -0
- data/lib/fog/compute/google/models/target_http_proxy.rb +73 -0
- data/lib/fog/compute/google/models/target_https_proxies.rb +24 -0
- data/lib/fog/compute/google/models/target_https_proxy.rb +105 -0
- data/lib/fog/compute/google/models/target_instance.rb +67 -0
- data/lib/fog/compute/google/models/target_instances.rb +46 -0
- data/lib/fog/compute/google/models/target_pool.rb +171 -0
- data/lib/fog/compute/google/models/target_pools.rb +43 -0
- data/lib/fog/compute/google/models/url_map.rb +121 -0
- data/lib/fog/compute/google/models/url_maps.rb +24 -0
- data/lib/fog/compute/google/models/zone.rb +25 -0
- data/lib/fog/compute/google/models/zones.rb +24 -0
- data/lib/fog/compute/google/real.rb +24 -0
- data/lib/fog/compute/google/requests/abandon_instances.rb +28 -0
- data/lib/fog/compute/google/requests/add_backend_service_backends.rb +19 -0
- data/lib/fog/compute/google/requests/add_instance_group_instances.rb +37 -0
- data/lib/fog/compute/google/requests/add_server_access_config.rb +32 -0
- data/lib/fog/compute/google/requests/add_target_pool_health_checks.rb +32 -0
- data/lib/fog/compute/google/requests/add_target_pool_instances.rb +30 -0
- data/lib/fog/compute/google/requests/attach_disk.rb +22 -0
- data/lib/fog/compute/google/requests/create_disk_snapshot.rb +24 -0
- data/lib/fog/compute/google/requests/delete_address.rb +24 -0
- data/lib/fog/compute/google/requests/delete_backend_service.rb +19 -0
- data/lib/fog/compute/google/requests/delete_disk.rb +25 -0
- data/lib/fog/compute/google/requests/delete_firewall.rb +19 -0
- data/lib/fog/compute/google/requests/delete_forwarding_rule.rb +20 -0
- data/lib/fog/compute/google/requests/delete_global_address.rb +19 -0
- data/lib/fog/compute/google/requests/delete_global_forwarding_rule.rb +19 -0
- data/lib/fog/compute/google/requests/delete_global_operation.rb +20 -0
- data/lib/fog/compute/google/requests/delete_http_health_check.rb +19 -0
- data/lib/fog/compute/google/requests/delete_image.rb +19 -0
- data/lib/fog/compute/google/requests/delete_instance_group.rb +19 -0
- data/lib/fog/compute/google/requests/delete_instance_group_manager.rb +19 -0
- data/lib/fog/compute/google/requests/delete_instance_template.rb +19 -0
- data/lib/fog/compute/google/requests/delete_network.rb +19 -0
- data/lib/fog/compute/google/requests/delete_region_operation.rb +22 -0
- data/lib/fog/compute/google/requests/delete_route.rb +23 -0
- data/lib/fog/compute/google/requests/delete_server.rb +19 -0
- data/lib/fog/compute/google/requests/delete_server_access_config.rb +22 -0
- data/lib/fog/compute/google/requests/delete_snapshot.rb +19 -0
- data/lib/fog/compute/google/requests/delete_ssl_certificate.rb +19 -0
- data/lib/fog/compute/google/requests/delete_subnetwork.rb +31 -0
- data/lib/fog/compute/google/requests/delete_target_http_proxy.rb +19 -0
- data/lib/fog/compute/google/requests/delete_target_https_proxy.rb +19 -0
- data/lib/fog/compute/google/requests/delete_target_instance.rb +20 -0
- data/lib/fog/compute/google/requests/delete_target_pool.rb +20 -0
- data/lib/fog/compute/google/requests/delete_url_map.rb +19 -0
- data/lib/fog/compute/google/requests/delete_zone_operation.rb +22 -0
- data/lib/fog/compute/google/requests/deprecate_image.rb +22 -0
- data/lib/fog/compute/google/requests/detach_disk.rb +20 -0
- data/lib/fog/compute/google/requests/expand_subnetwork_ip_cidr_range.rb +38 -0
- data/lib/fog/compute/google/requests/get_address.rb +24 -0
- data/lib/fog/compute/google/requests/get_backend_service.rb +19 -0
- data/lib/fog/compute/google/requests/get_backend_service_health.rb +24 -0
- data/lib/fog/compute/google/requests/get_disk.rb +24 -0
- data/lib/fog/compute/google/requests/get_disk_type.rb +19 -0
- data/lib/fog/compute/google/requests/get_firewall.rb +19 -0
- data/lib/fog/compute/google/requests/get_forwarding_rule.rb +22 -0
- data/lib/fog/compute/google/requests/get_global_address.rb +19 -0
- data/lib/fog/compute/google/requests/get_global_forwarding_rule.rb +19 -0
- data/lib/fog/compute/google/requests/get_global_operation.rb +23 -0
- data/lib/fog/compute/google/requests/get_http_health_check.rb +19 -0
- data/lib/fog/compute/google/requests/get_image.rb +20 -0
- data/lib/fog/compute/google/requests/get_image_from_family.rb +26 -0
- data/lib/fog/compute/google/requests/get_instance_group.rb +19 -0
- data/lib/fog/compute/google/requests/get_instance_group_manager.rb +19 -0
- data/lib/fog/compute/google/requests/get_instance_template.rb +19 -0
- data/lib/fog/compute/google/requests/get_machine_type.rb +20 -0
- data/lib/fog/compute/google/requests/get_network.rb +19 -0
- data/lib/fog/compute/google/requests/get_project.rb +19 -0
- data/lib/fog/compute/google/requests/get_region.rb +19 -0
- data/lib/fog/compute/google/requests/get_region_operation.rb +20 -0
- data/lib/fog/compute/google/requests/get_route.rb +22 -0
- data/lib/fog/compute/google/requests/get_server.rb +19 -0
- data/lib/fog/compute/google/requests/get_server_serial_port_output.rb +38 -0
- data/lib/fog/compute/google/requests/get_snapshot.rb +20 -0
- data/lib/fog/compute/google/requests/get_ssl_certificate.rb +19 -0
- data/lib/fog/compute/google/requests/get_subnetwork.rb +29 -0
- data/lib/fog/compute/google/requests/get_target_http_proxy.rb +19 -0
- data/lib/fog/compute/google/requests/get_target_https_proxy.rb +19 -0
- data/lib/fog/compute/google/requests/get_target_instance.rb +20 -0
- data/lib/fog/compute/google/requests/get_target_pool.rb +20 -0
- data/lib/fog/compute/google/requests/get_target_pool_health.rb +24 -0
- data/lib/fog/compute/google/requests/get_url_map.rb +19 -0
- data/lib/fog/compute/google/requests/get_zone.rb +19 -0
- data/lib/fog/compute/google/requests/get_zone_operation.rb +25 -0
- data/lib/fog/compute/google/requests/insert_address.rb +30 -0
- data/lib/fog/compute/google/requests/insert_backend_service.rb +23 -0
- data/lib/fog/compute/google/requests/insert_disk.rb +48 -0
- data/lib/fog/compute/google/requests/insert_firewall.rb +65 -0
- data/lib/fog/compute/google/requests/insert_forwarding_rule.rb +29 -0
- data/lib/fog/compute/google/requests/insert_global_address.rb +25 -0
- data/lib/fog/compute/google/requests/insert_global_forwarding_rule.rb +26 -0
- data/lib/fog/compute/google/requests/insert_http_health_check.rb +24 -0
- data/lib/fog/compute/google/requests/insert_image.rb +23 -0
- data/lib/fog/compute/google/requests/insert_instance_group.rb +37 -0
- data/lib/fog/compute/google/requests/insert_instance_group_manager.rb +31 -0
- data/lib/fog/compute/google/requests/insert_instance_template.rb +38 -0
- data/lib/fog/compute/google/requests/insert_network.rb +34 -0
- data/lib/fog/compute/google/requests/insert_route.rb +35 -0
- data/lib/fog/compute/google/requests/insert_server.rb +122 -0
- data/lib/fog/compute/google/requests/insert_ssl_certificate.rb +27 -0
- data/lib/fog/compute/google/requests/insert_subnetwork.rb +61 -0
- data/lib/fog/compute/google/requests/insert_target_http_proxy.rb +26 -0
- data/lib/fog/compute/google/requests/insert_target_https_proxy.rb +29 -0
- data/lib/fog/compute/google/requests/insert_target_instance.rb +25 -0
- data/lib/fog/compute/google/requests/insert_target_pool.rb +22 -0
- data/lib/fog/compute/google/requests/insert_url_map.rb +37 -0
- data/lib/fog/compute/google/requests/invalidate_url_map_cache.rb +24 -0
- data/lib/fog/compute/google/requests/list_addresses.rb +28 -0
- data/lib/fog/compute/google/requests/list_aggregated_addresses.rb +23 -0
- data/lib/fog/compute/google/requests/list_aggregated_disk_types.rb +24 -0
- data/lib/fog/compute/google/requests/list_aggregated_disks.rb +32 -0
- data/lib/fog/compute/google/requests/list_aggregated_forwarding_rules.rb +24 -0
- data/lib/fog/compute/google/requests/list_aggregated_instance_group_managers.rb +26 -0
- data/lib/fog/compute/google/requests/list_aggregated_instance_groups.rb +19 -0
- data/lib/fog/compute/google/requests/list_aggregated_machine_types.rb +24 -0
- data/lib/fog/compute/google/requests/list_aggregated_servers.rb +24 -0
- data/lib/fog/compute/google/requests/list_aggregated_subnetworks.rb +36 -0
- data/lib/fog/compute/google/requests/list_aggregated_target_instances.rb +26 -0
- data/lib/fog/compute/google/requests/list_aggregated_target_pools.rb +26 -0
- data/lib/fog/compute/google/requests/list_backend_services.rb +22 -0
- data/lib/fog/compute/google/requests/list_disk_types.rb +24 -0
- data/lib/fog/compute/google/requests/list_disks.rb +28 -0
- data/lib/fog/compute/google/requests/list_firewalls.rb +24 -0
- data/lib/fog/compute/google/requests/list_forwarding_rules.rb +25 -0
- data/lib/fog/compute/google/requests/list_global_addresses.rb +26 -0
- data/lib/fog/compute/google/requests/list_global_forwarding_rules.rb +24 -0
- data/lib/fog/compute/google/requests/list_global_operations.rb +27 -0
- data/lib/fog/compute/google/requests/list_http_health_checks.rb +24 -0
- data/lib/fog/compute/google/requests/list_images.rb +25 -0
- data/lib/fog/compute/google/requests/list_instance_group_instances.rb +21 -0
- data/lib/fog/compute/google/requests/list_instance_group_managers.rb +22 -0
- data/lib/fog/compute/google/requests/list_instance_groups.rb +19 -0
- data/lib/fog/compute/google/requests/list_instance_templates.rb +26 -0
- data/lib/fog/compute/google/requests/list_machine_types.rb +25 -0
- data/lib/fog/compute/google/requests/list_networks.rb +24 -0
- data/lib/fog/compute/google/requests/list_region_operations.rb +29 -0
- data/lib/fog/compute/google/requests/list_regions.rb +23 -0
- data/lib/fog/compute/google/requests/list_routes.rb +28 -0
- data/lib/fog/compute/google/requests/list_servers.rb +24 -0
- data/lib/fog/compute/google/requests/list_snapshots.rb +22 -0
- data/lib/fog/compute/google/requests/list_ssl_certificates.rb +26 -0
- data/lib/fog/compute/google/requests/list_subnetworks.rb +39 -0
- data/lib/fog/compute/google/requests/list_target_http_proxies.rb +25 -0
- data/lib/fog/compute/google/requests/list_target_https_proxies.rb +24 -0
- data/lib/fog/compute/google/requests/list_target_instances.rb +27 -0
- data/lib/fog/compute/google/requests/list_target_pools.rb +26 -0
- data/lib/fog/compute/google/requests/list_url_maps.rb +25 -0
- data/lib/fog/compute/google/requests/list_zone_operations.rb +28 -0
- data/lib/fog/compute/google/requests/list_zones.rb +26 -0
- data/lib/fog/compute/google/requests/patch_firewall.rb +27 -0
- data/lib/fog/compute/google/requests/patch_url_map.rb +21 -0
- data/lib/fog/compute/google/requests/recreate_instances.rb +28 -0
- data/lib/fog/compute/google/requests/remove_instance_group_instances.rb +37 -0
- data/lib/fog/compute/google/requests/remove_target_pool_health_checks.rb +30 -0
- data/lib/fog/compute/google/requests/remove_target_pool_instance.rb +30 -0
- data/lib/fog/compute/google/requests/remove_target_pool_instances.rb +30 -0
- data/lib/fog/compute/google/requests/reset_server.rb +19 -0
- data/lib/fog/compute/google/requests/reset_windows_password.rb +154 -0
- data/lib/fog/compute/google/requests/set_common_instance_metadata.rb +23 -0
- data/lib/fog/compute/google/requests/set_forwarding_rule_target.rb +23 -0
- data/lib/fog/compute/google/requests/set_global_forwarding_rule_target.rb +22 -0
- data/lib/fog/compute/google/requests/set_instance_template.rb +28 -0
- data/lib/fog/compute/google/requests/set_server_disk_auto_delete.rb +26 -0
- data/lib/fog/compute/google/requests/set_server_machine_type.rb +23 -0
- data/lib/fog/compute/google/requests/set_server_metadata.rb +39 -0
- data/lib/fog/compute/google/requests/set_server_scheduling.rb +24 -0
- data/lib/fog/compute/google/requests/set_server_tags.rb +25 -0
- data/lib/fog/compute/google/requests/set_snapshot_labels.rb +25 -0
- data/lib/fog/compute/google/requests/set_subnetwork_private_ip_google_access.rb +42 -0
- data/lib/fog/compute/google/requests/set_target_http_proxy_url_map.rb +24 -0
- data/lib/fog/compute/google/requests/set_target_https_proxy_ssl_certificates.rb +24 -0
- data/lib/fog/compute/google/requests/set_target_https_proxy_url_map.rb +24 -0
- data/lib/fog/compute/google/requests/set_target_pool_backup.rb +31 -0
- data/lib/fog/compute/google/requests/start_server.rb +19 -0
- data/lib/fog/compute/google/requests/stop_server.rb +19 -0
- data/lib/fog/compute/google/requests/update_firewall.rb +49 -0
- data/lib/fog/compute/google/requests/update_http_health_check.rb +25 -0
- data/lib/fog/compute/google/requests/update_url_map.rb +28 -0
- data/lib/fog/compute/google/requests/validate_url_map.rb +24 -0
- data/lib/fog/dns/google.rb +67 -0
- data/lib/fog/dns/google/mock.rb +33 -0
- data/lib/fog/dns/google/models/change.rb +38 -0
- data/lib/fog/dns/google/models/changes.rb +50 -0
- data/lib/fog/dns/google/models/project.rb +73 -0
- data/lib/fog/dns/google/models/projects.rb +23 -0
- data/lib/fog/dns/google/models/record.rb +108 -0
- data/lib/fog/dns/google/models/records.rb +53 -0
- data/lib/fog/dns/google/models/zone.rb +72 -0
- data/lib/fog/dns/google/models/zones.rb +32 -0
- data/lib/fog/dns/google/real.rb +19 -0
- data/lib/fog/dns/google/requests/create_change.rb +29 -0
- data/lib/fog/dns/google/requests/create_managed_zone.rb +29 -0
- data/lib/fog/dns/google/requests/delete_managed_zone.rb +23 -0
- data/lib/fog/dns/google/requests/get_change.rb +23 -0
- data/lib/fog/dns/google/requests/get_managed_zone.rb +23 -0
- data/lib/fog/dns/google/requests/get_project.rb +24 -0
- data/lib/fog/dns/google/requests/list_changes.rb +30 -0
- data/lib/fog/dns/google/requests/list_managed_zones.rb +26 -0
- data/lib/fog/dns/google/requests/list_resource_record_sets.rb +30 -0
- data/lib/fog/google.rb +53 -0
- data/lib/fog/google/mock.rb +14 -0
- data/lib/fog/google/models/monitoring/metric_descriptor.rb +23 -0
- data/lib/fog/google/models/monitoring/metric_descriptors.rb +43 -0
- data/lib/fog/google/models/monitoring/monitored_resource_descriptor.rb +20 -0
- data/lib/fog/google/models/monitoring/monitored_resource_descriptors.rb +37 -0
- data/lib/fog/google/models/monitoring/timeseries.rb +19 -0
- data/lib/fog/google/models/monitoring/timeseries_collection.rb +48 -0
- data/lib/fog/google/models/pubsub/received_message.rb +40 -0
- data/lib/fog/google/models/pubsub/subscription.rb +86 -0
- data/lib/fog/google/models/pubsub/subscriptions.rb +33 -0
- data/lib/fog/google/models/pubsub/topic.rb +71 -0
- data/lib/fog/google/models/pubsub/topics.rb +32 -0
- data/lib/fog/google/models/sql/backup_run.rb +37 -0
- data/lib/fog/google/models/sql/backup_runs.rb +38 -0
- data/lib/fog/google/models/sql/flag.rb +23 -0
- data/lib/fog/google/models/sql/flags.rb +21 -0
- data/lib/fog/google/models/sql/instance.rb +339 -0
- data/lib/fog/google/models/sql/instances.rb +39 -0
- data/lib/fog/google/models/sql/operation.rb +67 -0
- data/lib/fog/google/models/sql/operations.rb +47 -0
- data/lib/fog/google/models/sql/ssl_cert.rb +77 -0
- data/lib/fog/google/models/sql/ssl_certs.rb +49 -0
- data/lib/fog/google/models/sql/tier.rb +20 -0
- data/lib/fog/google/models/sql/tiers.rb +21 -0
- data/lib/fog/google/models/sql/user.rb +52 -0
- data/lib/fog/google/models/sql/users.rb +21 -0
- data/lib/fog/google/monitoring.rb +60 -0
- data/lib/fog/google/monitoring/mock.rb +35 -0
- data/lib/fog/google/monitoring/real.rb +20 -0
- data/lib/fog/google/pubsub.rb +69 -0
- data/lib/fog/google/pubsub/mock.rb +34 -0
- data/lib/fog/google/pubsub/real.rb +21 -0
- data/lib/fog/google/requests/monitoring/create_metric_descriptor.rb +51 -0
- data/lib/fog/google/requests/monitoring/create_timeseries.rb +29 -0
- data/lib/fog/google/requests/monitoring/delete_metric_descriptor.rb +19 -0
- data/lib/fog/google/requests/monitoring/get_metric_descriptor.rb +19 -0
- data/lib/fog/google/requests/monitoring/get_monitored_resource_descriptor.rb +19 -0
- data/lib/fog/google/requests/monitoring/list_metric_descriptors.rb +26 -0
- data/lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb +29 -0
- data/lib/fog/google/requests/monitoring/list_timeseries.rb +55 -0
- data/lib/fog/google/requests/pubsub/acknowledge_subscription.rb +29 -0
- data/lib/fog/google/requests/pubsub/create_subscription.rb +37 -0
- data/lib/fog/google/requests/pubsub/create_topic.rb +23 -0
- data/lib/fog/google/requests/pubsub/delete_subscription.rb +21 -0
- data/lib/fog/google/requests/pubsub/delete_topic.rb +21 -0
- data/lib/fog/google/requests/pubsub/get_subscription.rb +21 -0
- data/lib/fog/google/requests/pubsub/get_topic.rb +21 -0
- data/lib/fog/google/requests/pubsub/list_subscriptions.rb +29 -0
- data/lib/fog/google/requests/pubsub/list_topics.rb +29 -0
- data/lib/fog/google/requests/pubsub/publish_topic.rb +28 -0
- data/lib/fog/google/requests/pubsub/pull_subscription.rb +40 -0
- data/lib/fog/google/requests/sql/clone_instance.rb +42 -0
- data/lib/fog/google/requests/sql/delete_backup_run.rb +23 -0
- data/lib/fog/google/requests/sql/delete_instance.rb +24 -0
- data/lib/fog/google/requests/sql/delete_ssl_cert.rb +24 -0
- data/lib/fog/google/requests/sql/delete_user.rb +24 -0
- data/lib/fog/google/requests/sql/export_instance.rb +55 -0
- data/lib/fog/google/requests/sql/get_backup_run.rb +23 -0
- data/lib/fog/google/requests/sql/get_instance.rb +24 -0
- data/lib/fog/google/requests/sql/get_operation.rb +24 -0
- data/lib/fog/google/requests/sql/get_ssl_cert.rb +24 -0
- data/lib/fog/google/requests/sql/import_instance.rb +44 -0
- data/lib/fog/google/requests/sql/insert_backup_run.rb +28 -0
- data/lib/fog/google/requests/sql/insert_instance.rb +28 -0
- data/lib/fog/google/requests/sql/insert_ssl_cert.rb +30 -0
- data/lib/fog/google/requests/sql/insert_user.rb +25 -0
- data/lib/fog/google/requests/sql/list_backup_runs.rb +27 -0
- data/lib/fog/google/requests/sql/list_flags.rb +24 -0
- data/lib/fog/google/requests/sql/list_instances.rb +27 -0
- data/lib/fog/google/requests/sql/list_operations.rb +28 -0
- data/lib/fog/google/requests/sql/list_ssl_certs.rb +24 -0
- data/lib/fog/google/requests/sql/list_tiers.rb +24 -0
- data/lib/fog/google/requests/sql/list_users.rb +24 -0
- data/lib/fog/google/requests/sql/reset_instance_ssl_config.rb +26 -0
- data/lib/fog/google/requests/sql/restart_instance.rb +24 -0
- data/lib/fog/google/requests/sql/restore_instance_backup.rb +31 -0
- data/lib/fog/google/requests/sql/update_instance.rb +31 -0
- data/lib/fog/google/requests/sql/update_user.rb +27 -0
- data/lib/fog/google/shared.rb +253 -0
- data/lib/fog/google/sql.rb +104 -0
- data/lib/fog/google/sql/mock.rb +40 -0
- data/lib/fog/google/sql/real.rb +21 -0
- data/lib/fog/google/version.rb +5 -0
- data/lib/fog/parsers/storage/google.rb +15 -0
- data/lib/fog/parsers/storage/google/access_control_list.rb +44 -0
- data/lib/fog/parsers/storage/google/copy_object.rb +18 -0
- data/lib/fog/parsers/storage/google/get_bucket.rb +58 -0
- data/lib/fog/parsers/storage/google/get_bucket_logging.rb +36 -0
- data/lib/fog/parsers/storage/google/get_bucket_object_versions.rb +88 -0
- data/lib/fog/parsers/storage/google/get_bucket_versioning.rb +20 -0
- data/lib/fog/parsers/storage/google/get_request_payment.rb +16 -0
- data/lib/fog/parsers/storage/google/get_service.rb +28 -0
- data/lib/fog/storage/google.rb +20 -0
- data/lib/fog/storage/google_json.rb +74 -0
- data/lib/fog/storage/google_json/mock.rb +27 -0
- data/lib/fog/storage/google_json/models/directories.rb +41 -0
- data/lib/fog/storage/google_json/models/directory.rb +61 -0
- data/lib/fog/storage/google_json/models/file.rb +126 -0
- data/lib/fog/storage/google_json/models/files.rb +64 -0
- data/lib/fog/storage/google_json/real.rb +171 -0
- data/lib/fog/storage/google_json/requests/copy_object.rb +34 -0
- data/lib/fog/storage/google_json/requests/delete_bucket.rb +23 -0
- data/lib/fog/storage/google_json/requests/delete_object.rb +24 -0
- data/lib/fog/storage/google_json/requests/delete_object_url.rb +39 -0
- data/lib/fog/storage/google_json/requests/get_bucket.rb +43 -0
- data/lib/fog/storage/google_json/requests/get_bucket_acl.rb +32 -0
- data/lib/fog/storage/google_json/requests/get_object.rb +85 -0
- data/lib/fog/storage/google_json/requests/get_object_acl.rb +35 -0
- data/lib/fog/storage/google_json/requests/get_object_http_url.rb +32 -0
- data/lib/fog/storage/google_json/requests/get_object_https_url.rb +33 -0
- data/lib/fog/storage/google_json/requests/get_object_metadata.rb +32 -0
- data/lib/fog/storage/google_json/requests/get_object_url.rb +21 -0
- data/lib/fog/storage/google_json/requests/list_bucket_acl.rb +26 -0
- data/lib/fog/storage/google_json/requests/list_buckets.rb +30 -0
- data/lib/fog/storage/google_json/requests/list_object_acl.rb +29 -0
- data/lib/fog/storage/google_json/requests/list_objects.rb +48 -0
- data/lib/fog/storage/google_json/requests/put_bucket.rb +42 -0
- data/lib/fog/storage/google_json/requests/put_bucket_acl.rb +29 -0
- data/lib/fog/storage/google_json/requests/put_object.rb +102 -0
- data/lib/fog/storage/google_json/requests/put_object_acl.rb +35 -0
- data/lib/fog/storage/google_json/requests/put_object_url.rb +42 -0
- data/lib/fog/storage/google_json/utils.rb +40 -0
- data/lib/fog/storage/google_xml.rb +38 -0
- data/lib/fog/storage/google_xml/mock.rb +102 -0
- data/lib/fog/storage/google_xml/models/directories.rb +34 -0
- data/lib/fog/storage/google_xml/models/directory.rb +65 -0
- data/lib/fog/storage/google_xml/models/file.rb +130 -0
- data/lib/fog/storage/google_xml/models/files.rb +95 -0
- data/lib/fog/storage/google_xml/real.rb +108 -0
- data/lib/fog/storage/google_xml/requests/copy_object.rb +62 -0
- data/lib/fog/storage/google_xml/requests/delete_bucket.rb +39 -0
- data/lib/fog/storage/google_xml/requests/delete_object.rb +44 -0
- data/lib/fog/storage/google_xml/requests/delete_object_url.rb +42 -0
- data/lib/fog/storage/google_xml/requests/get_bucket.rb +95 -0
- data/lib/fog/storage/google_xml/requests/get_bucket_acl.rb +53 -0
- data/lib/fog/storage/google_xml/requests/get_object.rb +96 -0
- data/lib/fog/storage/google_xml/requests/get_object_acl.rb +62 -0
- data/lib/fog/storage/google_xml/requests/get_object_http_url.rb +37 -0
- data/lib/fog/storage/google_xml/requests/get_object_https_url.rb +37 -0
- data/lib/fog/storage/google_xml/requests/get_object_url.rb +31 -0
- data/lib/fog/storage/google_xml/requests/get_service.rb +44 -0
- data/lib/fog/storage/google_xml/requests/head_object.rb +55 -0
- data/lib/fog/storage/google_xml/requests/put_bucket.rb +71 -0
- data/lib/fog/storage/google_xml/requests/put_bucket_acl.rb +58 -0
- data/lib/fog/storage/google_xml/requests/put_object.rb +85 -0
- data/lib/fog/storage/google_xml/requests/put_object_acl.rb +58 -0
- data/lib/fog/storage/google_xml/requests/put_object_url.rb +42 -0
- data/lib/fog/storage/google_xml/utils.rb +83 -0
- data/tasks/bundler.rake +3 -0
- data/tasks/changelog.rake +39 -0
- data/tasks/console.rake +17 -0
- data/tasks/lint.rake +9 -0
- data/tasks/test.rake +115 -0
- data/test/helpers/client_helper.rb +63 -0
- data/test/helpers/integration_test_helper.rb +108 -0
- data/test/helpers/test_collection.rb +60 -0
- data/test/helpers/test_helper.rb +24 -0
- data/test/integration/compute/core_compute/test_client_options.rb +12 -0
- data/test/integration/compute/core_compute/test_coverage.rb +6 -0
- data/test/integration/compute/core_compute/test_disk_types.rb +43 -0
- data/test/integration/compute/core_compute/test_disks.rb +53 -0
- data/test/integration/compute/core_compute/test_images.rb +32 -0
- data/test/integration/compute/core_compute/test_machine_types.rb +55 -0
- data/test/integration/compute/core_compute/test_operations.rb +45 -0
- data/test/integration/compute/core_compute/test_projects.rb +19 -0
- data/test/integration/compute/core_compute/test_regions.rb +33 -0
- data/test/integration/compute/core_compute/test_servers.rb +149 -0
- data/test/integration/compute/core_compute/test_snapshots.rb +21 -0
- data/test/integration/compute/core_compute/test_zones.rb +35 -0
- data/test/integration/compute/core_networking/test_addresses.rb +107 -0
- data/test/integration/compute/core_networking/test_coverage.rb +6 -0
- data/test/integration/compute/core_networking/test_firewalls.rb +11 -0
- data/test/integration/compute/core_networking/test_networks.rb +41 -0
- data/test/integration/compute/core_networking/test_routes.rb +26 -0
- data/test/integration/compute/core_networking/test_subnetworks.rb +11 -0
- data/test/integration/compute/instance_groups/test_coverage.rb +6 -0
- data/test/integration/compute/instance_groups/test_instance_group_managers.rb +11 -0
- data/test/integration/compute/instance_groups/test_instance_groups.rb +11 -0
- data/test/integration/compute/instance_groups/test_instance_templates.rb +11 -0
- data/test/integration/compute/loadbalancing/test_backend_services.rb +11 -0
- data/test/integration/compute/loadbalancing/test_coverage.rb +6 -0
- data/test/integration/compute/loadbalancing/test_forwarding_rules.rb +11 -0
- data/test/integration/compute/loadbalancing/test_global_addresses.rb +11 -0
- data/test/integration/compute/loadbalancing/test_global_forwarding_rules.rb +11 -0
- data/test/integration/compute/loadbalancing/test_http_health_checks.rb +11 -0
- data/test/integration/compute/loadbalancing/test_ssl_certificates.rb +11 -0
- data/test/integration/compute/loadbalancing/test_target_http_proxies.rb +11 -0
- data/test/integration/compute/loadbalancing/test_target_https_proxies.rb +11 -0
- data/test/integration/compute/loadbalancing/test_target_instances.rb +11 -0
- data/test/integration/compute/loadbalancing/test_target_pools.rb +55 -0
- data/test/integration/compute/loadbalancing/test_url_maps.rb +11 -0
- data/test/integration/factories/addresses_factory.rb +20 -0
- data/test/integration/factories/backend_services_factory.rb +19 -0
- data/test/integration/factories/collection_factory.rb +52 -0
- data/test/integration/factories/disks_factory.rb +22 -0
- data/test/integration/factories/firewalls_factory.rb +13 -0
- data/test/integration/factories/forwarding_rules_factory.rb +25 -0
- data/test/integration/factories/global_addresses_factory.rb +15 -0
- data/test/integration/factories/global_forwarding_rules_factory.rb +20 -0
- data/test/integration/factories/http_health_checks_factory.rb +11 -0
- data/test/integration/factories/images_factory.rb +16 -0
- data/test/integration/factories/instance_group_manager_factory.rb +30 -0
- data/test/integration/factories/instance_groups_factory.rb +20 -0
- data/test/integration/factories/instance_template_factory.rb +24 -0
- data/test/integration/factories/networks_factory.rb +16 -0
- data/test/integration/factories/servers_factory.rb +30 -0
- data/test/integration/factories/sql_certs_factory.rb +20 -0
- data/test/integration/factories/sql_instances_factory.rb +19 -0
- data/test/integration/factories/sql_users_factory.rb +23 -0
- data/test/integration/factories/ssl_certificates_factory.rb +13 -0
- data/test/integration/factories/subnetworks_factory.rb +26 -0
- data/test/integration/factories/target_http_proxies_factory.rb +19 -0
- data/test/integration/factories/target_https_proxies_factory.rb +26 -0
- data/test/integration/factories/target_instances_factory.rb +24 -0
- data/test/integration/factories/target_pools_factory.rb +28 -0
- data/test/integration/factories/url_maps_factory.rb +19 -0
- data/test/integration/monitoring/test_coverage.rb +6 -0
- data/test/integration/monitoring/test_metric_descriptors.rb +131 -0
- data/test/integration/monitoring/test_monitored_resource_descriptors.rb +37 -0
- data/test/integration/monitoring/test_timeseries.rb +238 -0
- data/test/integration/pubsub/pubsub_shared.rb +75 -0
- data/test/integration/pubsub/test_coverage.rb +6 -0
- data/test/integration/pubsub/test_pubsub_models.rb +135 -0
- data/test/integration/pubsub/test_pubsub_requests.rb +105 -0
- data/test/integration/sql/test_certs.rb +50 -0
- data/test/integration/sql/test_common_flags.rb +31 -0
- data/test/integration/sql/test_common_tiers.rb +26 -0
- data/test/integration/sql/test_coverage.rb +6 -0
- data/test/integration/sql/test_instances.rb +101 -0
- data/test/integration/sql/test_users.rb +37 -0
- data/test/integration/storage/storage_shared.rb +96 -0
- data/test/integration/storage/test_buckets.rb +112 -0
- data/test/integration/storage/test_coverage.rb +6 -0
- data/test/integration/storage/test_directories.rb +67 -0
- data/test/integration/storage/test_files.rb +168 -0
- data/test/integration/storage/test_objects.rb +203 -0
- data/test/integration/test_authentication.rb +38 -0
- data/test/unit/compute/test_common_collections.rb +42 -0
- data/test/unit/compute/test_common_models.rb +35 -0
- data/test/unit/compute/test_server.rb +29 -0
- data/test/unit/dns/test_common_collections.rb +43 -0
- data/test/unit/monitoring/test_comon_collections.rb +44 -0
- data/test/unit/pubsub/test_common_collections.rb +35 -0
- data/test/unit/sql/test_common_collections.rb +46 -0
- data/test/unit/storage/test_common_json_collections.rb +38 -0
- data/test/unit/storage/test_common_xml_collections.rb +50 -0
- data/test/unit/storage/test_json_requests.rb +44 -0
- data/test/unit/storage/test_xml_requests.rb +60 -0
- metadata +897 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class GoogleJSON
|
4
|
+
class Mock
|
5
|
+
include Utils
|
6
|
+
include Fog::Google::Shared
|
7
|
+
|
8
|
+
MockClient = Struct.new(:issuer)
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, GOOGLE_STORAGE_JSON_BASE_URL)
|
12
|
+
@client = MockClient.new('test')
|
13
|
+
@storage_json = MockClient.new('test')
|
14
|
+
@iam_service = MockClient.new('test')
|
15
|
+
end
|
16
|
+
|
17
|
+
def signature(_params)
|
18
|
+
"foo"
|
19
|
+
end
|
20
|
+
|
21
|
+
def google_access_id
|
22
|
+
"my-account@project.iam.gserviceaccount"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class GoogleJSON
|
4
|
+
class Directories < Fog::Collection
|
5
|
+
model Fog::Storage::GoogleJSON::Directory
|
6
|
+
|
7
|
+
def all(opts = {})
|
8
|
+
data = service.list_buckets(opts).to_h[:items] || []
|
9
|
+
load(data)
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(bucket_name, options = {})
|
13
|
+
if_metageneration_match = options[:if_metageneration_match]
|
14
|
+
if_metageneration_not_match = options[:if_metageneration_not_match]
|
15
|
+
projection = options[:projection]
|
16
|
+
|
17
|
+
data = service.get_bucket(
|
18
|
+
bucket_name,
|
19
|
+
:if_metageneration_match => if_metageneration_match,
|
20
|
+
:if_metageneration_not_match => if_metageneration_not_match,
|
21
|
+
:projection => projection
|
22
|
+
).to_h
|
23
|
+
|
24
|
+
directory = new(data)
|
25
|
+
# Because fog-aws accepts these arguments on files at the
|
26
|
+
# directories.get level, we need to preload the directory files
|
27
|
+
# with these attributes here.
|
28
|
+
files_attr_names = %i(delimiter page_token max_results prefix)
|
29
|
+
|
30
|
+
file_opts = options.select { |k, _| files_attr_names.include? k }
|
31
|
+
directory.files(file_opts)
|
32
|
+
directory
|
33
|
+
rescue ::Google::Apis::ClientError => e
|
34
|
+
# metageneration check failures returns HTTP 412 Precondition Failed
|
35
|
+
raise e unless e.status_code == 404 || e.status_code == 412
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class GoogleJSON
|
4
|
+
##
|
5
|
+
# Represents a Google Storage bucket
|
6
|
+
class Directory < Fog::Model
|
7
|
+
identity :key, :aliases => ["Name", "name", :name]
|
8
|
+
|
9
|
+
attribute :acl
|
10
|
+
attribute :billing
|
11
|
+
attribute :cors
|
12
|
+
attribute :default_object_acl, aliases => "defaultObjectAcl"
|
13
|
+
attribute :etag
|
14
|
+
attribute :id
|
15
|
+
attribute :kind
|
16
|
+
attribute :labels
|
17
|
+
attribute :lifecycle
|
18
|
+
attribute :location
|
19
|
+
attribute :logging
|
20
|
+
attribute :metageneration
|
21
|
+
attribute :name
|
22
|
+
attribute :owner
|
23
|
+
attribute :project_number, aliases => "projectNumber"
|
24
|
+
attribute :self_link, aliases => "selfLink"
|
25
|
+
attribute :storage_class, aliases => "storageClass"
|
26
|
+
attribute :time_created, aliases => "timeCreated"
|
27
|
+
attribute :updated
|
28
|
+
attribute :versioning
|
29
|
+
attribute :website
|
30
|
+
|
31
|
+
def destroy
|
32
|
+
requires :key
|
33
|
+
service.delete_bucket(key)
|
34
|
+
true
|
35
|
+
rescue ::Google::Apis::ClientError => e
|
36
|
+
raise e unless e.status_code == 404
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
def files(attr = {})
|
41
|
+
@files ||= begin
|
42
|
+
Fog::Storage::GoogleJSON::Files.new(
|
43
|
+
attr.merge(:directory => self, :service => service)
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def public_url
|
49
|
+
requires :key
|
50
|
+
"#{GOOGLE_STORAGE_BUCKET_BASE_URL}#{key}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def save
|
54
|
+
requires :key
|
55
|
+
service.put_bucket(key, attributes)
|
56
|
+
true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class GoogleJSON
|
4
|
+
class File < Fog::Model
|
5
|
+
identity :key, :aliases => ["Key", :name]
|
6
|
+
|
7
|
+
attribute :acl
|
8
|
+
attribute :predefined_acl, :aliases => ["predefinedAcl", :predefined_acl]
|
9
|
+
attribute :cache_control, :aliases => ["cacheControl", :cache_control]
|
10
|
+
attribute :content_disposition, :aliases => ["contentDisposition", :content_disposition]
|
11
|
+
attribute :content_encoding, :aliases => ["contentEncoding", :content_encoding]
|
12
|
+
attribute :content_length, :aliases => ["size", :size], :type => :integer
|
13
|
+
attribute :content_md5, :aliases => ["md5Hash", :md5_hash]
|
14
|
+
attribute :content_type, :aliases => ["contentType", :content_type]
|
15
|
+
attribute :crc32c
|
16
|
+
attribute :etag, :aliases => ["etag", :etag]
|
17
|
+
attribute :time_created, :aliases => ["timeCreated", :time_created]
|
18
|
+
attribute :last_modified, :aliases => ["updated", :updated]
|
19
|
+
attribute :generation
|
20
|
+
attribute :metageneration
|
21
|
+
attribute :metadata, :aliases => ["metadata", :metadata]
|
22
|
+
attribute :self_link, :aliases => ["selfLink", :self_link]
|
23
|
+
attribute :media_link, :aliases => ["mediaLink", :media_link]
|
24
|
+
attribute :owner
|
25
|
+
attribute :storage_class, :aliases => "storageClass"
|
26
|
+
|
27
|
+
# attribute :body
|
28
|
+
|
29
|
+
# https://cloud.google.com/storage/docs/access-control/lists#predefined-acls
|
30
|
+
VALID_PREDEFINED_ACLS = [
|
31
|
+
"authenticatedRead",
|
32
|
+
"bucketOwnerFullControl",
|
33
|
+
"bucketOwnerRead",
|
34
|
+
"private",
|
35
|
+
"projectPrivate",
|
36
|
+
"publicRead",
|
37
|
+
"publicReadWrite"
|
38
|
+
].freeze
|
39
|
+
|
40
|
+
def predefined_acl=(new_predefined_acl)
|
41
|
+
unless VALID_PREDEFINED_ACLS.include?(new_predefined_acl)
|
42
|
+
raise ArgumentError.new("acl must be one of [#{VALID_PREDEFINED_ACLS.join(', ')}]")
|
43
|
+
end
|
44
|
+
@predefined_acl = new_predefined_acl
|
45
|
+
end
|
46
|
+
|
47
|
+
def body
|
48
|
+
last_modified && (file = collection.get(identity)) ? attributes[:body] ||= file.body : attributes[:body] ||= ""
|
49
|
+
end
|
50
|
+
|
51
|
+
def body=(new_body)
|
52
|
+
attributes[:body] = new_body
|
53
|
+
end
|
54
|
+
|
55
|
+
attr_reader :directory
|
56
|
+
|
57
|
+
def copy(target_directory_key, target_file_key, options = {})
|
58
|
+
requires :directory, :key
|
59
|
+
service.copy_object(directory.key, key, target_directory_key, target_file_key, options)
|
60
|
+
target_directory = service.directories.new(:key => target_directory_key)
|
61
|
+
target_directory.files.get(target_file_key)
|
62
|
+
end
|
63
|
+
|
64
|
+
def destroy
|
65
|
+
requires :directory, :key
|
66
|
+
service.delete_object(directory.key, key)
|
67
|
+
true
|
68
|
+
rescue ::Google::Apis::ClientError => e
|
69
|
+
raise e unless e.status_code == 404
|
70
|
+
false
|
71
|
+
end
|
72
|
+
|
73
|
+
def public=(new_public)
|
74
|
+
unless new_public.nil?
|
75
|
+
if new_public
|
76
|
+
@predefined_acl = "publicRead"
|
77
|
+
else
|
78
|
+
@predefined_acl = "projectPrivate"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
new_public
|
82
|
+
end
|
83
|
+
|
84
|
+
def public_url
|
85
|
+
requires :directory, :key
|
86
|
+
"https://storage.googleapis.com/#{directory.key}/#{key}"
|
87
|
+
end
|
88
|
+
|
89
|
+
FILE_INSERTABLE_FIELDS = %i(
|
90
|
+
content_type
|
91
|
+
predefined_acl
|
92
|
+
cache_control
|
93
|
+
content_disposition
|
94
|
+
content_encoding
|
95
|
+
metadata
|
96
|
+
).freeze
|
97
|
+
|
98
|
+
def save
|
99
|
+
requires :body, :directory, :key
|
100
|
+
|
101
|
+
options = Hash[
|
102
|
+
FILE_INSERTABLE_FIELDS.map { |k| [k, attributes[k]] }
|
103
|
+
.reject { |pair| pair[1].nil? }
|
104
|
+
]
|
105
|
+
|
106
|
+
options[:predefined_acl] ||= @predefined_acl
|
107
|
+
|
108
|
+
service.put_object(directory.key, key, body, options)
|
109
|
+
self.content_length = Fog::Storage.get_body_size(body)
|
110
|
+
self.content_type ||= Fog::Storage.get_content_type(body)
|
111
|
+
true
|
112
|
+
end
|
113
|
+
|
114
|
+
# params[:expires] : Eg: Time.now to integer value.
|
115
|
+
def url(expires, options = {})
|
116
|
+
requires :key
|
117
|
+
collection.get_https_url(key, expires, options)
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
attr_writer :directory
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class GoogleJSON
|
4
|
+
class Files < Fog::Collection
|
5
|
+
model Fog::Storage::GoogleJSON::File
|
6
|
+
|
7
|
+
extend Fog::Deprecation
|
8
|
+
deprecate :get_url, :get_https_url
|
9
|
+
|
10
|
+
attribute :common_prefixes, :aliases => "CommonPrefixes"
|
11
|
+
attribute :delimiter, :aliases => "Delimiter"
|
12
|
+
attribute :directory
|
13
|
+
attribute :page_token, :aliases => %w(pageToken page_token)
|
14
|
+
attribute :max_results, :aliases => ["MaxKeys", "max-keys"]
|
15
|
+
attribute :prefix, :aliases => "Prefix"
|
16
|
+
|
17
|
+
def all(options = {})
|
18
|
+
requires :directory
|
19
|
+
data = service.list_objects(directory.key, attributes.merge(options))
|
20
|
+
.to_h[:items] || []
|
21
|
+
load(data)
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method :each_file_this_page, :each
|
25
|
+
def each
|
26
|
+
if block_given?
|
27
|
+
subset = dup.all
|
28
|
+
|
29
|
+
subset.each_file_this_page { |f| yield f }
|
30
|
+
end
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def get(key, options = {}, &block)
|
35
|
+
requires :directory
|
36
|
+
data = service.get_object(directory.key, key, options, &block).to_h
|
37
|
+
new(data)
|
38
|
+
rescue ::Google::Apis::ClientError => e
|
39
|
+
raise e unless e.status_code == 404
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_https_url(key, expires, options = {})
|
44
|
+
requires :directory
|
45
|
+
service.get_object_https_url(directory.key, key, expires, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def metadata(key, options = {})
|
49
|
+
requires :directory
|
50
|
+
data = service.get_object_metadata(directory.key, key, options).to_h
|
51
|
+
new(data)
|
52
|
+
rescue ::Google::Apis::ClientError
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
alias_method :head, :metadata
|
56
|
+
|
57
|
+
def new(opts = {})
|
58
|
+
requires :directory
|
59
|
+
super({ :directory => directory }.merge(opts))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class GoogleJSON
|
4
|
+
class Real
|
5
|
+
include Utils
|
6
|
+
include Fog::Google::Shared
|
7
|
+
|
8
|
+
attr_accessor :client
|
9
|
+
attr_reader :storage_json
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, GOOGLE_STORAGE_JSON_BASE_URL)
|
13
|
+
options[:google_api_scope_url] = GOOGLE_STORAGE_JSON_API_SCOPE_URLS.join(" ")
|
14
|
+
@host = options[:host] || "storage.googleapis.com"
|
15
|
+
|
16
|
+
# TODO(temikus): Do we even need this client?
|
17
|
+
@client = initialize_google_client(options)
|
18
|
+
# IAM client used for SignBlob API
|
19
|
+
@iam_service = ::Google::Apis::IamcredentialsV1::IAMCredentialsService.new
|
20
|
+
apply_client_options(@iam_service, {
|
21
|
+
google_api_scope_url: GOOGLE_STORAGE_JSON_IAM_API_SCOPE_URLS.join(" ")
|
22
|
+
})
|
23
|
+
|
24
|
+
@storage_json = ::Google::Apis::StorageV1::StorageService.new
|
25
|
+
apply_client_options(@storage_json, options)
|
26
|
+
|
27
|
+
@storage_json.client_options.open_timeout_sec = options[:open_timeout_sec] if options[:open_timeout_sec]
|
28
|
+
@storage_json.client_options.read_timeout_sec = options[:read_timeout_sec] if options[:read_timeout_sec]
|
29
|
+
@storage_json.client_options.send_timeout_sec = options[:send_timeout_sec] if options[:send_timeout_sec]
|
30
|
+
end
|
31
|
+
|
32
|
+
def signature(params)
|
33
|
+
string_to_sign = <<-DATA
|
34
|
+
#{params[:method]}
|
35
|
+
#{params[:headers]['Content-MD5']}
|
36
|
+
#{params[:headers]['Content-Type']}
|
37
|
+
#{params[:headers]['Date']}
|
38
|
+
DATA
|
39
|
+
|
40
|
+
google_headers = {}
|
41
|
+
canonical_google_headers = ""
|
42
|
+
params[:headers].each do |key, value|
|
43
|
+
google_headers[key] = value if key[0..6] == "x-goog-"
|
44
|
+
end
|
45
|
+
|
46
|
+
google_headers = google_headers.sort_by { |a| a[0] }
|
47
|
+
google_headers.each do |key, value|
|
48
|
+
canonical_google_headers << "#{key}:#{value}\n"
|
49
|
+
end
|
50
|
+
string_to_sign << canonical_google_headers.to_s
|
51
|
+
|
52
|
+
canonical_resource = "/"
|
53
|
+
if subdomain = params.delete(:subdomain)
|
54
|
+
canonical_resource << "#{CGI.escape(subdomain).downcase}/"
|
55
|
+
end
|
56
|
+
canonical_resource << params[:path].to_s
|
57
|
+
canonical_resource << "?"
|
58
|
+
(params[:query] || {}).each_key do |key|
|
59
|
+
if %w(acl cors location logging requestPayment versions versioning).include?(key)
|
60
|
+
canonical_resource << "#{key}&"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
canonical_resource.chop!
|
64
|
+
string_to_sign << canonical_resource.to_s
|
65
|
+
|
66
|
+
# TODO(temikus): make signer configurable or add ability to supply your own via lambda
|
67
|
+
if !@storage_json.authorization.signing_key.nil?
|
68
|
+
signed_string = default_signer(string_to_sign)
|
69
|
+
else
|
70
|
+
# If client doesn't contain signing key attempt to auth via IAM SignBlob API
|
71
|
+
signed_string = iam_signer(string_to_sign)
|
72
|
+
end
|
73
|
+
|
74
|
+
Base64.encode64(signed_string).chomp!
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def google_access_id
|
80
|
+
@google_access_id ||= get_google_access_id
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Fetches the google service account name
|
85
|
+
#
|
86
|
+
# @return [String] Service account name, typically needed for GoogleAccessId, e.g.
|
87
|
+
# my-account@project.iam.gserviceaccount
|
88
|
+
# @raises [Fog::Errors::Error] If authorisation is incorrect or inapplicable for current action
|
89
|
+
def get_google_access_id
|
90
|
+
if @storage_json.authorization.is_a?(::Google::Auth::UserRefreshCredentials)
|
91
|
+
raise Fog::Errors::Error.new("User / Application Default Credentials are not supported for storage"\
|
92
|
+
"url signing, please use a service account or metadata authentication.")
|
93
|
+
end
|
94
|
+
|
95
|
+
if !@storage_json.authorization.issuer.nil?
|
96
|
+
return @storage_json.authorization.issuer
|
97
|
+
else
|
98
|
+
get_access_id_from_metadata
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# Attempts to fetch the google service account name from metadata using Google::Cloud::Env
|
104
|
+
#
|
105
|
+
# @return [String] Service account name, typically needed for GoogleAccessId, e.g.
|
106
|
+
# my-account@project.iam.gserviceaccount
|
107
|
+
# @raises [Fog::Errors::Error] If Metadata service is not available or returns an invalid response
|
108
|
+
def get_access_id_from_metadata
|
109
|
+
if @google_cloud_env.metadata?
|
110
|
+
access_id = @google_cloud_env.lookup_metadata("instance", "service-accounts/default/email")
|
111
|
+
else
|
112
|
+
raise Fog::Errors::Error.new("Metadata service not available, unable to retrieve service account info.")
|
113
|
+
end
|
114
|
+
|
115
|
+
if access_id.nil?
|
116
|
+
raise Fog::Errors::Error.new("Metadata service found but didn't return data." \
|
117
|
+
"Please file a bug: https://github.com/fog/fog-google")
|
118
|
+
end
|
119
|
+
|
120
|
+
return access_id
|
121
|
+
end
|
122
|
+
|
123
|
+
##
|
124
|
+
# Default url signer using service account keys
|
125
|
+
#
|
126
|
+
# @param [String] string_to_sign Special collection of headers and options for V2 storage signing, e.g.:
|
127
|
+
#
|
128
|
+
# StringToSign = HTTP_Verb + "\n" +
|
129
|
+
# Content_MD5 + "\n" +
|
130
|
+
# Content_Type + "\n" +
|
131
|
+
# Expires + "\n" +
|
132
|
+
# Canonicalized_Extension_Headers +
|
133
|
+
# Canonicalized_Resource
|
134
|
+
#
|
135
|
+
# See https://cloud.google.com/storage/docs/access-control/signed-urls-v2
|
136
|
+
# @return [String] Signature binary blob
|
137
|
+
def default_signer(string_to_sign)
|
138
|
+
key = OpenSSL::PKey::RSA.new(@storage_json.authorization.signing_key)
|
139
|
+
digest = OpenSSL::Digest::SHA256.new
|
140
|
+
return key.sign(digest, string_to_sign)
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# Fallback URL signer using the IAM SignServiceAccountBlob API, see
|
145
|
+
# Google::Apis::IamcredentialsV1::IAMCredentialsService#sign_service_account_blob
|
146
|
+
#
|
147
|
+
# @param [String] string_to_sign Special collection of headers and options for V2 storage signing, e.g.:
|
148
|
+
#
|
149
|
+
# StringToSign = HTTP_Verb + "\n" +
|
150
|
+
# Content_MD5 + "\n" +
|
151
|
+
# Content_Type + "\n" +
|
152
|
+
# Expires + "\n" +
|
153
|
+
# Canonicalized_Extension_Headers +
|
154
|
+
# Canonicalized_Resource
|
155
|
+
#
|
156
|
+
# See https://cloud.google.com/storage/docs/access-control/signed-urls-v2
|
157
|
+
# @return [String] Signature binary blob
|
158
|
+
def iam_signer(string_to_sign)
|
159
|
+
request = {
|
160
|
+
"payload": string_to_sign
|
161
|
+
}
|
162
|
+
|
163
|
+
resource = "projects/-/serviceAccounts/#{google_access_id}"
|
164
|
+
response = @iam_service.sign_service_account_blob resource, request, {}
|
165
|
+
|
166
|
+
return response.signed_blob
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|