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,1065 @@
|
|
|
1
|
+
require 'mtncloud/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class MtnCloud::Cli::UserSourcesCommand
|
|
4
|
+
include MtnCloud::Cli::CliCommand
|
|
5
|
+
include MtnCloud::Cli::AccountsHelper
|
|
6
|
+
|
|
7
|
+
set_command_name :'user-sources'
|
|
8
|
+
set_command_description "View and manage user identity sources"
|
|
9
|
+
|
|
10
|
+
register_subcommands :list, :get, :add, :update, :remove
|
|
11
|
+
register_subcommands :activate, :deactivate
|
|
12
|
+
register_subcommands({:'update-subdomain' => :update_subdomain})
|
|
13
|
+
register_subcommands({:'list-types' => :list_types})
|
|
14
|
+
register_subcommands({:'get-type' => :get_type})
|
|
15
|
+
|
|
16
|
+
def initialize()
|
|
17
|
+
# @appliance_name, @appliance_url = MtnCloud::Cli::Remote.active_appliance
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def connect(opts)
|
|
21
|
+
@api_client = establish_remote_appliance_connection(opts)
|
|
22
|
+
@user_sources_interface = @api_client.user_sources
|
|
23
|
+
@accounts_interface = @api_client.accounts
|
|
24
|
+
@account_users_interface = @api_client.account_users
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def handle(args)
|
|
28
|
+
handle_subcommand(args)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def list(args)
|
|
33
|
+
options = {}
|
|
34
|
+
params = {}
|
|
35
|
+
account = nil
|
|
36
|
+
account_id = nil
|
|
37
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
38
|
+
opts.banner = subcommand_usage()
|
|
39
|
+
opts.on( '--tenant TENANT', String, "Filter by Tenant" ) do |val|
|
|
40
|
+
account_id = val
|
|
41
|
+
end
|
|
42
|
+
opts.on( '-a', '--account ACCOUNT', "Filter by Tenant" ) do |val|
|
|
43
|
+
account_id = val
|
|
44
|
+
end
|
|
45
|
+
opts.add_hidden_option('-a, --account') if opts.is_a?(MtnCloud::Cli::OptionParser)
|
|
46
|
+
build_standard_list_options(opts, options)
|
|
47
|
+
opts.footer = "List identity sources."
|
|
48
|
+
end
|
|
49
|
+
optparse.parse!(args)
|
|
50
|
+
connect(options)
|
|
51
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
|
52
|
+
if args.count > 0
|
|
53
|
+
options[:phrase] = args.join(" ")
|
|
54
|
+
end
|
|
55
|
+
if account_id
|
|
56
|
+
account = find_account_by_name_or_id(account_id)
|
|
57
|
+
if account.nil?
|
|
58
|
+
return 1, "Tenant not found for '#{account_id}'"
|
|
59
|
+
end
|
|
60
|
+
account_id = account['id']
|
|
61
|
+
end
|
|
62
|
+
params.merge!(parse_list_options(options))
|
|
63
|
+
@user_sources_interface.setopts(options)
|
|
64
|
+
if options[:dry_run]
|
|
65
|
+
print_dry_run @user_sources_interface.dry.list(account_id, params)
|
|
66
|
+
return 0, nil
|
|
67
|
+
end
|
|
68
|
+
json_response = @user_sources_interface.list(account_id, params)
|
|
69
|
+
render_response(json_response, options, "userSources") do
|
|
70
|
+
user_sources = json_response["userSources"]
|
|
71
|
+
title = "Identity Sources"
|
|
72
|
+
subtitles = []
|
|
73
|
+
if account
|
|
74
|
+
subtitles << "Tenant: #{account['name']}".strip
|
|
75
|
+
end
|
|
76
|
+
subtitles += parse_list_subtitles(options)
|
|
77
|
+
print_h1 title, subtitles
|
|
78
|
+
if user_sources.empty?
|
|
79
|
+
print cyan,"No identity sources found.",reset,"\n"
|
|
80
|
+
else
|
|
81
|
+
print_user_sources_table(user_sources, options)
|
|
82
|
+
print_results_pagination(json_response)
|
|
83
|
+
end
|
|
84
|
+
print reset,"\n"
|
|
85
|
+
end
|
|
86
|
+
return 0, nil
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def get(args)
|
|
91
|
+
params = {}
|
|
92
|
+
options = {}
|
|
93
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
94
|
+
opts.banner = subcommand_usage("[name]")
|
|
95
|
+
# opts.on( '-c', '--config', "Display raw config only. Default is YAML. Combine with -j for JSON instead." ) do
|
|
96
|
+
# options[:show_config] = true
|
|
97
|
+
# end
|
|
98
|
+
# opts.on('--no-config', "Do not display Config YAML." ) do
|
|
99
|
+
# options[:no_config] = true
|
|
100
|
+
# end
|
|
101
|
+
build_standard_get_options(opts, options)
|
|
102
|
+
opts.footer = <<-EOT
|
|
103
|
+
Get details about an identity source.
|
|
104
|
+
[name] is required. This is the name or id of an identity source.
|
|
105
|
+
EOT
|
|
106
|
+
end
|
|
107
|
+
optparse.parse!(args)
|
|
108
|
+
verify_args!(args:args, optparse:optparse, min:1)
|
|
109
|
+
connect(options)
|
|
110
|
+
id_list = parse_id_list(args)
|
|
111
|
+
return run_command_for_each_arg(id_list) do |arg|
|
|
112
|
+
_get(arg, params, options)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def _get(user_source_id, params, options)
|
|
117
|
+
account_id = nil
|
|
118
|
+
account = nil
|
|
119
|
+
# account_id = args[0]
|
|
120
|
+
# account = find_account_by_name_or_id(account_id)
|
|
121
|
+
# exit 1 if account.nil?
|
|
122
|
+
# account_id = account['id']
|
|
123
|
+
# user_source_id = args[1]
|
|
124
|
+
|
|
125
|
+
@user_sources_interface.setopts(options)
|
|
126
|
+
if options[:dry_run]
|
|
127
|
+
if user_source_id.to_s =~ /\A\d{1,}\Z/
|
|
128
|
+
print_dry_run @user_sources_interface.dry.get(account_id, user_source_id.to_i)
|
|
129
|
+
else
|
|
130
|
+
print_dry_run @user_sources_interface.dry.list(account_id, {name:user_source_id})
|
|
131
|
+
end
|
|
132
|
+
return
|
|
133
|
+
end
|
|
134
|
+
user_source = find_user_source_by_name_or_id(account_id, user_source_id)
|
|
135
|
+
if user_source.nil?
|
|
136
|
+
return 1
|
|
137
|
+
end
|
|
138
|
+
# fetch by id to get config too
|
|
139
|
+
json_response = nil
|
|
140
|
+
if user_source_id.to_s =~ /\A\d{1,}\Z/
|
|
141
|
+
json_response = {'userSource' => user_source}
|
|
142
|
+
else
|
|
143
|
+
json_response = @user_sources_interface.get(account_id, user_source['id'])
|
|
144
|
+
user_source = json_response['userSource']
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
#user_source = json_response['userSource']
|
|
148
|
+
render_response(json_response, options, "userSource") do
|
|
149
|
+
print_h1 "Identity Source Details"
|
|
150
|
+
print cyan
|
|
151
|
+
description_cols = {
|
|
152
|
+
"ID" => lambda {|it| it['id'] },
|
|
153
|
+
"Name" => lambda {|it| it['name'] },
|
|
154
|
+
"Description" => lambda {|it| it['description'] },
|
|
155
|
+
"Type" => lambda {|it| it['type'] },
|
|
156
|
+
"Tenant" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
157
|
+
#"Subdomain" => lambda {|it| it['subdomain'] },
|
|
158
|
+
"Login URL" => lambda {|it| it['loginURL'] },
|
|
159
|
+
"Default Role" => lambda {|it| it['defaultAccountRole'] ? it['defaultAccountRole']['authority'] : '' },
|
|
160
|
+
"External Login" => lambda {|it| format_boolean it['externalLogin'] },
|
|
161
|
+
"Enable Role Mapping Permission" => lambda {|it| format_boolean it['allowCustomMappings'] },
|
|
162
|
+
"Manual Role Assignment" => lambda {|it| it['manualRoleAssignment'].nil? ? '' : format_boolean(it['manualRoleAssignment']) },
|
|
163
|
+
"Active" => lambda {|it| format_boolean it['active'] },
|
|
164
|
+
}
|
|
165
|
+
print_description_list(description_cols, user_source)
|
|
166
|
+
|
|
167
|
+
# show config settings...
|
|
168
|
+
user_source_config = user_source['config']
|
|
169
|
+
print_h2 "Configuration"
|
|
170
|
+
if user_source_config
|
|
171
|
+
columns = user_source_config.keys #.sort
|
|
172
|
+
print_description_list(columns, user_source_config)
|
|
173
|
+
# print reset,"\n"
|
|
174
|
+
else
|
|
175
|
+
print cyan,"No config found.","\n",reset
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
role_mappings = user_source['roleMappings']
|
|
179
|
+
print_h2 "Role Mappings"
|
|
180
|
+
if role_mappings && role_mappings.size > 0
|
|
181
|
+
# print_h2 "Role Mappings"
|
|
182
|
+
role_mapping_columns = [
|
|
183
|
+
{"ROLE" => lambda {|it|
|
|
184
|
+
it['mappedRole'] ? it['mappedRole']['authority'] : ''
|
|
185
|
+
} },
|
|
186
|
+
{"SOURCE ROLE NAME" => lambda {|it| it['sourceRoleName'] } },
|
|
187
|
+
{"SOURCE ROLE FQN" => lambda {|it| it['sourceRoleFqn'] } },
|
|
188
|
+
]
|
|
189
|
+
print as_pretty_table(role_mappings, role_mapping_columns)
|
|
190
|
+
else
|
|
191
|
+
print cyan,"No role mappings found for this identity source.","\n",reset
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
provider_settings = user_source['providerSettings']
|
|
195
|
+
if provider_settings && !provider_settings.empty?
|
|
196
|
+
print_h2 "Provider Settings"
|
|
197
|
+
print_description_list({
|
|
198
|
+
"Entity ID" => lambda {|it| it['entityId'] },
|
|
199
|
+
"ACS URL" => lambda {|it| it['acsUrl'] }
|
|
200
|
+
}, provider_settings)
|
|
201
|
+
print_h2 "SP Metadata"
|
|
202
|
+
print cyan
|
|
203
|
+
print provider_settings['spMetadata']
|
|
204
|
+
print "\n",reset
|
|
205
|
+
else
|
|
206
|
+
# print cyan,"No provider settings found.","\n",reset
|
|
207
|
+
end
|
|
208
|
+
print "\n",reset
|
|
209
|
+
end
|
|
210
|
+
return 0, nil
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def add(args)
|
|
214
|
+
options = {}
|
|
215
|
+
params = {}
|
|
216
|
+
account_id = nil
|
|
217
|
+
type_code = nil
|
|
218
|
+
role_mappings = nil
|
|
219
|
+
role_mapping_names = nil
|
|
220
|
+
default_role_id = nil
|
|
221
|
+
optparse = MtnCloud::Cli::OptionParser.new do|opts|
|
|
222
|
+
opts.banner = subcommand_usage("[account] [name]")
|
|
223
|
+
opts.on( '--tenant TENANT', String, "Tenant Name or ID the identity source will belong to, default is your own." ) do |val|
|
|
224
|
+
account_id = val
|
|
225
|
+
end
|
|
226
|
+
opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID the identity source will belong to, default is your own." ) do |val|
|
|
227
|
+
account_id = val
|
|
228
|
+
end
|
|
229
|
+
opts.add_hidden_option('-a, --account') if opts.is_a?(MtnCloud::Cli::OptionParser)
|
|
230
|
+
opts.on('--type CODE', String, "Identity Source Type") do |val|
|
|
231
|
+
type_code = val
|
|
232
|
+
end
|
|
233
|
+
opts.on('--name VALUE', String, "Name for this identity source") do |val|
|
|
234
|
+
params['name'] = val
|
|
235
|
+
end
|
|
236
|
+
opts.on('--description VALUE', String, "Description") do |val|
|
|
237
|
+
params['description'] = val
|
|
238
|
+
end
|
|
239
|
+
opts.on("--allow-custom-mappings [on|off]", ['on','off'], "Enable Role Mapping Permissions") do |val|
|
|
240
|
+
params['allowCustomMappings'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
|
241
|
+
end
|
|
242
|
+
opts.on("--allowCustomMappings [on|off]", ['on','off'], "Enable Role Mapping Permissions") do |val|
|
|
243
|
+
params['allowCustomMappings'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
|
244
|
+
end
|
|
245
|
+
opts.add_hidden_option('--allowCustomMappings')
|
|
246
|
+
opts.on("--manual-role-assignment [on|off]", ['on','off'], "Manual Role Assignment") do |val|
|
|
247
|
+
params['manualRoleAssignment'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
|
248
|
+
end
|
|
249
|
+
opts.on("--manualRoleAssignment [on|off]", ['on','off'], "Manual Role Assignment") do |val|
|
|
250
|
+
params['manualRoleAssignment'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
|
251
|
+
end
|
|
252
|
+
opts.add_hidden_option('--manualRoleAssignment')
|
|
253
|
+
opts.on("--manual-role-assignment [on|off]", ['on','off'], "Manual Role Assignment") do |val|
|
|
254
|
+
params['manualRoleAssignment'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
|
255
|
+
end
|
|
256
|
+
opts.on("--manualRoleAssignment [on|off]", ['on','off'], "Manual Role Assignment") do |val|
|
|
257
|
+
params['manualRoleAssignment'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
|
258
|
+
end
|
|
259
|
+
opts.add_hidden_option('--manualRoleAssignment')
|
|
260
|
+
opts.on('--role-mappings MAPPINGS', String, "Role Mappings FQN in the format id1:FQN1,id2:FQN2") do |val|
|
|
261
|
+
role_mappings = {}
|
|
262
|
+
val.split(',').collect {|it| it.strip.split(':') }.each do |pair|
|
|
263
|
+
k, v = pair[0], pair[1]
|
|
264
|
+
if !k.to_s.empty?
|
|
265
|
+
role_mappings[k.to_s] = v
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
opts.on('--role-mapping-names MAPPINGS', String, "Role Mapping Names in the format id1:Name1,id2:Name2") do |val|
|
|
270
|
+
role_mapping_names = {}
|
|
271
|
+
val.split(',').collect {|it| it.strip.split(':') }.each do |pair|
|
|
272
|
+
k, v = pair[0], pair[1]
|
|
273
|
+
if !k.to_s.empty?
|
|
274
|
+
role_mapping_names[k.to_s] = v
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
opts.on('--default-role ID', String, "Default Role ID or Authority") do |val|
|
|
280
|
+
default_role_id = val
|
|
281
|
+
end
|
|
282
|
+
#build_option_type_options(opts, options, add_user_source_option_types())
|
|
283
|
+
build_standard_add_options(opts, options)
|
|
284
|
+
opts.footer = "Create a new identity source." + "\n" +
|
|
285
|
+
"[account] is required. This is the name or id of an account."
|
|
286
|
+
end
|
|
287
|
+
optparse.parse!(args)
|
|
288
|
+
connect(options)
|
|
289
|
+
if args.count > 2
|
|
290
|
+
print_error MtnCloud::Terminal.angry_prompt
|
|
291
|
+
puts_error "wrong number of arguments, expected 0-2 and got (#{args.count}) #{args.inspect}\n#{optparse}"
|
|
292
|
+
return 1
|
|
293
|
+
end
|
|
294
|
+
if args[0]
|
|
295
|
+
account_id = args[0]
|
|
296
|
+
end
|
|
297
|
+
if args[1]
|
|
298
|
+
params['name'] = args[1]
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
# # find the account first, or just prompt for that too please.
|
|
304
|
+
# if !account_id
|
|
305
|
+
# print_error MtnCloud::Terminal.angry_prompt
|
|
306
|
+
# puts_error "missing required argument [account]\n#{optparse}"
|
|
307
|
+
# return 1
|
|
308
|
+
# end
|
|
309
|
+
|
|
310
|
+
# tenant is optional, it is expected in the url right now instead of in the payload...this sets both
|
|
311
|
+
account = nil
|
|
312
|
+
if account_id
|
|
313
|
+
options[:options]['tenant'] = account_id
|
|
314
|
+
end
|
|
315
|
+
account_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'tenant', 'fieldLabel' => 'Tenant', 'type' => 'select', 'optionSource' => 'tenants', 'required' => false, 'description' => 'Tenant'}], options[:options], @api_client)
|
|
316
|
+
if account_id
|
|
317
|
+
options[:options].delete('tenant')
|
|
318
|
+
end
|
|
319
|
+
account_id = account_prompt['tenant']
|
|
320
|
+
if !account_id.to_s.empty?
|
|
321
|
+
# reload tenant by id, sure why not..
|
|
322
|
+
account = find_account_by_name_or_id(account_id)
|
|
323
|
+
return 1 if account.nil?
|
|
324
|
+
account_id = account['id']
|
|
325
|
+
else
|
|
326
|
+
account_id = nil
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
# construct payload
|
|
331
|
+
payload = {}
|
|
332
|
+
if options[:payload]
|
|
333
|
+
payload = options[:payload]
|
|
334
|
+
payload.deep_merge!({'userSource' => parse_passed_options(options)})
|
|
335
|
+
|
|
336
|
+
# JD: should apply options on top of payload, but just do these two for now
|
|
337
|
+
|
|
338
|
+
# Tenant
|
|
339
|
+
if account
|
|
340
|
+
payload['userSource']['account'] = {'id' => account['id'] }
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# Name
|
|
344
|
+
if params['name']
|
|
345
|
+
payload['userSource']['name'] = params['name']
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
else
|
|
349
|
+
payload.deep_merge!({'userSource' => parse_passed_options(options)})
|
|
350
|
+
|
|
351
|
+
# support old -O options
|
|
352
|
+
payload['userSource'].deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
353
|
+
|
|
354
|
+
# Tenant
|
|
355
|
+
if account
|
|
356
|
+
payload['userSource']['account'] = {'id' => account['id'] }
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
# Identity Source Type
|
|
360
|
+
user_source_types = @user_sources_interface.list_types({userSelectable: true})['userSourceTypes']
|
|
361
|
+
if user_source_types.empty?
|
|
362
|
+
print_red_alert "No available Identity Source Types found"
|
|
363
|
+
return 1
|
|
364
|
+
end
|
|
365
|
+
user_source_type = nil
|
|
366
|
+
if !type_code
|
|
367
|
+
user_source_type_dropdown = user_source_types.collect {|it| { 'name' => it['type'], 'value' => it['type']} }
|
|
368
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'type', 'type' => 'select', 'selectOptions' => user_source_type_dropdown, 'fieldLabel' => 'Type', 'required' => true}], options[:options])
|
|
369
|
+
type_code = v_prompt['type'] if v_prompt['type']
|
|
370
|
+
end
|
|
371
|
+
user_source_type = user_source_types.find { |it| it['type'] == type_code }
|
|
372
|
+
|
|
373
|
+
if user_source_type.nil?
|
|
374
|
+
print_red_alert "Identity Source Type not found for '#{type_code}'"
|
|
375
|
+
return 1
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
payload['userSource']['type'] = type_code
|
|
379
|
+
|
|
380
|
+
# Name
|
|
381
|
+
if params['name']
|
|
382
|
+
payload['userSource']['name'] = params['name']
|
|
383
|
+
else
|
|
384
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'type' => 'text', 'fieldLabel' => 'Name', 'required' => true}], options[:options])
|
|
385
|
+
payload['userSource']['name'] = v_prompt['name'] if v_prompt['name']
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# custom options by type
|
|
389
|
+
my_option_types = load_user_source_type_option_types(user_source_type['type'])
|
|
390
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt(my_option_types, options[:options])
|
|
391
|
+
payload['userSource'].deep_merge!(v_prompt)
|
|
392
|
+
|
|
393
|
+
# Default Account Role
|
|
394
|
+
# always prompt for role to lookup id from name
|
|
395
|
+
if default_role_id
|
|
396
|
+
options[:options]['defaultAccountRole'] = {'id' => default_role_id }
|
|
397
|
+
end
|
|
398
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldContext' => 'defaultAccountRole', 'fieldName' => 'id', 'type' => 'select', 'selectOptions' => get_available_role_options(account_id), 'fieldLabel' => 'Default Role', 'required' => false }], options[:options])
|
|
399
|
+
if v_prompt['defaultAccountRole'] && v_prompt['defaultAccountRole']['id']
|
|
400
|
+
default_role_id = v_prompt['defaultAccountRole']['id']
|
|
401
|
+
end
|
|
402
|
+
payload['userSource']['defaultAccountRole'] = {'id' => default_role_id }
|
|
403
|
+
|
|
404
|
+
# Enable Role Mapping Permissions
|
|
405
|
+
if !params['allowCustomMappings'].nil?
|
|
406
|
+
payload['userSource']['allowCustomMappings'] = ["on","true"].include?(params['allowCustomMappings'].to_s)
|
|
407
|
+
else
|
|
408
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'allowCustomMappings', 'type' => 'checkbox', 'fieldLabel' => 'Enable Role Mapping Permissions', 'defaultValue' => false}], options[:options])
|
|
409
|
+
payload['userSource']['allowCustomMappings'] = ["on","true"].include?(v_prompt['allowCustomMappings'].to_s)
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
# Manual Role Assignment
|
|
413
|
+
if !params['manualRoleAssignment'].nil?
|
|
414
|
+
payload['userSource']['manualRoleAssignment'] = ["on","true"].include?(params['allowCustomMappings'].to_s)
|
|
415
|
+
else
|
|
416
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'manualRoleAssignment', 'type' => 'checkbox', 'fieldLabel' => 'Manual Role Assignment', 'defaultValue' => false}], options[:options])
|
|
417
|
+
payload['userSource']['manualRoleAssignment'] = ["on","true"].include?(v_prompt['manualRoleAssignment'].to_s)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
if role_mappings
|
|
421
|
+
payload['roleMappings'] = role_mappings
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
if role_mapping_names
|
|
425
|
+
payload['roleMappingNames'] = role_mapping_names
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
end
|
|
430
|
+
@user_sources_interface.setopts(options)
|
|
431
|
+
if options[:dry_run]
|
|
432
|
+
print_dry_run @user_sources_interface.dry.create(account_id, payload)
|
|
433
|
+
return
|
|
434
|
+
end
|
|
435
|
+
# do it
|
|
436
|
+
json_response = @user_sources_interface.create(account_id, payload)
|
|
437
|
+
# print and return result
|
|
438
|
+
render_response(json_response, options, 'userSource') do
|
|
439
|
+
user_source = json_response['userSource']
|
|
440
|
+
print_green_success "Added Identity Source #{user_source['name']}"
|
|
441
|
+
_get(user_source['id'], {}, options)
|
|
442
|
+
end
|
|
443
|
+
return 0, nil
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def update(args)
|
|
447
|
+
options = {}
|
|
448
|
+
params = {}
|
|
449
|
+
account_id = nil
|
|
450
|
+
role_mappings = nil
|
|
451
|
+
role_mapping_names = nil
|
|
452
|
+
default_role_id = nil
|
|
453
|
+
optparse = MtnCloud::Cli::OptionParser.new do|opts|
|
|
454
|
+
opts.banner = subcommand_usage("[name] [options]")
|
|
455
|
+
opts.on('--name VALUE', String, "Name for this identity source") do |val|
|
|
456
|
+
params['name'] = val
|
|
457
|
+
end
|
|
458
|
+
opts.on('--description VALUE', String, "Description") do |val|
|
|
459
|
+
params['description'] = val
|
|
460
|
+
end
|
|
461
|
+
opts.on("--allow-custom-mappings [on|off]", ['on','off'], "Enable Role Mapping Permissions") do |val|
|
|
462
|
+
params['allowCustomMappings'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
|
463
|
+
end
|
|
464
|
+
opts.on("--allowCustomMappings [on|off]", ['on','off'], "Enable Role Mapping Permissions") do |val|
|
|
465
|
+
params['allowCustomMappings'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
|
466
|
+
end
|
|
467
|
+
opts.add_hidden_option('--allowCustomMappings')
|
|
468
|
+
opts.on('--role-mappings MAPPINGS', String, "Role Mappings in the format id1:FQN,id2:FQN2") do |val|
|
|
469
|
+
role_mappings = {}
|
|
470
|
+
val.split(',').collect {|it| it.strip.split(':') }.each do |pair|
|
|
471
|
+
k, v = pair[0], pair[1]
|
|
472
|
+
if !k.to_s.empty?
|
|
473
|
+
role_mappings[k.to_s] = v
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
end
|
|
477
|
+
opts.on('--role-mapping-names MAPPINGS', String, "Role Mapping Names in the format id1:Name1,id2:Name2") do |val|
|
|
478
|
+
role_mapping_names = {}
|
|
479
|
+
val.split(',').collect {|it| it.strip.split(':') }.each do |pair|
|
|
480
|
+
k, v = pair[0], pair[1]
|
|
481
|
+
if !k.to_s.empty?
|
|
482
|
+
role_mapping_names[k.to_s] = v
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
opts.on('--default-role ROLE', String, "Default Role ID or Authority") do |val|
|
|
487
|
+
default_role_id = val
|
|
488
|
+
end
|
|
489
|
+
build_standard_update_options(opts, options)
|
|
490
|
+
opts.footer = "Update an identity source." + "\n" +
|
|
491
|
+
"[name] is required. This is the name or id of an identity source."
|
|
492
|
+
end
|
|
493
|
+
optparse.parse!(args)
|
|
494
|
+
if args.count < 1
|
|
495
|
+
puts optparse
|
|
496
|
+
exit 1
|
|
497
|
+
end
|
|
498
|
+
connect(options)
|
|
499
|
+
begin
|
|
500
|
+
user_source = find_user_source_by_name_or_id(nil, args[0])
|
|
501
|
+
exit 1 if user_source.nil?
|
|
502
|
+
payload = {}
|
|
503
|
+
if options[:payload]
|
|
504
|
+
payload = options[:payload]
|
|
505
|
+
payload.deep_merge!({'userSource' => parse_passed_options(options)})
|
|
506
|
+
else
|
|
507
|
+
payload.deep_merge!({'userSource' => parse_passed_options(options)})
|
|
508
|
+
|
|
509
|
+
# Name
|
|
510
|
+
if params['name']
|
|
511
|
+
payload['userSource']['name'] = params['name']
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
# Description
|
|
515
|
+
if params['description']
|
|
516
|
+
payload['userSource']['description'] = params['description']
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
# Enable Role Mapping Permissions
|
|
520
|
+
if !params['allowCustomMappings'].nil?
|
|
521
|
+
payload['userSource']['allowCustomMappings'] = params['allowCustomMappings']
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
# Manual Role Assignment
|
|
525
|
+
if !params['manualRoleAssignment'].nil?
|
|
526
|
+
payload['userSource']['manualRoleAssignment'] = params['manualRoleAssignment']
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
if role_mappings
|
|
530
|
+
payload['roleMappings'] = role_mappings
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
if role_mapping_names
|
|
534
|
+
payload['roleMappingNames'] = role_mapping_names
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
# Default Account Role
|
|
538
|
+
if default_role_id
|
|
539
|
+
if default_role_id == 'null'
|
|
540
|
+
payload['userSource']['defaultAccountRole'] = {'id' => nil }
|
|
541
|
+
else
|
|
542
|
+
# use no_prompt to convert name to id
|
|
543
|
+
options[:options]['defaultAccountRole'] = {'id' => default_role_id }
|
|
544
|
+
v_prompt = MtnCloud::Cli::OptionTypes.no_prompt([{'fieldContext' => 'defaultAccountRole', 'fieldName' => 'id', 'type' => 'select', 'selectOptions' => get_available_role_options(user_source['account']['id']), 'fieldLabel' => 'Default Role', 'required' => false }], options[:options])
|
|
545
|
+
if v_prompt['defaultAccountRole'] && v_prompt['defaultAccountRole']['id']
|
|
546
|
+
default_role_id = v_prompt['defaultAccountRole']['id']
|
|
547
|
+
end
|
|
548
|
+
payload['userSource']['defaultAccountRole'] = {'id' => default_role_id }
|
|
549
|
+
end
|
|
550
|
+
end
|
|
551
|
+
end
|
|
552
|
+
@user_sources_interface.setopts(options)
|
|
553
|
+
if options[:dry_run]
|
|
554
|
+
print_dry_run @user_sources_interface.dry.update(nil, user_source['id'], payload)
|
|
555
|
+
return
|
|
556
|
+
end
|
|
557
|
+
json_response = @user_sources_interface.update(nil, user_source['id'], payload)
|
|
558
|
+
render_response(json_response, options, 'userSource') do
|
|
559
|
+
user_source = json_response['userSource'] || user_source
|
|
560
|
+
print_green_success "Updated Identity Source #{user_source['name']}"
|
|
561
|
+
_get(user_source['id'], {}, options)
|
|
562
|
+
end
|
|
563
|
+
return 0, nil
|
|
564
|
+
rescue RestClient::Exception => e
|
|
565
|
+
print_rest_exception(e, options)
|
|
566
|
+
exit 1
|
|
567
|
+
end
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
def activate(args)
|
|
571
|
+
options = {}
|
|
572
|
+
params = {}
|
|
573
|
+
account_id = nil
|
|
574
|
+
role_mappings = nil
|
|
575
|
+
role_mapping_names = nil
|
|
576
|
+
optparse = MtnCloud::Cli::OptionParser.new do|opts|
|
|
577
|
+
opts.banner = subcommand_usage("[name]")
|
|
578
|
+
build_common_options(opts, options, [:options, :json, :dry_run, :remote])
|
|
579
|
+
opts.footer = "Activate an identity source." + "\n" +
|
|
580
|
+
"[name] is required. This is the name or id of an identity source."
|
|
581
|
+
end
|
|
582
|
+
optparse.parse!(args)
|
|
583
|
+
if args.count < 1
|
|
584
|
+
puts optparse
|
|
585
|
+
exit 1
|
|
586
|
+
end
|
|
587
|
+
connect(options)
|
|
588
|
+
begin
|
|
589
|
+
user_source = find_user_source_by_name_or_id(nil, args[0])
|
|
590
|
+
exit 1 if user_source.nil?
|
|
591
|
+
payload = nil
|
|
592
|
+
if options[:payload]
|
|
593
|
+
payload = options[:payload]
|
|
594
|
+
else
|
|
595
|
+
payload = {}
|
|
596
|
+
# support old -O options
|
|
597
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
598
|
+
end
|
|
599
|
+
@user_sources_interface.setopts(options)
|
|
600
|
+
if options[:dry_run]
|
|
601
|
+
print_dry_run @user_sources_interface.dry.activate(nil, user_source['id'], payload)
|
|
602
|
+
return
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
json_response = @user_sources_interface.activate(nil, user_source['id'], payload)
|
|
606
|
+
|
|
607
|
+
if options[:json]
|
|
608
|
+
puts JSON.pretty_generate(json_response)
|
|
609
|
+
return
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
print_green_success "Activated Identity Source #{user_source['name']}"
|
|
613
|
+
get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
614
|
+
rescue RestClient::Exception => e
|
|
615
|
+
print_rest_exception(e, options)
|
|
616
|
+
exit 1
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
def deactivate(args)
|
|
621
|
+
options = {}
|
|
622
|
+
params = {}
|
|
623
|
+
account_id = nil
|
|
624
|
+
role_mappings = nil
|
|
625
|
+
role_mapping_names = nil
|
|
626
|
+
optparse = MtnCloud::Cli::OptionParser.new do|opts|
|
|
627
|
+
opts.banner = subcommand_usage("[name]")
|
|
628
|
+
build_common_options(opts, options, [:options, :json, :dry_run, :remote])
|
|
629
|
+
opts.footer = "Deactivate an identity source." + "\n" +
|
|
630
|
+
"[name] is required. This is the name or id of an identity source."
|
|
631
|
+
end
|
|
632
|
+
optparse.parse!(args)
|
|
633
|
+
if args.count < 1
|
|
634
|
+
puts optparse
|
|
635
|
+
exit 1
|
|
636
|
+
end
|
|
637
|
+
connect(options)
|
|
638
|
+
begin
|
|
639
|
+
user_source = find_user_source_by_name_or_id(nil, args[0])
|
|
640
|
+
exit 1 if user_source.nil?
|
|
641
|
+
payload = nil
|
|
642
|
+
if options[:payload]
|
|
643
|
+
payload = options[:payload]
|
|
644
|
+
else
|
|
645
|
+
payload = {}
|
|
646
|
+
# support old -O options
|
|
647
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
648
|
+
end
|
|
649
|
+
@user_sources_interface.setopts(options)
|
|
650
|
+
if options[:dry_run]
|
|
651
|
+
print_dry_run @user_sources_interface.dry.deactivate(nil, user_source['id'], payload)
|
|
652
|
+
return
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
json_response = @user_sources_interface.deactivate(nil, user_source['id'], payload)
|
|
656
|
+
|
|
657
|
+
if options[:json]
|
|
658
|
+
puts JSON.pretty_generate(json_response)
|
|
659
|
+
return
|
|
660
|
+
end
|
|
661
|
+
|
|
662
|
+
print_green_success "Activated Identity Source #{user_source['name']}"
|
|
663
|
+
get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
664
|
+
rescue RestClient::Exception => e
|
|
665
|
+
print_rest_exception(e, options)
|
|
666
|
+
exit 1
|
|
667
|
+
end
|
|
668
|
+
end
|
|
669
|
+
|
|
670
|
+
def update_subdomain(args)
|
|
671
|
+
options = {}
|
|
672
|
+
params = {}
|
|
673
|
+
account_id = nil
|
|
674
|
+
optparse = MtnCloud::Cli::OptionParser.new do|opts|
|
|
675
|
+
opts.banner = subcommand_usage("[name]")
|
|
676
|
+
opts.on('--subdomain VALUE', String, "New subdomain for this identity source") do |val|
|
|
677
|
+
params['subdomain'] = (val == 'null') ? nil : val
|
|
678
|
+
end
|
|
679
|
+
build_common_options(opts, options, [:options, :json, :dry_run, :remote])
|
|
680
|
+
opts.footer = "Update subdomain for an identity source." + "\n" +
|
|
681
|
+
"[name] is required. This is the name or id of an identity source."
|
|
682
|
+
end
|
|
683
|
+
optparse.parse!(args)
|
|
684
|
+
if args.count < 1
|
|
685
|
+
puts optparse
|
|
686
|
+
exit 1
|
|
687
|
+
end
|
|
688
|
+
connect(options)
|
|
689
|
+
begin
|
|
690
|
+
user_source = find_user_source_by_name_or_id(nil, args[0])
|
|
691
|
+
exit 1 if user_source.nil?
|
|
692
|
+
payload = nil
|
|
693
|
+
if options[:payload]
|
|
694
|
+
payload = options[:payload]
|
|
695
|
+
else
|
|
696
|
+
payload = {}
|
|
697
|
+
payload['subdomain'] = params['subdomain'] if params.key?('subdomain')
|
|
698
|
+
# support old -O options
|
|
699
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
700
|
+
end
|
|
701
|
+
@user_sources_interface.setopts(options)
|
|
702
|
+
if options[:dry_run]
|
|
703
|
+
print_dry_run @user_sources_interface.dry.update_subdomain(nil, user_source['id'], payload)
|
|
704
|
+
return
|
|
705
|
+
end
|
|
706
|
+
|
|
707
|
+
json_response = @user_sources_interface.update_subdomain(nil, user_source['id'], payload)
|
|
708
|
+
|
|
709
|
+
if options[:json]
|
|
710
|
+
puts JSON.pretty_generate(json_response)
|
|
711
|
+
return
|
|
712
|
+
end
|
|
713
|
+
# JD: uhh this updates the account too, it cannot be set per identity source ...yet
|
|
714
|
+
print_green_success "Updated Identity Source #{user_source['name']} subdomain to '#{payload['subdomain']}'"
|
|
715
|
+
get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
716
|
+
rescue RestClient::Exception => e
|
|
717
|
+
print_rest_exception(e, options)
|
|
718
|
+
exit 1
|
|
719
|
+
end
|
|
720
|
+
end
|
|
721
|
+
|
|
722
|
+
def remove(args)
|
|
723
|
+
options = {}
|
|
724
|
+
optparse = MtnCloud::Cli::OptionParser.new do|opts|
|
|
725
|
+
opts.banner = subcommand_usage("[name]")
|
|
726
|
+
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
|
|
727
|
+
opts.footer = "Delete a user_source."
|
|
728
|
+
end
|
|
729
|
+
optparse.parse!(args)
|
|
730
|
+
if args.count < 1
|
|
731
|
+
puts optparse
|
|
732
|
+
exit 1
|
|
733
|
+
end
|
|
734
|
+
connect(options)
|
|
735
|
+
|
|
736
|
+
begin
|
|
737
|
+
user_source = find_user_source_by_name_or_id(nil, args[0])
|
|
738
|
+
exit 1 if user_source.nil?
|
|
739
|
+
|
|
740
|
+
unless MtnCloud::Cli::OptionTypes.confirm("Are you sure you want to delete the identity source #{user_source['name']}?", options)
|
|
741
|
+
exit
|
|
742
|
+
end
|
|
743
|
+
@user_sources_interface.setopts(options)
|
|
744
|
+
if options[:dry_run]
|
|
745
|
+
print_dry_run @user_sources_interface.dry.destroy(nil, user_source['id'])
|
|
746
|
+
return
|
|
747
|
+
end
|
|
748
|
+
json_response = @user_sources_interface.destroy(nil, user_source['id'])
|
|
749
|
+
|
|
750
|
+
if options[:json]
|
|
751
|
+
print JSON.pretty_generate(json_response), "\n"
|
|
752
|
+
return
|
|
753
|
+
end
|
|
754
|
+
|
|
755
|
+
print_green_success "Removed Identity Source #{user_source['name']}"
|
|
756
|
+
#list([])
|
|
757
|
+
rescue RestClient::Exception => e
|
|
758
|
+
print_rest_exception(e, options)
|
|
759
|
+
exit 1
|
|
760
|
+
end
|
|
761
|
+
end
|
|
762
|
+
|
|
763
|
+
def list_types(args)
|
|
764
|
+
options = {}
|
|
765
|
+
params = {}
|
|
766
|
+
account = nil
|
|
767
|
+
account_id = nil
|
|
768
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
769
|
+
opts.banner = subcommand_usage()
|
|
770
|
+
build_common_options(opts, options, [:list, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
771
|
+
opts.footer = "List identity source types."
|
|
772
|
+
end
|
|
773
|
+
optparse.parse!(args)
|
|
774
|
+
connect(options)
|
|
775
|
+
# instance is required right now.
|
|
776
|
+
# account_id = args[0] if !account_id
|
|
777
|
+
if args.count != 0
|
|
778
|
+
print_error MtnCloud::Terminal.angry_prompt
|
|
779
|
+
puts_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.inspect}\n#{optparse}"
|
|
780
|
+
return 1
|
|
781
|
+
end
|
|
782
|
+
begin
|
|
783
|
+
# construct payload
|
|
784
|
+
params.merge!(parse_list_options(options))
|
|
785
|
+
@user_sources_interface.setopts(options)
|
|
786
|
+
if options[:dry_run]
|
|
787
|
+
print_dry_run @user_sources_interface.dry.list_types(params)
|
|
788
|
+
return
|
|
789
|
+
end
|
|
790
|
+
|
|
791
|
+
json_response = @user_sources_interface.list_types(params)
|
|
792
|
+
if options[:json]
|
|
793
|
+
puts as_json(json_response, options, "userSourceTypes")
|
|
794
|
+
return 0
|
|
795
|
+
elsif options[:csv]
|
|
796
|
+
puts records_as_csv(json_response['userSourceTypes'], options)
|
|
797
|
+
return 0
|
|
798
|
+
elsif options[:yaml]
|
|
799
|
+
puts as_yaml(json_response, options, "userSourceTypes")
|
|
800
|
+
return 0
|
|
801
|
+
end
|
|
802
|
+
user_source_types = json_response['userSourceTypes']
|
|
803
|
+
title = "Identity Source Types"
|
|
804
|
+
subtitles = []
|
|
805
|
+
subtitles += parse_list_subtitles(options)
|
|
806
|
+
print_h1 title, subtitles
|
|
807
|
+
if user_source_types.empty?
|
|
808
|
+
print cyan,"No types found.",reset,"\n"
|
|
809
|
+
else
|
|
810
|
+
print_user_source_types_table(user_source_types, options)
|
|
811
|
+
print_results_pagination(json_response, {:label => "type", :n_label => "types"})
|
|
812
|
+
end
|
|
813
|
+
print reset,"\n"
|
|
814
|
+
rescue RestClient::Exception => e
|
|
815
|
+
print_rest_exception(e, options)
|
|
816
|
+
return 1
|
|
817
|
+
end
|
|
818
|
+
end
|
|
819
|
+
|
|
820
|
+
def get_type(args)
|
|
821
|
+
options = {}
|
|
822
|
+
params = {}
|
|
823
|
+
account = nil
|
|
824
|
+
account_id = nil
|
|
825
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
826
|
+
opts.banner = subcommand_usage("[type]")
|
|
827
|
+
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
828
|
+
opts.footer = "Get details about an identity source type." + "\n" +
|
|
829
|
+
"[type] is required. This is the type identifier."
|
|
830
|
+
end
|
|
831
|
+
optparse.parse!(args)
|
|
832
|
+
connect(options)
|
|
833
|
+
# instance is required right now.
|
|
834
|
+
# account_id = args[0] if !account_id
|
|
835
|
+
expected_arg_count = 1
|
|
836
|
+
if args.count != expected_arg_count
|
|
837
|
+
print_error MtnCloud::Terminal.angry_prompt
|
|
838
|
+
puts_error "wrong number of arguments, expected #{expected_arg_count} and got (#{args.count}) #{args.inspect}\n#{optparse}"
|
|
839
|
+
return 1
|
|
840
|
+
end
|
|
841
|
+
begin
|
|
842
|
+
user_source_type_id = args[0]
|
|
843
|
+
|
|
844
|
+
# construct payload
|
|
845
|
+
@user_sources_interface.setopts(options)
|
|
846
|
+
if options[:dry_run]
|
|
847
|
+
print_dry_run @user_sources_interface.dry.list_types(user_source_type_id, params)
|
|
848
|
+
return
|
|
849
|
+
end
|
|
850
|
+
json_response = @user_sources_interface.get_type(user_source_type_id, params)
|
|
851
|
+
user_source_type = json_response["userSourceType"]
|
|
852
|
+
if options[:json]
|
|
853
|
+
puts as_json(json_response, options, "userSourceType")
|
|
854
|
+
return 0
|
|
855
|
+
elsif options[:yaml]
|
|
856
|
+
puts as_yaml(json_response, options, "userSourceType")
|
|
857
|
+
return 0
|
|
858
|
+
elsif options[:csv]
|
|
859
|
+
puts records_as_csv([user_source_type], options)
|
|
860
|
+
return 0
|
|
861
|
+
end
|
|
862
|
+
title = "Identity Source Type"
|
|
863
|
+
subtitles = []
|
|
864
|
+
print_h1 title, subtitles
|
|
865
|
+
print cyan
|
|
866
|
+
description_cols = {
|
|
867
|
+
#"ID" => lambda {|it| it['id'] },
|
|
868
|
+
# "Name" => lambda {|it| it['name'] },
|
|
869
|
+
# "Code" => lambda {|it| it['code'] },
|
|
870
|
+
"Type" => lambda {|it| it['type'] },
|
|
871
|
+
"External Login" => lambda {|it| format_boolean it['externalLogin'] },
|
|
872
|
+
"Selectable" => lambda {|it| format_boolean it['userSelectable'] },
|
|
873
|
+
}
|
|
874
|
+
print_description_list(description_cols, user_source_type)
|
|
875
|
+
|
|
876
|
+
# show config settings...
|
|
877
|
+
my_option_types = user_source_type['optionTypes']
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
if !my_option_types
|
|
881
|
+
my_option_types = load_user_source_type_option_types(user_source_type['type'])
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
print_h2 "Configuration Option Types"
|
|
885
|
+
if my_option_types && my_option_types.size > 0
|
|
886
|
+
columns = [
|
|
887
|
+
{"FIELD LABEL" => lambda {|it| it['fieldLabel'] } },
|
|
888
|
+
{"FIELD NAME" => lambda {|it| [it['fieldContext'], it['fieldName']].select {|it| !it.to_s.empty? }.join('.') } },
|
|
889
|
+
{"TYPE" => lambda {|it| it['type'] } },
|
|
890
|
+
{"DEFAULT" => lambda {|it| it['defaultValue'] } },
|
|
891
|
+
{"REQUIRED" => lambda {|it| format_boolean it['required'] } },
|
|
892
|
+
]
|
|
893
|
+
print as_pretty_table(my_option_types, columns)
|
|
894
|
+
else
|
|
895
|
+
print cyan,"No option types found.","\n",reset
|
|
896
|
+
end
|
|
897
|
+
|
|
898
|
+
print reset,"\n"
|
|
899
|
+
rescue RestClient::Exception => e
|
|
900
|
+
print_rest_exception(e, options)
|
|
901
|
+
return 1
|
|
902
|
+
end
|
|
903
|
+
end
|
|
904
|
+
|
|
905
|
+
private
|
|
906
|
+
|
|
907
|
+
def find_user_source_by_name_or_id(account_id, val)
|
|
908
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
|
909
|
+
return find_user_source_by_id(account_id, val)
|
|
910
|
+
else
|
|
911
|
+
return find_user_source_by_name(account_id, val)
|
|
912
|
+
end
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
def find_user_source_by_id(account_id, id)
|
|
916
|
+
begin
|
|
917
|
+
json_response = @user_sources_interface.get(account_id, id.to_i)
|
|
918
|
+
return json_response['userSource']
|
|
919
|
+
rescue RestClient::Exception => e
|
|
920
|
+
if e.response && e.response.code == 404
|
|
921
|
+
print_red_alert "Identity Source not found by id #{id}"
|
|
922
|
+
else
|
|
923
|
+
raise e
|
|
924
|
+
end
|
|
925
|
+
end
|
|
926
|
+
end
|
|
927
|
+
|
|
928
|
+
def find_user_source_by_name(account_id, name)
|
|
929
|
+
user_sources = @user_sources_interface.list(account_id, {name: name.to_s})['userSources']
|
|
930
|
+
if user_sources.empty?
|
|
931
|
+
print_red_alert "Identity Source not found by name #{name}"
|
|
932
|
+
return nil
|
|
933
|
+
elsif user_sources.size > 1
|
|
934
|
+
print_red_alert "#{user_sources.size} identity sources found by name #{name}"
|
|
935
|
+
print_user_sources_table(user_sources, {color: red})
|
|
936
|
+
print_red_alert "Try using ID instead"
|
|
937
|
+
print reset,"\n"
|
|
938
|
+
return nil
|
|
939
|
+
else
|
|
940
|
+
return user_sources[0]
|
|
941
|
+
end
|
|
942
|
+
end
|
|
943
|
+
|
|
944
|
+
def print_user_sources_table(user_sources, opts={})
|
|
945
|
+
columns = [
|
|
946
|
+
{"ID" => lambda {|user_source| user_source['id'] } },
|
|
947
|
+
{"NAME" => lambda {|user_source| user_source['name'] } },
|
|
948
|
+
{"TYPE" => lambda {|user_source| user_source['type'] } },
|
|
949
|
+
{"TENANT" => lambda {|user_source| user_source['account'] ? user_source['account']['name'] : '' } },
|
|
950
|
+
{"ACTIVE" => lambda {|user_source| format_boolean user_source['active'] } },
|
|
951
|
+
]
|
|
952
|
+
if opts[:include_fields]
|
|
953
|
+
columns = opts[:include_fields]
|
|
954
|
+
end
|
|
955
|
+
print as_pretty_table(user_sources, columns, opts)
|
|
956
|
+
end
|
|
957
|
+
|
|
958
|
+
def print_user_source_types_table(user_sources, opts={})
|
|
959
|
+
columns = [
|
|
960
|
+
{"TYPE" => lambda {|user_source| user_source['type'] } },
|
|
961
|
+
# {"NAME" => lambda {|user_source| user_source['name'] } },
|
|
962
|
+
]
|
|
963
|
+
if opts[:include_fields]
|
|
964
|
+
columns = opts[:include_fields]
|
|
965
|
+
end
|
|
966
|
+
print as_pretty_table(user_sources, columns, opts)
|
|
967
|
+
end
|
|
968
|
+
|
|
969
|
+
# manual options until this is data driven
|
|
970
|
+
# * ldap [ldap]
|
|
971
|
+
# * jumpCloud [jumpCloud]
|
|
972
|
+
# * activeDirectory [activeDirectory]
|
|
973
|
+
# * okta [okta]
|
|
974
|
+
# * oneLogin [oneLogin]
|
|
975
|
+
# * saml [saml]
|
|
976
|
+
# * customExternal [customExternal]
|
|
977
|
+
# * customApi [customApi]
|
|
978
|
+
def load_user_source_type_option_types(type_code)
|
|
979
|
+
if type_code == 'ldap'
|
|
980
|
+
[
|
|
981
|
+
{'fieldContext' => 'config', 'fieldName' => 'url', 'type' => 'text', 'fieldLabel' => 'URL', 'required' => true, 'description' => ''},
|
|
982
|
+
{'fieldContext' => 'config', 'fieldName' => 'bindingUsername', 'type' => 'text', 'fieldLabel' => 'Binding Username', 'required' => true, 'description' => ''},
|
|
983
|
+
{'fieldContext' => 'config', 'fieldName' => 'bindingPassword', 'type' => 'password', 'fieldLabel' => 'Binding Password', 'required' => true, 'description' => ''},
|
|
984
|
+
{'fieldContext' => 'config', 'fieldName' => 'requiredGroup', 'type' => 'text', 'fieldLabel' => 'Required group name (a.k.a. tag)', 'required' => true, 'description' => ''},
|
|
985
|
+
]
|
|
986
|
+
elsif type_code == 'jumpCloud'
|
|
987
|
+
[
|
|
988
|
+
{'fieldContext' => 'config', 'fieldName' => 'organizationId', 'type' => 'text', 'fieldLabel' => 'Organization ID', 'required' => true, 'description' => ''},
|
|
989
|
+
{'fieldContext' => 'config', 'fieldName' => 'bindingUsername', 'type' => 'text', 'fieldLabel' => 'Binding Username', 'required' => true, 'description' => ''},
|
|
990
|
+
{'fieldContext' => 'config', 'fieldName' => 'bindingPassword', 'type' => 'password', 'fieldLabel' => 'Binding Password', 'required' => true, 'description' => ''},
|
|
991
|
+
{'fieldContext' => 'config', 'fieldName' => 'requiredRole', 'type' => 'text', 'fieldLabel' => 'Required group name (a.k.a. tag)', 'required' => true, 'description' => ''},
|
|
992
|
+
]
|
|
993
|
+
elsif type_code == 'activeDirectory'
|
|
994
|
+
[
|
|
995
|
+
{'fieldContext' => 'config', 'fieldName' => 'url', 'type' => 'text', 'fieldLabel' => 'AD Server', 'required' => true, 'description' => ''},
|
|
996
|
+
{'fieldContext' => 'config', 'fieldName' => 'domain', 'type' => 'text', 'fieldLabel' => 'Domain', 'required' => true, 'description' => ''},
|
|
997
|
+
{'fieldContext' => 'config', 'fieldName' => 'useSSL', 'type' => 'checkbox', 'fieldLabel' => 'Use SSL', 'required' => true, 'description' => '', 'defaultValue' => false},
|
|
998
|
+
{'fieldContext' => 'config', 'fieldName' => 'bindingUsername', 'type' => 'text', 'fieldLabel' => 'Binding Username', 'required' => true, 'description' => ''},
|
|
999
|
+
{'fieldContext' => 'config', 'fieldName' => 'bindingPassword', 'type' => 'password', 'fieldLabel' => 'Binding Password', 'required' => true, 'description' => ''},
|
|
1000
|
+
{'fieldContext' => 'config', 'fieldName' => 'requiredGroup', 'type' => 'text', 'fieldLabel' => 'Required Group', 'required' => true, 'description' => ''},
|
|
1001
|
+
{'fieldContext' => 'config', 'fieldName' => 'searchMemberGroups', 'type' => 'checkbox', 'fieldLabel' => 'Include Member Groups', 'required' => true, 'description' => '', 'defaultValue' => false},
|
|
1002
|
+
]
|
|
1003
|
+
elsif type_code == 'okta'
|
|
1004
|
+
[
|
|
1005
|
+
{'fieldContext' => 'config', 'fieldName' => 'url', 'type' => 'text', 'fieldLabel' => 'OKTA URL', 'required' => true, 'description' => ''},
|
|
1006
|
+
{'fieldContext' => 'config', 'fieldName' => 'administratorAPIToken', 'type' => 'password', 'fieldLabel' => 'Adminstrator API Token', 'required' => true, 'description' => ''},
|
|
1007
|
+
{'fieldContext' => 'config', 'fieldName' => 'requiredGroup', 'type' => 'text', 'fieldLabel' => 'Required Group', 'required' => true, 'description' => ''}
|
|
1008
|
+
]
|
|
1009
|
+
elsif type_code == 'oneLogin'
|
|
1010
|
+
[
|
|
1011
|
+
{'fieldContext' => 'config', 'fieldName' => 'subdomain', 'type' => 'text', 'fieldLabel' => 'OneLogin Subdomain', 'required' => true, 'description' => ''},
|
|
1012
|
+
{'fieldContext' => 'config', 'fieldName' => 'region', 'type' => 'text', 'fieldLabel' => 'OneLogin Region', 'required' => true, 'description' => ''},
|
|
1013
|
+
{'fieldContext' => 'config', 'fieldName' => 'clientSecret', 'type' => 'password', 'fieldLabel' => 'API Client Secret', 'required' => true, 'description' => ''},
|
|
1014
|
+
{'fieldContext' => 'config', 'fieldName' => 'clientId', 'type' => 'text', 'fieldLabel' => 'API Client ID', 'required' => true, 'description' => ''},
|
|
1015
|
+
{'fieldContext' => 'config', 'fieldName' => 'requiredRole', 'type' => 'text', 'fieldLabel' => 'Required Role', 'required' => true, 'description' => ''},
|
|
1016
|
+
]
|
|
1017
|
+
elsif type_code == 'saml'
|
|
1018
|
+
[
|
|
1019
|
+
{'fieldContext' => 'config', 'fieldName' => 'url', 'type' => 'text', 'fieldLabel' => 'Login Redirect URL', 'required' => true, 'description' => '', 'fieldGroup' => 'SAML SSO Configuration', 'displayOrder' => 1},
|
|
1020
|
+
{'fieldContext' => 'config', 'fieldName' => 'doNotIncludeSAMLRequest', 'type' => 'checkbox', 'fieldLabel' => 'Exclude SAMLRequest Parameter', 'required' => true, 'description' => 'Do not include SAMLRequest parameter', 'defaultValue' => false, 'fieldGroup' => 'SAML SSO Configuration', 'displayOrder' => 2},
|
|
1021
|
+
{'fieldContext' => 'config', 'fieldName' => 'logoutUrl', 'type' => 'text', 'fieldLabel' => 'Logout Post URL', 'required' => true, 'description' => '', 'fieldGroup' => 'SAML SSO Configuration', 'displayOrder' => 3},
|
|
1022
|
+
{'code' => 'saml.SAMLSignatureMode', 'fieldContext' => 'config', 'fieldName' => 'SAMLSignatureMode', 'type' => 'select', 'selectOptions' => [{'name' => 'No Signature', 'value' => 'NoSignature'},{'name' => 'Self Signed', 'value' => 'SelfSigned'},{'name' => 'Custom RSA Signature', 'value' => 'CustomSignature'}], 'fieldLabel' => 'SAML Request', 'required' => true, 'description' => '', 'fieldGroup' => 'SAML SSO Configuration', 'defaultValue' => 'NoSignature', 'displayOrder' => 4},
|
|
1023
|
+
{'dependsOnCode' => 'saml.SAMLSignatureMode:CustomSignature', 'fieldContext' => 'config', 'fieldName' => 'request509Certificate', 'type' => 'textarea', 'fieldLabel' => 'X.509 Certificate', 'required' => false, 'description' => '', 'fieldGroup' => 'SAML SSO Configuration', 'displayOrder' => 5},
|
|
1024
|
+
{'dependsOnCode' => 'saml.SAMLSignatureMode:CustomSignature', 'fieldContext' => 'config', 'fieldName' => 'requestPrivateKey', 'type' => 'textarea', 'fieldLabel' => 'RSA Private Key', 'required' => false, 'description' => '', 'fieldGroup' => 'SAML SSO Configuration', 'displayOrder' => 6},
|
|
1025
|
+
{'code' => 'saml.doNotValidateSignature', 'fieldContext' => 'config', 'fieldName' => 'doNotValidateSignature', 'type' => 'select', 'selectOptions' => [{'name' => 'Do Not Validate Assertion Signature', 'value' => 'true'},{'name' => 'Validate Assertion Signature', 'value' => 'false'}], 'fieldLabel' => 'SAML Response', 'required' => true, 'description' => '', 'fieldGroup' => 'SAML SSO Configuration', 'defaultValue' => 'Do Not Validate Assertion Signature', 'displayOrder' => 7},
|
|
1026
|
+
{'dependsOnCode' => 'saml.doNotValidateSignature:false', 'fieldContext' => 'config', 'fieldName' => 'publicKey', 'type' => 'textarea', 'fieldLabel' => 'Signing Public Key', 'required' => false, 'description' => '', 'fieldGroup' => 'SAML SSO Configuration', 'displayOrder' => 8},
|
|
1027
|
+
{'fieldContext' => 'config', 'fieldName' => 'privateKey', 'type' => 'textarea', 'fieldLabel' => 'Encryption RSA Private Key', 'required' => false, 'description' => '', 'fieldGroup' => 'SAML SSO Configuration', 'displayOrder' => 9},
|
|
1028
|
+
{'fieldContext' => 'config', 'fieldName' => 'givenNameAttribute', 'type' => 'text', 'fieldLabel' => 'Given Name Attribute Name', 'required' => false, 'description' => '', 'fieldGroup' => 'Assertion Attribute Mappings', 'displayOrder' => 10},
|
|
1029
|
+
{'fieldContext' => 'config', 'fieldName' => 'surnameAttribute', 'type' => 'text', 'fieldLabel' => 'Surname Attribute Name', 'required' => false, 'description' => '', 'fieldGroup' => 'Assertion Attribute Mappings', 'displayOrder' => 11},
|
|
1030
|
+
{'fieldContext' => 'config', 'fieldName' => 'roleAttributeName', 'type' => 'text', 'fieldLabel' => 'Role Attribute Name', 'required' => false, 'description' => '', 'fieldGroup' => 'Role Mappings', 'displayOrder' => 12},
|
|
1031
|
+
{'fieldContext' => 'config', 'fieldName' => 'requiredAttributeValue', 'type' => 'text', 'fieldLabel' => 'Required Role Attribute Value', 'required' => false, 'description' => '', 'fieldGroup' => 'Role Mappings', 'displayOrder' => 13},
|
|
1032
|
+
|
|
1033
|
+
]
|
|
1034
|
+
elsif type_code == 'customExternal'
|
|
1035
|
+
[
|
|
1036
|
+
{'fieldContext' => 'config', 'fieldName' => 'loginUrl', 'type' => 'text', 'fieldLabel' => 'External Login URL', 'required' => true, 'description' => ''},
|
|
1037
|
+
{'fieldContext' => 'config', 'fieldName' => 'doNotIncludeSAMLRequest', 'type' => 'checkbox', 'fieldLabel' => 'Exclude SAMLRequest Parameter', 'required' => true, 'description' => 'Do not include SAMLRequest parameter', 'defaultValue' => false},
|
|
1038
|
+
{'fieldContext' => 'config', 'fieldName' => 'logout', 'type' => 'text', 'fieldLabel' => 'External Logout URL', 'required' => true, 'description' => ''},
|
|
1039
|
+
{'fieldContext' => 'config', 'fieldName' => 'encryptionAlgo', 'type' => 'select', 'selectOptions' => ['NONE','AES','DES','DESede','HmacSHA1', 'HmacSHA256'].collect {|it| { 'name' => it, 'value' => it} }, 'fieldLabel' => 'Encryption Algorithm', 'required' => true, 'description' => ''},
|
|
1040
|
+
{'fieldContext' => 'config', 'fieldName' => 'encryptionKey', 'type' => 'text', 'fieldLabel' => 'Encryption Key', 'required' => true, 'description' => ''},
|
|
1041
|
+
]
|
|
1042
|
+
elsif type_code == 'customApi'
|
|
1043
|
+
[
|
|
1044
|
+
{'fieldContext' => 'config', 'fieldName' => 'endpoint', 'type' => 'text', 'fieldLabel' => 'API Endpoint', 'required' => true, 'description' => ''},
|
|
1045
|
+
{'fieldContext' => 'config', 'fieldName' => 'apiStyle', 'type' => 'select', 'selectOptions' => ['Form URL Encoded [GET]','Form URL Encoded [POST]','JSON [POST]','XML [POST]','HTTP Basic [GET]'].collect {|it| { 'name' => it, 'value' => it} }, 'fieldLabel' => 'API Style', 'required' => true, 'description' => ''},
|
|
1046
|
+
{'fieldContext' => 'config', 'fieldName' => 'encryptionAlgo', 'type' => 'select', 'selectOptions' => ['NONE','AES','DES','DESede','HmacSHA1', 'HmacSHA256'].collect {|it| { 'name' => it, 'value' => it} }, 'fieldLabel' => 'Encryption Algorithm', 'required' => true, 'description' => ''},
|
|
1047
|
+
{'fieldContext' => 'config', 'fieldName' => 'encryptionKey', 'type' => 'text', 'fieldLabel' => 'Encryption Key', 'required' => true, 'description' => ''},
|
|
1048
|
+
]
|
|
1049
|
+
else
|
|
1050
|
+
print "unknown identity source type: #{type_code}"
|
|
1051
|
+
[]
|
|
1052
|
+
end
|
|
1053
|
+
end
|
|
1054
|
+
|
|
1055
|
+
def get_available_role_options(account_id)
|
|
1056
|
+
available_roles = @account_users_interface.available_roles(account_id)['roles']
|
|
1057
|
+
# if available_roles.empty?
|
|
1058
|
+
# print_red_alert "No available roles found."
|
|
1059
|
+
# exit 1
|
|
1060
|
+
# end
|
|
1061
|
+
role_options = available_roles.collect {|role|
|
|
1062
|
+
{'name' => role['authority'], 'value' => role['id']}
|
|
1063
|
+
}
|
|
1064
|
+
end
|
|
1065
|
+
end
|