mtncloud-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.dockerignore +20 -0
- data/.github/pull_request_template.md +14 -0
- data/.github/workflows/ci.yml +56 -0
- data/.github/workflows/release.yml +46 -0
- data/.gitignore +25 -0
- data/CLAUDE.md +24 -0
- data/CONTRIBUTING.md +91 -0
- data/Dockerfile +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +23 -0
- data/README.md +187 -0
- data/Rakefile +26 -0
- data/bin/mcs +3 -0
- data/bin/mtncloud +27 -0
- data/lib/mtncloud/api/account_groups_interface.rb +48 -0
- data/lib/mtncloud/api/account_users_interface.rb +68 -0
- data/lib/mtncloud/api/accounts_interface.rb +9 -0
- data/lib/mtncloud/api/activity_interface.rb +9 -0
- data/lib/mtncloud/api/affinity_groups_interface.rb +46 -0
- data/lib/mtncloud/api/api_client.rb +1091 -0
- data/lib/mtncloud/api/appliance_settings_interface.rb +49 -0
- data/lib/mtncloud/api/approvals_interface.rb +32 -0
- data/lib/mtncloud/api/apps_interface.rb +180 -0
- data/lib/mtncloud/api/archive_buckets_interface.rb +116 -0
- data/lib/mtncloud/api/archive_files_interface.rb +173 -0
- data/lib/mtncloud/api/audit_interface.rb +9 -0
- data/lib/mtncloud/api/auth_interface.rb +58 -0
- data/lib/mtncloud/api/backup_jobs_interface.rb +13 -0
- data/lib/mtncloud/api/backup_restores_interface.rb +27 -0
- data/lib/mtncloud/api/backup_results_interface.rb +32 -0
- data/lib/mtncloud/api/backup_service_types_interface.rb +9 -0
- data/lib/mtncloud/api/backup_services_interface.rb +9 -0
- data/lib/mtncloud/api/backup_settings_interface.rb +20 -0
- data/lib/mtncloud/api/backup_types_interface.rb +9 -0
- data/lib/mtncloud/api/backups_interface.rb +21 -0
- data/lib/mtncloud/api/billing_interface.rb +34 -0
- data/lib/mtncloud/api/blueprints_interface.rb +70 -0
- data/lib/mtncloud/api/body_io.rb +22 -0
- data/lib/mtncloud/api/budgets_interface.rb +48 -0
- data/lib/mtncloud/api/catalog_item_types_interface.rb +29 -0
- data/lib/mtncloud/api/certificate_types_interface.rb +14 -0
- data/lib/mtncloud/api/certificates_interface.rb +9 -0
- data/lib/mtncloud/api/clients_interface.rb +41 -0
- data/lib/mtncloud/api/cloud_datastores_interface.rb +48 -0
- data/lib/mtncloud/api/cloud_folders_interface.rb +41 -0
- data/lib/mtncloud/api/cloud_policies_interface.rb +41 -0
- data/lib/mtncloud/api/cloud_resource_pools_interface.rb +66 -0
- data/lib/mtncloud/api/clouds_interface.rb +217 -0
- data/lib/mtncloud/api/clusters_interface.rb +471 -0
- data/lib/mtncloud/api/containers_interface.rb +145 -0
- data/lib/mtncloud/api/credential_types_interface.rb +9 -0
- data/lib/mtncloud/api/credentials_interface.rb +9 -0
- data/lib/mtncloud/api/custom_instance_types_interface.rb +99 -0
- data/lib/mtncloud/api/cypher_interface.rb +51 -0
- data/lib/mtncloud/api/dashboard_interface.rb +14 -0
- data/lib/mtncloud/api/datastores_interface.rb +21 -0
- data/lib/mtncloud/api/deploy_interface.rb +44 -0
- data/lib/mtncloud/api/deployments_interface.rb +79 -0
- data/lib/mtncloud/api/distributed_workers_interface.rb +41 -0
- data/lib/mtncloud/api/email_templates_interface.rb +53 -0
- data/lib/mtncloud/api/environments_interface.rb +48 -0
- data/lib/mtncloud/api/execute_schedules_interface.rb +71 -0
- data/lib/mtncloud/api/execution_request_interface.rb +27 -0
- data/lib/mtncloud/api/file_copy_request_interface.rb +68 -0
- data/lib/mtncloud/api/forgot_password_interface.rb +17 -0
- data/lib/mtncloud/api/group_policies_interface.rb +41 -0
- data/lib/mtncloud/api/groups_interface.rb +73 -0
- data/lib/mtncloud/api/guidance_interface.rb +44 -0
- data/lib/mtncloud/api/guidance_settings_interface.rb +17 -0
- data/lib/mtncloud/api/health_interface.rb +100 -0
- data/lib/mtncloud/api/host_vm_groups_interface.rb +37 -0
- data/lib/mtncloud/api/hub_interface.rb +25 -0
- data/lib/mtncloud/api/image_builder_boot_scripts_interface.rb +41 -0
- data/lib/mtncloud/api/image_builder_image_builds_interface.rb +73 -0
- data/lib/mtncloud/api/image_builder_interface.rb +20 -0
- data/lib/mtncloud/api/image_builder_preseed_scripts_interface.rb +41 -0
- data/lib/mtncloud/api/instance_types_interface.rb +20 -0
- data/lib/mtncloud/api/instances_interface.rb +453 -0
- data/lib/mtncloud/api/integration_types_interface.rb +14 -0
- data/lib/mtncloud/api/integrations_interface.rb +74 -0
- data/lib/mtncloud/api/invoice_line_items_interface.rb +9 -0
- data/lib/mtncloud/api/invoices_interface.rb +28 -0
- data/lib/mtncloud/api/jobs_interface.rb +83 -0
- data/lib/mtncloud/api/key_pairs_interface.rb +57 -0
- data/lib/mtncloud/api/library_cluster_layouts_interface.rb +47 -0
- data/lib/mtncloud/api/library_cluster_packages_interface.rb +60 -0
- data/lib/mtncloud/api/library_container_scripts_interface.rb +43 -0
- data/lib/mtncloud/api/library_container_templates_interface.rb +43 -0
- data/lib/mtncloud/api/library_container_types_interface.rb +59 -0
- data/lib/mtncloud/api/library_container_upgrades_interface.rb +60 -0
- data/lib/mtncloud/api/library_instance_types_interface.rb +74 -0
- data/lib/mtncloud/api/library_layouts_interface.rb +69 -0
- data/lib/mtncloud/api/library_operating_systems_interface.rb +63 -0
- data/lib/mtncloud/api/library_spec_template_types_interface.rb +43 -0
- data/lib/mtncloud/api/library_spec_templates_interface.rb +43 -0
- data/lib/mtncloud/api/license_interface.rb +30 -0
- data/lib/mtncloud/api/load_balancer_monitors_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_pool_nodes_interface.rb +8 -0
- data/lib/mtncloud/api/load_balancer_pools_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_pools_secondary_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_profiles_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_types_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_virtual_servers_interface.rb +18 -0
- data/lib/mtncloud/api/load_balancers_interface.rb +14 -0
- data/lib/mtncloud/api/log_settings_interface.rb +44 -0
- data/lib/mtncloud/api/logs_interface.rb +37 -0
- data/lib/mtncloud/api/migrations_interface.rb +49 -0
- data/lib/mtncloud/api/monitoring_alerts_interface.rb +39 -0
- data/lib/mtncloud/api/monitoring_apps_interface.rb +69 -0
- data/lib/mtncloud/api/monitoring_checks_interface.rb +103 -0
- data/lib/mtncloud/api/monitoring_contacts_interface.rb +41 -0
- data/lib/mtncloud/api/monitoring_groups_interface.rb +77 -0
- data/lib/mtncloud/api/monitoring_incidents_interface.rb +107 -0
- data/lib/mtncloud/api/monitoring_interface.rb +35 -0
- data/lib/mtncloud/api/monitoring_settings_interface.rb +21 -0
- data/lib/mtncloud/api/network_dhcp_relays_interface.rb +36 -0
- data/lib/mtncloud/api/network_dhcp_servers_interface.rb +36 -0
- data/lib/mtncloud/api/network_domain_records_interface.rb +41 -0
- data/lib/mtncloud/api/network_domains_interface.rb +41 -0
- data/lib/mtncloud/api/network_edge_clusters_interface.rb +26 -0
- data/lib/mtncloud/api/network_floating_ips_interface.rb +40 -0
- data/lib/mtncloud/api/network_groups_interface.rb +41 -0
- data/lib/mtncloud/api/network_pool_ips_interface.rb +41 -0
- data/lib/mtncloud/api/network_pool_server_types_interface.rb +9 -0
- data/lib/mtncloud/api/network_pool_servers_interface.rb +48 -0
- data/lib/mtncloud/api/network_pools_interface.rb +41 -0
- data/lib/mtncloud/api/network_proxies_interface.rb +41 -0
- data/lib/mtncloud/api/network_routers_interface.rb +181 -0
- data/lib/mtncloud/api/network_security_server_types_interface.rb +9 -0
- data/lib/mtncloud/api/network_security_servers_interface.rb +27 -0
- data/lib/mtncloud/api/network_server_groups_interface.rb +7 -0
- data/lib/mtncloud/api/network_server_types_interface.rb +9 -0
- data/lib/mtncloud/api/network_servers_interface.rb +102 -0
- data/lib/mtncloud/api/network_services_interface.rb +63 -0
- data/lib/mtncloud/api/network_static_routes_interface.rb +36 -0
- data/lib/mtncloud/api/network_subnets_interface.rb +42 -0
- data/lib/mtncloud/api/network_types_interface.rb +20 -0
- data/lib/mtncloud/api/networks_interface.rb +48 -0
- data/lib/mtncloud/api/option_type_forms_interface.rb +9 -0
- data/lib/mtncloud/api/option_type_lists_interface.rb +53 -0
- data/lib/mtncloud/api/option_types_interface.rb +41 -0
- data/lib/mtncloud/api/options_interface.rb +17 -0
- data/lib/mtncloud/api/packages_interface.rb +112 -0
- data/lib/mtncloud/api/ping_interface.rb +22 -0
- data/lib/mtncloud/api/plugins_interface.rb +22 -0
- data/lib/mtncloud/api/policies_interface.rb +56 -0
- data/lib/mtncloud/api/power_schedules_interface.rb +71 -0
- data/lib/mtncloud/api/price_sets_interface.rb +39 -0
- data/lib/mtncloud/api/prices_interface.rb +71 -0
- data/lib/mtncloud/api/processes_interface.rb +40 -0
- data/lib/mtncloud/api/projects_interface.rb +33 -0
- data/lib/mtncloud/api/provision_types_interface.rb +24 -0
- data/lib/mtncloud/api/provisioning_license_types_interface.rb +31 -0
- data/lib/mtncloud/api/provisioning_licenses_interface.rb +60 -0
- data/lib/mtncloud/api/provisioning_settings_interface.rb +26 -0
- data/lib/mtncloud/api/read_interface.rb +24 -0
- data/lib/mtncloud/api/reports_interface.rb +70 -0
- data/lib/mtncloud/api/resource_pool_groups_interface.rb +51 -0
- data/lib/mtncloud/api/rest_interface.rb +37 -0
- data/lib/mtncloud/api/roles_interface.rb +151 -0
- data/lib/mtncloud/api/scale_thresholds_interface.rb +9 -0
- data/lib/mtncloud/api/search_interface.rb +13 -0
- data/lib/mtncloud/api/secondary_read_interface.rb +25 -0
- data/lib/mtncloud/api/secondary_rest_interface.rb +42 -0
- data/lib/mtncloud/api/security_group_rules_interface.rb +35 -0
- data/lib/mtncloud/api/security_groups_interface.rb +56 -0
- data/lib/mtncloud/api/security_package_types_interface.rb +9 -0
- data/lib/mtncloud/api/security_packages_interface.rb +9 -0
- data/lib/mtncloud/api/security_scans_interface.rb +9 -0
- data/lib/mtncloud/api/server_devices_interface.rb +30 -0
- data/lib/mtncloud/api/server_types_interface.rb +20 -0
- data/lib/mtncloud/api/servers_interface.rb +230 -0
- data/lib/mtncloud/api/service_catalog_interface.rb +89 -0
- data/lib/mtncloud/api/service_plans_interface.rb +62 -0
- data/lib/mtncloud/api/setup_interface.rb +46 -0
- data/lib/mtncloud/api/snapshots_interface.rb +19 -0
- data/lib/mtncloud/api/storage_datastores_interface.rb +44 -0
- data/lib/mtncloud/api/storage_providers_interface.rb +151 -0
- data/lib/mtncloud/api/storage_server_types_interface.rb +14 -0
- data/lib/mtncloud/api/storage_servers_interface.rb +9 -0
- data/lib/mtncloud/api/storage_volume_types_interface.rb +9 -0
- data/lib/mtncloud/api/storage_volumes_interface.rb +24 -0
- data/lib/mtncloud/api/subnet_types_interface.rb +20 -0
- data/lib/mtncloud/api/subnets_interface.rb +41 -0
- data/lib/mtncloud/api/support_bundles_interface.rb +46 -0
- data/lib/mtncloud/api/system_types_interface.rb +13 -0
- data/lib/mtncloud/api/systems_interface.rb +55 -0
- data/lib/mtncloud/api/task_sets_interface.rb +52 -0
- data/lib/mtncloud/api/tasks_interface.rb +66 -0
- data/lib/mtncloud/api/tokens_interface.rb +39 -0
- data/lib/mtncloud/api/usage_interface.rb +18 -0
- data/lib/mtncloud/api/user_groups_interface.rb +59 -0
- data/lib/mtncloud/api/user_settings_interface.rb +90 -0
- data/lib/mtncloud/api/user_sources_interface.rb +99 -0
- data/lib/mtncloud/api/users_interface.rb +33 -0
- data/lib/mtncloud/api/vdi_allocations_interface.rb +9 -0
- data/lib/mtncloud/api/vdi_apps_interface.rb +9 -0
- data/lib/mtncloud/api/vdi_gateways_interface.rb +9 -0
- data/lib/mtncloud/api/vdi_interface.rb +28 -0
- data/lib/mtncloud/api/vdi_pools_interface.rb +19 -0
- data/lib/mtncloud/api/virtual_images_interface.rb +210 -0
- data/lib/mtncloud/api/virtual_servers_interface.rb +9 -0
- data/lib/mtncloud/api/virtual_switches_interface.rb +9 -0
- data/lib/mtncloud/api/whitelabel_settings_interface.rb +57 -0
- data/lib/mtncloud/api/whoami_interface.rb +13 -0
- data/lib/mtncloud/api/wiki_interface.rb +48 -0
- data/lib/mtncloud/api.rb +12 -0
- data/lib/mtncloud/benchmarking.rb +259 -0
- data/lib/mtncloud/cli/cli_command.rb +2281 -0
- data/lib/mtncloud/cli/cli_registry.rb +337 -0
- data/lib/mtncloud/cli/commands/access_token_command.rb +201 -0
- data/lib/mtncloud/cli/commands/account_groups_command.rb +530 -0
- data/lib/mtncloud/cli/commands/activity_command.rb +149 -0
- data/lib/mtncloud/cli/commands/affinity_groups_command.rb +554 -0
- data/lib/mtncloud/cli/commands/alias_command.rb +278 -0
- data/lib/mtncloud/cli/commands/appliance_settings_command.rb +382 -0
- data/lib/mtncloud/cli/commands/approvals_command.rb +236 -0
- data/lib/mtncloud/cli/commands/apps.rb +2549 -0
- data/lib/mtncloud/cli/commands/archives_command.rb +2161 -0
- data/lib/mtncloud/cli/commands/audit.rb +188 -0
- data/lib/mtncloud/cli/commands/backup_jobs_command.rb +366 -0
- data/lib/mtncloud/cli/commands/backup_restores_command.rb +144 -0
- data/lib/mtncloud/cli/commands/backup_results_command.rb +149 -0
- data/lib/mtncloud/cli/commands/backup_services_command.rb +44 -0
- data/lib/mtncloud/cli/commands/backup_settings_command.rb +184 -0
- data/lib/mtncloud/cli/commands/backup_types_command.rb +53 -0
- data/lib/mtncloud/cli/commands/backups_command.rb +674 -0
- data/lib/mtncloud/cli/commands/benchmark_command.rb +458 -0
- data/lib/mtncloud/cli/commands/blueprints_command.rb +2297 -0
- data/lib/mtncloud/cli/commands/boot_scripts_command.rb +379 -0
- data/lib/mtncloud/cli/commands/budgets_command.rb +754 -0
- data/lib/mtncloud/cli/commands/cat_command.rb +45 -0
- data/lib/mtncloud/cli/commands/catalog_item_types_command.rb +858 -0
- data/lib/mtncloud/cli/commands/certificates_command.rb +575 -0
- data/lib/mtncloud/cli/commands/change_password_command.rb +132 -0
- data/lib/mtncloud/cli/commands/clients_command.rb +331 -0
- data/lib/mtncloud/cli/commands/cloud_datastores_command.rb +543 -0
- data/lib/mtncloud/cli/commands/cloud_folders_command.rb +512 -0
- data/lib/mtncloud/cli/commands/cloud_resource_pools_command.rb +870 -0
- data/lib/mtncloud/cli/commands/clouds.rb +2037 -0
- data/lib/mtncloud/cli/commands/clouds_types.rb +140 -0
- data/lib/mtncloud/cli/commands/cluster_types.rb +179 -0
- data/lib/mtncloud/cli/commands/clusters.rb +5855 -0
- data/lib/mtncloud/cli/commands/coloring_command.rb +82 -0
- data/lib/mtncloud/cli/commands/containers_command.rb +967 -0
- data/lib/mtncloud/cli/commands/credential_types_command.rb +36 -0
- data/lib/mtncloud/cli/commands/credentials_command.rb +124 -0
- data/lib/mtncloud/cli/commands/curl_command.rb +168 -0
- data/lib/mtncloud/cli/commands/cypher_command.rb +587 -0
- data/lib/mtncloud/cli/commands/dashboard_command.rb +300 -0
- data/lib/mtncloud/cli/commands/debug_command.rb +75 -0
- data/lib/mtncloud/cli/commands/deploy.rb +485 -0
- data/lib/mtncloud/cli/commands/deployments.rb +923 -0
- data/lib/mtncloud/cli/commands/deploys.rb +485 -0
- data/lib/mtncloud/cli/commands/distributed_workers_command.rb +282 -0
- data/lib/mtncloud/cli/commands/echo_command.rb +61 -0
- data/lib/mtncloud/cli/commands/edit_profile_command.rb +57 -0
- data/lib/mtncloud/cli/commands/edit_rc_command.rb +77 -0
- data/lib/mtncloud/cli/commands/email_templates_command.rb +373 -0
- data/lib/mtncloud/cli/commands/environments_command.rb +401 -0
- data/lib/mtncloud/cli/commands/execute_schedules_command.rb +735 -0
- data/lib/mtncloud/cli/commands/execution_request_command.rb +333 -0
- data/lib/mtncloud/cli/commands/exit_command.rb +34 -0
- data/lib/mtncloud/cli/commands/file_copy_request_command.rb +352 -0
- data/lib/mtncloud/cli/commands/forgot_password.rb +133 -0
- data/lib/mtncloud/cli/commands/get_prompt_command.rb +36 -0
- data/lib/mtncloud/cli/commands/groups.rb +818 -0
- data/lib/mtncloud/cli/commands/guidance_command.rb +529 -0
- data/lib/mtncloud/cli/commands/guidance_settings.rb +148 -0
- data/lib/mtncloud/cli/commands/health_command.rb +1046 -0
- data/lib/mtncloud/cli/commands/history_command.rb +60 -0
- data/lib/mtncloud/cli/commands/host_vm_groups_command.rb +423 -0
- data/lib/mtncloud/cli/commands/hosts.rb +2986 -0
- data/lib/mtncloud/cli/commands/hub.rb +215 -0
- data/lib/mtncloud/cli/commands/image_builder_command.rb +1197 -0
- data/lib/mtncloud/cli/commands/instance_types.rb +163 -0
- data/lib/mtncloud/cli/commands/instances.rb +5813 -0
- data/lib/mtncloud/cli/commands/integrations_command.rb +1412 -0
- data/lib/mtncloud/cli/commands/invoices_command.rb +1151 -0
- data/lib/mtncloud/cli/commands/jobs_command.rb +998 -0
- data/lib/mtncloud/cli/commands/key_pairs.rb +470 -0
- data/lib/mtncloud/cli/commands/library_cluster_layouts_command.rb +901 -0
- data/lib/mtncloud/cli/commands/library_cluster_packages_command.rb +552 -0
- data/lib/mtncloud/cli/commands/library_container_scripts_command.rb +446 -0
- data/lib/mtncloud/cli/commands/library_container_templates_command.rb +526 -0
- data/lib/mtncloud/cli/commands/library_container_types_command.rb +698 -0
- data/lib/mtncloud/cli/commands/library_forms_command.rb +625 -0
- data/lib/mtncloud/cli/commands/library_instance_types_command.rb +668 -0
- data/lib/mtncloud/cli/commands/library_layouts_command.rb +849 -0
- data/lib/mtncloud/cli/commands/library_operating_systems_command.rb +671 -0
- data/lib/mtncloud/cli/commands/library_option_lists_command.rb +503 -0
- data/lib/mtncloud/cli/commands/library_option_types_command.rb +329 -0
- data/lib/mtncloud/cli/commands/library_spec_templates_command.rb +547 -0
- data/lib/mtncloud/cli/commands/library_upgrades_command.rb +596 -0
- data/lib/mtncloud/cli/commands/license.rb +475 -0
- data/lib/mtncloud/cli/commands/load_balancer_monitors.rb +70 -0
- data/lib/mtncloud/cli/commands/load_balancer_pool_nodes.rb +87 -0
- data/lib/mtncloud/cli/commands/load_balancer_pools.rb +129 -0
- data/lib/mtncloud/cli/commands/load_balancer_profiles.rb +64 -0
- data/lib/mtncloud/cli/commands/load_balancer_types.rb +38 -0
- data/lib/mtncloud/cli/commands/load_balancer_virtual_servers.rb +147 -0
- data/lib/mtncloud/cli/commands/load_balancers.rb +189 -0
- data/lib/mtncloud/cli/commands/log_level_command.rb +54 -0
- data/lib/mtncloud/cli/commands/log_settings_command.rb +443 -0
- data/lib/mtncloud/cli/commands/login.rb +148 -0
- data/lib/mtncloud/cli/commands/logout.rb +63 -0
- data/lib/mtncloud/cli/commands/logs_command.rb +140 -0
- data/lib/mtncloud/cli/commands/man_command.rb +409 -0
- data/lib/mtncloud/cli/commands/migrations.rb +453 -0
- data/lib/mtncloud/cli/commands/monitoring_alerts_command.rb +791 -0
- data/lib/mtncloud/cli/commands/monitoring_apps_command.rb +716 -0
- data/lib/mtncloud/cli/commands/monitoring_checks_command.rb +766 -0
- data/lib/mtncloud/cli/commands/monitoring_contacts_command.rb +339 -0
- data/lib/mtncloud/cli/commands/monitoring_groups_command.rb +674 -0
- data/lib/mtncloud/cli/commands/monitoring_incidents_command.rb +835 -0
- data/lib/mtncloud/cli/commands/monitoring_settings.rb +212 -0
- data/lib/mtncloud/cli/commands/network_dhcp_relays_command.rb +375 -0
- data/lib/mtncloud/cli/commands/network_dhcp_servers_command.rb +366 -0
- data/lib/mtncloud/cli/commands/network_domains_command.rb +896 -0
- data/lib/mtncloud/cli/commands/network_edge_clusters_command.rb +288 -0
- data/lib/mtncloud/cli/commands/network_firewalls_command.rb +783 -0
- data/lib/mtncloud/cli/commands/network_floating_ips.rb +147 -0
- data/lib/mtncloud/cli/commands/network_groups_command.rb +654 -0
- data/lib/mtncloud/cli/commands/network_pool_server_types.rb +20 -0
- data/lib/mtncloud/cli/commands/network_pool_servers_command.rb +318 -0
- data/lib/mtncloud/cli/commands/network_pools_command.rb +903 -0
- data/lib/mtncloud/cli/commands/network_proxies_command.rb +578 -0
- data/lib/mtncloud/cli/commands/network_routers_command.rb +2628 -0
- data/lib/mtncloud/cli/commands/network_security_server_types.rb +20 -0
- data/lib/mtncloud/cli/commands/network_server_groups_command.rb +222 -0
- data/lib/mtncloud/cli/commands/network_server_types_command.rb +20 -0
- data/lib/mtncloud/cli/commands/network_servers_command.rb +398 -0
- data/lib/mtncloud/cli/commands/network_services_command.rb +198 -0
- data/lib/mtncloud/cli/commands/network_static_routes_command.rb +451 -0
- data/lib/mtncloud/cli/commands/network_transport_zones_command.rb +412 -0
- data/lib/mtncloud/cli/commands/networks_command.rb +1692 -0
- data/lib/mtncloud/cli/commands/open_command.rb +30 -0
- data/lib/mtncloud/cli/commands/options.rb +231 -0
- data/lib/mtncloud/cli/commands/packages_command.rb +822 -0
- data/lib/mtncloud/cli/commands/ping.rb +242 -0
- data/lib/mtncloud/cli/commands/plugins.rb +214 -0
- data/lib/mtncloud/cli/commands/policies_command.rb +990 -0
- data/lib/mtncloud/cli/commands/power_schedules_command.rb +731 -0
- data/lib/mtncloud/cli/commands/preseed_scripts_command.rb +378 -0
- data/lib/mtncloud/cli/commands/price_sets_command.rb +557 -0
- data/lib/mtncloud/cli/commands/prices_command.rb +692 -0
- data/lib/mtncloud/cli/commands/processes_command.rb +469 -0
- data/lib/mtncloud/cli/commands/projects_command.rb +537 -0
- data/lib/mtncloud/cli/commands/provisioning_licenses_command.rb +509 -0
- data/lib/mtncloud/cli/commands/provisioning_settings_command.rb +238 -0
- data/lib/mtncloud/cli/commands/recent_activity_command.rb +171 -0
- data/lib/mtncloud/cli/commands/remote.rb +1818 -0
- data/lib/mtncloud/cli/commands/reports_command.rb +724 -0
- data/lib/mtncloud/cli/commands/resource_pool_groups_command.rb +586 -0
- data/lib/mtncloud/cli/commands/rm_command.rb +14 -0
- data/lib/mtncloud/cli/commands/roles.rb +3120 -0
- data/lib/mtncloud/cli/commands/scale_thresholds.rb +103 -0
- data/lib/mtncloud/cli/commands/search_command.rb +184 -0
- data/lib/mtncloud/cli/commands/security_group_rules.rb +230 -0
- data/lib/mtncloud/cli/commands/security_groups.rb +1294 -0
- data/lib/mtncloud/cli/commands/security_package_types.rb +32 -0
- data/lib/mtncloud/cli/commands/security_packages.rb +84 -0
- data/lib/mtncloud/cli/commands/security_scans.rb +107 -0
- data/lib/mtncloud/cli/commands/self_service_command.rb +17 -0
- data/lib/mtncloud/cli/commands/server_devices_command.rb +207 -0
- data/lib/mtncloud/cli/commands/service_catalog_command.rb +1528 -0
- data/lib/mtncloud/cli/commands/service_plans_command.rb +895 -0
- data/lib/mtncloud/cli/commands/set_prompt_command.rb +51 -0
- data/lib/mtncloud/cli/commands/setup.rb +423 -0
- data/lib/mtncloud/cli/commands/shell.rb +717 -0
- data/lib/mtncloud/cli/commands/sleep_command.rb +43 -0
- data/lib/mtncloud/cli/commands/snapshots.rb +156 -0
- data/lib/mtncloud/cli/commands/source_command.rb +30 -0
- data/lib/mtncloud/cli/commands/ssl_verification_command.rb +47 -0
- data/lib/mtncloud/cli/commands/storage_datastores.rb +457 -0
- data/lib/mtncloud/cli/commands/storage_providers_command.rb +1401 -0
- data/lib/mtncloud/cli/commands/storage_server_types.rb +45 -0
- data/lib/mtncloud/cli/commands/storage_servers.rb +116 -0
- data/lib/mtncloud/cli/commands/storage_volume_types.rb +45 -0
- data/lib/mtncloud/cli/commands/storage_volumes.rb +236 -0
- data/lib/mtncloud/cli/commands/subnets_command.rb +819 -0
- data/lib/mtncloud/cli/commands/support_bundles_command.rb +606 -0
- data/lib/mtncloud/cli/commands/systems.rb +1203 -0
- data/lib/mtncloud/cli/commands/tasks.rb +1391 -0
- data/lib/mtncloud/cli/commands/tee_command.rb +14 -0
- data/lib/mtncloud/cli/commands/tenants_command.rb +315 -0
- data/lib/mtncloud/cli/commands/tokens_command.rb +391 -0
- data/lib/mtncloud/cli/commands/update_command.rb +46 -0
- data/lib/mtncloud/cli/commands/usage_command.rb +203 -0
- data/lib/mtncloud/cli/commands/user_groups_command.rb +512 -0
- data/lib/mtncloud/cli/commands/user_settings_command.rb +849 -0
- data/lib/mtncloud/cli/commands/user_sources_command.rb +1065 -0
- data/lib/mtncloud/cli/commands/users.rb +897 -0
- data/lib/mtncloud/cli/commands/vdi_allocations_command.rb +159 -0
- data/lib/mtncloud/cli/commands/vdi_apps_command.rb +317 -0
- data/lib/mtncloud/cli/commands/vdi_command.rb +359 -0
- data/lib/mtncloud/cli/commands/vdi_gateways_command.rb +290 -0
- data/lib/mtncloud/cli/commands/vdi_pools_command.rb +574 -0
- data/lib/mtncloud/cli/commands/version_command.rb +38 -0
- data/lib/mtncloud/cli/commands/view.rb +107 -0
- data/lib/mtncloud/cli/commands/virtual_images.rb +1362 -0
- data/lib/mtncloud/cli/commands/virtual_switches_command.rb +336 -0
- data/lib/mtncloud/cli/commands/whitelabel_settings_command.rb +653 -0
- data/lib/mtncloud/cli/commands/whoami.rb +323 -0
- data/lib/mtncloud/cli/commands/wiki_command.rb +448 -0
- data/lib/mtncloud/cli/commands/workflows.rb +1022 -0
- data/lib/mtncloud/cli/credentials.rb +482 -0
- data/lib/mtncloud/cli/dot_file.rb +180 -0
- data/lib/mtncloud/cli/error_handler.rb +307 -0
- data/lib/mtncloud/cli/errors.rb +53 -0
- data/lib/mtncloud/cli/expression_parser.rb +153 -0
- data/lib/mtncloud/cli/mixins/accounts_helper.rb +484 -0
- data/lib/mtncloud/cli/mixins/affinity_helper.rb +118 -0
- data/lib/mtncloud/cli/mixins/backups_helper.rb +200 -0
- data/lib/mtncloud/cli/mixins/deployments_helper.rb +163 -0
- data/lib/mtncloud/cli/mixins/execution_request_helper.rb +50 -0
- data/lib/mtncloud/cli/mixins/infrastructure_helper.rb +966 -0
- data/lib/mtncloud/cli/mixins/jobs_helper.rb +202 -0
- data/lib/mtncloud/cli/mixins/library_helper.rb +539 -0
- data/lib/mtncloud/cli/mixins/load_balancers_helper.rb +176 -0
- data/lib/mtncloud/cli/mixins/logs_helper.rb +131 -0
- data/lib/mtncloud/cli/mixins/monitoring_helper.rb +876 -0
- data/lib/mtncloud/cli/mixins/networks_helper.rb +62 -0
- data/lib/mtncloud/cli/mixins/operations_helper.rb +41 -0
- data/lib/mtncloud/cli/mixins/option_source_helper.rb +254 -0
- data/lib/mtncloud/cli/mixins/print_helper.rb +1631 -0
- data/lib/mtncloud/cli/mixins/processes_helper.rb +286 -0
- data/lib/mtncloud/cli/mixins/prompt_helper.rb +136 -0
- data/lib/mtncloud/cli/mixins/provisioning_helper.rb +2963 -0
- data/lib/mtncloud/cli/mixins/remote_helper.rb +139 -0
- data/lib/mtncloud/cli/mixins/rest_command.rb +994 -0
- data/lib/mtncloud/cli/mixins/secondary_rest_command.rb +700 -0
- data/lib/mtncloud/cli/mixins/storage_servers_helper.rb +93 -0
- data/lib/mtncloud/cli/mixins/storage_volumes_helper.rb +76 -0
- data/lib/mtncloud/cli/mixins/vdi_helper.rb +246 -0
- data/lib/mtncloud/cli/mixins/whoami_helper.rb +73 -0
- data/lib/mtncloud/cli/option_parser.rb +127 -0
- data/lib/mtncloud/cli/option_types.rb +1622 -0
- data/lib/mtncloud/cli/version.rb +6 -0
- data/lib/mtncloud/cli.rb +105 -0
- data/lib/mtncloud/currency.rb +184 -0
- data/lib/mtncloud/ext/hash.rb +109 -0
- data/lib/mtncloud/ext/nil_class.rb +5 -0
- data/lib/mtncloud/ext/rest_client.rb +37 -0
- data/lib/mtncloud/ext/string.rb +66 -0
- data/lib/mtncloud/formatters.rb +511 -0
- data/lib/mtncloud/logging.rb +185 -0
- data/lib/mtncloud/morpkg.rb +119 -0
- data/lib/mtncloud/rest_client.rb +104 -0
- data/lib/mtncloud/routes.rb +304 -0
- data/lib/mtncloud/terminal.rb +528 -0
- data/lib/mtncloud/util.rb +29 -0
- data/lib/mtncloud.rb +5 -0
- data/mtncloud-cli.gemspec +38 -0
- data/test/api/affinity_groups_interface_test.rb +43 -0
- data/test/api/clients_interface_test.rb +23 -0
- data/test/api/clouds_interface_test.rb +67 -0
- data/test/api/containers_interface_test.rb +68 -0
- data/test/api/host_vm_groups_interface_test.rb +35 -0
- data/test/api/instances_interface_test.rb +22 -0
- data/test/api/network_routers_interface_test.rb +22 -0
- data/test/api/systems_interface_test.rb +26 -0
- data/test/api/whoami_interface_test.rb +14 -0
- data/test/branding_test.rb +160 -0
- data/test/cli/access_token_test.rb +36 -0
- data/test/cli/affinity_groups_cloud_cluster_scope_test.rb +270 -0
- data/test/cli/affinity_groups_cluster_scope_test.rb +171 -0
- data/test/cli/affinity_groups_test.rb +57 -0
- data/test/cli/affinity_groups_violations_scope_test.rb +141 -0
- data/test/cli/affinity_helper_test.rb +367 -0
- data/test/cli/auth_test.rb +88 -0
- data/test/cli/backups_test.rb +212 -0
- data/test/cli/cli_test.rb +48 -0
- data/test/cli/clients_test.rb +45 -0
- data/test/cli/clusters_uuid_test.rb +146 -0
- data/test/cli/containers_test.rb +92 -0
- data/test/cli/distributed_workers_test.rb +68 -0
- data/test/cli/help_test.rb +25 -0
- data/test/cli/host_vm_groups_cluster_scope_test.rb +187 -0
- data/test/cli/host_vm_groups_test.rb +63 -0
- data/test/cli/infrastructure_helper_cluster_resolver_test.rb +250 -0
- data/test/cli/instances_test.rb +37 -0
- data/test/cli/man_test.rb +14 -0
- data/test/cli/migrations_test.rb +39 -0
- data/test/cli/network_routers_test.rb +65 -0
- data/test/cli/remote_test.rb +89 -0
- data/test/cli/roles_test.rb +47 -0
- data/test/cli/shell_test.rb +81 -0
- data/test/cli/storage_volumes_test.rb +79 -0
- data/test/cli/systems_test.rb +206 -0
- data/test/cli/version_test.rb +23 -0
- data/test/cli/view_test.rb +55 -0
- data/test/cli/whoami_test.rb +17 -0
- data/test/mtncloud_test.rb +16 -0
- data/test/test_case.rb +342 -0
- data/test/test_config.rb +137 -0
- data/test/test_data_helper.rb +97 -0
- metadata +807 -0
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
# SecondaryRestCommand is a mixin for MtnCloud::Cli command classes.
|
|
2
|
+
# for resources that are secondary to some parent resource.
|
|
3
|
+
# Provides basic CRUD commands: list, get, add, update, remove
|
|
4
|
+
# The parent resource is specified as the first argument for all the comments.
|
|
5
|
+
#
|
|
6
|
+
# Example of a SecondaryRestCommand for `mtncloud load-balancer-virtual-servers`.
|
|
7
|
+
#
|
|
8
|
+
# class MtnCloud::Cli::LoadBalancerVirtualServers
|
|
9
|
+
#
|
|
10
|
+
# include MtnCloud::Cli::CliCommand
|
|
11
|
+
# include MtnCloud::Cli::RestCommand
|
|
12
|
+
# include MtnCloud::Cli::SecondaryRestCommand
|
|
13
|
+
# include MtnCloud::Cli::LoadBalancersHelper
|
|
14
|
+
#
|
|
15
|
+
# set_command_name :'load-balancer-virtual-servers'
|
|
16
|
+
# register_subcommands :list, :get, :add, :update, :remove
|
|
17
|
+
#
|
|
18
|
+
# register_interfaces :load_balancer_virtual_servers,
|
|
19
|
+
# :load_balancers, :load_balancer_types
|
|
20
|
+
#
|
|
21
|
+
# set_rest_parent_name :load_balancers
|
|
22
|
+
#
|
|
23
|
+
# end
|
|
24
|
+
#
|
|
25
|
+
module MtnCloud::Cli::SecondaryRestCommand
|
|
26
|
+
def self.included(base)
|
|
27
|
+
base.extend ClassMethods
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
module ClassMethods
|
|
31
|
+
|
|
32
|
+
## duplicated the rest_* settings with rest_parent_*, for defining the parent resource
|
|
33
|
+
|
|
34
|
+
# rest_parent_name is the rest_name for the parent
|
|
35
|
+
def rest_parent_name
|
|
36
|
+
defined?(@rest_parent_name) ? @rest_parent_name : default_rest_parent_name
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def default_rest_parent_name
|
|
40
|
+
words = rest_name.split("_")
|
|
41
|
+
if words.size > 1
|
|
42
|
+
words.pop
|
|
43
|
+
return words.join("_") + "s"
|
|
44
|
+
else
|
|
45
|
+
# this wont happen, default wont make sense in this scenario
|
|
46
|
+
# "parent_" + rest_name
|
|
47
|
+
raise "Unable to determine default_rest_parent_name for rest_name: #{rest_name}, class: #{self}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def rest_parent_name=(v)
|
|
52
|
+
@rest_parent_name = v.to_s
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
alias :set_rest_parent_name :rest_parent_name=
|
|
56
|
+
alias :set_rest_parent :rest_parent_name=
|
|
57
|
+
#alias :rest_parent= :rest_parent_name=
|
|
58
|
+
|
|
59
|
+
# rest_parent_key is the singular name of the resource eg. "neat_thing"
|
|
60
|
+
def rest_parent_key
|
|
61
|
+
defined?(@rest_parent_key) ? @rest_parent_key : default_rest_parent_key
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def default_rest_parent_key
|
|
65
|
+
rest_parent_name.chomp("s")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def rest_parent_key=(v)
|
|
69
|
+
@rest_parent_key = v.to_s
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
alias :set_rest_parent_key :rest_parent_key=
|
|
73
|
+
|
|
74
|
+
def rest_parent_arg
|
|
75
|
+
defined?(@rest_parent_arg) ? @rest_parent_arg : default_rest_parent_arg
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def default_rest_parent_arg
|
|
79
|
+
rest_parent_key.to_s.gsub("_", " ")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def rest_parent_arg=(v)
|
|
83
|
+
@rest_parent_arg = v.to_s
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
alias :set_rest_parent_arg :rest_parent_arg=
|
|
87
|
+
|
|
88
|
+
def rest_parent_param
|
|
89
|
+
defined?(@rest_parent_param) ? @rest_parent_param : default_rest_parent_param
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def default_rest_parent_param
|
|
93
|
+
param = rest_parent_key.to_s.split('_').collect(&:capitalize).join
|
|
94
|
+
"#{param[0].downcase}#{param[1..-1]}Id"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def rest_parent_param=(v)
|
|
98
|
+
@rest_parent_param = v.to_s
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
alias :set_rest_parent_param :rest_parent_param=
|
|
102
|
+
|
|
103
|
+
# rest_parent_has_name indicates a resource has a name and can be retrieved by name or id
|
|
104
|
+
# true by default, set to false for lookups by only id
|
|
105
|
+
def rest_parent_has_name
|
|
106
|
+
defined?(@rest_parent_has_name) ? @rest_parent_has_name : default_rest_parent_has_name
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def default_rest_parent_has_name
|
|
110
|
+
true
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def rest_parent_has_name=(v)
|
|
114
|
+
@rest_parent_has_name = !!v
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
alias :set_rest_parent_has_name :rest_parent_has_name=
|
|
118
|
+
|
|
119
|
+
# rest_parent_label is the capitalized resource label eg. "Neat Thing"
|
|
120
|
+
def rest_parent_label
|
|
121
|
+
defined?(@rest_parent_label) ? @rest_parent_label : default_rest_parent_label
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def default_rest_parent_label
|
|
125
|
+
rest_parent_key.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ")
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def rest_parent_label=(v)
|
|
129
|
+
@rest_parent_label = v.to_s
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
alias :set_rest_parent_label :rest_parent_label=
|
|
133
|
+
|
|
134
|
+
# the plural version of the label eg. "Neat Things"
|
|
135
|
+
def rest_parent_label_plural
|
|
136
|
+
defined?(@rest_parent_label_plural) ? @rest_parent_label_plural : default_rest_parent_label_plural
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def default_rest_parent_label_plural
|
|
140
|
+
#rest_parent_name.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ")
|
|
141
|
+
rest_parent_label.to_s.pluralize
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def rest_parent_label_plural=(v)
|
|
145
|
+
@rest_parent_label_plural = v.to_s
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
alias :set_rest_parent_label_plural :rest_parent_label_plural=
|
|
149
|
+
|
|
150
|
+
# the name of the default interface, matches the rest name eg. "neat_things"
|
|
151
|
+
def rest_parent_interface_name
|
|
152
|
+
defined?(@rest_parent_interface_name) ? @rest_parent_interface_name : default_rest_parent_interface_name
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def default_rest_parent_interface_name
|
|
156
|
+
rest_parent_name
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def rest_parent_interface_name=(v)
|
|
160
|
+
@rest_parent_interface_name = v.to_s
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
alias :set_rest_parent_interface_name :rest_parent_interface_name=
|
|
164
|
+
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
## duplicated the rest_* settings with rest_parent, for the parents resource
|
|
168
|
+
|
|
169
|
+
def rest_parent_name
|
|
170
|
+
self.class.rest_parent_name
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def rest_parent_key
|
|
174
|
+
self.class.rest_parent_key
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def rest_parent_arg
|
|
178
|
+
self.class.rest_parent_arg
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def rest_parent_param
|
|
182
|
+
self.class.rest_parent_param
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def rest_parent_has_name
|
|
186
|
+
self.class.rest_parent_has_name
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def rest_parent_label
|
|
190
|
+
self.class.rest_parent_label
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def rest_parent_label_plural
|
|
194
|
+
self.class.rest_parent_label_plural
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def rest_parent_interface_name
|
|
198
|
+
self.class.rest_parent_interface_name # || "@#{rest_parent_name}_interface"
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def rest_parent_interface
|
|
202
|
+
instance_variable_get("@#{rest_parent_interface_name}_interface")
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def rest_parent_object_key
|
|
206
|
+
send("#{rest_parent_key}_object_key")
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def rest_parent_list_key
|
|
210
|
+
send("#{rest_parent_key}_list_key")
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def rest_parent_column_definitions(options)
|
|
214
|
+
send("#{rest_parent_key}_column_definitions", options)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def rest_parent_list_column_definitions(options)
|
|
218
|
+
send("#{rest_parent_key}_list_column_definitions", options)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def rest_parent_find_by_name_or_id(val)
|
|
222
|
+
# use explicitly defined finders
|
|
223
|
+
# else default to new generic CliCommand find_by methods
|
|
224
|
+
if rest_parent_has_name
|
|
225
|
+
if respond_to?("find_#{rest_parent_key}_by_name_or_id", true)
|
|
226
|
+
send("find_#{rest_parent_key}_by_name_or_id", val)
|
|
227
|
+
else
|
|
228
|
+
find_by_name_or_id(rest_parent_key, val)
|
|
229
|
+
end
|
|
230
|
+
else
|
|
231
|
+
if respond_to?("find_#{rest_parent_key}_by_id", true)
|
|
232
|
+
send("find_#{rest_parent_key}_by_id", val)
|
|
233
|
+
else
|
|
234
|
+
find_by_id(rest_parent_key, val)
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# override RestCommand method to include parent_id parameter
|
|
240
|
+
def rest_find_by_name_or_id(parent_id, val)
|
|
241
|
+
# use explicitly defined finders
|
|
242
|
+
# else default to new generic CliCommand find_by methods
|
|
243
|
+
if rest_has_name
|
|
244
|
+
if respond_to?("find_#{rest_key}_by_name_or_id", true)
|
|
245
|
+
send("find_#{rest_key}_by_name_or_id", parent_id, val)
|
|
246
|
+
else
|
|
247
|
+
find_by_name_or_id(rest_key, parent_id, val)
|
|
248
|
+
end
|
|
249
|
+
else
|
|
250
|
+
if respond_to?("find_#{rest_key}_by_id", true)
|
|
251
|
+
send("find_#{rest_key}_by_id", parent_id, val)
|
|
252
|
+
else
|
|
253
|
+
find_by_id(rest_key, parent_id, val)
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def registered_interfaces
|
|
259
|
+
self.class.registered_interfaces
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def list(args)
|
|
263
|
+
parent_id, parent_record = nil, nil
|
|
264
|
+
params = {}
|
|
265
|
+
options = {}
|
|
266
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
267
|
+
opts.banner = subcommand_usage("[#{rest_parent_arg}] [search]")
|
|
268
|
+
build_list_options(opts, options, params)
|
|
269
|
+
opts.footer = <<-EOT
|
|
270
|
+
List #{rest_label_plural.downcase}.
|
|
271
|
+
[#{rest_parent_arg}] is required. This is the #{rest_parent_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_parent_label)} #{rest_parent_label.downcase}.
|
|
272
|
+
[search] is optional. This is a search phrase to filter the results.
|
|
273
|
+
EOT
|
|
274
|
+
end
|
|
275
|
+
optparse.parse!(args)
|
|
276
|
+
verify_args!(args:args, optparse:optparse, min:1)
|
|
277
|
+
connect(options)
|
|
278
|
+
parent_id = args[0]
|
|
279
|
+
parent_record = rest_parent_find_by_name_or_id(parent_id)
|
|
280
|
+
if parent_record.nil?
|
|
281
|
+
return 1, "#{rest_parent_label} not found for '#{parent_id}"
|
|
282
|
+
end
|
|
283
|
+
parent_id = parent_record['id']
|
|
284
|
+
parse_list_options!(args.count > 1 ? args[1..-1] : [], options, params)
|
|
285
|
+
rest_interface.setopts(options)
|
|
286
|
+
if options[:dry_run]
|
|
287
|
+
print_dry_run rest_interface.dry.list(parent_id, params)
|
|
288
|
+
return
|
|
289
|
+
end
|
|
290
|
+
json_response = rest_interface.list(parent_id, params)
|
|
291
|
+
render_response(json_response, options, rest_list_key) do
|
|
292
|
+
records = json_response[rest_list_key]
|
|
293
|
+
print_h1 "#{rest_label_plural}"
|
|
294
|
+
if records.nil? || records.empty?
|
|
295
|
+
print cyan,"No #{rest_label_plural.downcase} found.",reset,"\n"
|
|
296
|
+
else
|
|
297
|
+
print as_pretty_table(records, rest_list_column_definitions(options.merge({:parent_record => parent_record})).upcase_keys!, options)
|
|
298
|
+
print_results_pagination(json_response) if json_response['meta']
|
|
299
|
+
end
|
|
300
|
+
print reset,"\n"
|
|
301
|
+
end
|
|
302
|
+
return 0, nil
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def get(args)
|
|
306
|
+
params = {}
|
|
307
|
+
options = {}
|
|
308
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
309
|
+
opts.banner = subcommand_usage("[#{rest_parent_arg}] [#{rest_arg}]")
|
|
310
|
+
build_get_options(opts, options, params)
|
|
311
|
+
opts.footer = <<-EOT
|
|
312
|
+
Get details about #{a_or_an(rest_label)} #{rest_label.downcase}.
|
|
313
|
+
[#{rest_parent_arg}] is required. This is the #{rest_parent_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_parent_label)} #{rest_parent_label.downcase}.
|
|
314
|
+
[#{rest_arg}] is required. This is the #{rest_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_label)} #{rest_label.downcase}.
|
|
315
|
+
EOT
|
|
316
|
+
end
|
|
317
|
+
optparse.parse!(args)
|
|
318
|
+
verify_args!(args:args, optparse:optparse, min:2)
|
|
319
|
+
connect(options)
|
|
320
|
+
parse_get_options!(args.count > 1 ? args[1..-1] : [], options, params)
|
|
321
|
+
_get(args[0], args[1..-1].join(" "), params, options)
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def _get(parent_id, id, params, options)
|
|
325
|
+
parent_record = rest_parent_find_by_name_or_id(parent_id)
|
|
326
|
+
if parent_record.nil?
|
|
327
|
+
return 1, "#{rest_parent_label} not found for '#{parent_id}"
|
|
328
|
+
end
|
|
329
|
+
parent_id = parent_record['id']
|
|
330
|
+
if id !~ /\A\d{1,}\Z/
|
|
331
|
+
record = rest_find_by_name_or_id(parent_id, id)
|
|
332
|
+
if record.nil?
|
|
333
|
+
return 1, "#{rest_label} not found for '#{id}"
|
|
334
|
+
end
|
|
335
|
+
id = record['id']
|
|
336
|
+
end
|
|
337
|
+
rest_interface.setopts(options)
|
|
338
|
+
if options[:dry_run]
|
|
339
|
+
print_dry_run rest_interface.dry.get(parent_id, id, params)
|
|
340
|
+
return
|
|
341
|
+
end
|
|
342
|
+
json_response = rest_interface.get(parent_id, id, params)
|
|
343
|
+
render_response_for_get(json_response, options.merge({:parent_record => parent_record}))
|
|
344
|
+
return 0, nil
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def render_response_for_get(json_response, options)
|
|
348
|
+
render_response(json_response, options, rest_object_key) do
|
|
349
|
+
record = json_response[rest_object_key]
|
|
350
|
+
print_h1 rest_label, [], options
|
|
351
|
+
print cyan
|
|
352
|
+
print_description_list(rest_column_definitions(options), record, options)
|
|
353
|
+
# show config settings...
|
|
354
|
+
if record['optionTypes'] && record['optionTypes'].size > 0
|
|
355
|
+
print_h2 "Option Types", options
|
|
356
|
+
print format_option_types_table(record['optionTypes'], options, rest_object_key)
|
|
357
|
+
end
|
|
358
|
+
render_response_details_for_get(record, options)
|
|
359
|
+
print reset,"\n"
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def render_response_details_for_get(record, options)
|
|
364
|
+
# override for custom details
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def add(args)
|
|
368
|
+
parent_id, parent_record = nil, nil
|
|
369
|
+
record_type_id = nil
|
|
370
|
+
options = {:options => {:context_map => rest_option_context_map}}
|
|
371
|
+
option_types = respond_to?("add_#{rest_key}_option_types", true) ? send("add_#{rest_key}_option_types") : []
|
|
372
|
+
advanced_option_types = respond_to?("add_#{rest_key}_advanced_option_types", true) ? send("add_#{rest_key}_advanced_option_types") : []
|
|
373
|
+
type_option_type = option_types.find {|it| it['fieldName'] == 'type'}
|
|
374
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
375
|
+
if rest_has_name
|
|
376
|
+
opts.banner = subcommand_usage("[#{rest_parent_arg}] [name]")
|
|
377
|
+
else
|
|
378
|
+
opts.banner = subcommand_usage("[#{rest_parent_arg}]")
|
|
379
|
+
end
|
|
380
|
+
if rest_has_type && type_option_type.nil?
|
|
381
|
+
opts.on( '-t', "--#{rest_type_arg} TYPE", "#{rest_type_label}" ) do |val|
|
|
382
|
+
record_type_id = val
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
build_option_type_options(opts, options, option_types)
|
|
386
|
+
build_option_type_options(opts, options, advanced_option_types)
|
|
387
|
+
build_standard_add_options(opts, options)
|
|
388
|
+
opts.footer = <<-EOT
|
|
389
|
+
Create a new #{rest_label.downcase}.
|
|
390
|
+
[#{rest_parent_arg}] is required. This is the #{rest_parent_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_parent_label)} #{rest_parent_label.downcase}.
|
|
391
|
+
[name] is required. This is the name of the new #{rest_label.downcase}.
|
|
392
|
+
EOT
|
|
393
|
+
end
|
|
394
|
+
optparse.parse!(args)
|
|
395
|
+
verify_args!(args:args, optparse:optparse, min:1, max: 2)
|
|
396
|
+
# todo: make supporting args[0] optional and more flexible
|
|
397
|
+
# for now args[0] is assumed to be the 'name'
|
|
398
|
+
record_name = nil
|
|
399
|
+
parent_id = args[0]
|
|
400
|
+
if rest_has_name
|
|
401
|
+
if args[1]
|
|
402
|
+
record_name = args[1]
|
|
403
|
+
end
|
|
404
|
+
verify_args!(args:args, optparse:optparse, min:1, max: 2)
|
|
405
|
+
else
|
|
406
|
+
verify_args!(args:args, optparse:optparse, count: 1)
|
|
407
|
+
end
|
|
408
|
+
connect(options)
|
|
409
|
+
# load parent record
|
|
410
|
+
# todo: prompt instead of error
|
|
411
|
+
parent_record = rest_parent_find_by_name_or_id(parent_id)
|
|
412
|
+
if parent_record.nil?
|
|
413
|
+
return 1, "#{rest_parent_label} not found for '#{parent_id}"
|
|
414
|
+
end
|
|
415
|
+
parent_id = parent_record['id']
|
|
416
|
+
# load or prompt for type
|
|
417
|
+
if rest_has_type && type_option_type.nil?
|
|
418
|
+
if record_type_id.nil?
|
|
419
|
+
#raise_command_error "#{rest_type_label} is required.\n#{optparse}"
|
|
420
|
+
type_list = rest_type_interface.list({max:10000, creatable: true})[rest_type_list_key]
|
|
421
|
+
type_dropdown_options = type_list.collect {|it| {'name' => it['name'], 'value' => it['code']} }
|
|
422
|
+
record_type_id = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'type', 'fieldLabel' => rest_type_label, 'type' => 'select', 'selectOptions' => type_dropdown_options, 'required' => true}], options[:options], @api_client)['type']
|
|
423
|
+
end
|
|
424
|
+
record_type = rest_type_find_by_name_or_id(record_type_id)
|
|
425
|
+
if record_type.nil?
|
|
426
|
+
return 1, "#{rest_type_label} not found for '#{record_type_id}"
|
|
427
|
+
end
|
|
428
|
+
end
|
|
429
|
+
passed_options = parse_passed_options(options)
|
|
430
|
+
options[:params] ||= {}
|
|
431
|
+
options[:params][rest_parent_param] = parent_id
|
|
432
|
+
options[:options]['_object_key'] = rest_object_key
|
|
433
|
+
payload = {}
|
|
434
|
+
if options[:payload]
|
|
435
|
+
payload = options[:payload]
|
|
436
|
+
payload.deep_merge!({rest_object_key => passed_options})
|
|
437
|
+
else
|
|
438
|
+
record_payload = {}
|
|
439
|
+
if record_name
|
|
440
|
+
record_payload['name'] = record_name
|
|
441
|
+
options[:options]['name'] = record_name # injected for prompt
|
|
442
|
+
options[:options][rest_arg] = record_name
|
|
443
|
+
end
|
|
444
|
+
if rest_has_type && record_type
|
|
445
|
+
# record_payload['type'] = {'code' => record_type['code']}
|
|
446
|
+
record_payload['type'] = record_type['code']
|
|
447
|
+
options[:options]['type'] = record_type['code'] # injected for prompt
|
|
448
|
+
# initialize params for loading optionSource data
|
|
449
|
+
options[:params]['type'] = record_type['code']
|
|
450
|
+
end
|
|
451
|
+
record_payload.deep_merge!(passed_options)
|
|
452
|
+
if option_types && !option_types.empty?
|
|
453
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt(option_types, options[:options], @api_client, options[:params])
|
|
454
|
+
v_prompt.deep_compact!
|
|
455
|
+
v_prompt.booleanize! # 'on' => true
|
|
456
|
+
record_payload.deep_merge!(v_prompt)
|
|
457
|
+
end
|
|
458
|
+
# options by type
|
|
459
|
+
if rest_has_type && record_type.nil?
|
|
460
|
+
type_value = record_payload['type'].is_a?(Hash) ? record_payload['type']['id'] : record_payload['type']
|
|
461
|
+
if type_value
|
|
462
|
+
record_type = rest_type_find_by_name_or_id(type_value)
|
|
463
|
+
if record_type.nil?
|
|
464
|
+
return 1, "#{rest_type_label} not found for '#{type_value}"
|
|
465
|
+
end
|
|
466
|
+
end
|
|
467
|
+
# reload the type by id to get all the details ie. optionTypes
|
|
468
|
+
if record_type && record_type['optionTypes'].nil?
|
|
469
|
+
record_type = rest_type_find_by_name_or_id(record_type['id'])
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
if respond_to?("load_option_types_for_#{rest_key}", true)
|
|
473
|
+
my_option_types = send("load_option_types_for_#{rest_key}", record_type, parent_record)
|
|
474
|
+
else
|
|
475
|
+
my_option_types = record_type ? record_type['optionTypes'] : nil
|
|
476
|
+
end
|
|
477
|
+
if my_option_types && !my_option_types.empty?
|
|
478
|
+
# remove redundant fieldContext
|
|
479
|
+
my_option_types.each do |option_type|
|
|
480
|
+
if option_type['fieldContext'] == rest_object_key
|
|
481
|
+
option_type['fieldContext'] = nil
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
api_params = (options[:params] || {}).merge(record_payload)
|
|
485
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt(my_option_types, options[:options], @api_client, api_params)
|
|
486
|
+
v_prompt.deep_compact!
|
|
487
|
+
v_prompt.booleanize! # 'on' => true
|
|
488
|
+
record_payload.deep_merge!(v_prompt)
|
|
489
|
+
end
|
|
490
|
+
# advanced options (uses no_prompt)
|
|
491
|
+
if advanced_option_types && !advanced_option_types.empty?
|
|
492
|
+
v_prompt = MtnCloud::Cli::OptionTypes.no_prompt(advanced_option_types, options[:options], @api_client, options[:params])
|
|
493
|
+
v_prompt.deep_compact!
|
|
494
|
+
v_prompt.booleanize! # 'on' => true
|
|
495
|
+
record_payload.deep_merge!(v_prompt)
|
|
496
|
+
end
|
|
497
|
+
if respond_to?("#{rest_key}_add_prompt", true)
|
|
498
|
+
record_payload = send("#{rest_key}_add_prompt", record_payload, record_type, parent_record, options)
|
|
499
|
+
end
|
|
500
|
+
# permissions
|
|
501
|
+
if rest_perms_config[:enabled]
|
|
502
|
+
if rest_perms_config[:version] == 2
|
|
503
|
+
perms = prompt_permissions_v2(options.deep_merge(rest_perms_config[:options] || {}), rest_perms_config[:excludes] || [])
|
|
504
|
+
else
|
|
505
|
+
perms = prompt_permissions(options.deep_merge(rest_perms_config[:options] || {}), rest_perms_config[:excludes] || [])
|
|
506
|
+
end
|
|
507
|
+
unless rest_perms_config[:name].nil?
|
|
508
|
+
perms.transform_keys! {|k| k == 'resourcePermissions' ? rest_perms_config[:name] : k}
|
|
509
|
+
end
|
|
510
|
+
unless rest_perms_config[:context].nil?
|
|
511
|
+
perms_context = {}
|
|
512
|
+
perms_context[rest_perms_config[:context]] = perms
|
|
513
|
+
perms = perms_context
|
|
514
|
+
end
|
|
515
|
+
record_payload.merge!(perms)
|
|
516
|
+
end
|
|
517
|
+
payload[rest_object_key] = record_payload
|
|
518
|
+
end
|
|
519
|
+
rest_interface.setopts(options)
|
|
520
|
+
if options[:dry_run]
|
|
521
|
+
print_dry_run rest_interface.dry.create(parent_id, payload)
|
|
522
|
+
return
|
|
523
|
+
end
|
|
524
|
+
json_response = rest_interface.create(parent_id, payload)
|
|
525
|
+
if json_response['success']
|
|
526
|
+
render_response(json_response, options, rest_object_key) do
|
|
527
|
+
record = json_response[rest_object_key]
|
|
528
|
+
print_green_success "Added #{rest_label.downcase} #{record.nil? ? json_response['id'] : record['name'] || record['id']}"
|
|
529
|
+
return _get(parent_id, record.nil? ? json_response['id'] : record['id'], {}, options)
|
|
530
|
+
end
|
|
531
|
+
else
|
|
532
|
+
print red
|
|
533
|
+
print json_response['msg']
|
|
534
|
+
print "\n"
|
|
535
|
+
end
|
|
536
|
+
return 0, nil
|
|
537
|
+
end
|
|
538
|
+
|
|
539
|
+
def update(args)
|
|
540
|
+
record_type = nil
|
|
541
|
+
record_type_id = nil
|
|
542
|
+
options = {}
|
|
543
|
+
option_types = respond_to?("update_#{rest_key}_option_types", true) ? send("update_#{rest_key}_option_types") : []
|
|
544
|
+
advanced_option_types = respond_to?("update_#{rest_key}_advanced_option_types", true) ? send("update_#{rest_key}_advanced_option_types") : []
|
|
545
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
546
|
+
opts.banner = subcommand_usage("[#{rest_parent_arg}] [#{rest_arg}] [options]")
|
|
547
|
+
build_standard_update_options(opts, options)
|
|
548
|
+
opts.footer = <<-EOT
|
|
549
|
+
Update an existing #{rest_label.downcase}.
|
|
550
|
+
[#{rest_parent_arg}] is required. This is the #{rest_parent_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_parent_label)} #{rest_parent_label.downcase}.
|
|
551
|
+
[#{rest_arg}] is required. This is the #{rest_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_label)} #{rest_label.downcase}.
|
|
552
|
+
EOT
|
|
553
|
+
end
|
|
554
|
+
optparse.parse!(args)
|
|
555
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
|
556
|
+
connect(options)
|
|
557
|
+
parent_id = args[0]
|
|
558
|
+
id = args[1]
|
|
559
|
+
parent_record = rest_parent_find_by_name_or_id(parent_id)
|
|
560
|
+
if parent_record.nil?
|
|
561
|
+
return 1, "#{rest_parent_label} not found for '#{parent_id}"
|
|
562
|
+
end
|
|
563
|
+
parent_id = parent_record['id']
|
|
564
|
+
connect(options)
|
|
565
|
+
record = rest_find_by_name_or_id(parent_id, id)
|
|
566
|
+
if record.nil?
|
|
567
|
+
return 1, "#{rest_name} not found for '#{id}'"
|
|
568
|
+
end
|
|
569
|
+
# load type so we can prompt for those option types
|
|
570
|
+
if rest_has_type
|
|
571
|
+
record_type_id = record['type']['id']
|
|
572
|
+
record_type = rest_type_find_by_name_or_id(record_type_id)
|
|
573
|
+
if record_type.nil?
|
|
574
|
+
return 1, "#{rest_type_label} not found for '#{record_type_id}"
|
|
575
|
+
end
|
|
576
|
+
# reload the type by id to get all the details ie. optionTypes
|
|
577
|
+
if record_type['optionTypes'].nil?
|
|
578
|
+
record_type = rest_type_find_by_name_or_id(record_type['id'])
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
passed_options = parse_passed_options(options)
|
|
582
|
+
payload = {}
|
|
583
|
+
if options[:payload]
|
|
584
|
+
payload = options[:payload]
|
|
585
|
+
payload.deep_merge!({rest_object_key => passed_options}) unless passed_options.empty?
|
|
586
|
+
else
|
|
587
|
+
record_payload = passed_options
|
|
588
|
+
if rest_has_type && record_type
|
|
589
|
+
# inject type to options for prompting
|
|
590
|
+
# record_payload['type'] = record_type['code']
|
|
591
|
+
# options[:options]['type'] = record_type['code']
|
|
592
|
+
# initialize params for loading optionSource data
|
|
593
|
+
options[:params] ||= {}
|
|
594
|
+
options[:params]['type'] = record_type['code']
|
|
595
|
+
end
|
|
596
|
+
# update options without prompting by default
|
|
597
|
+
if false && option_types && !option_types.empty?
|
|
598
|
+
api_params = (options[:params] || {}).merge(record_payload) # need to merge in values from record too, ughhh
|
|
599
|
+
v_prompt = MtnCloud::Cli::OptionTypes.no_prompt(option_types, options[:options], @api_client, api_params)
|
|
600
|
+
v_prompt.deep_compact!
|
|
601
|
+
v_prompt.booleanize! # 'on' => true
|
|
602
|
+
record_payload.deep_merge!(v_prompt)
|
|
603
|
+
end
|
|
604
|
+
# options by type
|
|
605
|
+
my_option_types = nil
|
|
606
|
+
if respond_to?("load_option_types_for_#{rest_key}", true)
|
|
607
|
+
my_option_types = send("load_option_types_for_#{rest_key}", record_type, parent_record)
|
|
608
|
+
else
|
|
609
|
+
my_option_types = record_type ? record_type['optionTypes'] : nil
|
|
610
|
+
end
|
|
611
|
+
if false && my_option_types && !my_option_types.empty?
|
|
612
|
+
# remove redundant fieldContext
|
|
613
|
+
# make them optional for updates
|
|
614
|
+
# todo: use current value as default instead of just making things optioanl
|
|
615
|
+
# maybe new prompt() options like {:mode => :edit, :object => storage_server} or something
|
|
616
|
+
my_option_types.each do |option_type|
|
|
617
|
+
if option_type['fieldContext'] == rest_object_key
|
|
618
|
+
option_type['fieldContext'] = nil
|
|
619
|
+
end
|
|
620
|
+
option_type.delete('required')
|
|
621
|
+
option_type.delete('defaultValue')
|
|
622
|
+
end
|
|
623
|
+
v_prompt = MtnCloud::Cli::OptionTypes.no_prompt(my_option_types, options[:options], @api_client, options[:params])
|
|
624
|
+
v_prompt.deep_compact!
|
|
625
|
+
v_prompt.booleanize! # 'on' => true
|
|
626
|
+
record_payload.deep_merge!(v_prompt)
|
|
627
|
+
end
|
|
628
|
+
# advanced options
|
|
629
|
+
if false && advanced_option_types && !advanced_option_types.empty?
|
|
630
|
+
v_prompt = MtnCloud::Cli::OptionTypes.no_prompt(advanced_option_types, options[:options], @api_client, options[:params])
|
|
631
|
+
v_prompt.deep_compact!
|
|
632
|
+
v_prompt.booleanize! # 'on' => true
|
|
633
|
+
record_payload.deep_merge!(v_prompt)
|
|
634
|
+
end
|
|
635
|
+
# remove empty config, compact could hanlde this
|
|
636
|
+
if record_payload['config'] && record_payload['config'].empty?
|
|
637
|
+
record_payload.delete('config')
|
|
638
|
+
end
|
|
639
|
+
# prevent updating with empty payload
|
|
640
|
+
if record_payload.empty?
|
|
641
|
+
raise_command_error "Specify at least one option to update.\n#{optparse}"
|
|
642
|
+
end
|
|
643
|
+
payload[rest_object_key] = record_payload
|
|
644
|
+
end
|
|
645
|
+
rest_interface.setopts(options)
|
|
646
|
+
if options[:dry_run]
|
|
647
|
+
print_dry_run rest_interface.dry.update(parent_id, record['id'], payload)
|
|
648
|
+
return
|
|
649
|
+
end
|
|
650
|
+
json_response = rest_interface.update(parent_id, record['id'], payload)
|
|
651
|
+
render_response(json_response, options, rest_object_key) do
|
|
652
|
+
print_green_success "Updated #{rest_label.downcase} #{record['name'] || record['id']}"
|
|
653
|
+
_get(parent_id, record["id"], {}, options)
|
|
654
|
+
end
|
|
655
|
+
return 0, nil
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
def remove(args)
|
|
659
|
+
params = {}
|
|
660
|
+
options = {}
|
|
661
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
662
|
+
opts.banner = subcommand_usage("[#{rest_parent_arg}] [#{rest_arg}]")
|
|
663
|
+
build_standard_remove_options(opts, options)
|
|
664
|
+
opts.footer = <<-EOT
|
|
665
|
+
Delete an existing #{rest_label.downcase}.
|
|
666
|
+
[#{rest_parent_arg}] is required. This is the #{rest_parent_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_parent_label)} #{rest_parent_label.downcase}.
|
|
667
|
+
[#{rest_arg}] is required. This is the #{rest_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_label)} #{rest_label.downcase}.
|
|
668
|
+
EOT
|
|
669
|
+
end
|
|
670
|
+
optparse.parse!(args)
|
|
671
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
|
672
|
+
connect(options)
|
|
673
|
+
parent_id = args[0]
|
|
674
|
+
id = args[1]
|
|
675
|
+
parent_record = rest_parent_find_by_name_or_id(parent_id)
|
|
676
|
+
if parent_record.nil?
|
|
677
|
+
return 1, "#{rest_parent_label} not found for '#{parent_id}"
|
|
678
|
+
end
|
|
679
|
+
record = rest_find_by_name_or_id(parent_record['id'], id)
|
|
680
|
+
if record.nil?
|
|
681
|
+
return 1, "#{rest_name} not found for '#{id}'"
|
|
682
|
+
end
|
|
683
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm("Are you sure you want to delete the #{rest_label.downcase} #{record['name'] || record['id']}?")
|
|
684
|
+
return 9, "aborted"
|
|
685
|
+
end
|
|
686
|
+
params.merge!(parse_query_options(options))
|
|
687
|
+
rest_interface.setopts(options)
|
|
688
|
+
if options[:dry_run]
|
|
689
|
+
print_dry_run rest_interface.dry.destroy(parent_id, record['id'], params)
|
|
690
|
+
return 0, nil
|
|
691
|
+
end
|
|
692
|
+
json_response = rest_interface.destroy(parent_id, record['id'], params)
|
|
693
|
+
render_response(json_response, options) do
|
|
694
|
+
print_green_success "Removed #{rest_label.downcase} #{record['name'] || record['id']}"
|
|
695
|
+
end
|
|
696
|
+
return 0, nil
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
end
|
|
700
|
+
|