ey-pro-cli 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +94 -0
- data/README.md +1 -0
- data/bin/ey-pro +5 -0
- data/ey-pro-cli.gemspec +40 -0
- data/lib/ey_pro_cli.rb +100 -0
- data/lib/ey_pro_cli/version.rb +3 -0
- data/lib/vendor/core/ey-core.rb +58 -0
- data/lib/vendor/core/ey-core/associations.rb +155 -0
- data/lib/vendor/core/ey-core/cli.rb +107 -0
- data/lib/vendor/core/ey-core/client.rb +764 -0
- data/lib/vendor/core/ey-core/collection.rb +131 -0
- data/lib/vendor/core/ey-core/collections/account_cancellations.rb +6 -0
- data/lib/vendor/core/ey-core/collections/account_referrals.rb +10 -0
- data/lib/vendor/core/ey-core/collections/accounts.rb +8 -0
- data/lib/vendor/core/ey-core/collections/addon_attachments.rb +17 -0
- data/lib/vendor/core/ey-core/collections/addons.rb +16 -0
- data/lib/vendor/core/ey-core/collections/addresses.rb +9 -0
- data/lib/vendor/core/ey-core/collections/alerts.rb +9 -0
- data/lib/vendor/core/ey-core/collections/application_archives.rb +9 -0
- data/lib/vendor/core/ey-core/collections/application_deployments.rb +9 -0
- data/lib/vendor/core/ey-core/collections/applications.rb +9 -0
- data/lib/vendor/core/ey-core/collections/backup_files.rb +9 -0
- data/lib/vendor/core/ey-core/collections/backups.rb +9 -0
- data/lib/vendor/core/ey-core/collections/cluster_components.rb +9 -0
- data/lib/vendor/core/ey-core/collections/cluster_updates.rb +9 -0
- data/lib/vendor/core/ey-core/collections/clusters.rb +9 -0
- data/lib/vendor/core/ey-core/collections/component_actions.rb +9 -0
- data/lib/vendor/core/ey-core/collections/components.rb +9 -0
- data/lib/vendor/core/ey-core/collections/connectors.rb +9 -0
- data/lib/vendor/core/ey-core/collections/contacts.rb +9 -0
- data/lib/vendor/core/ey-core/collections/costs.rb +8 -0
- data/lib/vendor/core/ey-core/collections/database_plan_usages.rb +7 -0
- data/lib/vendor/core/ey-core/collections/database_server_revisions.rb +7 -0
- data/lib/vendor/core/ey-core/collections/database_server_snapshots.rb +17 -0
- data/lib/vendor/core/ey-core/collections/database_server_usages.rb +7 -0
- data/lib/vendor/core/ey-core/collections/database_servers.rb +9 -0
- data/lib/vendor/core/ey-core/collections/database_services.rb +9 -0
- data/lib/vendor/core/ey-core/collections/environment_plan_usages.rb +7 -0
- data/lib/vendor/core/ey-core/collections/environments.rb +15 -0
- data/lib/vendor/core/ey-core/collections/features.rb +9 -0
- data/lib/vendor/core/ey-core/collections/firewall_rules.rb +9 -0
- data/lib/vendor/core/ey-core/collections/firewalls.rb +9 -0
- data/lib/vendor/core/ey-core/collections/gems.rb +6 -0
- data/lib/vendor/core/ey-core/collections/keypair_deployments.rb +9 -0
- data/lib/vendor/core/ey-core/collections/keypairs.rb +9 -0
- data/lib/vendor/core/ey-core/collections/legacy_alerts.rb +9 -0
- data/lib/vendor/core/ey-core/collections/load_balancer_nodes.rb +9 -0
- data/lib/vendor/core/ey-core/collections/load_balancer_services.rb +9 -0
- data/lib/vendor/core/ey-core/collections/load_balancers.rb +16 -0
- data/lib/vendor/core/ey-core/collections/logical_databases.rb +16 -0
- data/lib/vendor/core/ey-core/collections/logs.rb +9 -0
- data/lib/vendor/core/ey-core/collections/memberships.rb +9 -0
- data/lib/vendor/core/ey-core/collections/messages.rb +9 -0
- data/lib/vendor/core/ey-core/collections/plan_usages.rb +7 -0
- data/lib/vendor/core/ey-core/collections/provider_locations.rb +13 -0
- data/lib/vendor/core/ey-core/collections/providers.rb +15 -0
- data/lib/vendor/core/ey-core/collections/requests.rb +10 -0
- data/lib/vendor/core/ey-core/collections/server_events.rb +9 -0
- data/lib/vendor/core/ey-core/collections/server_usages.rb +7 -0
- data/lib/vendor/core/ey-core/collections/servers.rb +9 -0
- data/lib/vendor/core/ey-core/collections/slot_components.rb +9 -0
- data/lib/vendor/core/ey-core/collections/slots.rb +30 -0
- data/lib/vendor/core/ey-core/collections/ssl_certificates.rb +9 -0
- data/lib/vendor/core/ey-core/collections/storage_users.rb +10 -0
- data/lib/vendor/core/ey-core/collections/storages.rb +9 -0
- data/lib/vendor/core/ey-core/collections/tasks.rb +9 -0
- data/lib/vendor/core/ey-core/collections/tokens.rb +8 -0
- data/lib/vendor/core/ey-core/collections/untracked_servers.rb +9 -0
- data/lib/vendor/core/ey-core/collections/users.rb +12 -0
- data/lib/vendor/core/ey-core/collections/volumes.rb +9 -0
- data/lib/vendor/core/ey-core/logger.rb +31 -0
- data/lib/vendor/core/ey-core/memory_cache.rb +17 -0
- data/lib/vendor/core/ey-core/mock/helper.rb +102 -0
- data/lib/vendor/core/ey-core/mock/params.rb +31 -0
- data/lib/vendor/core/ey-core/mock/resources.rb +120 -0
- data/lib/vendor/core/ey-core/mock/searching.rb +111 -0
- data/lib/vendor/core/ey-core/mock/util.rb +19 -0
- data/lib/vendor/core/ey-core/model.rb +39 -0
- data/lib/vendor/core/ey-core/models/account.rb +63 -0
- data/lib/vendor/core/ey-core/models/account_cancellation.rb +6 -0
- data/lib/vendor/core/ey-core/models/account_referral.rb +8 -0
- data/lib/vendor/core/ey-core/models/account_trial.rb +15 -0
- data/lib/vendor/core/ey-core/models/addon.rb +45 -0
- data/lib/vendor/core/ey-core/models/addon_attachment.rb +36 -0
- data/lib/vendor/core/ey-core/models/address.rb +46 -0
- data/lib/vendor/core/ey-core/models/alert.rb +88 -0
- data/lib/vendor/core/ey-core/models/application.rb +32 -0
- data/lib/vendor/core/ey-core/models/application_archive.rb +67 -0
- data/lib/vendor/core/ey-core/models/application_deployment.rb +18 -0
- data/lib/vendor/core/ey-core/models/backup.rb +36 -0
- data/lib/vendor/core/ey-core/models/backup_file.rb +52 -0
- data/lib/vendor/core/ey-core/models/billing.rb +27 -0
- data/lib/vendor/core/ey-core/models/cluster.rb +80 -0
- data/lib/vendor/core/ey-core/models/cluster_component.rb +62 -0
- data/lib/vendor/core/ey-core/models/cluster_update.rb +32 -0
- data/lib/vendor/core/ey-core/models/component.rb +11 -0
- data/lib/vendor/core/ey-core/models/component_action.rb +29 -0
- data/lib/vendor/core/ey-core/models/connector.rb +34 -0
- data/lib/vendor/core/ey-core/models/contact.rb +14 -0
- data/lib/vendor/core/ey-core/models/cost.rb +16 -0
- data/lib/vendor/core/ey-core/models/database_plan_usage.rb +10 -0
- data/lib/vendor/core/ey-core/models/database_server.rb +56 -0
- data/lib/vendor/core/ey-core/models/database_server_revision.rb +10 -0
- data/lib/vendor/core/ey-core/models/database_server_snapshot.rb +16 -0
- data/lib/vendor/core/ey-core/models/database_server_usage.rb +15 -0
- data/lib/vendor/core/ey-core/models/database_service.rb +53 -0
- data/lib/vendor/core/ey-core/models/environment.rb +68 -0
- data/lib/vendor/core/ey-core/models/environment_plan_usage.rb +10 -0
- data/lib/vendor/core/ey-core/models/feature.rb +33 -0
- data/lib/vendor/core/ey-core/models/firewall.rb +45 -0
- data/lib/vendor/core/ey-core/models/firewall_rule.rb +41 -0
- data/lib/vendor/core/ey-core/models/gem.rb +5 -0
- data/lib/vendor/core/ey-core/models/keypair.rb +38 -0
- data/lib/vendor/core/ey-core/models/keypair_deployment.rb +26 -0
- data/lib/vendor/core/ey-core/models/legacy_alert.rb +12 -0
- data/lib/vendor/core/ey-core/models/load_balancer.rb +43 -0
- data/lib/vendor/core/ey-core/models/load_balancer_node.rb +17 -0
- data/lib/vendor/core/ey-core/models/load_balancer_service.rb +22 -0
- data/lib/vendor/core/ey-core/models/log.rb +33 -0
- data/lib/vendor/core/ey-core/models/logical_database.rb +40 -0
- data/lib/vendor/core/ey-core/models/membership.rb +42 -0
- data/lib/vendor/core/ey-core/models/message.rb +27 -0
- data/lib/vendor/core/ey-core/models/metadata.rb +15 -0
- data/lib/vendor/core/ey-core/models/plan_usage.rb +14 -0
- data/lib/vendor/core/ey-core/models/provider.rb +59 -0
- data/lib/vendor/core/ey-core/models/provider_location.rb +11 -0
- data/lib/vendor/core/ey-core/models/request.rb +89 -0
- data/lib/vendor/core/ey-core/models/server.rb +69 -0
- data/lib/vendor/core/ey-core/models/server_event.rb +11 -0
- data/lib/vendor/core/ey-core/models/server_usage.rb +13 -0
- data/lib/vendor/core/ey-core/models/slot.rb +64 -0
- data/lib/vendor/core/ey-core/models/slot_component.rb +28 -0
- data/lib/vendor/core/ey-core/models/ssl_certificate.rb +44 -0
- data/lib/vendor/core/ey-core/models/storage.rb +38 -0
- data/lib/vendor/core/ey-core/models/storage_user.rb +44 -0
- data/lib/vendor/core/ey-core/models/task.rb +35 -0
- data/lib/vendor/core/ey-core/models/token.rb +20 -0
- data/lib/vendor/core/ey-core/models/untracked_server.rb +45 -0
- data/lib/vendor/core/ey-core/models/user.rb +35 -0
- data/lib/vendor/core/ey-core/models/volume.rb +20 -0
- data/lib/vendor/core/ey-core/request_failure.rb +11 -0
- data/lib/vendor/core/ey-core/requests/attach_address.rb +53 -0
- data/lib/vendor/core/ey-core/requests/authorized_channel.rb +22 -0
- data/lib/vendor/core/ey-core/requests/bootstrap_logical_database.rb +80 -0
- data/lib/vendor/core/ey-core/requests/cancel_account.rb +33 -0
- data/lib/vendor/core/ey-core/requests/create_account.rb +33 -0
- data/lib/vendor/core/ey-core/requests/create_addon.rb +35 -0
- data/lib/vendor/core/ey-core/requests/create_address.rb +53 -0
- data/lib/vendor/core/ey-core/requests/create_alert.rb +60 -0
- data/lib/vendor/core/ey-core/requests/create_application.rb +55 -0
- data/lib/vendor/core/ey-core/requests/create_application_archive.rb +44 -0
- data/lib/vendor/core/ey-core/requests/create_backup.rb +46 -0
- data/lib/vendor/core/ey-core/requests/create_backup_file.rb +52 -0
- data/lib/vendor/core/ey-core/requests/create_cluster.rb +98 -0
- data/lib/vendor/core/ey-core/requests/create_cluster_component.rb +57 -0
- data/lib/vendor/core/ey-core/requests/create_cluster_update.rb +208 -0
- data/lib/vendor/core/ey-core/requests/create_connector.rb +46 -0
- data/lib/vendor/core/ey-core/requests/create_database_server.rb +72 -0
- data/lib/vendor/core/ey-core/requests/create_database_service.rb +57 -0
- data/lib/vendor/core/ey-core/requests/create_environment.rb +57 -0
- data/lib/vendor/core/ey-core/requests/create_firewall.rb +62 -0
- data/lib/vendor/core/ey-core/requests/create_firewall_rule.rb +60 -0
- data/lib/vendor/core/ey-core/requests/create_keypair.rb +42 -0
- data/lib/vendor/core/ey-core/requests/create_keypair_deployment.rb +36 -0
- data/lib/vendor/core/ey-core/requests/create_load_balancer.rb +62 -0
- data/lib/vendor/core/ey-core/requests/create_log.rb +53 -0
- data/lib/vendor/core/ey-core/requests/create_logical_database.rb +56 -0
- data/lib/vendor/core/ey-core/requests/create_membership.rb +33 -0
- data/lib/vendor/core/ey-core/requests/create_message.rb +35 -0
- data/lib/vendor/core/ey-core/requests/create_provider.rb +90 -0
- data/lib/vendor/core/ey-core/requests/create_slots.rb +100 -0
- data/lib/vendor/core/ey-core/requests/create_ssl_certificate.rb +83 -0
- data/lib/vendor/core/ey-core/requests/create_storage.rb +64 -0
- data/lib/vendor/core/ey-core/requests/create_storage_user.rb +64 -0
- data/lib/vendor/core/ey-core/requests/create_task.rb +55 -0
- data/lib/vendor/core/ey-core/requests/create_token.rb +24 -0
- data/lib/vendor/core/ey-core/requests/create_untracked_server.rb +39 -0
- data/lib/vendor/core/ey-core/requests/create_user.rb +48 -0
- data/lib/vendor/core/ey-core/requests/destroy_addon.rb +24 -0
- data/lib/vendor/core/ey-core/requests/destroy_cluster.rb +30 -0
- data/lib/vendor/core/ey-core/requests/destroy_database_server.rb +41 -0
- data/lib/vendor/core/ey-core/requests/destroy_database_service.rb +57 -0
- data/lib/vendor/core/ey-core/requests/destroy_environment.rb +43 -0
- data/lib/vendor/core/ey-core/requests/destroy_firewall.rb +41 -0
- data/lib/vendor/core/ey-core/requests/destroy_firewall_rule.rb +41 -0
- data/lib/vendor/core/ey-core/requests/destroy_load_balancer.rb +30 -0
- data/lib/vendor/core/ey-core/requests/destroy_logical_database.rb +41 -0
- data/lib/vendor/core/ey-core/requests/destroy_provider.rb +34 -0
- data/lib/vendor/core/ey-core/requests/destroy_server.rb +46 -0
- data/lib/vendor/core/ey-core/requests/destroy_ssl_certificate.rb +28 -0
- data/lib/vendor/core/ey-core/requests/destroy_storage.rb +33 -0
- data/lib/vendor/core/ey-core/requests/destroy_storage_user.rb +38 -0
- data/lib/vendor/core/ey-core/requests/destroy_user.rb +29 -0
- data/lib/vendor/core/ey-core/requests/detach_address.rb +48 -0
- data/lib/vendor/core/ey-core/requests/disable_feature.rb +30 -0
- data/lib/vendor/core/ey-core/requests/discover_database_server.rb +66 -0
- data/lib/vendor/core/ey-core/requests/discover_database_server_snapshots.rb +69 -0
- data/lib/vendor/core/ey-core/requests/discover_provider_location.rb +57 -0
- data/lib/vendor/core/ey-core/requests/download_file.rb +25 -0
- data/lib/vendor/core/ey-core/requests/enable_feature.rb +35 -0
- data/lib/vendor/core/ey-core/requests/finish_backup.rb +26 -0
- data/lib/vendor/core/ey-core/requests/get_account.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_account_cancellation.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_account_referrals.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_account_trial.rb +31 -0
- data/lib/vendor/core/ey-core/requests/get_accounts.rb +42 -0
- data/lib/vendor/core/ey-core/requests/get_addon.rb +25 -0
- data/lib/vendor/core/ey-core/requests/get_addon_attachment.rb +33 -0
- data/lib/vendor/core/ey-core/requests/get_addon_attachments.rb +42 -0
- data/lib/vendor/core/ey-core/requests/get_addons.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_address.rb +25 -0
- data/lib/vendor/core/ey-core/requests/get_addresses.rb +27 -0
- data/lib/vendor/core/ey-core/requests/get_alert.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_alerting_environments.rb +37 -0
- data/lib/vendor/core/ey-core/requests/get_alerts.rb +40 -0
- data/lib/vendor/core/ey-core/requests/get_application.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_application_archive.rb +32 -0
- data/lib/vendor/core/ey-core/requests/get_application_archives.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_application_deployment.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_application_deployments.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_applications.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_backup.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_backup_file.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_backup_files.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_backups.rb +27 -0
- data/lib/vendor/core/ey-core/requests/get_billing.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_cluster.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_cluster_component.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_cluster_components.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_cluster_update.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_cluster_updates.rb +26 -0
- data/lib/vendor/core/ey-core/requests/get_clusters.rb +35 -0
- data/lib/vendor/core/ey-core/requests/get_component.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_component_action.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_component_actions.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_components.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_connector.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_connectors.rb +37 -0
- data/lib/vendor/core/ey-core/requests/get_contacts.rb +34 -0
- data/lib/vendor/core/ey-core/requests/get_costs.rb +25 -0
- data/lib/vendor/core/ey-core/requests/get_current_user.rb +19 -0
- data/lib/vendor/core/ey-core/requests/get_database_plan_usages.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_database_server.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_database_server_revisions.rb +27 -0
- data/lib/vendor/core/ey-core/requests/get_database_server_snapshot.rb +20 -0
- data/lib/vendor/core/ey-core/requests/get_database_server_snapshots.rb +34 -0
- data/lib/vendor/core/ey-core/requests/get_database_server_usages.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_database_servers.rb +30 -0
- data/lib/vendor/core/ey-core/requests/get_database_servers_firewalls.rb +30 -0
- data/lib/vendor/core/ey-core/requests/get_database_service.rb +20 -0
- data/lib/vendor/core/ey-core/requests/get_database_services.rb +55 -0
- data/lib/vendor/core/ey-core/requests/get_environment.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_environment_database_services.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_environment_logical_databases.rb +20 -0
- data/lib/vendor/core/ey-core/requests/get_environment_plan_usages.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_environments.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_feature.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_features.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_firewall.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_firewall_rule.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_firewall_rules.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_firewalls.rb +45 -0
- data/lib/vendor/core/ey-core/requests/get_gem.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_keypair.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_keypair_deployment.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_keypair_deployments.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_keypairs.rb +34 -0
- data/lib/vendor/core/ey-core/requests/get_legacy_alert.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_legacy_alerts.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_load_balancer.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_load_balancer_node.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_load_balancer_nodes.rb +30 -0
- data/lib/vendor/core/ey-core/requests/get_load_balancer_service.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_load_balancer_services.rb +30 -0
- data/lib/vendor/core/ey-core/requests/get_load_balancers.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_log.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_logical_database.rb +23 -0
- data/lib/vendor/core/ey-core/requests/get_logical_databases.rb +43 -0
- data/lib/vendor/core/ey-core/requests/get_logs.rb +37 -0
- data/lib/vendor/core/ey-core/requests/get_membership.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_message.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_messages.rb +27 -0
- data/lib/vendor/core/ey-core/requests/get_metadata.rb +26 -0
- data/lib/vendor/core/ey-core/requests/get_operational_contact.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_operational_contacts.rb +20 -0
- data/lib/vendor/core/ey-core/requests/get_plan_usages.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_possible_provider_locations.rb +19 -0
- data/lib/vendor/core/ey-core/requests/get_provider.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_provider_location.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_provider_locations.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_providers.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_request.rb +71 -0
- data/lib/vendor/core/ey-core/requests/get_requests.rb +29 -0
- data/lib/vendor/core/ey-core/requests/get_server.rb +34 -0
- data/lib/vendor/core/ey-core/requests/get_server_event.rb +20 -0
- data/lib/vendor/core/ey-core/requests/get_server_events.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_server_usages.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_servers.rb +25 -0
- data/lib/vendor/core/ey-core/requests/get_slot.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_slot_component.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_slot_components.rb +36 -0
- data/lib/vendor/core/ey-core/requests/get_slots.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_ssl_certificate.rb +23 -0
- data/lib/vendor/core/ey-core/requests/get_ssl_certificates.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_storage.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_storage_user.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_storage_users.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_storages.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_task.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_tasks.rb +28 -0
- data/lib/vendor/core/ey-core/requests/get_untracked_server.rb +18 -0
- data/lib/vendor/core/ey-core/requests/get_untracked_servers.rb +24 -0
- data/lib/vendor/core/ey-core/requests/get_user.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_users.rb +42 -0
- data/lib/vendor/core/ey-core/requests/get_volume.rb +21 -0
- data/lib/vendor/core/ey-core/requests/get_volumes.rb +28 -0
- data/lib/vendor/core/ey-core/requests/reboot_server.rb +39 -0
- data/lib/vendor/core/ey-core/requests/request_callback.rb +24 -0
- data/lib/vendor/core/ey-core/requests/run_cluster_application_action.rb +28 -0
- data/lib/vendor/core/ey-core/requests/run_cluster_component_action.rb +181 -0
- data/lib/vendor/core/ey-core/requests/run_environment_application_action.rb +29 -0
- data/lib/vendor/core/ey-core/requests/signup.rb +60 -0
- data/lib/vendor/core/ey-core/requests/update_addon.rb +28 -0
- data/lib/vendor/core/ey-core/requests/update_addon_attachment.rb +63 -0
- data/lib/vendor/core/ey-core/requests/update_alert.rb +32 -0
- data/lib/vendor/core/ey-core/requests/update_application_archive.rb +23 -0
- data/lib/vendor/core/ey-core/requests/update_billing.rb +26 -0
- data/lib/vendor/core/ey-core/requests/update_cluster.rb +33 -0
- data/lib/vendor/core/ey-core/requests/update_cluster_component.rb +29 -0
- data/lib/vendor/core/ey-core/requests/update_connector.rb +32 -0
- data/lib/vendor/core/ey-core/requests/update_membership.rb +29 -0
- data/lib/vendor/core/ey-core/requests/update_server.rb +29 -0
- data/lib/vendor/core/ey-core/requests/update_slot.rb +37 -0
- data/lib/vendor/core/ey-core/requests/update_slot_component.rb +29 -0
- data/lib/vendor/core/ey-core/requests/update_ssl_certificate.rb +25 -0
- data/lib/vendor/core/ey-core/requests/update_untracked_server.rb +24 -0
- data/lib/vendor/core/ey-core/requests/upload_file.rb +44 -0
- data/lib/vendor/core/ey-core/response.rb +55 -0
- data/lib/vendor/core/ey-core/response_cache.rb +29 -0
- data/lib/vendor/core/ey-core/subscribable.rb +49 -0
- data/lib/vendor/core/ey-core/token_authentication.rb +13 -0
- data/lib/vendor/core/ey-core/version.rb +5 -0
- metadata +577 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d3ac1354471718392e29083db65e0a4778490ce
|
4
|
+
data.tar.gz: bb5d44ca7f4e4e40c7160e83585b550af339ba96
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88947ac9c4683060f4195f67fe3460e996d0c019bbc671a9f1e9d7f39de64d4afd021a67115cb79c5dc2330e29345b40922c4cb241fe92e6963a48f219f79d54
|
7
|
+
data.tar.gz: 58b3a3d2d5c4ec2e961a9a9983c8bda5bb5984f8d65a8d880928ccf8996149d4d59b62603139b2303da9a34c9c2c20d28e436e035431ba395b12ab90080c7505
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ey-pro-cli (0.0.2)
|
5
|
+
addressable (~> 2.2)
|
6
|
+
cistern (~> 0.11, >= 0.11.1)
|
7
|
+
colorize
|
8
|
+
ey-hmac (~> 2.0)
|
9
|
+
faraday (~> 0.9)
|
10
|
+
faraday_middleware (~> 0.9)
|
11
|
+
faye
|
12
|
+
mime-types
|
13
|
+
sshkey (~> 1.6)
|
14
|
+
thor
|
15
|
+
|
16
|
+
GEM
|
17
|
+
remote: https://rubygems.org/
|
18
|
+
specs:
|
19
|
+
addressable (2.3.8)
|
20
|
+
awesome_print (1.6.1)
|
21
|
+
cistern (0.11.3)
|
22
|
+
coderay (1.1.0)
|
23
|
+
colorize (0.7.7)
|
24
|
+
cookiejar (0.3.2)
|
25
|
+
diff-lcs (1.2.5)
|
26
|
+
em-http-request (1.1.2)
|
27
|
+
addressable (>= 2.3.4)
|
28
|
+
cookiejar
|
29
|
+
em-socksify (>= 0.3)
|
30
|
+
eventmachine (>= 1.0.3)
|
31
|
+
http_parser.rb (>= 0.6.0)
|
32
|
+
em-socksify (0.3.0)
|
33
|
+
eventmachine (>= 1.0.0.beta.4)
|
34
|
+
eventmachine (1.0.7)
|
35
|
+
ey-hmac (2.0.0)
|
36
|
+
faraday (0.9.1)
|
37
|
+
multipart-post (>= 1.2, < 3)
|
38
|
+
faraday_middleware (0.10.0)
|
39
|
+
faraday (>= 0.7.4, < 0.10)
|
40
|
+
faye (1.1.2)
|
41
|
+
cookiejar (>= 0.3.0)
|
42
|
+
em-http-request (>= 0.3.0)
|
43
|
+
eventmachine (>= 0.12.0)
|
44
|
+
faye-websocket (>= 0.9.1)
|
45
|
+
multi_json (>= 1.0.0)
|
46
|
+
rack (>= 1.0.0)
|
47
|
+
websocket-driver (>= 0.5.1)
|
48
|
+
faye-websocket (0.10.0)
|
49
|
+
eventmachine (>= 0.12.0)
|
50
|
+
websocket-driver (>= 0.5.1)
|
51
|
+
http_parser.rb (0.6.0)
|
52
|
+
method_source (0.8.2)
|
53
|
+
mime-types (2.6.1)
|
54
|
+
multi_json (1.11.2)
|
55
|
+
multipart-post (2.0.0)
|
56
|
+
pry (0.10.1)
|
57
|
+
coderay (~> 1.1.0)
|
58
|
+
method_source (~> 0.8.1)
|
59
|
+
slop (~> 3.4)
|
60
|
+
pry-nav (0.2.4)
|
61
|
+
pry (>= 0.9.10, < 0.11.0)
|
62
|
+
rack (1.6.4)
|
63
|
+
rspec (3.3.0)
|
64
|
+
rspec-core (~> 3.3.0)
|
65
|
+
rspec-expectations (~> 3.3.0)
|
66
|
+
rspec-mocks (~> 3.3.0)
|
67
|
+
rspec-core (3.3.2)
|
68
|
+
rspec-support (~> 3.3.0)
|
69
|
+
rspec-expectations (3.3.1)
|
70
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
+
rspec-support (~> 3.3.0)
|
72
|
+
rspec-mocks (3.3.2)
|
73
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
74
|
+
rspec-support (~> 3.3.0)
|
75
|
+
rspec-support (3.3.0)
|
76
|
+
slop (3.6.0)
|
77
|
+
sshkey (1.7.0)
|
78
|
+
thor (0.19.1)
|
79
|
+
websocket-driver (0.6.2)
|
80
|
+
websocket-extensions (>= 0.1.0)
|
81
|
+
websocket-extensions (0.1.2)
|
82
|
+
|
83
|
+
PLATFORMS
|
84
|
+
ruby
|
85
|
+
|
86
|
+
DEPENDENCIES
|
87
|
+
awesome_print
|
88
|
+
ey-pro-cli!
|
89
|
+
pry
|
90
|
+
pry-nav
|
91
|
+
rspec
|
92
|
+
|
93
|
+
BUNDLED WITH
|
94
|
+
1.10.5
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# ey-pro-cli
|
data/bin/ey-pro
ADDED
data/ey-pro-cli.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
3
|
+
require File.expand_path('../lib/ey_pro_cli/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ey-pro-cli"
|
7
|
+
s.version = EyProCliVersion::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.author = "Engine Yard Cloud Team"
|
10
|
+
s.email = "cloud@engineyard.com"
|
11
|
+
s.summary = "Command-line deployment for Engine Yard pro"
|
12
|
+
s.description = "This gem allows you to deploy your rails application to Engine Yard Pro directly from the command line."
|
13
|
+
|
14
|
+
s.required_ruby_version = '>= 1.9.3'
|
15
|
+
|
16
|
+
s.executables = ["ey-pro"]
|
17
|
+
s.default_executable = "ey-pro"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split($/)
|
20
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
21
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
|
24
|
+
s.add_dependency "thor"
|
25
|
+
s.add_dependency "colorize"
|
26
|
+
s.add_dependency "faye"
|
27
|
+
|
28
|
+
s.add_development_dependency "awesome_print"
|
29
|
+
s.add_development_dependency "pry"
|
30
|
+
s.add_development_dependency "pry-nav"
|
31
|
+
|
32
|
+
#ey-core dependencies
|
33
|
+
s.add_dependency "addressable", "~> 2.2"
|
34
|
+
s.add_dependency "cistern", "~> 0.11", ">= 0.11.1"
|
35
|
+
s.add_dependency "ey-hmac", "~> 2.0"
|
36
|
+
s.add_dependency "sshkey", "~> 1.6"
|
37
|
+
s.add_dependency "faraday", "~> 0.9"
|
38
|
+
s.add_dependency "faraday_middleware", "~> 0.9"
|
39
|
+
s.add_dependency "mime-types"
|
40
|
+
end
|
data/lib/ey_pro_cli.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
if ENV["TEST"] == 'true'
|
2
|
+
require 'awesome_print'
|
3
|
+
end
|
4
|
+
|
5
|
+
$:.unshift(File.dirname(__FILE__) + '/vendor/core')
|
6
|
+
|
7
|
+
require 'colorize'
|
8
|
+
require 'thor'
|
9
|
+
require File.expand_path(File.dirname(__FILE__) + '/ey_pro_cli/version')
|
10
|
+
require File.expand_path(File.dirname(__FILE__) + '/vendor/core/ey-core')
|
11
|
+
|
12
|
+
class EyProCli < Thor
|
13
|
+
desc "deploy [OPTIONS]", "Deploy your EY Pro application"
|
14
|
+
option :ref, desc: "A git reference to deploy"
|
15
|
+
option :migrate, desc: "The migration command to run"
|
16
|
+
option :environment, desc: "Name of the environment to deploy to", required: true
|
17
|
+
option :account, desc: "Name of the account that the environment resides in. If no account is specified, the app will deploy to the first environment that meets the criteria, in the accounts you have access to."
|
18
|
+
option :app, desc: "Application name to deploy. If :account is not specified, this will be the first app that matches the criteria in the accounts you have access to."
|
19
|
+
option :stream, desc: "Stream deploy output to console", type: :boolean
|
20
|
+
option "no-migrate", desc: "Do not run migration command"
|
21
|
+
option "no-update-check", desc: "Do not check for updates", type: :boolean
|
22
|
+
|
23
|
+
def deploy
|
24
|
+
check_for_updates unless options["no-update-check"]
|
25
|
+
environment = core_environment_for(options)
|
26
|
+
app = core_application_for(options)
|
27
|
+
|
28
|
+
deploy_options = {}
|
29
|
+
deploy_options.merge!(ref: options[:ref]) if options[:ref]
|
30
|
+
deploy_options.merge!(migrate_command: options[:migrate]) if options[:migrate]
|
31
|
+
deploy_options.merge!(migrate_command: '') if options["no-migrate"]
|
32
|
+
request = environment.deploy(app, deploy_options)
|
33
|
+
|
34
|
+
puts "Deploy started to environment: #{environment.name} with application: #{app.name}"
|
35
|
+
if options[:stream]
|
36
|
+
request.subscribe { |m| print m["message"] if m.is_a?(Hash) }
|
37
|
+
puts "" # fix console output from stream
|
38
|
+
else
|
39
|
+
request.ready!
|
40
|
+
end
|
41
|
+
|
42
|
+
if request.successful
|
43
|
+
puts "Deploy successful!"
|
44
|
+
else
|
45
|
+
abort "Deploy failed!"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def check_for_updates
|
52
|
+
gem = core_client.gems.get("ey-pro-cli")
|
53
|
+
unless gem
|
54
|
+
puts "Unable to find current version of CLI utility".yellow
|
55
|
+
return
|
56
|
+
end
|
57
|
+
current_version = gem.current_version
|
58
|
+
if Gem::Version.new(EyProCliVersion::VERSION) < Gem::Version.new(current_version)
|
59
|
+
print <<-EOF
|
60
|
+
ey-pro-cli gem outdated, consider updating!
|
61
|
+
Installed version: #{EyProCliVersion::VERSION}
|
62
|
+
Current Version: #{current_version}
|
63
|
+
EOF
|
64
|
+
.yellow
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def core_client
|
69
|
+
url = ENV["CORE_URL"] || "https://api.engineyard.com"
|
70
|
+
@core_client ||= Ey::Core::Client.new(url: url)
|
71
|
+
end
|
72
|
+
|
73
|
+
def core_account_for(options={})
|
74
|
+
@core_account ||= core_client.accounts.get(options[:account])
|
75
|
+
@core_account ||= core_client.accounts.first(name: options[:account])
|
76
|
+
end
|
77
|
+
|
78
|
+
def operator(options)
|
79
|
+
options[:account] ? core_account_for(options) : core_client
|
80
|
+
end
|
81
|
+
|
82
|
+
def core_environment_for(options={})
|
83
|
+
operator(options).environments.first(name: options[:environment])
|
84
|
+
end
|
85
|
+
|
86
|
+
def core_application_for(options={})
|
87
|
+
return nil unless options[:app]
|
88
|
+
|
89
|
+
app = begin
|
90
|
+
Integer(options[:app])
|
91
|
+
rescue
|
92
|
+
options[:app]
|
93
|
+
end
|
94
|
+
if app.is_a?(Integer)
|
95
|
+
operator(options).applications.get(app)
|
96
|
+
else
|
97
|
+
operator(options).applications.first(name: app)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'ey-core/version'
|
2
|
+
|
3
|
+
require 'addressable/uri'
|
4
|
+
require 'cistern'
|
5
|
+
require 'ey-hmac'
|
6
|
+
require 'ey-hmac/faraday'
|
7
|
+
require 'faraday'
|
8
|
+
require 'faraday_middleware'
|
9
|
+
require 'mime/types'
|
10
|
+
require 'sshkey'
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
require 'forwardable'
|
14
|
+
require 'logger'
|
15
|
+
require 'yaml'
|
16
|
+
require 'securerandom'
|
17
|
+
require 'json'
|
18
|
+
|
19
|
+
Cistern.timeout = 5 * 60 # 5 minutes
|
20
|
+
|
21
|
+
module Ey
|
22
|
+
module Core
|
23
|
+
|
24
|
+
IP_REGEX = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\/(\d|[1-2]\d|3[0-2]))?/
|
25
|
+
|
26
|
+
def self.paging_parameters(params)
|
27
|
+
if url = params['url']
|
28
|
+
Addressable::URI.parse(url).query_values
|
29
|
+
else
|
30
|
+
params
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @fixme find a much better way to do this
|
35
|
+
def self.colocated?(location_a, location_b)
|
36
|
+
location_a.gsub(/[a-z]$/, "") == location_b.gsub(/[a-z]$/, "")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
require 'ey-core/associations'
|
42
|
+
require 'ey-core/collection'
|
43
|
+
require 'ey-core/logger'
|
44
|
+
require 'ey-core/model'
|
45
|
+
require 'ey-core/subscribable'
|
46
|
+
require 'ey-core/response'
|
47
|
+
require 'ey-core/token_authentication'
|
48
|
+
require 'ey-core/request_failure'
|
49
|
+
require 'ey-core/response_cache'
|
50
|
+
require 'ey-core/memory_cache'
|
51
|
+
|
52
|
+
require 'ey-core/mock/helper'
|
53
|
+
require 'ey-core/mock/params'
|
54
|
+
require 'ey-core/mock/resources'
|
55
|
+
require 'ey-core/mock/searching'
|
56
|
+
require 'ey-core/mock/util'
|
57
|
+
|
58
|
+
require 'ey-core/client'
|
@@ -0,0 +1,155 @@
|
|
1
|
+
module Ey::Core::Associations
|
2
|
+
def assoc_coverage(options)
|
3
|
+
if defined? Cistern::Coverage
|
4
|
+
call = Cistern::Coverage.find_caller_before("ey-core/associations.rb")
|
5
|
+
|
6
|
+
if call and call.label.start_with?("<class:")
|
7
|
+
options[:coverage_file] = call.absolute_path
|
8
|
+
options[:coverage_line] = call.lineno
|
9
|
+
options[:coverage_hits] = 0
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def associations
|
15
|
+
@associations ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def assoc_reader(name, options={})
|
19
|
+
assoc_key = options[:key] || "#{name}_id"
|
20
|
+
collection = options[:collection] || "#{name}s"
|
21
|
+
resource = options[:resource] || name
|
22
|
+
assoc_name = options[:assoc_name] || resource
|
23
|
+
|
24
|
+
# handle polymorphic assocations
|
25
|
+
#
|
26
|
+
# really only used for connector sources, as they may be cluster_components or addons
|
27
|
+
disambiguate = Proc.new do |object, url, index=0|
|
28
|
+
if object.is_a?(Array) && index > (object.size - 1)
|
29
|
+
raise "No matching object found in #{object}"
|
30
|
+
elsif object.is_a?(Array) && url
|
31
|
+
url_pieces = URI.parse(url).path.split("/").map { |piece| piece.gsub(/-|_/,'') } # "/cluster-components/x" => ["clustercomponents", "x"]
|
32
|
+
|
33
|
+
object.find do |model|
|
34
|
+
normalized_model = model.to_s.gsub(/-|_/, '') # [:cluster_components, :addons] => ["clustercomponents", "addons"]
|
35
|
+
url_pieces.find { |piece| piece.include?(normalized_model) }
|
36
|
+
end
|
37
|
+
elsif object.is_a?(Array)
|
38
|
+
object[index]
|
39
|
+
else
|
40
|
+
object
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
define_method(name) do
|
45
|
+
url = self.send("#{name}_url")
|
46
|
+
id = send(assoc_key)
|
47
|
+
|
48
|
+
if id || url
|
49
|
+
begin
|
50
|
+
index ||= 0
|
51
|
+
this_resource = disambiguate[resource, url, index]
|
52
|
+
this_assoc_name = disambiguate[assoc_name, url, index]
|
53
|
+
this_collection = disambiguate[collection, url, index]
|
54
|
+
|
55
|
+
fetched = self.connection.send("get_#{this_assoc_name}", {"id" => id, "url" => url}).body
|
56
|
+
rescue RuntimeError => e
|
57
|
+
if e.message.match(/url needed/i)
|
58
|
+
index += 1
|
59
|
+
retry if index < 3
|
60
|
+
else
|
61
|
+
raise e
|
62
|
+
end
|
63
|
+
rescue Ey::Core::Response::NotFound
|
64
|
+
index += 1
|
65
|
+
index < 3 ? retry : raise
|
66
|
+
end
|
67
|
+
|
68
|
+
unless fetched[this_resource.to_s]
|
69
|
+
raise "Expected a '#{this_resource.to_s}' in '#{fetched.inspect}'"
|
70
|
+
end
|
71
|
+
|
72
|
+
attributes = fetched[this_resource.to_s]
|
73
|
+
|
74
|
+
if self.connection.respond_to?(this_collection)
|
75
|
+
attributes = attributes.merge(collection: self.connection.send(this_collection))
|
76
|
+
end
|
77
|
+
|
78
|
+
self.connection.send(this_assoc_name, attributes)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def assoc_writer(name, options={})
|
84
|
+
assoc_key = options[:key] || "#{name}_id"
|
85
|
+
url_key = options[:key] || "#{name}_url"
|
86
|
+
|
87
|
+
attr_accessor assoc_key
|
88
|
+
|
89
|
+
define_method("#{name}=") do |assoc|
|
90
|
+
if assoc.respond_to?(:identity)
|
91
|
+
self.send("#{assoc_key}=", assoc.identity)
|
92
|
+
elsif assoc.is_a?(String) && assoc.match(URI::regexp)
|
93
|
+
self.send("#{url_key}=", assoc)
|
94
|
+
else
|
95
|
+
self.send("#{assoc_key}=", assoc)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def assoc_accessor(name, options={})
|
101
|
+
assoc_coverage(options)
|
102
|
+
|
103
|
+
if self.associations[name]
|
104
|
+
raise ArgumentError, "#{self.name} association[#{name}] specified more than once"
|
105
|
+
else
|
106
|
+
self.associations[name] = options
|
107
|
+
end
|
108
|
+
|
109
|
+
aliases = Array(options[:aliases] || name.to_s)
|
110
|
+
|
111
|
+
attribute(:"#{name}_url", aliases: aliases, parser: lambda { |v,_| v.is_a?(String) && v })
|
112
|
+
|
113
|
+
assoc_reader(name, options)
|
114
|
+
assoc_writer(name, options)
|
115
|
+
end
|
116
|
+
|
117
|
+
alias has_one assoc_accessor
|
118
|
+
|
119
|
+
def collection_reader(name, options={})
|
120
|
+
assoc_coverage(options)
|
121
|
+
|
122
|
+
if self.associations[name]
|
123
|
+
raise ArgumentError, "#{self.name} association[#{name}] specified more than once"
|
124
|
+
else
|
125
|
+
self.associations[name] = options
|
126
|
+
end
|
127
|
+
|
128
|
+
attribute(:"#{name}_url", aliases: options[:aliases] || [name.to_s])
|
129
|
+
|
130
|
+
assoc_key = options[:key] || name
|
131
|
+
collection_key = options[:model] || assoc_key
|
132
|
+
|
133
|
+
define_method(name) do
|
134
|
+
value = self.send("#{name}_url")
|
135
|
+
|
136
|
+
if self.identity && !value
|
137
|
+
raise "Cannot load #{name} association: #{name}_url is not set"
|
138
|
+
end
|
139
|
+
|
140
|
+
# @fixme this allows collections to be stored in a url variable on create before being replaced
|
141
|
+
# by a url entry after create upon {#merge_attributes}
|
142
|
+
if value.nil?
|
143
|
+
[]
|
144
|
+
elsif value.is_a?(String) && value.match(URI::regexp)
|
145
|
+
self.connection.send(collection_key, {"url" => value})
|
146
|
+
elsif value.is_a?(Hash)
|
147
|
+
[value]
|
148
|
+
else
|
149
|
+
Array(value)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
alias has_many collection_reader
|
155
|
+
end
|