├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── enhancement.md ├── dependabot.yml └── workflows │ ├── PULL_REQUEST_TEMPLATE.md │ ├── build-artifacts.yml │ └── codeql-analysis.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── README_ja.md ├── build ├── Dockerfile └── build.sh ├── generators ├── assets │ ├── cli │ │ ├── en.yaml │ │ └── ja.yaml │ ├── sandbox │ │ ├── soracom-sandbox-api.en.yaml │ │ └── soracom-sandbox-api.ja.yaml │ ├── soracom-api.en.yaml │ └── soracom-api.ja.yaml ├── cmd │ ├── predefined │ │ ├── api_credentials.go │ │ ├── api_credentials_source.go │ │ ├── apiclient.go │ │ ├── apiclient_test.go │ │ ├── auth_request.go │ │ ├── auth_result.go │ │ ├── check_param.go │ │ ├── completion.go │ │ ├── configure.go │ │ ├── configure_get.go │ │ ├── configure_sandbox.go │ │ ├── endpoint.go │ │ ├── harvest_files_path_escape.go │ │ ├── harvest_files_path_escape_test.go │ │ ├── lang_utils.go │ │ ├── lang_utils_test.go │ │ ├── pretty_print_json.go │ │ ├── pretty_print_json_test.go │ │ ├── profiles.go │ │ ├── profiles_test.go │ │ ├── prompt.go │ │ ├── prompt_test.go │ │ ├── self_update.go │ │ ├── self_update_test.go │ │ ├── stringutils.go │ │ ├── switch_user_request.go │ │ ├── test.go │ │ ├── to_json.go │ │ ├── version.go │ │ ├── version_checker.go │ │ └── version_checker_test.go │ ├── src │ │ ├── .gitignore │ │ ├── gen_leaf_cmd.go │ │ ├── gen_leaf_cmd_test.go │ │ ├── gen_root_cmd.go │ │ ├── gen_trunk_cmd.go │ │ ├── gen_trunk_cmd_test.go │ │ ├── main.go │ │ └── types.go │ └── templates │ │ ├── leaf.gotmpl │ │ ├── root.gotmpl │ │ └── trunk.gotmpl ├── lib │ ├── case_conv.go │ ├── case_conv_test.go │ ├── fileperm.go │ ├── fileperm_windows.go │ └── printer.go └── winres │ ├── SIS0233CL_256x256.png │ └── winres.json ├── go.mod ├── go.sum ├── install.sh ├── scripts ├── build-lambda-layer.sh ├── build-snap.sh ├── build.sh ├── build_local_bin.sh ├── copy-apidef-files.sh ├── release-lambda-layer.sh ├── release-snap.sh ├── release.sh └── update-homebrew-formula.sh ├── snap ├── Dockerfile ├── build.sh └── release.sh ├── soracom ├── .gitignore ├── .goxc.json ├── generated │ └── cmd │ │ ├── api_credentials.go │ │ ├── api_credentials_source.go │ │ ├── apiclient.go │ │ ├── apiclient_test.go │ │ ├── assets │ │ ├── cli │ │ │ ├── en.yaml │ │ │ └── ja.yaml │ │ ├── sandbox │ │ │ ├── soracom-sandbox-api.en.yaml │ │ │ └── soracom-sandbox-api.ja.yaml │ │ ├── soracom-api.en.yaml │ │ └── soracom-api.ja.yaml │ │ ├── audit_logs.go │ │ ├── audit_logs_api.go │ │ ├── audit_logs_api_get.go │ │ ├── audit_logs_napter.go │ │ ├── audit_logs_napter_get.go │ │ ├── auth.go │ │ ├── auth_issue_password_reset_token.go │ │ ├── auth_request.go │ │ ├── auth_result.go │ │ ├── auth_switch_user.go │ │ ├── auth_verify_password_reset_token.go │ │ ├── bills.go │ │ ├── bills_export.go │ │ ├── bills_export_latest.go │ │ ├── bills_get.go │ │ ├── bills_get_daily.go │ │ ├── bills_get_latest.go │ │ ├── bills_list.go │ │ ├── bills_summaries.go │ │ ├── bills_summaries_get_bill_items.go │ │ ├── bills_summaries_get_sims.go │ │ ├── cell_locations.go │ │ ├── cell_locations_batch_get.go │ │ ├── cell_locations_get.go │ │ ├── check_param.go │ │ ├── completion.go │ │ ├── configure.go │ │ ├── configure_get.go │ │ ├── configure_sandbox.go │ │ ├── coupons.go │ │ ├── coupons_confirm.go │ │ ├── coupons_create.go │ │ ├── coupons_list.go │ │ ├── coupons_register.go │ │ ├── credentials.go │ │ ├── credentials_create.go │ │ ├── credentials_delete.go │ │ ├── credentials_list.go │ │ ├── credentials_update.go │ │ ├── data.go │ │ ├── data_delete_entry.go │ │ ├── data_get.go │ │ ├── data_get_entries.go │ │ ├── data_get_entry.go │ │ ├── data_list_source_resources.go │ │ ├── devices.go │ │ ├── devices_create.go │ │ ├── devices_create_object_model.go │ │ ├── devices_delete.go │ │ ├── devices_delete_device_tag.go │ │ ├── devices_delete_object_model.go │ │ ├── devices_execute_resource.go │ │ ├── devices_get.go │ │ ├── devices_get_data.go │ │ ├── devices_get_instance.go │ │ ├── devices_get_object_model.go │ │ ├── devices_get_resource.go │ │ ├── devices_list.go │ │ ├── devices_list_object_models.go │ │ ├── devices_observe_resource.go │ │ ├── devices_observe_resources.go │ │ ├── devices_put_device_tags.go │ │ ├── devices_put_resource.go │ │ ├── devices_set_group.go │ │ ├── devices_set_object_model_scope.go │ │ ├── devices_unobserve_resource.go │ │ ├── devices_unobserve_resources.go │ │ ├── devices_unset_group.go │ │ ├── devices_update_object_model.go │ │ ├── diagnostics.go │ │ ├── diagnostics_get.go │ │ ├── diagnostics_send_request.go │ │ ├── emails.go │ │ ├── emails_delete.go │ │ ├── emails_get.go │ │ ├── emails_issue_add_email_token.go │ │ ├── emails_list.go │ │ ├── emails_verify_add_email_token.go │ │ ├── endpoint.go │ │ ├── event_handlers.go │ │ ├── event_handlers_create.go │ │ ├── event_handlers_delete.go │ │ ├── event_handlers_get.go │ │ ├── event_handlers_ignore.go │ │ ├── event_handlers_list.go │ │ ├── event_handlers_list_for_subscriber.go │ │ ├── event_handlers_unignore.go │ │ ├── event_handlers_update.go │ │ ├── files.go │ │ ├── files_delete.go │ │ ├── files_delete_directory.go │ │ ├── files_find.go │ │ ├── files_get.go │ │ ├── files_get_exported.go │ │ ├── files_get_metadata.go │ │ ├── files_list.go │ │ ├── files_put.go │ │ ├── gadgets.go │ │ ├── gadgets_delete_tag.go │ │ ├── gadgets_disable_termination.go │ │ ├── gadgets_enable_termination.go │ │ ├── gadgets_get.go │ │ ├── gadgets_list.go │ │ ├── gadgets_put_tags.go │ │ ├── gadgets_register.go │ │ ├── gadgets_terminate.go │ │ ├── groups.go │ │ ├── groups_create.go │ │ ├── groups_delete.go │ │ ├── groups_delete_config.go │ │ ├── groups_delete_config_namespace.go │ │ ├── groups_delete_tag.go │ │ ├── groups_get.go │ │ ├── groups_list.go │ │ ├── groups_list_subscribers.go │ │ ├── groups_put_config.go │ │ ├── groups_put_tags.go │ │ ├── harvest_files_path_escape.go │ │ ├── harvest_files_path_escape_test.go │ │ ├── lagoon.go │ │ ├── lagoon_create_user.go │ │ ├── lagoon_delete_user.go │ │ ├── lagoon_get_image_link.go │ │ ├── lagoon_license_packs.go │ │ ├── lagoon_license_packs_list_status.go │ │ ├── lagoon_license_packs_update.go │ │ ├── lagoon_list_users.go │ │ ├── lagoon_register.go │ │ ├── lagoon_terminate.go │ │ ├── lagoon_update_user_email.go │ │ ├── lagoon_update_user_password.go │ │ ├── lagoon_update_user_permission.go │ │ ├── lagoon_updated_plan.go │ │ ├── lagoon_users.go │ │ ├── lagoon_users_create.go │ │ ├── lagoon_users_delete.go │ │ ├── lagoon_users_list.go │ │ ├── lagoon_users_update_email.go │ │ ├── lagoon_users_update_password.go │ │ ├── lagoon_users_update_permission.go │ │ ├── lang_utils.go │ │ ├── lang_utils_test.go │ │ ├── logout.go │ │ ├── logs.go │ │ ├── logs_get.go │ │ ├── lora_devices.go │ │ ├── lora_devices_delete_tag.go │ │ ├── lora_devices_disable_termination.go │ │ ├── lora_devices_enable_termination.go │ │ ├── lora_devices_get.go │ │ ├── lora_devices_get_data.go │ │ ├── lora_devices_list.go │ │ ├── lora_devices_put_tags.go │ │ ├── lora_devices_register.go │ │ ├── lora_devices_send_data.go │ │ ├── lora_devices_set_group.go │ │ ├── lora_devices_terminate.go │ │ ├── lora_devices_unset_group.go │ │ ├── lora_gateways.go │ │ ├── lora_gateways_delete_tag.go │ │ ├── lora_gateways_disable_termination.go │ │ ├── lora_gateways_enable_termination.go │ │ ├── lora_gateways_get.go │ │ ├── lora_gateways_list.go │ │ ├── lora_gateways_put_tags.go │ │ ├── lora_gateways_set_network_set.go │ │ ├── lora_gateways_terminate.go │ │ ├── lora_gateways_unset_network_set.go │ │ ├── lora_network_sets.go │ │ ├── lora_network_sets_add_permission.go │ │ ├── lora_network_sets_create.go │ │ ├── lora_network_sets_delete.go │ │ ├── lora_network_sets_delete_tag.go │ │ ├── lora_network_sets_get.go │ │ ├── lora_network_sets_list.go │ │ ├── lora_network_sets_list_gateways.go │ │ ├── lora_network_sets_put_tag.go │ │ ├── lora_network_sets_revoke_permission.go │ │ ├── operator.go │ │ ├── operator_add_contract.go │ │ ├── operator_add_coverage_type.go │ │ ├── operator_auth_keys.go │ │ ├── operator_auth_keys_delete.go │ │ ├── operator_auth_keys_generate.go │ │ ├── operator_auth_keys_list.go │ │ ├── operator_configuration.go │ │ ├── operator_configuration_delete.go │ │ ├── operator_configuration_get.go │ │ ├── operator_configuration_set.go │ │ ├── operator_create_company_information.go │ │ ├── operator_create_individual_information.go │ │ ├── operator_delete_contract.go │ │ ├── operator_enable_mfa.go │ │ ├── operator_generate_api_token.go │ │ ├── operator_get.go │ │ ├── operator_get_company_information.go │ │ ├── operator_get_individual_information.go │ │ ├── operator_get_mfa_status.go │ │ ├── operator_get_support_token.go │ │ ├── operator_issue_mfa_revoke_token.go │ │ ├── operator_revoke_mfa.go │ │ ├── operator_revoke_operator_auth_tokens.go │ │ ├── operator_update_company_information.go │ │ ├── operator_update_individual_information.go │ │ ├── operator_update_password.go │ │ ├── operator_verify_mfa_otp.go │ │ ├── operator_verify_mfa_revoke_token.go │ │ ├── orders.go │ │ ├── orders_cancel.go │ │ ├── orders_confirm.go │ │ ├── orders_create.go │ │ ├── orders_get.go │ │ ├── orders_list.go │ │ ├── orders_list_subscribers.go │ │ ├── orders_register_subscribers.go │ │ ├── orders_resource_initial_setting.go │ │ ├── orders_resource_initial_setting_update.go │ │ ├── payer_information.go │ │ ├── payer_information_get.go │ │ ├── payer_information_register.go │ │ ├── payment_history.go │ │ ├── payment_history_get.go │ │ ├── payment_methods.go │ │ ├── payment_methods_get_current.go │ │ ├── payment_methods_reactivate_current.go │ │ ├── payment_statements.go │ │ ├── payment_statements_export.go │ │ ├── payment_statements_list.go │ │ ├── port_mappings.go │ │ ├── port_mappings_create.go │ │ ├── port_mappings_delete.go │ │ ├── port_mappings_get.go │ │ ├── port_mappings_list.go │ │ ├── port_mappings_list_for_sim.go │ │ ├── port_mappings_list_for_subscriber.go │ │ ├── pretty_print_json.go │ │ ├── pretty_print_json_test.go │ │ ├── products.go │ │ ├── products_list.go │ │ ├── profiles.go │ │ ├── profiles_test.go │ │ ├── prompt.go │ │ ├── prompt_test.go │ │ ├── query.go │ │ ├── query_devices.go │ │ ├── query_sigfox_devices.go │ │ ├── query_sims.go │ │ ├── query_subscribers.go │ │ ├── query_subscribers_traffic_volume_ranking.go │ │ ├── query_traffic_ranking.go │ │ ├── resource_summaries.go │ │ ├── resource_summaries_get.go │ │ ├── roles.go │ │ ├── roles_create.go │ │ ├── roles_delete.go │ │ ├── roles_get.go │ │ ├── roles_list.go │ │ ├── roles_list_users.go │ │ ├── roles_update.go │ │ ├── root.go │ │ ├── sandbox.go │ │ ├── sandbox_coupons.go │ │ ├── sandbox_coupons_create.go │ │ ├── sandbox_init.go │ │ ├── sandbox_operators.go │ │ ├── sandbox_operators_delete.go │ │ ├── sandbox_operators_get_signup_token.go │ │ ├── sandbox_orders.go │ │ ├── sandbox_orders_ship.go │ │ ├── sandbox_stats.go │ │ ├── sandbox_stats_air.go │ │ ├── sandbox_stats_air_insert.go │ │ ├── sandbox_stats_beam.go │ │ ├── sandbox_stats_beam_insert.go │ │ ├── sandbox_subscribers.go │ │ ├── sandbox_subscribers_create.go │ │ ├── self_update.go │ │ ├── self_update_test.go │ │ ├── shipping_addresses.go │ │ ├── shipping_addresses_create.go │ │ ├── shipping_addresses_delete.go │ │ ├── shipping_addresses_get.go │ │ ├── shipping_addresses_list.go │ │ ├── shipping_addresses_update.go │ │ ├── sigfox_devices.go │ │ ├── sigfox_devices_delete_tag.go │ │ ├── sigfox_devices_disable_termination.go │ │ ├── sigfox_devices_enable_termination.go │ │ ├── sigfox_devices_get.go │ │ ├── sigfox_devices_get_data.go │ │ ├── sigfox_devices_list.go │ │ ├── sigfox_devices_put_tags.go │ │ ├── sigfox_devices_register.go │ │ ├── sigfox_devices_send_data.go │ │ ├── sigfox_devices_set_group.go │ │ ├── sigfox_devices_terminate.go │ │ ├── sigfox_devices_unset_group.go │ │ ├── sim_profile_orders.go │ │ ├── sim_profile_orders_confirm.go │ │ ├── sim_profile_orders_create.go │ │ ├── sim_profile_orders_delete.go │ │ ├── sim_profile_orders_get.go │ │ ├── sim_profile_orders_list.go │ │ ├── sim_profile_orders_list_profiles.go │ │ ├── sims.go │ │ ├── sims_activate.go │ │ ├── sims_add_subscription.go │ │ ├── sims_attach_arc_credentials.go │ │ ├── sims_cancel_subscription_container_download.go │ │ ├── sims_create.go │ │ ├── sims_create_arc_session.go │ │ ├── sims_create_packet_capture_session.go │ │ ├── sims_deactivate.go │ │ ├── sims_delete_packet_capture_session.go │ │ ├── sims_delete_session.go │ │ ├── sims_delete_tag.go │ │ ├── sims_disable_termination.go │ │ ├── sims_downlink_http.go │ │ ├── sims_downlink_ping.go │ │ ├── sims_downlink_ssh.go │ │ ├── sims_enable_termination.go │ │ ├── sims_get.go │ │ ├── sims_get_data.go │ │ ├── sims_get_packet_capture_session.go │ │ ├── sims_list.go │ │ ├── sims_list_packet_capture_sessions.go │ │ ├── sims_list_status_history.go │ │ ├── sims_put_tags.go │ │ ├── sims_register.go │ │ ├── sims_remove_arc_credentials.go │ │ ├── sims_renew_arc_credentials.go │ │ ├── sims_report_local_info.go │ │ ├── sims_send_sms.go │ │ ├── sims_session_events.go │ │ ├── sims_set_expiry_time.go │ │ ├── sims_set_group.go │ │ ├── sims_set_imei_lock.go │ │ ├── sims_set_to_standby.go │ │ ├── sims_stop_packet_capture_session.go │ │ ├── sims_suspend.go │ │ ├── sims_terminate.go │ │ ├── sims_terminate_subscription_container.go │ │ ├── sims_unset_expiry_time.go │ │ ├── sims_unset_group.go │ │ ├── sims_unset_imei_lock.go │ │ ├── sims_update_speed_class.go │ │ ├── sora_cam.go │ │ ├── sora_cam_devices.go │ │ ├── sora_cam_devices_atom_cam.go │ │ ├── sora_cam_devices_atom_cam_assign_license.go │ │ ├── sora_cam_devices_atom_cam_get_firmware_update.go │ │ ├── sora_cam_devices_atom_cam_get_settings.go │ │ ├── sora_cam_devices_atom_cam_list_firmware_updates.go │ │ ├── sora_cam_devices_atom_cam_settings.go │ │ ├── sora_cam_devices_atom_cam_settings_get_logo.go │ │ ├── sora_cam_devices_atom_cam_settings_get_motion.go │ │ ├── sora_cam_devices_atom_cam_settings_get_motion_sensitivity.go │ │ ├── sora_cam_devices_atom_cam_settings_get_motion_tagging.go │ │ ├── sora_cam_devices_atom_cam_settings_get_night_vision.go │ │ ├── sora_cam_devices_atom_cam_settings_get_quality.go │ │ ├── sora_cam_devices_atom_cam_settings_get_rotation.go │ │ ├── sora_cam_devices_atom_cam_settings_get_sound.go │ │ ├── sora_cam_devices_atom_cam_settings_get_sound_sensitivity.go │ │ ├── sora_cam_devices_atom_cam_settings_get_status_light.go │ │ ├── sora_cam_devices_atom_cam_settings_get_timestamp.go │ │ ├── sora_cam_devices_atom_cam_settings_set_logo.go │ │ ├── sora_cam_devices_atom_cam_settings_set_motion.go │ │ ├── sora_cam_devices_atom_cam_settings_set_motion_sensitivity.go │ │ ├── sora_cam_devices_atom_cam_settings_set_motion_tagging.go │ │ ├── sora_cam_devices_atom_cam_settings_set_night_vision.go │ │ ├── sora_cam_devices_atom_cam_settings_set_quality.go │ │ ├── sora_cam_devices_atom_cam_settings_set_rotation.go │ │ ├── sora_cam_devices_atom_cam_settings_set_sound.go │ │ ├── sora_cam_devices_atom_cam_settings_set_sound_sensitivity.go │ │ ├── sora_cam_devices_atom_cam_settings_set_status_light.go │ │ ├── sora_cam_devices_atom_cam_settings_set_timestamp.go │ │ ├── sora_cam_devices_atom_cam_unassign_license.go │ │ ├── sora_cam_devices_atom_cam_update_firmware.go │ │ ├── sora_cam_devices_data.go │ │ ├── sora_cam_devices_data_create_entry.go │ │ ├── sora_cam_devices_data_update_entry.go │ │ ├── sora_cam_devices_delete.go │ │ ├── sora_cam_devices_delete_export_usage_limit_override.go │ │ ├── sora_cam_devices_events.go │ │ ├── sora_cam_devices_events_list.go │ │ ├── sora_cam_devices_events_list_for_device.go │ │ ├── sora_cam_devices_get.go │ │ ├── sora_cam_devices_get_export_usage.go │ │ ├── sora_cam_devices_get_name.go │ │ ├── sora_cam_devices_get_power_state.go │ │ ├── sora_cam_devices_get_streaming_video.go │ │ ├── sora_cam_devices_images.go │ │ ├── sora_cam_devices_images_export.go │ │ ├── sora_cam_devices_images_get_exported.go │ │ ├── sora_cam_devices_images_list_exports.go │ │ ├── sora_cam_devices_images_list_exports_for_device.go │ │ ├── sora_cam_devices_list.go │ │ ├── sora_cam_devices_reboot.go │ │ ├── sora_cam_devices_recordings_and_events.go │ │ ├── sora_cam_devices_recordings_and_events_list_for_device.go │ │ ├── sora_cam_devices_set_name.go │ │ ├── sora_cam_devices_set_power_state.go │ │ ├── sora_cam_devices_update_export_usage_limit_override.go │ │ ├── sora_cam_devices_videos.go │ │ ├── sora_cam_devices_videos_export.go │ │ ├── sora_cam_devices_videos_get_exported.go │ │ ├── sora_cam_devices_videos_list_exports.go │ │ ├── sora_cam_devices_videos_list_exports_for_device.go │ │ ├── sora_cam_license_packs.go │ │ ├── sora_cam_license_packs_list.go │ │ ├── sora_cam_license_packs_update_quantity.go │ │ ├── soralets.go │ │ ├── soralets_create.go │ │ ├── soralets_delete.go │ │ ├── soralets_delete_version.go │ │ ├── soralets_exec.go │ │ ├── soralets_get.go │ │ ├── soralets_get_logs.go │ │ ├── soralets_list.go │ │ ├── soralets_list_versions.go │ │ ├── soralets_test_cmd.go │ │ ├── soralets_upload.go │ │ ├── stats.go │ │ ├── stats_air.go │ │ ├── stats_air_export.go │ │ ├── stats_air_get.go │ │ ├── stats_air_groups.go │ │ ├── stats_air_groups_get.go │ │ ├── stats_air_operators.go │ │ ├── stats_air_operators_get.go │ │ ├── stats_air_sims.go │ │ ├── stats_air_sims_get.go │ │ ├── stats_beam.go │ │ ├── stats_beam_export.go │ │ ├── stats_beam_get.go │ │ ├── stats_funk.go │ │ ├── stats_funk_export.go │ │ ├── stats_funk_get.go │ │ ├── stats_funnel.go │ │ ├── stats_funnel_export.go │ │ ├── stats_funnel_get.go │ │ ├── stats_harvest.go │ │ ├── stats_harvest_export.go │ │ ├── stats_harvest_operators.go │ │ ├── stats_harvest_operators_get.go │ │ ├── stats_harvest_subscribers.go │ │ ├── stats_harvest_subscribers_get.go │ │ ├── stats_napter.go │ │ ├── stats_napter_audit_logs.go │ │ ├── stats_napter_audit_logs_get.go │ │ ├── stringutils.go │ │ ├── subscribers.go │ │ ├── subscribers_activate.go │ │ ├── subscribers_deactivate.go │ │ ├── subscribers_delete_session.go │ │ ├── subscribers_delete_tag.go │ │ ├── subscribers_delete_transfer_token.go │ │ ├── subscribers_disable_termination.go │ │ ├── subscribers_downlink_ping.go │ │ ├── subscribers_enable_termination.go │ │ ├── subscribers_export.go │ │ ├── subscribers_get.go │ │ ├── subscribers_get_data.go │ │ ├── subscribers_issue_transfer_token.go │ │ ├── subscribers_list.go │ │ ├── subscribers_put_bundles.go │ │ ├── subscribers_put_tags.go │ │ ├── subscribers_register.go │ │ ├── subscribers_report_local_info.go │ │ ├── subscribers_send_sms.go │ │ ├── subscribers_send_sms_by_msisdn.go │ │ ├── subscribers_session_events.go │ │ ├── subscribers_set_expiry_time.go │ │ ├── subscribers_set_group.go │ │ ├── subscribers_set_imei_lock.go │ │ ├── subscribers_set_to_standby.go │ │ ├── subscribers_suspend.go │ │ ├── subscribers_terminate.go │ │ ├── subscribers_unset_expiry_time.go │ │ ├── subscribers_unset_group.go │ │ ├── subscribers_unset_imei_lock.go │ │ ├── subscribers_update_speed_class.go │ │ ├── subscribers_verify_transfer_token.go │ │ ├── switch_user_request.go │ │ ├── system_notifications.go │ │ ├── system_notifications_delete.go │ │ ├── system_notifications_get.go │ │ ├── system_notifications_list.go │ │ ├── system_notifications_set.go │ │ ├── test.go │ │ ├── to_json.go │ │ ├── users.go │ │ ├── users_attach_role.go │ │ ├── users_auth_keys.go │ │ ├── users_auth_keys_delete.go │ │ ├── users_auth_keys_generate.go │ │ ├── users_auth_keys_get.go │ │ ├── users_auth_keys_list.go │ │ ├── users_create.go │ │ ├── users_default_permissions.go │ │ ├── users_default_permissions_delete.go │ │ ├── users_default_permissions_get.go │ │ ├── users_default_permissions_update.go │ │ ├── users_delete.go │ │ ├── users_detach_role.go │ │ ├── users_get.go │ │ ├── users_list.go │ │ ├── users_list_roles.go │ │ ├── users_mfa.go │ │ ├── users_mfa_enable.go │ │ ├── users_mfa_get.go │ │ ├── users_mfa_revoke.go │ │ ├── users_mfa_verify.go │ │ ├── users_password.go │ │ ├── users_password_configured.go │ │ ├── users_password_create.go │ │ ├── users_password_delete.go │ │ ├── users_password_update.go │ │ ├── users_permissions.go │ │ ├── users_permissions_delete.go │ │ ├── users_permissions_get.go │ │ ├── users_permissions_update.go │ │ ├── users_revoke_user_auth_tokens.go │ │ ├── users_trust_policy.go │ │ ├── users_trust_policy_delete.go │ │ ├── users_trust_policy_get.go │ │ ├── users_trust_policy_update.go │ │ ├── users_update.go │ │ ├── version.go │ │ ├── version_checker.go │ │ ├── version_checker_test.go │ │ ├── volume_discounts.go │ │ ├── volume_discounts_available_discounts.go │ │ ├── volume_discounts_confirm.go │ │ ├── volume_discounts_create.go │ │ ├── volume_discounts_get.go │ │ ├── volume_discounts_list.go │ │ ├── vpg.go │ │ ├── vpg_accept_transit_gateway_vpc_attachment.go │ │ ├── vpg_close_gate.go │ │ ├── vpg_create.go │ │ ├── vpg_create_customer_route.go │ │ ├── vpg_create_mirroring_peer.go │ │ ├── vpg_create_packet_capture_session.go │ │ ├── vpg_create_transit_gateway_peering_connection.go │ │ ├── vpg_create_transit_gateway_vpc_attachment.go │ │ ├── vpg_create_vpc_peering_connection.go │ │ ├── vpg_delete_customer_route.go │ │ ├── vpg_delete_ip_address_map_entry.go │ │ ├── vpg_delete_mirroring_peer.go │ │ ├── vpg_delete_packet_capture_session.go │ │ ├── vpg_delete_tag.go │ │ ├── vpg_delete_transit_gateway_peering_connection.go │ │ ├── vpg_delete_transit_gateway_vpc_attachment.go │ │ ├── vpg_delete_vpc_peering_connection.go │ │ ├── vpg_disable_gate_privacy_separator.go │ │ ├── vpg_disable_sim_based_routing.go │ │ ├── vpg_enable_gate_privacy_separator.go │ │ ├── vpg_enable_sim_based_routing.go │ │ ├── vpg_get.go │ │ ├── vpg_get_packet_capture_session.go │ │ ├── vpg_list.go │ │ ├── vpg_list_gate_peers.go │ │ ├── vpg_list_ip_address_map_entries.go │ │ ├── vpg_list_packet_capture_sessions.go │ │ ├── vpg_open_gate.go │ │ ├── vpg_put_ip_address_map_entry.go │ │ ├── vpg_put_sim_based_routing_routes.go │ │ ├── vpg_register_gate_peer.go │ │ ├── vpg_release_fixed_public_ip_addresses.go │ │ ├── vpg_set_fixed_public_ip_addresses.go │ │ ├── vpg_set_inspection.go │ │ ├── vpg_set_redirection.go │ │ ├── vpg_set_routing_filter.go │ │ ├── vpg_set_vxlan_id.go │ │ ├── vpg_stop_packet_capture_session.go │ │ ├── vpg_terminate.go │ │ ├── vpg_unregister_gate_peer.go │ │ ├── vpg_unset_inspection.go │ │ ├── vpg_unset_redirection.go │ │ ├── vpg_update_customer_route.go │ │ ├── vpg_update_mirroring_peer.go │ │ └── vpg_update_tags.go ├── main.go ├── rsrc_windows_386.syso ├── rsrc_windows_amd64.syso └── winres │ ├── SIS0233CL_256x256.png │ └── winres.json └── test ├── data ├── gps-multi-unit.wasm ├── help_en_expected.txt └── help_ja_expected.txt ├── find_unprovided_text_resources.sh └── test.sh /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * ogu@soracom.jp 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a bug report 4 | title: Bug Report 5 | labels: bug 6 | assignees: bearmini 7 | 8 | --- 9 | 10 | 15 | 16 | ## System Informations 17 | 18 | * OS: 19 | 20 | ## Expected Behavior 21 | 22 | 23 | ## Current Behavior 24 | 25 | 26 | ## Steps to Reproduce 27 | 28 | 1. 29 | 1. 30 | 1. 31 | 32 | ## Logs 33 | 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Support Request 4 | url: https://soracom.zendesk.com/hc/ja/requests/ 5 | about: Support request or question relating to SORACOM 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement Issue 3 | about: Create an enhancement issue 4 | title: Enhancement Issue 5 | labels: feature 6 | assignees: bearmini 7 | 8 | --- 9 | 10 | ## What would you like to be added? 11 | 12 | ## Why is this needed? 13 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Please see the documentation for all configuration options: 2 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 3 | 4 | version: 2 5 | updates: 6 | - package-ecosystem: "gomod" 7 | directory: "/" 8 | schedule: 9 | interval: "weekly" 10 | 11 | - package-ecosystem: "github-actions" 12 | directory: "/" 13 | schedule: 14 | interval: "weekly" 15 | -------------------------------------------------------------------------------- /.github/workflows/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | #### What this PR does / why we need it: 4 | 5 | #### Which issue(s) this PR fixes: 6 | 7 | 11 | 12 | Fixes # 13 | 14 | #### Special notes for your reviewer: 15 | 16 | None 17 | 18 | #### Does this PR introduce a user-facing change? 19 | 20 | No 21 | 22 | #### Additional documentation 23 | -------------------------------------------------------------------------------- /.github/workflows/build-artifacts.yml: -------------------------------------------------------------------------------- 1 | name: Build artifacts 2 | 3 | on: push 4 | 5 | jobs: 6 | build: 7 | name: Build 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Set up Go 1.x 11 | uses: actions/setup-go@v5 12 | with: 13 | go-version: '1.24.0' 14 | id: go 15 | 16 | - name: Check out code into the Go module directory 17 | uses: actions/checkout@v4 18 | 19 | - name: Run build-artifacts command 20 | run: make ci-build-artifacts 21 | 22 | - uses: actions/upload-artifact@v4 23 | with: 24 | path: soracom/dist/ghactions/ 25 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '17 7 * * 4' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'go' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v4 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v3 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v3 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v3 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cache/ 2 | vendor/ 3 | .envrc 4 | .DS_Store 5 | .node-version 6 | .vscode/ 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Soracom, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM public.ecr.aws/docker/library/golang:1.24.0 2 | 3 | RUN apt update && apt upgrade -y && apt install -y fakeroot shellcheck zip 4 | 5 | ADD build.sh /build/ 6 | 7 | CMD [ "bash", "-x", "/build/build.sh" ] 8 | -------------------------------------------------------------------------------- /generators/cmd/predefined/api_credentials.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | "github.com/dvsekhvalnov/jose2go/base64url" 8 | ) 9 | 10 | type APICredentials struct { 11 | APIKey string 12 | APIToken string 13 | } 14 | 15 | func apiCredentialsFromAuthResult(ares *authResult) *APICredentials { 16 | return &APICredentials{ 17 | APIKey: ares.APIKey, 18 | APIToken: ares.Token, 19 | } 20 | } 21 | 22 | func (c *APICredentials) getOperatorID() string { 23 | if c == nil { 24 | return "" 25 | } 26 | 27 | return extractOperatorIDFromAPIToken(c.APIToken) 28 | } 29 | 30 | type jwtPayload struct { 31 | Operator jwtPayloadOperator `json:"operator"` 32 | } 33 | 34 | type jwtPayloadOperator struct { 35 | OperatorID string `json:"operatorId"` 36 | } 37 | 38 | func extractOperatorIDFromAPIToken(apiToken string) string { 39 | parts := strings.Split(apiToken, ".") 40 | if len(parts) < 2 { 41 | return "" 42 | } 43 | 44 | b64Decoded, err := base64url.Decode(parts[1]) 45 | if err != nil { 46 | return "" 47 | } 48 | 49 | var jp jwtPayload 50 | err = json.Unmarshal(b64Decoded, &jp) 51 | if err != nil { 52 | return "" 53 | } 54 | 55 | return jp.Operator.OperatorID 56 | } 57 | -------------------------------------------------------------------------------- /generators/cmd/predefined/auth_request.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | type authRequest struct { 4 | Email *string `json:"email,omitempty"` 5 | Password *string `json:"password,omitempty"` 6 | AuthKeyID *string `json:"authKeyId,omitempty"` 7 | AuthKey *string `json:"authKey,omitempty"` 8 | Username *string `json:"userName,omitempty"` 9 | OperatorID *string `json:"operatorId,omitempty"` 10 | MfaOTPCode *string `json:"mfaOTPCode,omitempty"` 11 | } 12 | 13 | func authRequestFromProfile(p *profile) *authRequest { 14 | return &authRequest{ 15 | Email: p.Email, 16 | Password: p.Password, 17 | AuthKeyID: p.AuthKeyID, 18 | AuthKey: p.AuthKey, 19 | Username: p.Username, 20 | OperatorID: p.OperatorID, 21 | MfaOTPCode: p.MfaOTPCode, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /generators/cmd/predefined/auth_result.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | type authResult struct { 4 | APIKey string `json:"apiKey"` 5 | Token string `json:"token"` 6 | OperatorID string `json:"operatorId"` 7 | } 8 | -------------------------------------------------------------------------------- /generators/cmd/predefined/completion.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func init() { 10 | RootCmd.AddCommand(CompletionCmd) 11 | CompletionCmd.AddCommand(completionBashCmd) 12 | CompletionCmd.AddCommand(completionZshCmd) 13 | } 14 | 15 | // CompletionCmd defines 'completion' subcommand 16 | var CompletionCmd = &cobra.Command{ 17 | Use: "completion", 18 | Short: TRCLI("cli.completion.summary"), 19 | Long: TRCLI("cli.completion.description"), 20 | RunE: func(cmd *cobra.Command, args []string) error { 21 | // For backward compatibility 22 | err := RootCmd.GenBashCompletion(os.Stdout) 23 | if err != nil { 24 | return err 25 | } 26 | return nil 27 | }, 28 | } 29 | 30 | var completionBashCmd = &cobra.Command{ 31 | Use: "bash", 32 | Short: TRCLI("cli.completion.bash.summary"), 33 | Long: TRCLI("cli.completion.bash.description"), 34 | RunE: func(cmd *cobra.Command, args []string) error { 35 | err := RootCmd.GenBashCompletion(os.Stdout) 36 | if err != nil { 37 | return err 38 | } 39 | return nil 40 | }, 41 | } 42 | 43 | var completionZshCmd = &cobra.Command{ 44 | Use: "zsh", 45 | Short: TRCLI("cli.completion.zsh.summary"), 46 | Long: TRCLI("cli.completion.zsh.description"), 47 | RunE: func(cmd *cobra.Command, args []string) error { 48 | err := RootCmd.GenZshCompletion(os.Stdout) 49 | if err != nil { 50 | return err 51 | } 52 | return nil 53 | }, 54 | } 55 | -------------------------------------------------------------------------------- /generators/cmd/predefined/configure.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import "github.com/spf13/cobra" 4 | 5 | var configureOverwrite bool 6 | 7 | func init() { 8 | ConfigureCmd.Flags().BoolVar(&configureOverwrite, "overwrite", false, TRCLI("cli.configure.overwrite")) 9 | RootCmd.AddCommand(ConfigureCmd) 10 | RootCmd.AddCommand(UnconfigureCmd) 11 | } 12 | 13 | // ConfigureCmd defines 'configure' subcommand 14 | var ConfigureCmd = &cobra.Command{ 15 | Use: "configure", 16 | Short: TRCLI("cli.configure.summary"), 17 | Long: TRCLI("cli.configure.description"), 18 | RunE: func(cmd *cobra.Command, args []string) error { 19 | pn := getSpecifiedProfileName() 20 | if pn == "" { 21 | pn = "default" 22 | } 23 | 24 | profile, err := collectProfileInfo(pn) 25 | if err != nil { 26 | cmd.SilenceUsage = true 27 | return err 28 | } 29 | 30 | err = saveProfile(pn, profile, configureOverwrite) 31 | if err != nil { 32 | cmd.SilenceUsage = true 33 | return err 34 | } 35 | 36 | return nil 37 | }, 38 | } 39 | 40 | // UnconfigureCmd defines 'unconfigure' subcommand 41 | var UnconfigureCmd = &cobra.Command{ 42 | Use: "unconfigure", 43 | Short: TRCLI("cli.unconfigure.summary"), 44 | Long: TRCLI("cli.unconfigure.description"), 45 | RunE: func(cmd *cobra.Command, args []string) error { 46 | pn := getSpecifiedProfileName() 47 | if pn == "" { 48 | pn = "default" 49 | } 50 | 51 | if confirmDeleteProfile(pn) { 52 | err := deleteProfile(pn) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | } 58 | 59 | return nil 60 | }, 61 | } 62 | -------------------------------------------------------------------------------- /generators/cmd/predefined/configure_get.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func init() { 10 | ConfigureCmd.AddCommand(ConfigureGetCmd) 11 | } 12 | 13 | // ConfigureGetCmd defineds 'get' subcommand 14 | var ConfigureGetCmd = &cobra.Command{ 15 | Use: "get", 16 | Short: TRCLI("cli.configure.get.summary"), 17 | Long: TRCLI("cli.configure.get.description"), 18 | RunE: func(cmd *cobra.Command, args []string) error { 19 | pn := getSpecifiedProfileName() 20 | if pn == "" { 21 | pn = "default" 22 | } 23 | 24 | p, err := loadProfile(pn) 25 | if err != nil { 26 | return err 27 | } 28 | 29 | return prettyPrintObjectAsJSON(p, os.Stdout) 30 | }, 31 | } 32 | -------------------------------------------------------------------------------- /generators/cmd/predefined/endpoint.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | // API Endpoint Specification Precedence: 8 | // 1. SORACOM_ENDPOINT env var 9 | // 2. --coverage-type argument (use coverage type default) 10 | // 3. endpoint in profile 11 | // 4. coverageType in profile (use coverage type default) 12 | 13 | func getSpecifiedEndpoint() string { 14 | e := os.Getenv("SORACOM_ENDPOINT") 15 | if e != "" { 16 | return e 17 | } 18 | 19 | ct := getSpecifiedCoverageType() 20 | profile, err := getProfile() 21 | if err != nil { 22 | return getDefaultEndpointForCoverageType(ct) 23 | } 24 | 25 | if ct != "" { 26 | if profile.Sandbox { 27 | return getDefaultSandboxEndpoint(ct) 28 | } 29 | return getDefaultEndpointForCoverageType(ct) 30 | } 31 | 32 | if profile.Endpoint != nil { 33 | return *profile.Endpoint 34 | } 35 | 36 | if profile.Sandbox { 37 | return getDefaultSandboxEndpoint(profile.CoverageType) 38 | } 39 | 40 | return getDefaultEndpointForCoverageType(profile.CoverageType) 41 | } 42 | 43 | func getDefaultEndpointForCoverageType(ct string) string { 44 | if ct == "g" { 45 | return "https://g.api.soracom.io" 46 | } 47 | return "https://api.soracom.io" 48 | } 49 | 50 | func getSpecifiedSandboxEndpoint(coverageType string) string { 51 | e := os.Getenv("SORACOM_ENDPOINT") 52 | if e != "" { 53 | return e 54 | } 55 | return getDefaultSandboxEndpoint(coverageType) 56 | } 57 | 58 | func getDefaultSandboxEndpoint(ct string) string { 59 | if ct == "g" { 60 | return "https://g.api-sandbox.soracom.io" 61 | } 62 | return "https://api-sandbox.soracom.io" 63 | } 64 | -------------------------------------------------------------------------------- /generators/cmd/predefined/harvest_files_path_escape.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "net/url" 5 | "strings" 6 | ) 7 | 8 | func harvestFilesPathEscape(path string) string { 9 | result := []string{} 10 | for _, s := range strings.Split(path, "/") { 11 | if s == "" { 12 | continue 13 | } 14 | result = append(result, url.PathEscape(s)) 15 | } 16 | return strings.Join(result, "/") 17 | } 18 | -------------------------------------------------------------------------------- /generators/cmd/predefined/harvest_files_path_escape_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestHarvestFilesPathEscape(t *testing.T) { 8 | var testData = []struct { 9 | Name string 10 | Path string 11 | Expected string 12 | }{ 13 | { 14 | Name: "pattern 1", 15 | Path: "hoge", 16 | Expected: "hoge", 17 | }, 18 | } 19 | 20 | for _, data := range testData { 21 | data := data // capture 22 | t.Run(data.Name, func(t *testing.T) { 23 | t.Parallel() 24 | 25 | v := harvestFilesPathEscape(data.Path) 26 | if v != data.Expected { 27 | t.Errorf("result of harvestFilesPathEscape() is unmatched with expected.\nArg: %s\nExpected: %s\nActual: %s", data.Path, data.Expected, v) 28 | } 29 | }) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /generators/cmd/predefined/pretty_print_json.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io" 7 | "os" 8 | "strings" 9 | ) 10 | 11 | func prettyPrintStringAsJSON(rawJSON string) error { 12 | return prettyPrintStringAsJSONToWriter(rawJSON, os.Stdout) 13 | } 14 | 15 | func prettyPrintStringAsJSONToWriter(rawJSON string, w io.Writer) error { 16 | var obj interface{} 17 | 18 | d := json.NewDecoder(strings.NewReader(rawJSON)) 19 | d.UseNumber() 20 | err := d.Decode(&obj) 21 | if err != nil { 22 | return err 23 | } 24 | return prettyPrintObjectAsJSON(obj, w) 25 | } 26 | 27 | func prettyPrintObjectAsJSON(obj interface{}, w io.Writer) error { 28 | var bb bytes.Buffer 29 | e := json.NewEncoder(&bb) 30 | e.SetEscapeHTML(false) 31 | e.SetIndent("", "\t") 32 | err := e.Encode(obj) 33 | if err != nil { 34 | return err 35 | } 36 | 37 | _, err = bb.WriteTo(w) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | return nil 43 | } 44 | 45 | func printStringAsJSONL(rawJSON string) error { 46 | return printStringAsJSONLToWriter(rawJSON, os.Stdout) 47 | } 48 | 49 | func printStringAsJSONLToWriter(rawJSON string, w io.Writer) error { 50 | var arr []interface{} 51 | 52 | d := json.NewDecoder(strings.NewReader(rawJSON)) 53 | d.UseNumber() 54 | err := d.Decode(&arr) 55 | if err != nil { 56 | return err 57 | } 58 | 59 | for _, obj := range arr { 60 | err = printObjectOneLine(obj, w) 61 | if err != nil { 62 | return err 63 | } 64 | } 65 | 66 | return nil 67 | } 68 | 69 | func printObjectOneLine(obj interface{}, w io.Writer) error { 70 | var bb bytes.Buffer 71 | e := json.NewEncoder(&bb) 72 | e.SetEscapeHTML(false) 73 | err := e.Encode(obj) 74 | if err != nil { 75 | return err 76 | } 77 | 78 | _, err = bb.WriteTo(w) 79 | if err != nil { 80 | return err 81 | } 82 | 83 | return nil 84 | } 85 | -------------------------------------------------------------------------------- /generators/cmd/predefined/pretty_print_json_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/tj/assert" 8 | ) 9 | 10 | func TestPrintStringAsJSONL(t *testing.T) { 11 | data1 := `[{"a":1},{"b":2},{"c":3}]` 12 | expected := `{"a":1} 13 | {"b":2} 14 | {"c":3} 15 | ` 16 | out1 := new(bytes.Buffer) 17 | err := printStringAsJSONLToWriter(data1, out1) 18 | assert.NoError(t, err) 19 | assert.Equal(t, expected, out1.String()) 20 | 21 | noArray1 := `{"a":1,"b":2}` 22 | out2 := new(bytes.Buffer) 23 | err = printStringAsJSONLToWriter(noArray1, out2) 24 | assert.Error(t, err) 25 | } 26 | -------------------------------------------------------------------------------- /generators/cmd/predefined/profiles_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func TestGetProfileFromExternalCommand(t *testing.T) { 11 | email := "test@example.com" 12 | password := "testpassword" 13 | authKeyID := "testKeyID" 14 | authKey := "testAuthKey" 15 | username := "testUsername" 16 | operatorID := "testOperatorID" 17 | 18 | command := fmt.Sprintf("/bin/echo \"{\\\"email\\\": \\\"%s\\\",\\\"password\\\": \\\"%s\\\",\\\"authKeyId\\\": \\\"%s\\\",\\\"authKey\\\": \\\"%s\\\",\\\"userName\\\": \\\"%s\\\",\\\"operatorId\\\": \\\"%s\\\"}\"", email, password, authKeyID, authKey, username, operatorID) 19 | p, err := getProfileFromExternalCommand(command) 20 | 21 | if !assert.NoError(t, err) { 22 | t.FailNow() 23 | } 24 | assert.EqualValues(t, email, *(p.Email)) 25 | assert.EqualValues(t, password, *(p.Password)) 26 | assert.EqualValues(t, authKeyID, *(p.AuthKeyID)) 27 | assert.EqualValues(t, authKey, *(p.AuthKey)) 28 | assert.EqualValues(t, username, *(p.Username)) 29 | assert.EqualValues(t, operatorID, *(p.OperatorID)) 30 | } 31 | -------------------------------------------------------------------------------- /generators/cmd/predefined/prompt.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bufio" 5 | "os" 6 | "strings" 7 | ) 8 | 9 | // XXX: visible for testing 10 | var promptStdin = os.Stdin 11 | 12 | // readConfirmationPrompt returns true when the input value is 'y', 'Y', or empty. 13 | func readDefaultYesConfirmationPrompt() (bool, error) { 14 | s, err := readLine() 15 | if err != nil { 16 | return false, err 17 | } 18 | return s == "" || strings.ToLower(s) == "y", nil 19 | } 20 | 21 | // readConfirmationPrompt returns true when the input value is 'y', 'Y'. 22 | func readDefaultNoConfirmationPrompt() (bool, error) { 23 | s, err := readLine() 24 | if err != nil { 25 | return false, err 26 | } 27 | return s != "" && strings.ToLower(s) == "y", nil 28 | } 29 | 30 | func readLine() (string, error) { 31 | reader := bufio.NewReader(promptStdin) 32 | s, err := reader.ReadString('\n') 33 | if err != nil { 34 | return "", err 35 | } 36 | 37 | return strings.TrimSpace(s), nil 38 | } 39 | -------------------------------------------------------------------------------- /generators/cmd/predefined/prompt_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "testing" 7 | 8 | "github.com/stretchr/testify/assert" 9 | ) 10 | 11 | func TestReadDefaultYesConfirmationPrompt(t *testing.T) { 12 | type test struct { 13 | input string 14 | expected bool 15 | } 16 | 17 | tests := []*test{ 18 | {input: "y", expected: true}, 19 | {input: "Y", expected: true}, 20 | {input: "", expected: true}, 21 | {input: "n", expected: false}, 22 | {input: "o", expected: false}, 23 | } 24 | 25 | tempFile, err := os.CreateTemp("", "") 26 | assert.NoError(t, err) 27 | originalPromptStdin := promptStdin 28 | promptStdin = tempFile 29 | defer func() { 30 | promptStdin = originalPromptStdin 31 | _ = os.Remove(tempFile.Name()) 32 | }() 33 | 34 | for _, testCase := range tests { 35 | _, err = tempFile.WriteString(fmt.Sprintf("%s\n", testCase.input)) 36 | assert.NoError(t, err) 37 | _, err = tempFile.Seek(0, 0) 38 | assert.NoError(t, err) 39 | 40 | yes, err := readDefaultYesConfirmationPrompt() 41 | assert.NoError(t, err) 42 | assert.Equal(t, testCase.expected, yes) 43 | 44 | err = tempFile.Truncate(0) 45 | assert.NoError(t, err) 46 | _, err = tempFile.Seek(0, 0) 47 | assert.NoError(t, err) 48 | } 49 | 50 | _ = tempFile.Close() 51 | } 52 | 53 | func TestReadDefaultNoConfirmationPrompt(t *testing.T) { 54 | type test struct { 55 | input string 56 | expected bool 57 | } 58 | 59 | tests := []*test{ 60 | {input: "y", expected: true}, 61 | {input: "Y", expected: true}, 62 | {input: "", expected: false}, 63 | {input: "n", expected: false}, 64 | {input: "o", expected: false}, 65 | } 66 | 67 | tempFile, err := os.CreateTemp("", "") 68 | assert.NoError(t, err) 69 | originalPromptStdin := promptStdin 70 | promptStdin = tempFile 71 | defer func() { 72 | promptStdin = originalPromptStdin 73 | _ = os.Remove(tempFile.Name()) 74 | }() 75 | 76 | for _, testCase := range tests { 77 | _, err = tempFile.WriteString(fmt.Sprintf("%s\n", testCase.input)) 78 | assert.NoError(t, err) 79 | _, err = tempFile.Seek(0, 0) 80 | assert.NoError(t, err) 81 | 82 | yes, err := readDefaultNoConfirmationPrompt() 83 | assert.NoError(t, err) 84 | assert.Equal(t, testCase.expected, yes) 85 | 86 | err = tempFile.Truncate(0) 87 | assert.NoError(t, err) 88 | _, err = tempFile.Seek(0, 0) 89 | assert.NoError(t, err) 90 | } 91 | 92 | _ = tempFile.Close() 93 | } 94 | -------------------------------------------------------------------------------- /generators/cmd/predefined/stringutils.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // it was difficult to use fmt.Sprintf() in template codes 9 | // because we need to import only if fmt.Sprintf() is called 10 | // but the condition was too complicated. So we separated 11 | // fmt.Sprintf() to a func which can be referenced from 12 | // inside the complicated condition. 13 | 14 | func sprintf(format string, a ...interface{}) string { 15 | return fmt.Sprintf(format, a...) 16 | } 17 | 18 | func strReplace(s, old, new string, n int) string { 19 | return strings.Replace(s, old, new, n) 20 | } 21 | -------------------------------------------------------------------------------- /generators/cmd/predefined/switch_user_request.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | type switchUserRequest struct { 4 | OperatorID string `json:"operatorId"` 5 | UserName string `json:"userName"` 6 | TokenTimeoutSeconds *int `json:"tokenTimeoutSeconds,omitempty"` 7 | } 8 | -------------------------------------------------------------------------------- /generators/cmd/predefined/test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func init() { 10 | RootCmd.AddCommand(TestCmd) 11 | TestCmd.AddCommand(Test500Cmd) 12 | } 13 | 14 | // TestCmd defines 'test' subcommand 15 | var TestCmd = &cobra.Command{ 16 | Use: "test", 17 | Short: TRCLI("cli.test.summary"), 18 | Long: TRCLI("cli.test.description"), 19 | Hidden: true, 20 | } 21 | 22 | // Test500Cmd defines 'test 500' subcommand 23 | var Test500Cmd = &cobra.Command{ 24 | Use: "500", 25 | Short: TRCLI("cli.test._500.summary"), 26 | Long: TRCLI("cli.test._500.description"), 27 | RunE: func(cmd *cobra.Command, args []string) error { 28 | opt := &apiClientOptions{ 29 | BasePath: "/", 30 | Language: getSelectedLanguage(), 31 | } 32 | 33 | ac := newAPIClient(opt) 34 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 35 | ac.SetVerbose(true) 36 | } 37 | 38 | param := &apiParams{ 39 | method: "POST", 40 | path: "500", 41 | contentType: "application/json", 42 | body: `{"expect":"500 Internal Server Error"}`, 43 | } 44 | 45 | _, err := ac.callAPI(param) 46 | 47 | return err 48 | }, 49 | } 50 | -------------------------------------------------------------------------------- /generators/cmd/predefined/to_json.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import "encoding/json" 4 | 5 | func toJSON(x interface{}) string { 6 | bodyBytes, err := json.Marshal(x) 7 | if err != nil { 8 | return "" 9 | } 10 | return string(bodyBytes) 11 | } 12 | -------------------------------------------------------------------------------- /generators/cmd/predefined/version.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func init() { 10 | RootCmd.AddCommand(VersionCmd) 11 | } 12 | 13 | var version string 14 | 15 | // VersionCmd defines 'version' subcommand 16 | var VersionCmd = &cobra.Command{ 17 | Use: "version", 18 | Short: TRCLI("cli.version.summary"), 19 | Long: TRCLI("cli.version.description"), 20 | Run: func(cmd *cobra.Command, args []string) { 21 | fmt.Printf("SORACOM API client v%s\n", version) 22 | }, 23 | } 24 | -------------------------------------------------------------------------------- /generators/cmd/predefined/version_checker.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "regexp" 5 | "strconv" 6 | ) 7 | 8 | // version strings are in the form of "v1.22.333" or "v0.0.1" 9 | func isNewerThanCurrentVersion(latestVersion string) bool { 10 | cv := versionInt(version) 11 | lv := versionInt(latestVersion) 12 | return cv < lv 13 | } 14 | 15 | func versionInt(ver string) uint32 { 16 | s := splitVersionString(ver) 17 | if len(s) < 3 { 18 | return 0 19 | } 20 | 21 | var n uint32 22 | shift := uint(24) 23 | for i := 0; i < 4; i++ { 24 | if len(s) <= i { 25 | break 26 | } 27 | x, err := strconv.Atoi(s[i]) 28 | if err == nil { 29 | n |= uint32((x & 0xff) << shift) 30 | } 31 | shift -= 8 32 | } 33 | return n 34 | } 35 | 36 | var versionStringRegexp = regexp.MustCompile("([[:digit:]]+)[[:^digit:]]*") 37 | 38 | func splitVersionString(ver string) []string { 39 | m := versionStringRegexp.FindAllStringSubmatch(ver, -1) 40 | if len(m) < 2 { 41 | return []string{} 42 | } 43 | result := make([]string, len(m)) 44 | for i, s := range m { 45 | result[i] = s[1] 46 | } 47 | return result 48 | } 49 | -------------------------------------------------------------------------------- /generators/cmd/predefined/version_checker_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import "testing" 4 | 5 | func TestVersionInt(t *testing.T) { 6 | var testData = []struct { 7 | Name string 8 | VerStr string 9 | VerInt uint32 10 | }{ 11 | { 12 | Name: "pattern 1", 13 | VerStr: "v0.1.2", 14 | VerInt: 0x00010200, 15 | }, 16 | { 17 | Name: "pattern 2", 18 | VerStr: "v1.22.333", // 333 == 0x14d but only 0x4d will be stored in the 3rd place 19 | VerInt: 0x01164d00, 20 | }, 21 | { 22 | Name: "pattern 3", 23 | VerStr: "1.2.3", // no "v" prefix 24 | VerInt: 0x01020300, 25 | }, 26 | { 27 | Name: "pattern 4", 28 | VerStr: "v1.2.3-special", 29 | VerInt: 0x01020300, 30 | }, 31 | { 32 | Name: "pattern 5", 33 | VerStr: "v1.2.3-special1", 34 | VerInt: 0x01020301, 35 | }, 36 | { 37 | Name: "pattern 6", 38 | VerStr: "v1.2.3.4", 39 | VerInt: 0x01020304, 40 | }, 41 | } 42 | 43 | for _, data := range testData { 44 | data := data // capture 45 | t.Run(data.Name, func(t *testing.T) { 46 | t.Parallel() 47 | 48 | v := versionInt(data.VerStr) 49 | if v != data.VerInt { 50 | t.Errorf("result of versionInt() is unmatched with expected.\nArg: %v\nExpected: %#08x\nActual: %#08x", data.VerStr, data.VerInt, v) 51 | } 52 | }) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /generators/cmd/src/.gitignore: -------------------------------------------------------------------------------- 1 | generate-cmd 2 | -------------------------------------------------------------------------------- /generators/cmd/src/gen_leaf_cmd_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/tj/assert" 7 | ) 8 | 9 | func TestRemoveLineBreaks(t *testing.T) { 10 | testData := []struct { 11 | Input string 12 | Expected string 13 | }{ 14 | { 15 | Input: "", 16 | Expected: "", 17 | }, 18 | { 19 | Input: "a\nb", 20 | Expected: "ab", 21 | }, 22 | { 23 | Input: "aaaa\r\nbbbbb\r\n", 24 | Expected: "aaaabbbbb", 25 | }, 26 | } 27 | 28 | for _, data := range testData { 29 | data := data // capture 30 | t.Run(data.Input, func(t *testing.T) { 31 | t.Parallel() 32 | 33 | assert.Equal(t, data.Expected, removeLineBreaks(data.Input)) 34 | }) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /generators/cmd/src/gen_root_cmd.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "sort" 5 | 6 | "github.com/getkin/kin-openapi/openapi3" 7 | ) 8 | 9 | type rootCommandArgs struct { 10 | Use string 11 | Short string 12 | Long string 13 | Subcommands []subcommand 14 | } 15 | 16 | type subcommand struct { 17 | CommandVariableName string 18 | } 19 | 20 | func generateRootCommand(apiDef, apiSandboxDef *openapi3.T, templateDir, outputDir string) error { 21 | t, err := openTemplateFile(templateDir, "root.gotmpl") 22 | if err != nil { 23 | return err 24 | } 25 | 26 | subcommands := getAllSubcommands(apiDef) 27 | subcommands = append(subcommands, getAllSubcommands(apiSandboxDef)...) 28 | sort.Slice(subcommands, func(i, j int) bool { 29 | return subcommands[i].CommandVariableName < subcommands[j].CommandVariableName 30 | }) 31 | 32 | w, err := openOutputFile(outputDir, "root.go") 33 | if err != nil { 34 | return err 35 | } 36 | 37 | a := rootCommandArgs{ 38 | Use: "soracom", 39 | Short: "soracom command", 40 | Long: `A command line tool to invoke SORACOM API`, 41 | Subcommands: subcommands, 42 | } 43 | err = t.Execute(w, a) 44 | if err != nil { 45 | return err 46 | } 47 | return nil 48 | } 49 | 50 | func getAllSubcommands(apiDef *openapi3.T) []subcommand { 51 | var result []subcommand 52 | 53 | for _, pathItem := range apiDef.Paths.Map() { 54 | for _, op := range pathItem.Operations() { 55 | for _, commandName := range getCLICommands(op) { 56 | result = append(result, subcommand{ 57 | CommandVariableName: getCommandVariableName(commandName), 58 | }) 59 | } 60 | } 61 | } 62 | 63 | return result 64 | } 65 | -------------------------------------------------------------------------------- /generators/cmd/src/gen_trunk_cmd.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | "strings" 7 | 8 | "github.com/getkin/kin-openapi/openapi3" 9 | "github.com/soracom/soracom-cli/generators/lib" 10 | ) 11 | 12 | func generateTrunkCommands(apiDef *openapi3.T, templateDir, outputDir string) error { 13 | subCommandTemplate, err := openTemplateFile(templateDir, "trunk.gotmpl") 14 | if err != nil { 15 | return err 16 | } 17 | 18 | argsSlice := generateArgsForTrunkCommands(apiDef) 19 | 20 | for _, args := range argsSlice { 21 | f, err := openOutputFile(outputDir, args.FileName) 22 | if err != nil { 23 | return err 24 | } 25 | err = subCommandTemplate.Execute(f, args) 26 | if err != nil { 27 | return err 28 | } 29 | } 30 | 31 | return nil 32 | } 33 | 34 | func generateArgsForTrunkCommands(apiDef *openapi3.T) []commandArgs { 35 | trunkCommands := extractTrunkCommands(apiDef) 36 | 37 | result := make([]commandArgs, 0) 38 | 39 | for _, tc := range trunkCommands { 40 | s := strings.Split(tc, " ") 41 | ca := commandArgs{ 42 | Use: s[len(s)-1], 43 | Short: fmt.Sprintf("cli.%s.summary", strings.Join(s, ".")), 44 | Long: fmt.Sprintf("cli.%s.description", strings.Join(s, ".")), 45 | CommandVariableName: getCommandVariableName(strings.Join(s, " ")), 46 | ParentCommandVariableName: getParentCommandVariableName(strings.Join(s, " ")), 47 | FileName: fmt.Sprintf("%s.go", lib.SnakeCase(strings.Join(s, "-"))), 48 | } 49 | result = append(result, ca) 50 | } 51 | 52 | return result 53 | } 54 | 55 | func extractTrunkCommands(apiDef *openapi3.T) []string { 56 | commands := map[string]interface{}{} 57 | 58 | for _, path := range apiDef.Paths.Map() { 59 | for _, op := range path.Operations() { 60 | cliCommands := getCLICommands(op) 61 | for _, cmd := range cliCommands { 62 | s := strings.Split(cmd, " ") 63 | if len(s) <= 1 { 64 | continue 65 | } 66 | 67 | for i := 1; i < len(s); i++ { 68 | ss := s[:i] 69 | commands[strings.Join(ss, " ")] = true 70 | } 71 | } 72 | } 73 | } 74 | 75 | result := []string{} 76 | for k := range commands { 77 | result = append(result, k) 78 | } 79 | 80 | sort.Strings(result) 81 | return result 82 | } 83 | -------------------------------------------------------------------------------- /generators/cmd/templates/root.gotmpl: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | // RootCmd defines 'soracom' command 9 | var RootCmd = &cobra.Command{ 10 | Use: "{{.Use}}", 11 | Short: "{{.Short}}", 12 | Long: `{{.Long}}`, 13 | } 14 | 15 | var specifiedProfileName string 16 | var specifiedCoverageType string 17 | var providedAPIKey string 18 | var providedAPIToken string 19 | var providedAuthKeyID string 20 | var providedAuthKey string 21 | var providedProfileCommand string 22 | var rawOutput bool 23 | var noRetryOnError bool 24 | 25 | func InitRootCmd() { 26 | RootCmd.PersistentFlags().StringVar(&specifiedProfileName, "profile", "", TRCLI("cli.global-flags.profile")) 27 | RootCmd.PersistentFlags().StringVar(&specifiedCoverageType, "coverage-type", "", TRCLI("cli.global-flags.coverage-type")) 28 | RootCmd.PersistentFlags().StringVar(&providedAPIKey, "api-key", "", TRCLI("cli.global-flags.api-key")) 29 | RootCmd.PersistentFlags().StringVar(&providedAPIToken, "api-token", "", TRCLI("cli.global-flags.api-token")) 30 | RootCmd.PersistentFlags().StringVar(&providedAuthKeyID, "auth-key-id", "", TRCLI("cli.global-flags.auth-key-id")) 31 | RootCmd.PersistentFlags().StringVar(&providedAuthKey, "auth-key", "", TRCLI("cli.global-flags.auth-key")) 32 | RootCmd.PersistentFlags().StringVar(&providedProfileCommand, "profile-command", "", TRCLI("cli.global-flags.profile-command")) 33 | RootCmd.PersistentFlags().BoolVar(&rawOutput, "raw-output", false, TRCLI("cli.global-flags.raw-output")) 34 | RootCmd.PersistentFlags().BoolVar(&noRetryOnError, "no-retry-on-error", false, TRCLI("cli.global-flags.no-retry-on-error")) 35 | 36 | InitAllSubCommands() 37 | } 38 | 39 | func InitAllSubCommands() { 40 | {{- range .Subcommands }} 41 | Init{{.CommandVariableName}}() 42 | {{- end}} 43 | } 44 | -------------------------------------------------------------------------------- /generators/cmd/templates/trunk.gotmpl: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | {{.ParentCommandVariableName}}.AddCommand({{.CommandVariableName}}) 10 | } 11 | 12 | // {{.CommandVariableName}} defines '{{.Use}}' subcommand 13 | var {{.CommandVariableName}} = &cobra.Command{ 14 | Use: "{{.Use}}", 15 | Short: TRCLI("{{.Short}}"), 16 | Long: TRCLI(`{{.Long}}`), 17 | } 18 | -------------------------------------------------------------------------------- /generators/lib/case_conv.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "bytes" 5 | "regexp" 6 | "strings" 7 | ) 8 | 9 | var wordRegex = regexp.MustCompile("[0-9A-Za-z]+") 10 | var optionRegex = regexp.MustCompile("([a-z])([A-Z])") 11 | 12 | // CamelCase converts strings like "space separated", "dash-separated", "snake_case" to "camelCase" 13 | // but does not convert "TitleCase" to "camelCase" 14 | func CamelCase(src string) string { 15 | byteSrc := bytes.NewBufferString(src).Bytes() 16 | chunks := wordRegex.FindAll(byteSrc, -1) 17 | for idx, val := range chunks { 18 | if idx > 0 { 19 | chunks[idx] = bytes.Title(val) 20 | } 21 | } 22 | return bytes.NewBuffer(bytes.Join(chunks, nil)).String() 23 | } 24 | 25 | // TitleCase converts strings like "space separated", "dash-separated", "snake_case", "camelCase" to "TitleCase" 26 | func TitleCase(src string) string { 27 | byteSrc := bytes.NewBufferString(src).Bytes() 28 | chunks := wordRegex.FindAll(byteSrc, -1) 29 | for idx, val := range chunks { 30 | chunks[idx] = bytes.Title(val) 31 | } 32 | return bytes.NewBuffer(bytes.Join(chunks, nil)).String() 33 | } 34 | 35 | // SnakeCase converts strings like "space separated", "dash-separated", "camelCase", "TitleCase" to "snake_case" 36 | func SnakeCase(s string) string { 37 | s1 := optionRegex.ReplaceAll([]byte(s), []byte("$1-$2")) 38 | s2 := strings.Replace(string(s1), " ", "_", -1) 39 | s3 := strings.Replace(s2, "-", "_", -1) 40 | s4 := bytes.ToLower([]byte(s3)) 41 | return string(s4) 42 | } 43 | 44 | // OptionCase converts strings like "space separated", "snake_case", "camelCase", "TitleCase" to "option-case" 45 | func OptionCase(s string) string { 46 | s1 := optionRegex.ReplaceAll([]byte(s), []byte("$1-$2")) 47 | s2 := strings.Replace(string(s1), " ", "-", -1) 48 | s3 := strings.Replace(s2, "_", "-", -1) 49 | s4 := bytes.ToLower([]byte(s3)) 50 | return string(s4) 51 | } 52 | -------------------------------------------------------------------------------- /generators/lib/fileperm.go: -------------------------------------------------------------------------------- 1 | //go:build !windows 2 | // +build !windows 3 | 4 | package lib 5 | 6 | import "os" 7 | 8 | // IsFilePermissionTooOpen returns true only when the `path` doesn't have the expected permission 9 | func IsFilePermissionTooOpen(path string) (bool, error) { 10 | s, err := os.Stat(path) 11 | if err != nil { 12 | return false, err 13 | } 14 | 15 | if s.Mode()&077 != 0 { 16 | return true, nil 17 | } 18 | 19 | return false, nil 20 | } 21 | 22 | // ProtectFile changes the mode of the specified `path` 23 | func ProtectFile(path string) error { 24 | return os.Chmod(path, 0600) 25 | } 26 | -------------------------------------------------------------------------------- /generators/lib/fileperm_windows.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | package lib 5 | 6 | import ( 7 | "fmt" 8 | 9 | acl "github.com/bearmini/go-acl" 10 | "github.com/bearmini/go-acl/api" 11 | "golang.org/x/sys/windows" 12 | ) 13 | 14 | func IsFilePermissionTooOpen(path string) (bool, error) { 15 | var ( 16 | ownerSID *windows.SID 17 | dacl *api.ACL 18 | secDesc windows.Handle 19 | ) 20 | err := api.GetNamedSecurityInfo( 21 | path, 22 | api.SE_FILE_OBJECT, 23 | api.OWNER_SECURITY_INFORMATION|api.DACL_SECURITY_INFORMATION, 24 | &ownerSID, 25 | nil, 26 | &dacl, 27 | nil, 28 | &secDesc, 29 | ) 30 | defer windows.LocalFree(secDesc) 31 | if err != nil { 32 | // This `err` always contains "The operation completed successfully" 33 | // So we create a new error instance 34 | return false, fmt.Errorf("unable to get security info for the file: %s", path) 35 | } 36 | 37 | currProcSID, err := GetCurrentProcessSID() 38 | if err != nil { 39 | return false, err 40 | } 41 | 42 | //fmt.Printf("dacl == %+v\n", dacl) 43 | aces := dacl.GetACEList() 44 | //fmt.Printf("ACEs == %+v\n", aces) 45 | for _, ace := range aces { 46 | switch ace.(type) { 47 | case *api.AccessAllowedACE: 48 | // ok to have this if it's sid == mine 49 | default: 50 | return true, nil 51 | } 52 | sid := ace.GetSID() 53 | if !windows.EqualSid(sid, currProcSID) { 54 | return true, nil 55 | } 56 | } 57 | return false, nil 58 | } 59 | 60 | // the returned SID from this function must NOT be freed. It's resident data in the Process Token 61 | func GetCurrentProcessSID() (*windows.SID, error) { 62 | token, err := windows.OpenCurrentProcessToken() 63 | if err != nil { 64 | return nil, err 65 | } 66 | defer token.Close() 67 | 68 | tu, err := token.GetTokenUser() 69 | if err != nil { 70 | return nil, err 71 | } 72 | return tu.User.Sid, nil 73 | } 74 | 75 | func ProtectFile(path string) error { 76 | return acl.Apply(path, true, false, acl.GrantName((0600)<<23, "CREATOR OWNER")) 77 | } 78 | -------------------------------------------------------------------------------- /generators/lib/printer.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | // PrintfStderr formats according to a format specifier and writes to standard error 9 | func PrintfStderr(format string, args ...interface{}) { 10 | _, err := fmt.Fprintf(os.Stderr, format, args...) 11 | if err != nil { 12 | //fmt.Printf("err: %+v\n", err) // this messes up stdout 13 | } 14 | } 15 | 16 | // WarnfStderr formats according to a format specifier and writes to standard error with `WARN: ` prefix 17 | func WarnfStderr(format string, args ...interface{}) { 18 | PrintfStderr("WARN: "+format, args...) 19 | } 20 | -------------------------------------------------------------------------------- /generators/winres/SIS0233CL_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soracom/soracom-cli/86ff177a1904dc83ead79efe710324a20021fc74/generators/winres/SIS0233CL_256x256.png -------------------------------------------------------------------------------- /generators/winres/winres.json: -------------------------------------------------------------------------------- 1 | { 2 | "RT_GROUP_ICON": { 3 | "APP": { 4 | "0000": [ 5 | "SIS0233CL_256x256.png" 6 | ] 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/soracom/soracom-cli 2 | 3 | require ( 4 | github.com/bearmini/go-acl v0.0.0-20170614023114-a423b25ba3ef 5 | github.com/dvsekhvalnov/jose2go v1.7.0 6 | github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4 7 | github.com/getkin/kin-openapi v0.128.0 8 | github.com/kennygrant/sanitize v1.2.4 9 | github.com/mattn/go-shellwords v1.0.12 10 | github.com/mitchellh/go-homedir v1.1.0 11 | github.com/pkg/errors v0.9.1 12 | github.com/spf13/cobra v1.8.1 13 | github.com/stretchr/testify v1.9.0 14 | github.com/tj/assert v0.0.3 15 | golang.org/x/sys v0.31.0 16 | golang.org/x/term v0.26.0 17 | gopkg.in/yaml.v2 v2.4.0 18 | ) 19 | 20 | require ( 21 | github.com/davecgh/go-spew v1.1.1 // indirect 22 | github.com/elazarl/goproxy/ext v0.0.0-20200809112317-0581fc3aee2d // indirect 23 | github.com/go-openapi/jsonpointer v0.21.0 // indirect 24 | github.com/go-openapi/swag v0.23.0 // indirect 25 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 26 | github.com/invopop/yaml v0.3.1 // indirect 27 | github.com/josharian/intern v1.0.0 // indirect 28 | github.com/mailru/easyjson v0.7.7 // indirect 29 | github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect 30 | github.com/perimeterx/marshmallow v1.1.5 // indirect 31 | github.com/pmezard/go-difflib v1.0.0 // indirect 32 | github.com/spf13/pflag v1.0.5 // indirect 33 | golang.org/x/net v0.23.0 // indirect 34 | gopkg.in/yaml.v3 v3.0.1 // indirect 35 | ) 36 | 37 | go 1.23.0 38 | 39 | toolchain go1.24.0 40 | -------------------------------------------------------------------------------- /scripts/build-lambda-layer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | d=$( cd "$( dirname "$0" )" && cd .. && pwd -P ) 4 | 5 | VERSION=${1:-} 6 | if [ -z "$VERSION" ]; then 7 | echo "Please specify version number (e.g. 1.2.3)" 8 | exit 1 9 | fi 10 | 11 | generate_layer_zip() { 12 | wd=$1 13 | arch=$2 14 | curl -s -L "https://github.com/soracom/soracom-cli/releases/download/v${VERSION}/soracom_${VERSION}_linux_${arch}" -o "$wd/bin/soracom" 15 | chmod +x "$wd/bin/soracom" 16 | cd "$wd" && zip -r "layer_${VERSION}_${arch}.zip" . && cd - 17 | } 18 | 19 | wd="$d/soracom/dist/$VERSION/lambda-layer" 20 | rm -rf "$wd" 21 | mkdir -p "$wd/bin" 22 | 23 | set -x 24 | generate_layer_zip "$wd" amd64 25 | generate_layer_zip "$wd" arm64 -------------------------------------------------------------------------------- /scripts/build-snap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | VERSION=$1 3 | if [ -z "$1" ]; then 4 | echo "Please specify version number (e.g. 1.2.3)" 5 | exit 1 6 | fi 7 | 8 | set -Eeuo pipefail 9 | d=$( cd "$( dirname "$0" )" && cd .. && pwd -P ) 10 | 11 | docker build -t snapbuild "$d/snap" 12 | docker run -it --rm -v="$d/soracom/dist/$VERSION:/mnt" snapbuild sh -c "bash /opt/build.sh $VERSION" 13 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | VERSION=$1 3 | if [ -z "$1" ]; then 4 | VERSION='0.0.0' 5 | echo "Version number (e.g. 1.2.3) is not specified. Using $VERSION as the default version number" 6 | fi 7 | 8 | set -Eeuo pipefail 9 | 10 | d="$( cd "$( dirname "$0" )" && cd .. && pwd -P )" 11 | RED="\\033[1;31m" 12 | GREEN="\\033[1;32m" 13 | RESET="\\033[0m" 14 | 15 | gopath=${GOPATH:-$HOME/go} 16 | gopath=${gopath%%:*} 17 | 18 | mkdir -p "$d/.cache" 19 | 20 | docker build -t soracom-cli-build "$d/build" 21 | docker run --rm -t \ 22 | --network host \ 23 | --user "$(id -u):$(id -g)" \ 24 | -e "VERSION=$VERSION" \ 25 | -v "$d":/go/src/github.com/soracom/soracom-cli \ 26 | -v "$gopath":/go \ 27 | -v "$d/.cache":/.cache \ 28 | -w "/go/src/github.com/soracom/soracom-cli/" \ 29 | soracom-cli-build bash -x -c "/build/build.sh" || { 30 | echo 31 | echo -e "${RED}Build failed.${RESET}" 32 | echo 33 | exit 1 34 | } 35 | 36 | echo 37 | echo -e "${GREEN}OK${RESET}" 38 | echo 39 | -------------------------------------------------------------------------------- /scripts/build_local_bin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | d="$( cd "$( dirname "$0" )" && cd .. && pwd -P )" 4 | 5 | uname_s="$(uname -s)" 6 | if [ "$uname_s" == "Darwin" ]; then 7 | OS=darwin 8 | elif [ "$uname_s" == "Linux" ]; then 9 | OS=linux 10 | elif [ "$uname_s" == "FreeBSD" ]; then 11 | OS=freebsd 12 | else 13 | echo "Operating system $uname_s is not supported for a test environment" 14 | exit 1 15 | fi 16 | 17 | uname_m="$(uname -m)" 18 | if [ "$uname_m" == "x86_64" ] || [ "$uname_m" == "amd64" ]; then 19 | ARCH=amd64 20 | else 21 | echo "Machine architecture $uname_m is not supported for a test environment" 22 | exit 1 23 | fi 24 | 25 | VERSION=$1 26 | if [ -z "$1" ]; then 27 | VERSION="0.0.0" 28 | echo "Version number (e.g. 1.2.3) is not specified. Using $VERSION as the default version number" 29 | fi 30 | 31 | pushd "$d/soracom" >/dev/null 2>&1 32 | "$d/scripts/build.sh" "$VERSION" "$OS" 33 | popd >/dev/null 2>&1 34 | 35 | pushd "$d/soracom/dist/$VERSION/" >/dev/null 2>&1 36 | if [ "$OS" == "darwin" ] || [ "$OS" == "freebsd" ]; then 37 | unzip -o "soracom_${VERSION}_${OS}_${ARCH}.zip" 38 | elif [ "$OS" == "linux" ]; then 39 | tar xvzf "soracom_${VERSION}_${OS}_${ARCH}.tar.gz" 40 | fi 41 | 42 | popd >/dev/null 2>&1 43 | -------------------------------------------------------------------------------- /scripts/copy-apidef-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | d="$( cd "$( dirname "$0" )" && cd .. && pwd )" 4 | 5 | fen="$d/../soracom-api/dist/prod/soracom-api.en.yaml" 6 | fja="$d/../soracom-api/dist/prod/soracom-api.ja.yaml" 7 | sen="$d/../soracom-api/dist/sandbox/soracom-sandbox-api.en.yaml" 8 | sja="$d/../soracom-api/dist/sandbox/soracom-sandbox-api.ja.yaml" 9 | 10 | if [ ! -f "$fen" ] || [ ! -f "$fja" ] || [ ! -f "$sen" ] || [ ! -f "$sja" ]; then 11 | echo "API definition files not found. Build soracom-api first." 12 | exit 1 13 | fi 14 | 15 | set -x 16 | cp "$fen" "$d/generators/assets/soracom-api.en.yaml" 17 | cp "$fja" "$d/generators/assets/soracom-api.ja.yaml" 18 | cp "$sen" "$d/generators/assets/sandbox/soracom-sandbox-api.en.yaml" 19 | cp "$sja" "$d/generators/assets/sandbox/soracom-sandbox-api.ja.yaml" 20 | set +x 21 | -------------------------------------------------------------------------------- /scripts/release-lambda-layer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | d="$( cd "$( dirname "$0" )" && cd .. && pwd -P )" 4 | 5 | usage() { 6 | echo "Usage: $0 [aws profile name]" 7 | } 8 | 9 | VERSION=${1:-} 10 | if [ -z "$VERSION" ]; then 11 | echo "Version number (e.g. 1.2.3) must be specified. Abort." 12 | usage 13 | exit 1 14 | fi 15 | 16 | AWS_PROFILE=${2:-} 17 | if [ -z "$AWS_PROFILE" ]; then 18 | AWS_PROFILE=soracom-dev # 'soracom-dev' is for testing, as a safe default. if you want to go production, specify 'registry' 19 | fi 20 | 21 | publish_layer() { 22 | local layer_name=$1 23 | local region=$2 24 | local arch=$3 25 | 26 | local compatible_arch=$arch 27 | if [ "$compatible_arch" == "amd64" ]; then 28 | compatible_arch="x86_64" 29 | fi 30 | 31 | cd "$d" && \ 32 | aws lambda publish-layer-version \ 33 | --layer-name "$layer_name" \ 34 | --zip-file "fileb://soracom/dist/$VERSION/lambda-layer/layer_${VERSION}_${arch}.zip" \ 35 | --description "soracom-cli version $VERSION" \ 36 | --compatible-architectures "$compatible_arch" \ 37 | --profile "$AWS_PROFILE" \ 38 | --region "$region" \ 39 | --no-cli-pager \ 40 | && cd - 41 | 42 | layer_version="$( 43 | aws lambda list-layer-versions \ 44 | --layer-name "$layer_name" \ 45 | --profile "$AWS_PROFILE" \ 46 | --region "$region" | jq -r '.LayerVersions[].Version' | sort -n -r | head -n 1 47 | )" 48 | 49 | aws lambda add-layer-version-permission \ 50 | --layer-name "$layer_name" \ 51 | --version-number "$layer_version" \ 52 | --statement-id AllowGetLayerVersion\ 53 | --principal '*' \ 54 | --action lambda:GetLayerVersion \ 55 | --profile "$AWS_PROFILE" \ 56 | --region "$region" \ 57 | --no-cli-pager 58 | } 59 | 60 | should_skip() { 61 | region=$1 62 | 63 | if [ "$region" == "ap-east-1" ]; then 64 | return 0 65 | fi 66 | 67 | return 1 68 | } 69 | 70 | while read -r region; do 71 | if should_skip "$region"; then 72 | continue 73 | fi 74 | 75 | layer_name_amd64="soracom-cli-${VERSION//./}" 76 | publish_layer "$layer_name_amd64" "$region" "amd64" 77 | 78 | layer_name_arm64="soracom-cli-${VERSION//./}-arm64" 79 | publish_layer "$layer_name_arm64" "$region" "arm64" 80 | done <<< "$( aws ec2 describe-regions --profile "$AWS_PROFILE" --region ap-northeast-1 | jq -r '.Regions[].RegionName' )" 81 | -------------------------------------------------------------------------------- /scripts/release-snap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | VERSION=$1 3 | if [ -z "$1" ]; then 4 | echo "Version number (e.g. 1.2.3) must be specified. Abort." 5 | exit 1 6 | fi 7 | 8 | set -Eeuo pipefail 9 | d="$( cd "$( dirname "$0" )" && cd .. && pwd )" 10 | 11 | docker run -it --rm -v="$d/soracom/dist/$VERSION:/mnt" snapbuild sh -c "bash /opt/release.sh $VERSION" 12 | -------------------------------------------------------------------------------- /scripts/release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | VERSION=$1 3 | if [ -z "$1" ]; then 4 | echo "Version number (e.g. 1.2.3) must be specified. Abort." 5 | exit 1 6 | fi 7 | 8 | set -Eeuo pipefail 9 | d="$( cd "$( dirname "$0" )" && cd .. && pwd )" 10 | 11 | command -v ghr > /dev/null 2>&1 || { 12 | echo "'ghr' is required." 13 | echo "Install ghr by following the instructions: https://github.com/tcnksm/ghr#install" 14 | exit 1 15 | } 16 | 17 | pushd "$d/soracom" >/dev/null 2>&1 18 | rm -f "$d/soracom/dist/$VERSION/downloads.md" 19 | ghr --prerelease --replace -u soracom -r soracom-cli "v$VERSION" "$d/soracom/dist/$VERSION/" 20 | popd >/dev/null 2>&1 21 | 22 | echo 23 | echo "Please run \`update-homebrew-formula.sh\` as soon as the release gets published" 24 | echo 25 | 26 | -------------------------------------------------------------------------------- /scripts/update-homebrew-formula.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | version=$1 3 | git_username=$2 4 | git_email=$3 5 | 6 | if [[ "$version" == "" ]] || [[ "$git_username" == "" ]] || [[ "$git_email" == "" ]]; then 7 | echo "usage: $0 " 8 | exit 1 9 | fi 10 | 11 | set -Eeuo pipefail 12 | 13 | tmpdir=$(mktemp -d) 14 | 15 | function cleanup { 16 | rm -rf "$tmpdir" 17 | } 18 | 19 | trap cleanup EXIT 20 | 21 | cd "$tmpdir" 22 | git clone git@github.com:soracom/homebrew-soracom-cli 23 | cd homebrew-soracom-cli 24 | git checkout master 25 | bash ./update-formula.sh "$version" 26 | git add soracom-cli.rb 27 | git config user.name "$git_username" 28 | git config user.email "$git_email" 29 | git commit -m "bump version" 30 | git push origin master 31 | -------------------------------------------------------------------------------- /snap/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM snapcore/snapcraft 2 | 3 | COPY *.sh /opt/ 4 | -------------------------------------------------------------------------------- /snap/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | set -x 4 | 5 | VERSION=$1 6 | 7 | cd /mnt 8 | ls 9 | 10 | generate_snapcraft_yaml() { 11 | local arch=$1 12 | goarch=$arch 13 | if [ "$goarch" == "armhf" ]; then 14 | goarch="arm" 15 | fi 16 | 17 | mkdir -p "/mnt/snap" 18 | cat < "/mnt/snap/snapcraft.yaml" 19 | name: soracom 20 | version: '$VERSION' 21 | summary: A CLI tool to use SORACOM API. 22 | description: | 23 | This is a tool to invoke SORACOM API. You can control SORACOM platform 24 | and its services automatically by using this tool. 25 | 26 | grade: stable 27 | confinement: strict 28 | architectures: 29 | - build-on: all 30 | run-on: ${arch} 31 | 32 | plugs: 33 | dot-soracom: 34 | interface: personal-files 35 | read: 36 | - \$HOME/.soracom 37 | write: 38 | - \$HOME/.soracom 39 | 40 | parts: 41 | soracom: 42 | plugin: dump 43 | source: soracom_${VERSION}_linux_${goarch}.tar.gz 44 | override-build: | 45 | chmod +x soracom 46 | snapcraftctl build 47 | 48 | apps: 49 | soracom: 50 | command: soracom 51 | plugs: 52 | - home 53 | - network 54 | - dot-soracom 55 | EOD 56 | } 57 | 58 | for arch in amd64 arm64 armhf; do 59 | generate_snapcraft_yaml "$arch" 60 | snapcraft clean soracom -s pull 61 | snapcraft 62 | done 63 | 64 | snapcraft clean 65 | -------------------------------------------------------------------------------- /snap/release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | set -x 4 | 5 | VERSION=$1 6 | 7 | snapcraft login 8 | 9 | for arch in amd64 arm64 armhf; do 10 | res="$( snapcraft upload "/mnt/soracom_${VERSION}_${arch}.snap" )" 11 | rev="$( echo "$res" | sed -rn 's/.*Revision ([0-9]+) of .* created./\1/p' )" 12 | channels=beta,edge,candidate,stable 13 | snapcraft release soracom "$rev" "$channels" 14 | done 15 | -------------------------------------------------------------------------------- /soracom/.gitignore: -------------------------------------------------------------------------------- 1 | # goxc artifacts 2 | debian/ 3 | dist/ 4 | 5 | -------------------------------------------------------------------------------- /soracom/.goxc.json: -------------------------------------------------------------------------------- 1 | { 2 | "PackageVersion": "0.0.3", 3 | "ConfigVersion": "0.9" 4 | } 5 | -------------------------------------------------------------------------------- /soracom/generated/cmd/api_credentials.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | "github.com/dvsekhvalnov/jose2go/base64url" 8 | ) 9 | 10 | type APICredentials struct { 11 | APIKey string 12 | APIToken string 13 | } 14 | 15 | func apiCredentialsFromAuthResult(ares *authResult) *APICredentials { 16 | return &APICredentials{ 17 | APIKey: ares.APIKey, 18 | APIToken: ares.Token, 19 | } 20 | } 21 | 22 | func (c *APICredentials) getOperatorID() string { 23 | if c == nil { 24 | return "" 25 | } 26 | 27 | return extractOperatorIDFromAPIToken(c.APIToken) 28 | } 29 | 30 | type jwtPayload struct { 31 | Operator jwtPayloadOperator `json:"operator"` 32 | } 33 | 34 | type jwtPayloadOperator struct { 35 | OperatorID string `json:"operatorId"` 36 | } 37 | 38 | func extractOperatorIDFromAPIToken(apiToken string) string { 39 | parts := strings.Split(apiToken, ".") 40 | if len(parts) < 2 { 41 | return "" 42 | } 43 | 44 | b64Decoded, err := base64url.Decode(parts[1]) 45 | if err != nil { 46 | return "" 47 | } 48 | 49 | var jp jwtPayload 50 | err = json.Unmarshal(b64Decoded, &jp) 51 | if err != nil { 52 | return "" 53 | } 54 | 55 | return jp.Operator.OperatorID 56 | } 57 | -------------------------------------------------------------------------------- /soracom/generated/cmd/audit_logs.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(AuditLogsCmd) 10 | } 11 | 12 | // AuditLogsCmd defines 'audit-logs' subcommand 13 | var AuditLogsCmd = &cobra.Command{ 14 | Use: "audit-logs", 15 | Short: TRCLI("cli.audit-logs.summary"), 16 | Long: TRCLI(`cli.audit-logs.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/audit_logs_api.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | AuditLogsCmd.AddCommand(AuditLogsApiCmd) 10 | } 11 | 12 | // AuditLogsApiCmd defines 'api' subcommand 13 | var AuditLogsApiCmd = &cobra.Command{ 14 | Use: "api", 15 | Short: TRCLI("cli.audit-logs.api.summary"), 16 | Long: TRCLI(`cli.audit-logs.api.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/audit_logs_napter.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | AuditLogsCmd.AddCommand(AuditLogsNapterCmd) 10 | } 11 | 12 | // AuditLogsNapterCmd defines 'napter' subcommand 13 | var AuditLogsNapterCmd = &cobra.Command{ 14 | Use: "napter", 15 | Short: TRCLI("cli.audit-logs.napter.summary"), 16 | Long: TRCLI(`cli.audit-logs.napter.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/auth_request.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | type authRequest struct { 4 | Email *string `json:"email,omitempty"` 5 | Password *string `json:"password,omitempty"` 6 | AuthKeyID *string `json:"authKeyId,omitempty"` 7 | AuthKey *string `json:"authKey,omitempty"` 8 | Username *string `json:"userName,omitempty"` 9 | OperatorID *string `json:"operatorId,omitempty"` 10 | MfaOTPCode *string `json:"mfaOTPCode,omitempty"` 11 | } 12 | 13 | func authRequestFromProfile(p *profile) *authRequest { 14 | return &authRequest{ 15 | Email: p.Email, 16 | Password: p.Password, 17 | AuthKeyID: p.AuthKeyID, 18 | AuthKey: p.AuthKey, 19 | Username: p.Username, 20 | OperatorID: p.OperatorID, 21 | MfaOTPCode: p.MfaOTPCode, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /soracom/generated/cmd/auth_result.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | type authResult struct { 4 | APIKey string `json:"apiKey"` 5 | Token string `json:"token"` 6 | OperatorID string `json:"operatorId"` 7 | } 8 | -------------------------------------------------------------------------------- /soracom/generated/cmd/bills.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(BillsCmd) 10 | } 11 | 12 | // BillsCmd defines 'bills' subcommand 13 | var BillsCmd = &cobra.Command{ 14 | Use: "bills", 15 | Short: TRCLI("cli.bills.summary"), 16 | Long: TRCLI(`cli.bills.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/bills_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // BillsGetCmdYyyyMM holds value of 'yyyyMM' option 13 | var BillsGetCmdYyyyMM string 14 | 15 | func InitBillsGetCmd() { 16 | BillsGetCmd.Flags().StringVar(&BillsGetCmdYyyyMM, "yyyy-mm", "", TRAPI("Target year and month")) 17 | 18 | BillsGetCmd.RunE = BillsGetCmdRunE 19 | 20 | BillsCmd.AddCommand(BillsGetCmd) 21 | } 22 | 23 | // BillsGetCmd defines 'get' subcommand 24 | var BillsGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/bills/{yyyyMM}:get:summary"), 27 | Long: TRAPI(`/bills/{yyyyMM}:get:description`) + "\n\n" + createLinkToAPIReference("Billing", "getBilling"), 28 | } 29 | 30 | func BillsGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectBillsGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectBillsGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("yyyyMM", "yyyy-mm", "path", parsedBody, BillsGetCmdYyyyMM) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "GET", 84 | path: buildPathForBillsGetCmd("/bills/{yyyyMM}"), 85 | query: buildQueryForBillsGetCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForBillsGetCmd(path string) string { 92 | 93 | escapedYyyyMM := url.PathEscape(BillsGetCmdYyyyMM) 94 | 95 | path = strReplace(path, "{"+"yyyyMM"+"}", escapedYyyyMM, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForBillsGetCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/bills_get_daily.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // BillsGetDailyCmdYyyyMM holds value of 'yyyyMM' option 13 | var BillsGetDailyCmdYyyyMM string 14 | 15 | func InitBillsGetDailyCmd() { 16 | BillsGetDailyCmd.Flags().StringVar(&BillsGetDailyCmdYyyyMM, "yyyy-mm", "", TRAPI("Target year and month")) 17 | 18 | BillsGetDailyCmd.RunE = BillsGetDailyCmdRunE 19 | 20 | BillsCmd.AddCommand(BillsGetDailyCmd) 21 | } 22 | 23 | // BillsGetDailyCmd defines 'get-daily' subcommand 24 | var BillsGetDailyCmd = &cobra.Command{ 25 | Use: "get-daily", 26 | Short: TRAPI("/bills/{yyyyMM}/daily:get:summary"), 27 | Long: TRAPI(`/bills/{yyyyMM}/daily:get:description`) + "\n\n" + createLinkToAPIReference("Billing", "getBillingPerDay"), 28 | } 29 | 30 | func BillsGetDailyCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectBillsGetDailyCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectBillsGetDailyCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("yyyyMM", "yyyy-mm", "path", parsedBody, BillsGetDailyCmdYyyyMM) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "GET", 84 | path: buildPathForBillsGetDailyCmd("/bills/{yyyyMM}/daily"), 85 | query: buildQueryForBillsGetDailyCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForBillsGetDailyCmd(path string) string { 92 | 93 | escapedYyyyMM := url.PathEscape(BillsGetDailyCmdYyyyMM) 94 | 95 | path = strReplace(path, "{"+"yyyyMM"+"}", escapedYyyyMM, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForBillsGetDailyCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/bills_get_latest.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitBillsGetLatestCmd() { 13 | 14 | BillsGetLatestCmd.RunE = BillsGetLatestCmdRunE 15 | 16 | BillsCmd.AddCommand(BillsGetLatestCmd) 17 | } 18 | 19 | // BillsGetLatestCmd defines 'get-latest' subcommand 20 | var BillsGetLatestCmd = &cobra.Command{ 21 | Use: "get-latest", 22 | Short: TRAPI("/bills/latest:get:summary"), 23 | Long: TRAPI(`/bills/latest:get:description`) + "\n\n" + createLinkToAPIReference("Billing", "getLatestBilling"), 24 | } 25 | 26 | func BillsGetLatestCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectBillsGetLatestCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectBillsGetLatestCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForBillsGetLatestCmd("/bills/latest"), 75 | query: buildQueryForBillsGetLatestCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForBillsGetLatestCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForBillsGetLatestCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/bills_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitBillsListCmd() { 13 | 14 | BillsListCmd.RunE = BillsListCmdRunE 15 | 16 | BillsCmd.AddCommand(BillsListCmd) 17 | } 18 | 19 | // BillsListCmd defines 'list' subcommand 20 | var BillsListCmd = &cobra.Command{ 21 | Use: "list", 22 | Short: TRAPI("/bills:get:summary"), 23 | Long: TRAPI(`/bills:get:description`) + "\n\n" + createLinkToAPIReference("Billing", "getBillingHistory"), 24 | } 25 | 26 | func BillsListCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectBillsListCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectBillsListCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForBillsListCmd("/bills"), 75 | query: buildQueryForBillsListCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForBillsListCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForBillsListCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/bills_summaries.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | BillsCmd.AddCommand(BillsSummariesCmd) 10 | } 11 | 12 | // BillsSummariesCmd defines 'summaries' subcommand 13 | var BillsSummariesCmd = &cobra.Command{ 14 | Use: "summaries", 15 | Short: TRCLI("cli.bills.summaries.summary"), 16 | Long: TRCLI(`cli.bills.summaries.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/bills_summaries_get_bill_items.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // BillsSummariesGetBillItemsCmdOutputJSONL indicates to output with jsonl format 13 | var BillsSummariesGetBillItemsCmdOutputJSONL bool 14 | 15 | func InitBillsSummariesGetBillItemsCmd() { 16 | BillsSummariesGetBillItemsCmd.Flags().BoolVar(&BillsSummariesGetBillItemsCmdOutputJSONL, "jsonl", false, TRCLI("cli.common_params.jsonl.short_help")) 17 | 18 | BillsSummariesGetBillItemsCmd.RunE = BillsSummariesGetBillItemsCmdRunE 19 | 20 | BillsSummariesCmd.AddCommand(BillsSummariesGetBillItemsCmd) 21 | } 22 | 23 | // BillsSummariesGetBillItemsCmd defines 'get-bill-items' subcommand 24 | var BillsSummariesGetBillItemsCmd = &cobra.Command{ 25 | Use: "get-bill-items", 26 | Short: TRAPI("/bills/summaries/bill_items:get:summary"), 27 | Long: TRAPI(`/bills/summaries/bill_items:get:description`) + "\n\n" + createLinkToAPIReference("Billing", "getBillingSummaryOfBillItems"), 28 | } 29 | 30 | func BillsSummariesGetBillItemsCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectBillsSummariesGetBillItemsCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | if BillsSummariesGetBillItemsCmdOutputJSONL { 70 | return printStringAsJSONL(body) 71 | } 72 | 73 | return prettyPrintStringAsJSON(body) 74 | } 75 | return err 76 | } 77 | 78 | func collectBillsSummariesGetBillItemsCmdParams(ac *apiClient) (*apiParams, error) { 79 | 80 | return &apiParams{ 81 | method: "GET", 82 | path: buildPathForBillsSummariesGetBillItemsCmd("/bills/summaries/bill_items"), 83 | query: buildQueryForBillsSummariesGetBillItemsCmd(), 84 | 85 | noRetryOnError: noRetryOnError, 86 | }, nil 87 | } 88 | 89 | func buildPathForBillsSummariesGetBillItemsCmd(path string) string { 90 | 91 | return path 92 | } 93 | 94 | func buildQueryForBillsSummariesGetBillItemsCmd() url.Values { 95 | result := url.Values{} 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/bills_summaries_get_sims.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // BillsSummariesGetSimsCmdOutputJSONL indicates to output with jsonl format 13 | var BillsSummariesGetSimsCmdOutputJSONL bool 14 | 15 | func InitBillsSummariesGetSimsCmd() { 16 | BillsSummariesGetSimsCmd.Flags().BoolVar(&BillsSummariesGetSimsCmdOutputJSONL, "jsonl", false, TRCLI("cli.common_params.jsonl.short_help")) 17 | 18 | BillsSummariesGetSimsCmd.RunE = BillsSummariesGetSimsCmdRunE 19 | 20 | BillsSummariesCmd.AddCommand(BillsSummariesGetSimsCmd) 21 | } 22 | 23 | // BillsSummariesGetSimsCmd defines 'get-sims' subcommand 24 | var BillsSummariesGetSimsCmd = &cobra.Command{ 25 | Use: "get-sims", 26 | Short: TRAPI("/bills/summaries/sims:get:summary"), 27 | Long: TRAPI(`/bills/summaries/sims:get:description`) + "\n\n" + createLinkToAPIReference("Billing", "getBillingSummaryOfSims"), 28 | } 29 | 30 | func BillsSummariesGetSimsCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectBillsSummariesGetSimsCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | if BillsSummariesGetSimsCmdOutputJSONL { 70 | return printStringAsJSONL(body) 71 | } 72 | 73 | return prettyPrintStringAsJSON(body) 74 | } 75 | return err 76 | } 77 | 78 | func collectBillsSummariesGetSimsCmdParams(ac *apiClient) (*apiParams, error) { 79 | 80 | return &apiParams{ 81 | method: "GET", 82 | path: buildPathForBillsSummariesGetSimsCmd("/bills/summaries/sims"), 83 | query: buildQueryForBillsSummariesGetSimsCmd(), 84 | 85 | noRetryOnError: noRetryOnError, 86 | }, nil 87 | } 88 | 89 | func buildPathForBillsSummariesGetSimsCmd(path string) string { 90 | 91 | return path 92 | } 93 | 94 | func buildQueryForBillsSummariesGetSimsCmd() url.Values { 95 | result := url.Values{} 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/cell_locations.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(CellLocationsCmd) 10 | } 11 | 12 | // CellLocationsCmd defines 'cell-locations' subcommand 13 | var CellLocationsCmd = &cobra.Command{ 14 | Use: "cell-locations", 15 | Short: TRCLI("cli.cell-locations.summary"), 16 | Long: TRCLI(`cli.cell-locations.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/completion.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func init() { 10 | RootCmd.AddCommand(CompletionCmd) 11 | CompletionCmd.AddCommand(completionBashCmd) 12 | CompletionCmd.AddCommand(completionZshCmd) 13 | } 14 | 15 | // CompletionCmd defines 'completion' subcommand 16 | var CompletionCmd = &cobra.Command{ 17 | Use: "completion", 18 | Short: TRCLI("cli.completion.summary"), 19 | Long: TRCLI("cli.completion.description"), 20 | RunE: func(cmd *cobra.Command, args []string) error { 21 | // For backward compatibility 22 | err := RootCmd.GenBashCompletion(os.Stdout) 23 | if err != nil { 24 | return err 25 | } 26 | return nil 27 | }, 28 | } 29 | 30 | var completionBashCmd = &cobra.Command{ 31 | Use: "bash", 32 | Short: TRCLI("cli.completion.bash.summary"), 33 | Long: TRCLI("cli.completion.bash.description"), 34 | RunE: func(cmd *cobra.Command, args []string) error { 35 | err := RootCmd.GenBashCompletion(os.Stdout) 36 | if err != nil { 37 | return err 38 | } 39 | return nil 40 | }, 41 | } 42 | 43 | var completionZshCmd = &cobra.Command{ 44 | Use: "zsh", 45 | Short: TRCLI("cli.completion.zsh.summary"), 46 | Long: TRCLI("cli.completion.zsh.description"), 47 | RunE: func(cmd *cobra.Command, args []string) error { 48 | err := RootCmd.GenZshCompletion(os.Stdout) 49 | if err != nil { 50 | return err 51 | } 52 | return nil 53 | }, 54 | } 55 | -------------------------------------------------------------------------------- /soracom/generated/cmd/configure.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import "github.com/spf13/cobra" 4 | 5 | var configureOverwrite bool 6 | 7 | func init() { 8 | ConfigureCmd.Flags().BoolVar(&configureOverwrite, "overwrite", false, TRCLI("cli.configure.overwrite")) 9 | RootCmd.AddCommand(ConfigureCmd) 10 | RootCmd.AddCommand(UnconfigureCmd) 11 | } 12 | 13 | // ConfigureCmd defines 'configure' subcommand 14 | var ConfigureCmd = &cobra.Command{ 15 | Use: "configure", 16 | Short: TRCLI("cli.configure.summary"), 17 | Long: TRCLI("cli.configure.description"), 18 | RunE: func(cmd *cobra.Command, args []string) error { 19 | pn := getSpecifiedProfileName() 20 | if pn == "" { 21 | pn = "default" 22 | } 23 | 24 | profile, err := collectProfileInfo(pn) 25 | if err != nil { 26 | cmd.SilenceUsage = true 27 | return err 28 | } 29 | 30 | err = saveProfile(pn, profile, configureOverwrite) 31 | if err != nil { 32 | cmd.SilenceUsage = true 33 | return err 34 | } 35 | 36 | return nil 37 | }, 38 | } 39 | 40 | // UnconfigureCmd defines 'unconfigure' subcommand 41 | var UnconfigureCmd = &cobra.Command{ 42 | Use: "unconfigure", 43 | Short: TRCLI("cli.unconfigure.summary"), 44 | Long: TRCLI("cli.unconfigure.description"), 45 | RunE: func(cmd *cobra.Command, args []string) error { 46 | pn := getSpecifiedProfileName() 47 | if pn == "" { 48 | pn = "default" 49 | } 50 | 51 | if confirmDeleteProfile(pn) { 52 | err := deleteProfile(pn) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | } 58 | 59 | return nil 60 | }, 61 | } 62 | -------------------------------------------------------------------------------- /soracom/generated/cmd/configure_get.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func init() { 10 | ConfigureCmd.AddCommand(ConfigureGetCmd) 11 | } 12 | 13 | // ConfigureGetCmd defineds 'get' subcommand 14 | var ConfigureGetCmd = &cobra.Command{ 15 | Use: "get", 16 | Short: TRCLI("cli.configure.get.summary"), 17 | Long: TRCLI("cli.configure.get.description"), 18 | RunE: func(cmd *cobra.Command, args []string) error { 19 | pn := getSpecifiedProfileName() 20 | if pn == "" { 21 | pn = "default" 22 | } 23 | 24 | p, err := loadProfile(pn) 25 | if err != nil { 26 | return err 27 | } 28 | 29 | return prettyPrintObjectAsJSON(p, os.Stdout) 30 | }, 31 | } 32 | -------------------------------------------------------------------------------- /soracom/generated/cmd/coupons.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(CouponsCmd) 10 | } 11 | 12 | // CouponsCmd defines 'coupons' subcommand 13 | var CouponsCmd = &cobra.Command{ 14 | Use: "coupons", 15 | Short: TRCLI("cli.coupons.summary"), 16 | Long: TRCLI(`cli.coupons.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/coupons_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitCouponsListCmd() { 13 | 14 | CouponsListCmd.RunE = CouponsListCmdRunE 15 | 16 | CouponsCmd.AddCommand(CouponsListCmd) 17 | } 18 | 19 | // CouponsListCmd defines 'list' subcommand 20 | var CouponsListCmd = &cobra.Command{ 21 | Use: "list", 22 | Short: TRAPI("/coupons:get:summary"), 23 | Long: TRAPI(`/coupons:get:description`) + "\n\n" + createLinkToAPIReference("Payment", "listCoupons"), 24 | } 25 | 26 | func CouponsListCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectCouponsListCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectCouponsListCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForCouponsListCmd("/coupons"), 75 | query: buildQueryForCouponsListCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForCouponsListCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForCouponsListCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/credentials.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(CredentialsCmd) 10 | } 11 | 12 | // CredentialsCmd defines 'credentials' subcommand 13 | var CredentialsCmd = &cobra.Command{ 14 | Use: "credentials", 15 | Short: TRCLI("cli.credentials.summary"), 16 | Long: TRCLI(`cli.credentials.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/credentials_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // CredentialsListCmdOutputJSONL indicates to output with jsonl format 13 | var CredentialsListCmdOutputJSONL bool 14 | 15 | func InitCredentialsListCmd() { 16 | CredentialsListCmd.Flags().BoolVar(&CredentialsListCmdOutputJSONL, "jsonl", false, TRCLI("cli.common_params.jsonl.short_help")) 17 | 18 | CredentialsListCmd.RunE = CredentialsListCmdRunE 19 | 20 | CredentialsCmd.AddCommand(CredentialsListCmd) 21 | } 22 | 23 | // CredentialsListCmd defines 'list' subcommand 24 | var CredentialsListCmd = &cobra.Command{ 25 | Use: "list", 26 | Short: TRAPI("/credentials:get:summary"), 27 | Long: TRAPI(`/credentials:get:description`) + "\n\n" + createLinkToAPIReference("Credential", "listCredentials"), 28 | } 29 | 30 | func CredentialsListCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectCredentialsListCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | if CredentialsListCmdOutputJSONL { 70 | return printStringAsJSONL(body) 71 | } 72 | 73 | return prettyPrintStringAsJSON(body) 74 | } 75 | return err 76 | } 77 | 78 | func collectCredentialsListCmdParams(ac *apiClient) (*apiParams, error) { 79 | 80 | return &apiParams{ 81 | method: "GET", 82 | path: buildPathForCredentialsListCmd("/credentials"), 83 | query: buildQueryForCredentialsListCmd(), 84 | 85 | noRetryOnError: noRetryOnError, 86 | }, nil 87 | } 88 | 89 | func buildPathForCredentialsListCmd(path string) string { 90 | 91 | return path 92 | } 93 | 94 | func buildQueryForCredentialsListCmd() url.Values { 95 | result := url.Values{} 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/data.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(DataCmd) 10 | } 11 | 12 | // DataCmd defines 'data' subcommand 13 | var DataCmd = &cobra.Command{ 14 | Use: "data", 15 | Short: TRCLI("cli.data.summary"), 16 | Long: TRCLI(`cli.data.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/devices.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(DevicesCmd) 10 | } 11 | 12 | // DevicesCmd defines 'devices' subcommand 13 | var DevicesCmd = &cobra.Command{ 14 | Use: "devices", 15 | Short: TRCLI("cli.devices.summary"), 16 | Long: TRCLI(`cli.devices.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/devices_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // DevicesDeleteCmdDeviceId holds value of 'device_id' option 13 | var DevicesDeleteCmdDeviceId string 14 | 15 | func InitDevicesDeleteCmd() { 16 | DevicesDeleteCmd.Flags().StringVar(&DevicesDeleteCmdDeviceId, "device-id", "", TRAPI("Device to delete")) 17 | 18 | DevicesDeleteCmd.RunE = DevicesDeleteCmdRunE 19 | 20 | DevicesCmd.AddCommand(DevicesDeleteCmd) 21 | } 22 | 23 | // DevicesDeleteCmd defines 'delete' subcommand 24 | var DevicesDeleteCmd = &cobra.Command{ 25 | Use: "delete", 26 | Short: TRAPI("/devices/{device_id}:delete:summary"), 27 | Long: TRAPI(`/devices/{device_id}:delete:description`) + "\n\n" + createLinkToAPIReference("Device", "deleteDevice"), 28 | } 29 | 30 | func DevicesDeleteCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectDevicesDeleteCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectDevicesDeleteCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("device_id", "device-id", "path", parsedBody, DevicesDeleteCmdDeviceId) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "DELETE", 84 | path: buildPathForDevicesDeleteCmd("/devices/{device_id}"), 85 | query: buildQueryForDevicesDeleteCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForDevicesDeleteCmd(path string) string { 92 | 93 | escapedDeviceId := url.PathEscape(DevicesDeleteCmdDeviceId) 94 | 95 | path = strReplace(path, "{"+"device_id"+"}", escapedDeviceId, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForDevicesDeleteCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/diagnostics.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(DiagnosticsCmd) 10 | } 11 | 12 | // DiagnosticsCmd defines 'diagnostics' subcommand 13 | var DiagnosticsCmd = &cobra.Command{ 14 | Use: "diagnostics", 15 | Short: TRCLI("cli.diagnostics.summary"), 16 | Long: TRCLI(`cli.diagnostics.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/emails.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(EmailsCmd) 10 | } 11 | 12 | // EmailsCmd defines 'emails' subcommand 13 | var EmailsCmd = &cobra.Command{ 14 | Use: "emails", 15 | Short: TRCLI("cli.emails.summary"), 16 | Long: TRCLI(`cli.emails.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/endpoint.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | // API Endpoint Specification Precedence: 8 | // 1. SORACOM_ENDPOINT env var 9 | // 2. --coverage-type argument (use coverage type default) 10 | // 3. endpoint in profile 11 | // 4. coverageType in profile (use coverage type default) 12 | 13 | func getSpecifiedEndpoint() string { 14 | e := os.Getenv("SORACOM_ENDPOINT") 15 | if e != "" { 16 | return e 17 | } 18 | 19 | ct := getSpecifiedCoverageType() 20 | profile, err := getProfile() 21 | if err != nil { 22 | return getDefaultEndpointForCoverageType(ct) 23 | } 24 | 25 | if ct != "" { 26 | if profile.Sandbox { 27 | return getDefaultSandboxEndpoint(ct) 28 | } 29 | return getDefaultEndpointForCoverageType(ct) 30 | } 31 | 32 | if profile.Endpoint != nil { 33 | return *profile.Endpoint 34 | } 35 | 36 | if profile.Sandbox { 37 | return getDefaultSandboxEndpoint(profile.CoverageType) 38 | } 39 | 40 | return getDefaultEndpointForCoverageType(profile.CoverageType) 41 | } 42 | 43 | func getDefaultEndpointForCoverageType(ct string) string { 44 | if ct == "g" { 45 | return "https://g.api.soracom.io" 46 | } 47 | return "https://api.soracom.io" 48 | } 49 | 50 | func getSpecifiedSandboxEndpoint(coverageType string) string { 51 | e := os.Getenv("SORACOM_ENDPOINT") 52 | if e != "" { 53 | return e 54 | } 55 | return getDefaultSandboxEndpoint(coverageType) 56 | } 57 | 58 | func getDefaultSandboxEndpoint(ct string) string { 59 | if ct == "g" { 60 | return "https://g.api-sandbox.soracom.io" 61 | } 62 | return "https://api-sandbox.soracom.io" 63 | } 64 | -------------------------------------------------------------------------------- /soracom/generated/cmd/event_handlers.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(EventHandlersCmd) 10 | } 11 | 12 | // EventHandlersCmd defines 'event-handlers' subcommand 13 | var EventHandlersCmd = &cobra.Command{ 14 | Use: "event-handlers", 15 | Short: TRCLI("cli.event-handlers.summary"), 16 | Long: TRCLI(`cli.event-handlers.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/files.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(FilesCmd) 10 | } 11 | 12 | // FilesCmd defines 'files' subcommand 13 | var FilesCmd = &cobra.Command{ 14 | Use: "files", 15 | Short: TRCLI("cli.files.summary"), 16 | Long: TRCLI(`cli.files.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/gadgets.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(GadgetsCmd) 10 | } 11 | 12 | // GadgetsCmd defines 'gadgets' subcommand 13 | var GadgetsCmd = &cobra.Command{ 14 | Use: "gadgets", 15 | Short: TRCLI("cli.gadgets.summary"), 16 | Long: TRCLI(`cli.gadgets.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/groups.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(GroupsCmd) 10 | } 11 | 12 | // GroupsCmd defines 'groups' subcommand 13 | var GroupsCmd = &cobra.Command{ 14 | Use: "groups", 15 | Short: TRCLI("cli.groups.summary"), 16 | Long: TRCLI(`cli.groups.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/groups_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // GroupsDeleteCmdGroupId holds value of 'group_id' option 13 | var GroupsDeleteCmdGroupId string 14 | 15 | func InitGroupsDeleteCmd() { 16 | GroupsDeleteCmd.Flags().StringVar(&GroupsDeleteCmdGroupId, "group-id", "", TRAPI("ID of the target Group.")) 17 | 18 | GroupsDeleteCmd.RunE = GroupsDeleteCmdRunE 19 | 20 | GroupsCmd.AddCommand(GroupsDeleteCmd) 21 | } 22 | 23 | // GroupsDeleteCmd defines 'delete' subcommand 24 | var GroupsDeleteCmd = &cobra.Command{ 25 | Use: "delete", 26 | Short: TRAPI("/groups/{group_id}:delete:summary"), 27 | Long: TRAPI(`/groups/{group_id}:delete:description`) + "\n\n" + createLinkToAPIReference("Group", "deleteGroup"), 28 | } 29 | 30 | func GroupsDeleteCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectGroupsDeleteCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectGroupsDeleteCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("group_id", "group-id", "path", parsedBody, GroupsDeleteCmdGroupId) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "DELETE", 84 | path: buildPathForGroupsDeleteCmd("/groups/{group_id}"), 85 | query: buildQueryForGroupsDeleteCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForGroupsDeleteCmd(path string) string { 92 | 93 | escapedGroupId := url.PathEscape(GroupsDeleteCmdGroupId) 94 | 95 | path = strReplace(path, "{"+"group_id"+"}", escapedGroupId, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForGroupsDeleteCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/groups_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // GroupsGetCmdGroupId holds value of 'group_id' option 13 | var GroupsGetCmdGroupId string 14 | 15 | func InitGroupsGetCmd() { 16 | GroupsGetCmd.Flags().StringVar(&GroupsGetCmdGroupId, "group-id", "", TRAPI("ID of the target Group.")) 17 | 18 | GroupsGetCmd.RunE = GroupsGetCmdRunE 19 | 20 | GroupsCmd.AddCommand(GroupsGetCmd) 21 | } 22 | 23 | // GroupsGetCmd defines 'get' subcommand 24 | var GroupsGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/groups/{group_id}:get:summary"), 27 | Long: TRAPI(`/groups/{group_id}:get:description`) + "\n\n" + createLinkToAPIReference("Group", "getGroup"), 28 | } 29 | 30 | func GroupsGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectGroupsGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectGroupsGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("group_id", "group-id", "path", parsedBody, GroupsGetCmdGroupId) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "GET", 84 | path: buildPathForGroupsGetCmd("/groups/{group_id}"), 85 | query: buildQueryForGroupsGetCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForGroupsGetCmd(path string) string { 92 | 93 | escapedGroupId := url.PathEscape(GroupsGetCmdGroupId) 94 | 95 | path = strReplace(path, "{"+"group_id"+"}", escapedGroupId, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForGroupsGetCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/harvest_files_path_escape.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "net/url" 5 | "strings" 6 | ) 7 | 8 | func harvestFilesPathEscape(path string) string { 9 | result := []string{} 10 | for _, s := range strings.Split(path, "/") { 11 | if s == "" { 12 | continue 13 | } 14 | result = append(result, url.PathEscape(s)) 15 | } 16 | return strings.Join(result, "/") 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/harvest_files_path_escape_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestHarvestFilesPathEscape(t *testing.T) { 8 | var testData = []struct { 9 | Name string 10 | Path string 11 | Expected string 12 | }{ 13 | { 14 | Name: "pattern 1", 15 | Path: "hoge", 16 | Expected: "hoge", 17 | }, 18 | } 19 | 20 | for _, data := range testData { 21 | data := data // capture 22 | t.Run(data.Name, func(t *testing.T) { 23 | t.Parallel() 24 | 25 | v := harvestFilesPathEscape(data.Path) 26 | if v != data.Expected { 27 | t.Errorf("result of harvestFilesPathEscape() is unmatched with expected.\nArg: %s\nExpected: %s\nActual: %s", data.Path, data.Expected, v) 28 | } 29 | }) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lagoon.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(LagoonCmd) 10 | } 11 | 12 | // LagoonCmd defines 'lagoon' subcommand 13 | var LagoonCmd = &cobra.Command{ 14 | Use: "lagoon", 15 | Short: TRCLI("cli.lagoon.summary"), 16 | Long: TRCLI(`cli.lagoon.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lagoon_get_image_link.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitLagoonGetImageLinkCmd() { 13 | 14 | LagoonGetImageLinkCmd.RunE = LagoonGetImageLinkCmdRunE 15 | 16 | LagoonCmd.AddCommand(LagoonGetImageLinkCmd) 17 | } 18 | 19 | // LagoonGetImageLinkCmd defines 'get-image-link' subcommand 20 | var LagoonGetImageLinkCmd = &cobra.Command{ 21 | Use: "get-image-link", 22 | Short: TRAPI("/lagoon/image/link:get:summary"), 23 | Long: TRAPI(`/lagoon/image/link:get:description`) + "\n\n" + createLinkToAPIReference("Lagoon", "getImageLink"), 24 | } 25 | 26 | func LagoonGetImageLinkCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectLagoonGetImageLinkCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectLagoonGetImageLinkCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForLagoonGetImageLinkCmd("/lagoon/image/link"), 75 | query: buildQueryForLagoonGetImageLinkCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForLagoonGetImageLinkCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForLagoonGetImageLinkCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lagoon_license_packs.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | LagoonCmd.AddCommand(LagoonLicensePacksCmd) 10 | } 11 | 12 | // LagoonLicensePacksCmd defines 'license-packs' subcommand 13 | var LagoonLicensePacksCmd = &cobra.Command{ 14 | Use: "license-packs", 15 | Short: TRCLI("cli.lagoon.license-packs.summary"), 16 | Long: TRCLI(`cli.lagoon.license-packs.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lagoon_license_packs_list_status.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // LagoonLicensePacksListStatusCmdOutputJSONL indicates to output with jsonl format 13 | var LagoonLicensePacksListStatusCmdOutputJSONL bool 14 | 15 | func InitLagoonLicensePacksListStatusCmd() { 16 | LagoonLicensePacksListStatusCmd.Flags().BoolVar(&LagoonLicensePacksListStatusCmdOutputJSONL, "jsonl", false, TRCLI("cli.common_params.jsonl.short_help")) 17 | 18 | LagoonLicensePacksListStatusCmd.RunE = LagoonLicensePacksListStatusCmdRunE 19 | 20 | LagoonLicensePacksCmd.AddCommand(LagoonLicensePacksListStatusCmd) 21 | } 22 | 23 | // LagoonLicensePacksListStatusCmd defines 'list-status' subcommand 24 | var LagoonLicensePacksListStatusCmd = &cobra.Command{ 25 | Use: "list-status", 26 | Short: TRAPI("/lagoon/license_packs:get:summary"), 27 | Long: TRAPI(`/lagoon/license_packs:get:description`) + "\n\n" + createLinkToAPIReference("Lagoon", "listLagoonLicensePackStatus"), 28 | } 29 | 30 | func LagoonLicensePacksListStatusCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectLagoonLicensePacksListStatusCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | if LagoonLicensePacksListStatusCmdOutputJSONL { 70 | return printStringAsJSONL(body) 71 | } 72 | 73 | return prettyPrintStringAsJSON(body) 74 | } 75 | return err 76 | } 77 | 78 | func collectLagoonLicensePacksListStatusCmdParams(ac *apiClient) (*apiParams, error) { 79 | 80 | return &apiParams{ 81 | method: "GET", 82 | path: buildPathForLagoonLicensePacksListStatusCmd("/lagoon/license_packs"), 83 | query: buildQueryForLagoonLicensePacksListStatusCmd(), 84 | 85 | noRetryOnError: noRetryOnError, 86 | }, nil 87 | } 88 | 89 | func buildPathForLagoonLicensePacksListStatusCmd(path string) string { 90 | 91 | return path 92 | } 93 | 94 | func buildQueryForLagoonLicensePacksListStatusCmd() url.Values { 95 | result := url.Values{} 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lagoon_list_users.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // LagoonListUsersCmdOutputJSONL indicates to output with jsonl format 13 | var LagoonListUsersCmdOutputJSONL bool 14 | 15 | func InitLagoonListUsersCmd() { 16 | LagoonListUsersCmd.Flags().BoolVar(&LagoonListUsersCmdOutputJSONL, "jsonl", false, TRCLI("cli.common_params.jsonl.short_help")) 17 | 18 | LagoonListUsersCmd.RunE = LagoonListUsersCmdRunE 19 | 20 | LagoonCmd.AddCommand(LagoonListUsersCmd) 21 | } 22 | 23 | // LagoonListUsersCmd defines 'list-users' subcommand 24 | var LagoonListUsersCmd = &cobra.Command{ 25 | Use: "list-users", 26 | Short: TRAPI("/lagoon/users:get:summary"), 27 | Long: TRAPI(`/lagoon/users:get:description`) + "\n\n" + createLinkToAPIReference("Lagoon", "listLagoonUsers"), 28 | } 29 | 30 | func LagoonListUsersCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectLagoonListUsersCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | if LagoonListUsersCmdOutputJSONL { 70 | return printStringAsJSONL(body) 71 | } 72 | 73 | return prettyPrintStringAsJSON(body) 74 | } 75 | return err 76 | } 77 | 78 | func collectLagoonListUsersCmdParams(ac *apiClient) (*apiParams, error) { 79 | 80 | return &apiParams{ 81 | method: "GET", 82 | path: buildPathForLagoonListUsersCmd("/lagoon/users"), 83 | query: buildQueryForLagoonListUsersCmd(), 84 | 85 | noRetryOnError: noRetryOnError, 86 | }, nil 87 | } 88 | 89 | func buildPathForLagoonListUsersCmd(path string) string { 90 | 91 | return path 92 | } 93 | 94 | func buildQueryForLagoonListUsersCmd() url.Values { 95 | result := url.Values{} 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lagoon_terminate.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitLagoonTerminateCmd() { 13 | 14 | LagoonTerminateCmd.RunE = LagoonTerminateCmdRunE 15 | 16 | LagoonCmd.AddCommand(LagoonTerminateCmd) 17 | } 18 | 19 | // LagoonTerminateCmd defines 'terminate' subcommand 20 | var LagoonTerminateCmd = &cobra.Command{ 21 | Use: "terminate", 22 | Short: TRAPI("/lagoon/terminate:post:summary"), 23 | Long: TRAPI(`/lagoon/terminate:post:description`) + "\n\n" + createLinkToAPIReference("Lagoon", "terminateLagoon"), 24 | } 25 | 26 | func LagoonTerminateCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectLagoonTerminateCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectLagoonTerminateCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "POST", 74 | path: buildPathForLagoonTerminateCmd("/lagoon/terminate"), 75 | query: buildQueryForLagoonTerminateCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForLagoonTerminateCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForLagoonTerminateCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lagoon_users.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | LagoonCmd.AddCommand(LagoonUsersCmd) 10 | } 11 | 12 | // LagoonUsersCmd defines 'users' subcommand 13 | var LagoonUsersCmd = &cobra.Command{ 14 | Use: "users", 15 | Short: TRCLI("cli.lagoon.users.summary"), 16 | Long: TRCLI(`cli.lagoon.users.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lagoon_users_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // LagoonUsersListCmdOutputJSONL indicates to output with jsonl format 13 | var LagoonUsersListCmdOutputJSONL bool 14 | 15 | func InitLagoonUsersListCmd() { 16 | LagoonUsersListCmd.Flags().BoolVar(&LagoonUsersListCmdOutputJSONL, "jsonl", false, TRCLI("cli.common_params.jsonl.short_help")) 17 | 18 | LagoonUsersListCmd.RunE = LagoonUsersListCmdRunE 19 | 20 | LagoonUsersCmd.AddCommand(LagoonUsersListCmd) 21 | } 22 | 23 | // LagoonUsersListCmd defines 'list' subcommand 24 | var LagoonUsersListCmd = &cobra.Command{ 25 | Use: "list", 26 | Short: TRAPI("/lagoon/users:get:summary"), 27 | Long: TRAPI(`/lagoon/users:get:description`) + "\n\n" + createLinkToAPIReference("Lagoon", "listLagoonUsers"), 28 | } 29 | 30 | func LagoonUsersListCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectLagoonUsersListCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | if LagoonUsersListCmdOutputJSONL { 70 | return printStringAsJSONL(body) 71 | } 72 | 73 | return prettyPrintStringAsJSON(body) 74 | } 75 | return err 76 | } 77 | 78 | func collectLagoonUsersListCmdParams(ac *apiClient) (*apiParams, error) { 79 | 80 | return &apiParams{ 81 | method: "GET", 82 | path: buildPathForLagoonUsersListCmd("/lagoon/users"), 83 | query: buildQueryForLagoonUsersListCmd(), 84 | 85 | noRetryOnError: noRetryOnError, 86 | }, nil 87 | } 88 | 89 | func buildPathForLagoonUsersListCmd(path string) string { 90 | 91 | return path 92 | } 93 | 94 | func buildQueryForLagoonUsersListCmd() url.Values { 95 | result := url.Values{} 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/logout.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitLogoutCmd() { 13 | 14 | LogoutCmd.RunE = LogoutCmdRunE 15 | 16 | RootCmd.AddCommand(LogoutCmd) 17 | } 18 | 19 | // LogoutCmd defines 'logout' subcommand 20 | var LogoutCmd = &cobra.Command{ 21 | Use: "logout", 22 | Short: TRAPI("/auth/logout:post:summary"), 23 | Long: TRAPI(`/auth/logout:post:description`) + "\n\n" + createLinkToAPIReference("Auth", "logout"), 24 | } 25 | 26 | func LogoutCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectLogoutCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectLogoutCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "POST", 74 | path: buildPathForLogoutCmd("/auth/logout"), 75 | query: buildQueryForLogoutCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForLogoutCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForLogoutCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/logs.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(LogsCmd) 10 | } 11 | 12 | // LogsCmd defines 'logs' subcommand 13 | var LogsCmd = &cobra.Command{ 14 | Use: "logs", 15 | Short: TRCLI("cli.logs.summary"), 16 | Long: TRCLI(`cli.logs.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lora_devices.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(LoraDevicesCmd) 10 | } 11 | 12 | // LoraDevicesCmd defines 'lora-devices' subcommand 13 | var LoraDevicesCmd = &cobra.Command{ 14 | Use: "lora-devices", 15 | Short: TRCLI("cli.lora-devices.summary"), 16 | Long: TRCLI(`cli.lora-devices.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lora_gateways.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(LoraGatewaysCmd) 10 | } 11 | 12 | // LoraGatewaysCmd defines 'lora-gateways' subcommand 13 | var LoraGatewaysCmd = &cobra.Command{ 14 | Use: "lora-gateways", 15 | Short: TRCLI("cli.lora-gateways.summary"), 16 | Long: TRCLI(`cli.lora-gateways.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/lora_network_sets.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(LoraNetworkSetsCmd) 10 | } 11 | 12 | // LoraNetworkSetsCmd defines 'lora-network-sets' subcommand 13 | var LoraNetworkSetsCmd = &cobra.Command{ 14 | Use: "lora-network-sets", 15 | Short: TRCLI("cli.lora-network-sets.summary"), 16 | Long: TRCLI(`cli.lora-network-sets.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/operator.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(OperatorCmd) 10 | } 11 | 12 | // OperatorCmd defines 'operator' subcommand 13 | var OperatorCmd = &cobra.Command{ 14 | Use: "operator", 15 | Short: TRCLI("cli.operator.summary"), 16 | Long: TRCLI(`cli.operator.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/operator_auth_keys.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | OperatorCmd.AddCommand(OperatorAuthKeysCmd) 10 | } 11 | 12 | // OperatorAuthKeysCmd defines 'auth-keys' subcommand 13 | var OperatorAuthKeysCmd = &cobra.Command{ 14 | Use: "auth-keys", 15 | Short: TRCLI("cli.operator.auth-keys.summary"), 16 | Long: TRCLI(`cli.operator.auth-keys.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/operator_configuration.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | OperatorCmd.AddCommand(OperatorConfigurationCmd) 10 | } 11 | 12 | // OperatorConfigurationCmd defines 'configuration' subcommand 13 | var OperatorConfigurationCmd = &cobra.Command{ 14 | Use: "configuration", 15 | Short: TRCLI("cli.operator.configuration.summary"), 16 | Long: TRCLI(`cli.operator.configuration.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/operator_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // OperatorGetCmdOperatorId holds value of 'operator_id' option 13 | var OperatorGetCmdOperatorId string 14 | 15 | func InitOperatorGetCmd() { 16 | OperatorGetCmd.Flags().StringVar(&OperatorGetCmdOperatorId, "operator-id", "", TRAPI("Operator ID.")) 17 | 18 | OperatorGetCmd.RunE = OperatorGetCmdRunE 19 | 20 | OperatorCmd.AddCommand(OperatorGetCmd) 21 | } 22 | 23 | // OperatorGetCmd defines 'get' subcommand 24 | var OperatorGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/operators/{operator_id}:get:summary"), 27 | Long: TRAPI(`/operators/{operator_id}:get:description`) + "\n\n" + createLinkToAPIReference("Operator", "getOperator"), 28 | } 29 | 30 | func OperatorGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectOperatorGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectOperatorGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | if OperatorGetCmdOperatorId == "" { 76 | OperatorGetCmdOperatorId = ac.apiCredentials.getOperatorID() 77 | } 78 | 79 | return &apiParams{ 80 | method: "GET", 81 | path: buildPathForOperatorGetCmd("/operators/{operator_id}"), 82 | query: buildQueryForOperatorGetCmd(), 83 | 84 | noRetryOnError: noRetryOnError, 85 | }, nil 86 | } 87 | 88 | func buildPathForOperatorGetCmd(path string) string { 89 | 90 | escapedOperatorId := url.PathEscape(OperatorGetCmdOperatorId) 91 | 92 | path = strReplace(path, "{"+"operator_id"+"}", escapedOperatorId, -1) 93 | 94 | return path 95 | } 96 | 97 | func buildQueryForOperatorGetCmd() url.Values { 98 | result := url.Values{} 99 | 100 | return result 101 | } 102 | -------------------------------------------------------------------------------- /soracom/generated/cmd/orders.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(OrdersCmd) 10 | } 11 | 12 | // OrdersCmd defines 'orders' subcommand 13 | var OrdersCmd = &cobra.Command{ 14 | Use: "orders", 15 | Short: TRCLI("cli.orders.summary"), 16 | Long: TRCLI(`cli.orders.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/orders_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // OrdersGetCmdOrderId holds value of 'order_id' option 13 | var OrdersGetCmdOrderId string 14 | 15 | func InitOrdersGetCmd() { 16 | OrdersGetCmd.Flags().StringVar(&OrdersGetCmdOrderId, "order-id", "", TRAPI("Order ID. You can get it by calling [Order:listOrders API](#!/Order/listOrders).")) 17 | 18 | OrdersGetCmd.RunE = OrdersGetCmdRunE 19 | 20 | OrdersCmd.AddCommand(OrdersGetCmd) 21 | } 22 | 23 | // OrdersGetCmd defines 'get' subcommand 24 | var OrdersGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/orders/{order_id}:get:summary"), 27 | Long: TRAPI(`/orders/{order_id}:get:description`) + "\n\n" + createLinkToAPIReference("Order", "getOrder"), 28 | } 29 | 30 | func OrdersGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectOrdersGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectOrdersGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("order_id", "order-id", "path", parsedBody, OrdersGetCmdOrderId) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "GET", 84 | path: buildPathForOrdersGetCmd("/orders/{order_id}"), 85 | query: buildQueryForOrdersGetCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForOrdersGetCmd(path string) string { 92 | 93 | escapedOrderId := url.PathEscape(OrdersGetCmdOrderId) 94 | 95 | path = strReplace(path, "{"+"order_id"+"}", escapedOrderId, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForOrdersGetCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/orders_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitOrdersListCmd() { 13 | 14 | OrdersListCmd.RunE = OrdersListCmdRunE 15 | 16 | OrdersCmd.AddCommand(OrdersListCmd) 17 | } 18 | 19 | // OrdersListCmd defines 'list' subcommand 20 | var OrdersListCmd = &cobra.Command{ 21 | Use: "list", 22 | Short: TRAPI("/orders:get:summary"), 23 | Long: TRAPI(`/orders:get:description`) + "\n\n" + createLinkToAPIReference("Order", "listOrders"), 24 | } 25 | 26 | func OrdersListCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectOrdersListCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectOrdersListCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForOrdersListCmd("/orders"), 75 | query: buildQueryForOrdersListCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForOrdersListCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForOrdersListCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/orders_resource_initial_setting.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | OrdersCmd.AddCommand(OrdersResourceInitialSettingCmd) 10 | } 11 | 12 | // OrdersResourceInitialSettingCmd defines 'resource-initial-setting' subcommand 13 | var OrdersResourceInitialSettingCmd = &cobra.Command{ 14 | Use: "resource-initial-setting", 15 | Short: TRCLI("cli.orders.resource-initial-setting.summary"), 16 | Long: TRCLI(`cli.orders.resource-initial-setting.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/payer_information.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(PayerInformationCmd) 10 | } 11 | 12 | // PayerInformationCmd defines 'payer-information' subcommand 13 | var PayerInformationCmd = &cobra.Command{ 14 | Use: "payer-information", 15 | Short: TRCLI("cli.payer-information.summary"), 16 | Long: TRCLI(`cli.payer-information.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/payer_information_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitPayerInformationGetCmd() { 13 | 14 | PayerInformationGetCmd.RunE = PayerInformationGetCmdRunE 15 | 16 | PayerInformationCmd.AddCommand(PayerInformationGetCmd) 17 | } 18 | 19 | // PayerInformationGetCmd defines 'get' subcommand 20 | var PayerInformationGetCmd = &cobra.Command{ 21 | Use: "get", 22 | Short: TRAPI("/payment_statements/payer_information:get:summary"), 23 | Long: TRAPI(`/payment_statements/payer_information:get:description`) + "\n\n" + createLinkToAPIReference("Payment", "getPayerInformation"), 24 | } 25 | 26 | func PayerInformationGetCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectPayerInformationGetCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectPayerInformationGetCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForPayerInformationGetCmd("/payment_statements/payer_information"), 75 | query: buildQueryForPayerInformationGetCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForPayerInformationGetCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForPayerInformationGetCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/payment_history.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(PaymentHistoryCmd) 10 | } 11 | 12 | // PaymentHistoryCmd defines 'payment-history' subcommand 13 | var PaymentHistoryCmd = &cobra.Command{ 14 | Use: "payment-history", 15 | Short: TRCLI("cli.payment-history.summary"), 16 | Long: TRCLI(`cli.payment-history.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/payment_methods.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(PaymentMethodsCmd) 10 | } 11 | 12 | // PaymentMethodsCmd defines 'payment-methods' subcommand 13 | var PaymentMethodsCmd = &cobra.Command{ 14 | Use: "payment-methods", 15 | Short: TRCLI("cli.payment-methods.summary"), 16 | Long: TRCLI(`cli.payment-methods.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/payment_methods_get_current.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitPaymentMethodsGetCurrentCmd() { 13 | 14 | PaymentMethodsGetCurrentCmd.RunE = PaymentMethodsGetCurrentCmdRunE 15 | 16 | PaymentMethodsCmd.AddCommand(PaymentMethodsGetCurrentCmd) 17 | } 18 | 19 | // PaymentMethodsGetCurrentCmd defines 'get-current' subcommand 20 | var PaymentMethodsGetCurrentCmd = &cobra.Command{ 21 | Use: "get-current", 22 | Short: TRAPI("/payment_methods/current:get:summary"), 23 | Long: TRAPI(`/payment_methods/current:get:description`) + "\n\n" + createLinkToAPIReference("Payment", "getPaymentMethod"), 24 | } 25 | 26 | func PaymentMethodsGetCurrentCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectPaymentMethodsGetCurrentCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectPaymentMethodsGetCurrentCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForPaymentMethodsGetCurrentCmd("/payment_methods/current"), 75 | query: buildQueryForPaymentMethodsGetCurrentCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForPaymentMethodsGetCurrentCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForPaymentMethodsGetCurrentCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/payment_methods_reactivate_current.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitPaymentMethodsReactivateCurrentCmd() { 13 | 14 | PaymentMethodsReactivateCurrentCmd.RunE = PaymentMethodsReactivateCurrentCmdRunE 15 | 16 | PaymentMethodsCmd.AddCommand(PaymentMethodsReactivateCurrentCmd) 17 | } 18 | 19 | // PaymentMethodsReactivateCurrentCmd defines 'reactivate-current' subcommand 20 | var PaymentMethodsReactivateCurrentCmd = &cobra.Command{ 21 | Use: "reactivate-current", 22 | Short: TRAPI("/payment_methods/current/activate:post:summary"), 23 | Long: TRAPI(`/payment_methods/current/activate:post:description`) + "\n\n" + createLinkToAPIReference("Payment", "activatePaymentMethod"), 24 | } 25 | 26 | func PaymentMethodsReactivateCurrentCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectPaymentMethodsReactivateCurrentCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectPaymentMethodsReactivateCurrentCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "POST", 74 | path: buildPathForPaymentMethodsReactivateCurrentCmd("/payment_methods/current/activate"), 75 | query: buildQueryForPaymentMethodsReactivateCurrentCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForPaymentMethodsReactivateCurrentCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForPaymentMethodsReactivateCurrentCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/payment_statements.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(PaymentStatementsCmd) 10 | } 11 | 12 | // PaymentStatementsCmd defines 'payment-statements' subcommand 13 | var PaymentStatementsCmd = &cobra.Command{ 14 | Use: "payment-statements", 15 | Short: TRCLI("cli.payment-statements.summary"), 16 | Long: TRCLI(`cli.payment-statements.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/payment_statements_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitPaymentStatementsListCmd() { 13 | 14 | PaymentStatementsListCmd.RunE = PaymentStatementsListCmdRunE 15 | 16 | PaymentStatementsCmd.AddCommand(PaymentStatementsListCmd) 17 | } 18 | 19 | // PaymentStatementsListCmd defines 'list' subcommand 20 | var PaymentStatementsListCmd = &cobra.Command{ 21 | Use: "list", 22 | Short: TRAPI("/payment_statements:get:summary"), 23 | Long: TRAPI(`/payment_statements:get:description`) + "\n\n" + createLinkToAPIReference("Payment", "listPaymentStatements"), 24 | } 25 | 26 | func PaymentStatementsListCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectPaymentStatementsListCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectPaymentStatementsListCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForPaymentStatementsListCmd("/payment_statements"), 75 | query: buildQueryForPaymentStatementsListCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForPaymentStatementsListCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForPaymentStatementsListCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/port_mappings.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(PortMappingsCmd) 10 | } 11 | 12 | // PortMappingsCmd defines 'port-mappings' subcommand 13 | var PortMappingsCmd = &cobra.Command{ 14 | Use: "port-mappings", 15 | Short: TRCLI("cli.port-mappings.summary"), 16 | Long: TRCLI(`cli.port-mappings.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/pretty_print_json.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io" 7 | "os" 8 | "strings" 9 | ) 10 | 11 | func prettyPrintStringAsJSON(rawJSON string) error { 12 | return prettyPrintStringAsJSONToWriter(rawJSON, os.Stdout) 13 | } 14 | 15 | func prettyPrintStringAsJSONToWriter(rawJSON string, w io.Writer) error { 16 | var obj interface{} 17 | 18 | d := json.NewDecoder(strings.NewReader(rawJSON)) 19 | d.UseNumber() 20 | err := d.Decode(&obj) 21 | if err != nil { 22 | return err 23 | } 24 | return prettyPrintObjectAsJSON(obj, w) 25 | } 26 | 27 | func prettyPrintObjectAsJSON(obj interface{}, w io.Writer) error { 28 | var bb bytes.Buffer 29 | e := json.NewEncoder(&bb) 30 | e.SetEscapeHTML(false) 31 | e.SetIndent("", "\t") 32 | err := e.Encode(obj) 33 | if err != nil { 34 | return err 35 | } 36 | 37 | _, err = bb.WriteTo(w) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | return nil 43 | } 44 | 45 | func printStringAsJSONL(rawJSON string) error { 46 | return printStringAsJSONLToWriter(rawJSON, os.Stdout) 47 | } 48 | 49 | func printStringAsJSONLToWriter(rawJSON string, w io.Writer) error { 50 | var arr []interface{} 51 | 52 | d := json.NewDecoder(strings.NewReader(rawJSON)) 53 | d.UseNumber() 54 | err := d.Decode(&arr) 55 | if err != nil { 56 | return err 57 | } 58 | 59 | for _, obj := range arr { 60 | err = printObjectOneLine(obj, w) 61 | if err != nil { 62 | return err 63 | } 64 | } 65 | 66 | return nil 67 | } 68 | 69 | func printObjectOneLine(obj interface{}, w io.Writer) error { 70 | var bb bytes.Buffer 71 | e := json.NewEncoder(&bb) 72 | e.SetEscapeHTML(false) 73 | err := e.Encode(obj) 74 | if err != nil { 75 | return err 76 | } 77 | 78 | _, err = bb.WriteTo(w) 79 | if err != nil { 80 | return err 81 | } 82 | 83 | return nil 84 | } 85 | -------------------------------------------------------------------------------- /soracom/generated/cmd/pretty_print_json_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/tj/assert" 8 | ) 9 | 10 | func TestPrintStringAsJSONL(t *testing.T) { 11 | data1 := `[{"a":1},{"b":2},{"c":3}]` 12 | expected := `{"a":1} 13 | {"b":2} 14 | {"c":3} 15 | ` 16 | out1 := new(bytes.Buffer) 17 | err := printStringAsJSONLToWriter(data1, out1) 18 | assert.NoError(t, err) 19 | assert.Equal(t, expected, out1.String()) 20 | 21 | noArray1 := `{"a":1,"b":2}` 22 | out2 := new(bytes.Buffer) 23 | err = printStringAsJSONLToWriter(noArray1, out2) 24 | assert.Error(t, err) 25 | } 26 | -------------------------------------------------------------------------------- /soracom/generated/cmd/products.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(ProductsCmd) 10 | } 11 | 12 | // ProductsCmd defines 'products' subcommand 13 | var ProductsCmd = &cobra.Command{ 14 | Use: "products", 15 | Short: TRCLI("cli.products.summary"), 16 | Long: TRCLI(`cli.products.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/products_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // ProductsListCmdCampaignCode holds value of 'campaign_code' option 13 | var ProductsListCmdCampaignCode string 14 | 15 | func InitProductsListCmd() { 16 | ProductsListCmd.Flags().StringVar(&ProductsListCmdCampaignCode, "campaign-code", "", TRAPI("")) 17 | 18 | ProductsListCmd.RunE = ProductsListCmdRunE 19 | 20 | ProductsCmd.AddCommand(ProductsListCmd) 21 | } 22 | 23 | // ProductsListCmd defines 'list' subcommand 24 | var ProductsListCmd = &cobra.Command{ 25 | Use: "list", 26 | Short: TRAPI("/products:get:summary"), 27 | Long: TRAPI(`/products:get:description`) + "\n\n" + createLinkToAPIReference("Order", "listProducts"), 28 | } 29 | 30 | func ProductsListCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectProductsListCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectProductsListCmdParams(ac *apiClient) (*apiParams, error) { 75 | 76 | return &apiParams{ 77 | method: "GET", 78 | path: buildPathForProductsListCmd("/products"), 79 | query: buildQueryForProductsListCmd(), 80 | 81 | noRetryOnError: noRetryOnError, 82 | }, nil 83 | } 84 | 85 | func buildPathForProductsListCmd(path string) string { 86 | 87 | return path 88 | } 89 | 90 | func buildQueryForProductsListCmd() url.Values { 91 | result := url.Values{} 92 | 93 | if ProductsListCmdCampaignCode != "" { 94 | result.Add("campaign_code", ProductsListCmdCampaignCode) 95 | } 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/profiles_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func TestGetProfileFromExternalCommand(t *testing.T) { 11 | email := "test@example.com" 12 | password := "testpassword" 13 | authKeyID := "testKeyID" 14 | authKey := "testAuthKey" 15 | username := "testUsername" 16 | operatorID := "testOperatorID" 17 | 18 | command := fmt.Sprintf("/bin/echo \"{\\\"email\\\": \\\"%s\\\",\\\"password\\\": \\\"%s\\\",\\\"authKeyId\\\": \\\"%s\\\",\\\"authKey\\\": \\\"%s\\\",\\\"userName\\\": \\\"%s\\\",\\\"operatorId\\\": \\\"%s\\\"}\"", email, password, authKeyID, authKey, username, operatorID) 19 | p, err := getProfileFromExternalCommand(command) 20 | 21 | if !assert.NoError(t, err) { 22 | t.FailNow() 23 | } 24 | assert.EqualValues(t, email, *(p.Email)) 25 | assert.EqualValues(t, password, *(p.Password)) 26 | assert.EqualValues(t, authKeyID, *(p.AuthKeyID)) 27 | assert.EqualValues(t, authKey, *(p.AuthKey)) 28 | assert.EqualValues(t, username, *(p.Username)) 29 | assert.EqualValues(t, operatorID, *(p.OperatorID)) 30 | } 31 | -------------------------------------------------------------------------------- /soracom/generated/cmd/prompt.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bufio" 5 | "os" 6 | "strings" 7 | ) 8 | 9 | // XXX: visible for testing 10 | var promptStdin = os.Stdin 11 | 12 | // readConfirmationPrompt returns true when the input value is 'y', 'Y', or empty. 13 | func readDefaultYesConfirmationPrompt() (bool, error) { 14 | s, err := readLine() 15 | if err != nil { 16 | return false, err 17 | } 18 | return s == "" || strings.ToLower(s) == "y", nil 19 | } 20 | 21 | // readConfirmationPrompt returns true when the input value is 'y', 'Y'. 22 | func readDefaultNoConfirmationPrompt() (bool, error) { 23 | s, err := readLine() 24 | if err != nil { 25 | return false, err 26 | } 27 | return s != "" && strings.ToLower(s) == "y", nil 28 | } 29 | 30 | func readLine() (string, error) { 31 | reader := bufio.NewReader(promptStdin) 32 | s, err := reader.ReadString('\n') 33 | if err != nil { 34 | return "", err 35 | } 36 | 37 | return strings.TrimSpace(s), nil 38 | } 39 | -------------------------------------------------------------------------------- /soracom/generated/cmd/prompt_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "testing" 7 | 8 | "github.com/stretchr/testify/assert" 9 | ) 10 | 11 | func TestReadDefaultYesConfirmationPrompt(t *testing.T) { 12 | type test struct { 13 | input string 14 | expected bool 15 | } 16 | 17 | tests := []*test{ 18 | {input: "y", expected: true}, 19 | {input: "Y", expected: true}, 20 | {input: "", expected: true}, 21 | {input: "n", expected: false}, 22 | {input: "o", expected: false}, 23 | } 24 | 25 | tempFile, err := os.CreateTemp("", "") 26 | assert.NoError(t, err) 27 | originalPromptStdin := promptStdin 28 | promptStdin = tempFile 29 | defer func() { 30 | promptStdin = originalPromptStdin 31 | _ = os.Remove(tempFile.Name()) 32 | }() 33 | 34 | for _, testCase := range tests { 35 | _, err = tempFile.WriteString(fmt.Sprintf("%s\n", testCase.input)) 36 | assert.NoError(t, err) 37 | _, err = tempFile.Seek(0, 0) 38 | assert.NoError(t, err) 39 | 40 | yes, err := readDefaultYesConfirmationPrompt() 41 | assert.NoError(t, err) 42 | assert.Equal(t, testCase.expected, yes) 43 | 44 | err = tempFile.Truncate(0) 45 | assert.NoError(t, err) 46 | _, err = tempFile.Seek(0, 0) 47 | assert.NoError(t, err) 48 | } 49 | 50 | _ = tempFile.Close() 51 | } 52 | 53 | func TestReadDefaultNoConfirmationPrompt(t *testing.T) { 54 | type test struct { 55 | input string 56 | expected bool 57 | } 58 | 59 | tests := []*test{ 60 | {input: "y", expected: true}, 61 | {input: "Y", expected: true}, 62 | {input: "", expected: false}, 63 | {input: "n", expected: false}, 64 | {input: "o", expected: false}, 65 | } 66 | 67 | tempFile, err := os.CreateTemp("", "") 68 | assert.NoError(t, err) 69 | originalPromptStdin := promptStdin 70 | promptStdin = tempFile 71 | defer func() { 72 | promptStdin = originalPromptStdin 73 | _ = os.Remove(tempFile.Name()) 74 | }() 75 | 76 | for _, testCase := range tests { 77 | _, err = tempFile.WriteString(fmt.Sprintf("%s\n", testCase.input)) 78 | assert.NoError(t, err) 79 | _, err = tempFile.Seek(0, 0) 80 | assert.NoError(t, err) 81 | 82 | yes, err := readDefaultNoConfirmationPrompt() 83 | assert.NoError(t, err) 84 | assert.Equal(t, testCase.expected, yes) 85 | 86 | err = tempFile.Truncate(0) 87 | assert.NoError(t, err) 88 | _, err = tempFile.Seek(0, 0) 89 | assert.NoError(t, err) 90 | } 91 | 92 | _ = tempFile.Close() 93 | } 94 | -------------------------------------------------------------------------------- /soracom/generated/cmd/query.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(QueryCmd) 10 | } 11 | 12 | // QueryCmd defines 'query' subcommand 13 | var QueryCmd = &cobra.Command{ 14 | Use: "query", 15 | Short: TRCLI("cli.query.summary"), 16 | Long: TRCLI(`cli.query.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/resource_summaries.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(ResourceSummariesCmd) 10 | } 11 | 12 | // ResourceSummariesCmd defines 'resource-summaries' subcommand 13 | var ResourceSummariesCmd = &cobra.Command{ 14 | Use: "resource-summaries", 15 | Short: TRCLI("cli.resource-summaries.summary"), 16 | Long: TRCLI(`cli.resource-summaries.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/roles.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(RolesCmd) 10 | } 11 | 12 | // RolesCmd defines 'roles' subcommand 13 | var RolesCmd = &cobra.Command{ 14 | Use: "roles", 15 | Short: TRCLI("cli.roles.summary"), 16 | Long: TRCLI(`cli.roles.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sandbox.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(SandboxCmd) 10 | } 11 | 12 | // SandboxCmd defines 'sandbox' subcommand 13 | var SandboxCmd = &cobra.Command{ 14 | Use: "sandbox", 15 | Short: TRCLI("cli.sandbox.summary"), 16 | Long: TRCLI(`cli.sandbox.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sandbox_coupons.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SandboxCmd.AddCommand(SandboxCouponsCmd) 10 | } 11 | 12 | // SandboxCouponsCmd defines 'coupons' subcommand 13 | var SandboxCouponsCmd = &cobra.Command{ 14 | Use: "coupons", 15 | Short: TRCLI("cli.sandbox.coupons.summary"), 16 | Long: TRCLI(`cli.sandbox.coupons.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sandbox_operators.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SandboxCmd.AddCommand(SandboxOperatorsCmd) 10 | } 11 | 12 | // SandboxOperatorsCmd defines 'operators' subcommand 13 | var SandboxOperatorsCmd = &cobra.Command{ 14 | Use: "operators", 15 | Short: TRCLI("cli.sandbox.operators.summary"), 16 | Long: TRCLI(`cli.sandbox.operators.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sandbox_orders.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SandboxCmd.AddCommand(SandboxOrdersCmd) 10 | } 11 | 12 | // SandboxOrdersCmd defines 'orders' subcommand 13 | var SandboxOrdersCmd = &cobra.Command{ 14 | Use: "orders", 15 | Short: TRCLI("cli.sandbox.orders.summary"), 16 | Long: TRCLI(`cli.sandbox.orders.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sandbox_stats.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SandboxCmd.AddCommand(SandboxStatsCmd) 10 | } 11 | 12 | // SandboxStatsCmd defines 'stats' subcommand 13 | var SandboxStatsCmd = &cobra.Command{ 14 | Use: "stats", 15 | Short: TRCLI("cli.sandbox.stats.summary"), 16 | Long: TRCLI(`cli.sandbox.stats.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sandbox_stats_air.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SandboxStatsCmd.AddCommand(SandboxStatsAirCmd) 10 | } 11 | 12 | // SandboxStatsAirCmd defines 'air' subcommand 13 | var SandboxStatsAirCmd = &cobra.Command{ 14 | Use: "air", 15 | Short: TRCLI("cli.sandbox.stats.air.summary"), 16 | Long: TRCLI(`cli.sandbox.stats.air.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sandbox_stats_beam.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SandboxStatsCmd.AddCommand(SandboxStatsBeamCmd) 10 | } 11 | 12 | // SandboxStatsBeamCmd defines 'beam' subcommand 13 | var SandboxStatsBeamCmd = &cobra.Command{ 14 | Use: "beam", 15 | Short: TRCLI("cli.sandbox.stats.beam.summary"), 16 | Long: TRCLI(`cli.sandbox.stats.beam.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sandbox_subscribers.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SandboxCmd.AddCommand(SandboxSubscribersCmd) 10 | } 11 | 12 | // SandboxSubscribersCmd defines 'subscribers' subcommand 13 | var SandboxSubscribersCmd = &cobra.Command{ 14 | Use: "subscribers", 15 | Short: TRCLI("cli.sandbox.subscribers.summary"), 16 | Long: TRCLI(`cli.sandbox.subscribers.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/shipping_addresses.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(ShippingAddressesCmd) 10 | } 11 | 12 | // ShippingAddressesCmd defines 'shipping-addresses' subcommand 13 | var ShippingAddressesCmd = &cobra.Command{ 14 | Use: "shipping-addresses", 15 | Short: TRCLI("cli.shipping-addresses.summary"), 16 | Long: TRCLI(`cli.shipping-addresses.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sigfox_devices.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(SigfoxDevicesCmd) 10 | } 11 | 12 | // SigfoxDevicesCmd defines 'sigfox-devices' subcommand 13 | var SigfoxDevicesCmd = &cobra.Command{ 14 | Use: "sigfox-devices", 15 | Short: TRCLI("cli.sigfox-devices.summary"), 16 | Long: TRCLI(`cli.sigfox-devices.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sim_profile_orders.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(SimProfileOrdersCmd) 10 | } 11 | 12 | // SimProfileOrdersCmd defines 'sim-profile-orders' subcommand 13 | var SimProfileOrdersCmd = &cobra.Command{ 14 | Use: "sim-profile-orders", 15 | Short: TRCLI("cli.sim-profile-orders.summary"), 16 | Long: TRCLI(`cli.sim-profile-orders.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sims.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(SimsCmd) 10 | } 11 | 12 | // SimsCmd defines 'sims' subcommand 13 | var SimsCmd = &cobra.Command{ 14 | Use: "sims", 15 | Short: TRCLI("cli.sims.summary"), 16 | Long: TRCLI(`cli.sims.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sims_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // SimsGetCmdSimId holds value of 'sim_id' option 13 | var SimsGetCmdSimId string 14 | 15 | func InitSimsGetCmd() { 16 | SimsGetCmd.Flags().StringVar(&SimsGetCmdSimId, "sim-id", "", TRAPI("SIM ID of the target SIM. The SIM ID can be obtained from the [Sim:listSims API](#!/Sim/listSims).")) 17 | 18 | SimsGetCmd.RunE = SimsGetCmdRunE 19 | 20 | SimsCmd.AddCommand(SimsGetCmd) 21 | } 22 | 23 | // SimsGetCmd defines 'get' subcommand 24 | var SimsGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/sims/{sim_id}:get:summary"), 27 | Long: TRAPI(`/sims/{sim_id}:get:description`) + "\n\n" + createLinkToAPIReference("Sim", "getSim"), 28 | } 29 | 30 | func SimsGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectSimsGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectSimsGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("sim_id", "sim-id", "path", parsedBody, SimsGetCmdSimId) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "GET", 84 | path: buildPathForSimsGetCmd("/sims/{sim_id}"), 85 | query: buildQueryForSimsGetCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForSimsGetCmd(path string) string { 92 | 93 | escapedSimId := url.PathEscape(SimsGetCmdSimId) 94 | 95 | path = strReplace(path, "{"+"sim_id"+"}", escapedSimId, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForSimsGetCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sims_suspend.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // SimsSuspendCmdSimId holds value of 'sim_id' option 13 | var SimsSuspendCmdSimId string 14 | 15 | func InitSimsSuspendCmd() { 16 | SimsSuspendCmd.Flags().StringVar(&SimsSuspendCmdSimId, "sim-id", "", TRAPI("SIM ID of the target SIM. The SIM ID can be obtained from the [Sim:listSims API](#!/Sim/listSims).")) 17 | 18 | SimsSuspendCmd.RunE = SimsSuspendCmdRunE 19 | 20 | SimsCmd.AddCommand(SimsSuspendCmd) 21 | } 22 | 23 | // SimsSuspendCmd defines 'suspend' subcommand 24 | var SimsSuspendCmd = &cobra.Command{ 25 | Use: "suspend", 26 | Short: TRAPI("/sims/{sim_id}/suspend:post:summary"), 27 | Long: TRAPI(`/sims/{sim_id}/suspend:post:description`) + "\n\n" + createLinkToAPIReference("Sim", "suspendSim"), 28 | } 29 | 30 | func SimsSuspendCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectSimsSuspendCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectSimsSuspendCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("sim_id", "sim-id", "path", parsedBody, SimsSuspendCmdSimId) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "POST", 84 | path: buildPathForSimsSuspendCmd("/sims/{sim_id}/suspend"), 85 | query: buildQueryForSimsSuspendCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForSimsSuspendCmd(path string) string { 92 | 93 | escapedSimId := url.PathEscape(SimsSuspendCmdSimId) 94 | 95 | path = strReplace(path, "{"+"sim_id"+"}", escapedSimId, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForSimsSuspendCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(SoraCamCmd) 10 | } 11 | 12 | // SoraCamCmd defines 'sora-cam' subcommand 13 | var SoraCamCmd = &cobra.Command{ 14 | Use: "sora-cam", 15 | Short: TRCLI("cli.sora-cam.summary"), 16 | Long: TRCLI(`cli.sora-cam.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamCmd.AddCommand(SoraCamDevicesCmd) 10 | } 11 | 12 | // SoraCamDevicesCmd defines 'devices' subcommand 13 | var SoraCamDevicesCmd = &cobra.Command{ 14 | Use: "devices", 15 | Short: TRCLI("cli.sora-cam.devices.summary"), 16 | Long: TRCLI(`cli.sora-cam.devices.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices_atom_cam.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamDevicesCmd.AddCommand(SoraCamDevicesAtomCamCmd) 10 | } 11 | 12 | // SoraCamDevicesAtomCamCmd defines 'atom-cam' subcommand 13 | var SoraCamDevicesAtomCamCmd = &cobra.Command{ 14 | Use: "atom-cam", 15 | Short: TRCLI("cli.sora-cam.devices.atom-cam.summary"), 16 | Long: TRCLI(`cli.sora-cam.devices.atom-cam.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices_atom_cam_settings.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamDevicesAtomCamCmd.AddCommand(SoraCamDevicesAtomCamSettingsCmd) 10 | } 11 | 12 | // SoraCamDevicesAtomCamSettingsCmd defines 'settings' subcommand 13 | var SoraCamDevicesAtomCamSettingsCmd = &cobra.Command{ 14 | Use: "settings", 15 | Short: TRCLI("cli.sora-cam.devices.atom-cam.settings.summary"), 16 | Long: TRCLI(`cli.sora-cam.devices.atom-cam.settings.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices_data.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamDevicesCmd.AddCommand(SoraCamDevicesDataCmd) 10 | } 11 | 12 | // SoraCamDevicesDataCmd defines 'data' subcommand 13 | var SoraCamDevicesDataCmd = &cobra.Command{ 14 | Use: "data", 15 | Short: TRCLI("cli.sora-cam.devices.data.summary"), 16 | Long: TRCLI(`cli.sora-cam.devices.data.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices_events.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamDevicesCmd.AddCommand(SoraCamDevicesEventsCmd) 10 | } 11 | 12 | // SoraCamDevicesEventsCmd defines 'events' subcommand 13 | var SoraCamDevicesEventsCmd = &cobra.Command{ 14 | Use: "events", 15 | Short: TRCLI("cli.sora-cam.devices.events.summary"), 16 | Long: TRCLI(`cli.sora-cam.devices.events.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices_images.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamDevicesCmd.AddCommand(SoraCamDevicesImagesCmd) 10 | } 11 | 12 | // SoraCamDevicesImagesCmd defines 'images' subcommand 13 | var SoraCamDevicesImagesCmd = &cobra.Command{ 14 | Use: "images", 15 | Short: TRCLI("cli.sora-cam.devices.images.summary"), 16 | Long: TRCLI(`cli.sora-cam.devices.images.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // SoraCamDevicesListCmdOutputJSONL indicates to output with jsonl format 13 | var SoraCamDevicesListCmdOutputJSONL bool 14 | 15 | func InitSoraCamDevicesListCmd() { 16 | SoraCamDevicesListCmd.Flags().BoolVar(&SoraCamDevicesListCmdOutputJSONL, "jsonl", false, TRCLI("cli.common_params.jsonl.short_help")) 17 | 18 | SoraCamDevicesListCmd.RunE = SoraCamDevicesListCmdRunE 19 | 20 | SoraCamDevicesCmd.AddCommand(SoraCamDevicesListCmd) 21 | } 22 | 23 | // SoraCamDevicesListCmd defines 'list' subcommand 24 | var SoraCamDevicesListCmd = &cobra.Command{ 25 | Use: "list", 26 | Short: TRAPI("/sora_cam/devices:get:summary"), 27 | Long: TRAPI(`/sora_cam/devices:get:description`) + "\n\n" + createLinkToAPIReference("SoraCam", "listSoraCamDevices"), 28 | } 29 | 30 | func SoraCamDevicesListCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectSoraCamDevicesListCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | if SoraCamDevicesListCmdOutputJSONL { 70 | return printStringAsJSONL(body) 71 | } 72 | 73 | return prettyPrintStringAsJSON(body) 74 | } 75 | return err 76 | } 77 | 78 | func collectSoraCamDevicesListCmdParams(ac *apiClient) (*apiParams, error) { 79 | 80 | return &apiParams{ 81 | method: "GET", 82 | path: buildPathForSoraCamDevicesListCmd("/sora_cam/devices"), 83 | query: buildQueryForSoraCamDevicesListCmd(), 84 | 85 | noRetryOnError: noRetryOnError, 86 | }, nil 87 | } 88 | 89 | func buildPathForSoraCamDevicesListCmd(path string) string { 90 | 91 | return path 92 | } 93 | 94 | func buildQueryForSoraCamDevicesListCmd() url.Values { 95 | result := url.Values{} 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices_recordings_and_events.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamDevicesCmd.AddCommand(SoraCamDevicesRecordingsAndEventsCmd) 10 | } 11 | 12 | // SoraCamDevicesRecordingsAndEventsCmd defines 'recordings-and-events' subcommand 13 | var SoraCamDevicesRecordingsAndEventsCmd = &cobra.Command{ 14 | Use: "recordings-and-events", 15 | Short: TRCLI("cli.sora-cam.devices.recordings-and-events.summary"), 16 | Long: TRCLI(`cli.sora-cam.devices.recordings-and-events.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_devices_videos.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamDevicesCmd.AddCommand(SoraCamDevicesVideosCmd) 10 | } 11 | 12 | // SoraCamDevicesVideosCmd defines 'videos' subcommand 13 | var SoraCamDevicesVideosCmd = &cobra.Command{ 14 | Use: "videos", 15 | Short: TRCLI("cli.sora-cam.devices.videos.summary"), 16 | Long: TRCLI(`cli.sora-cam.devices.videos.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_license_packs.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | SoraCamCmd.AddCommand(SoraCamLicensePacksCmd) 10 | } 11 | 12 | // SoraCamLicensePacksCmd defines 'license-packs' subcommand 13 | var SoraCamLicensePacksCmd = &cobra.Command{ 14 | Use: "license-packs", 15 | Short: TRCLI("cli.sora-cam.license-packs.summary"), 16 | Long: TRCLI(`cli.sora-cam.license-packs.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/sora_cam_license_packs_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // SoraCamLicensePacksListCmdOutputJSONL indicates to output with jsonl format 13 | var SoraCamLicensePacksListCmdOutputJSONL bool 14 | 15 | func InitSoraCamLicensePacksListCmd() { 16 | SoraCamLicensePacksListCmd.Flags().BoolVar(&SoraCamLicensePacksListCmdOutputJSONL, "jsonl", false, TRCLI("cli.common_params.jsonl.short_help")) 17 | 18 | SoraCamLicensePacksListCmd.RunE = SoraCamLicensePacksListCmdRunE 19 | 20 | SoraCamLicensePacksCmd.AddCommand(SoraCamLicensePacksListCmd) 21 | } 22 | 23 | // SoraCamLicensePacksListCmd defines 'list' subcommand 24 | var SoraCamLicensePacksListCmd = &cobra.Command{ 25 | Use: "list", 26 | Short: TRAPI("/sora_cam/license_packs:get:summary"), 27 | Long: TRAPI(`/sora_cam/license_packs:get:description`) + "\n\n" + createLinkToAPIReference("SoraCam", "listSoraCamLicensePacks"), 28 | } 29 | 30 | func SoraCamLicensePacksListCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectSoraCamLicensePacksListCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | if SoraCamLicensePacksListCmdOutputJSONL { 70 | return printStringAsJSONL(body) 71 | } 72 | 73 | return prettyPrintStringAsJSON(body) 74 | } 75 | return err 76 | } 77 | 78 | func collectSoraCamLicensePacksListCmdParams(ac *apiClient) (*apiParams, error) { 79 | 80 | return &apiParams{ 81 | method: "GET", 82 | path: buildPathForSoraCamLicensePacksListCmd("/sora_cam/license_packs"), 83 | query: buildQueryForSoraCamLicensePacksListCmd(), 84 | 85 | noRetryOnError: noRetryOnError, 86 | }, nil 87 | } 88 | 89 | func buildPathForSoraCamLicensePacksListCmd(path string) string { 90 | 91 | return path 92 | } 93 | 94 | func buildQueryForSoraCamLicensePacksListCmd() url.Values { 95 | result := url.Values{} 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/soralets.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(SoraletsCmd) 10 | } 11 | 12 | // SoraletsCmd defines 'soralets' subcommand 13 | var SoraletsCmd = &cobra.Command{ 14 | Use: "soralets", 15 | Short: TRCLI("cli.soralets.summary"), 16 | Long: TRCLI(`cli.soralets.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/soralets_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // SoraletsGetCmdSoraletId holds value of 'soralet_id' option 13 | var SoraletsGetCmdSoraletId string 14 | 15 | func InitSoraletsGetCmd() { 16 | SoraletsGetCmd.Flags().StringVar(&SoraletsGetCmdSoraletId, "soralet-id", "", TRAPI("The identifier of Soralet.")) 17 | 18 | SoraletsGetCmd.RunE = SoraletsGetCmdRunE 19 | 20 | SoraletsCmd.AddCommand(SoraletsGetCmd) 21 | } 22 | 23 | // SoraletsGetCmd defines 'get' subcommand 24 | var SoraletsGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/soralets/{soralet_id}:get:summary"), 27 | Long: TRAPI(`/soralets/{soralet_id}:get:description`) + "\n\n" + createLinkToAPIReference("Soralet", "getSoralet"), 28 | } 29 | 30 | func SoraletsGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectSoraletsGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectSoraletsGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("soralet_id", "soralet-id", "path", parsedBody, SoraletsGetCmdSoraletId) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "GET", 84 | path: buildPathForSoraletsGetCmd("/soralets/{soralet_id}"), 85 | query: buildQueryForSoraletsGetCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForSoraletsGetCmd(path string) string { 92 | 93 | escapedSoraletId := url.PathEscape(SoraletsGetCmdSoraletId) 94 | 95 | path = strReplace(path, "{"+"soralet_id"+"}", escapedSoraletId, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForSoraletsGetCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(StatsCmd) 10 | } 11 | 12 | // StatsCmd defines 'stats' subcommand 13 | var StatsCmd = &cobra.Command{ 14 | Use: "stats", 15 | Short: TRCLI("cli.stats.summary"), 16 | Long: TRCLI(`cli.stats.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_air.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsCmd.AddCommand(StatsAirCmd) 10 | } 11 | 12 | // StatsAirCmd defines 'air' subcommand 13 | var StatsAirCmd = &cobra.Command{ 14 | Use: "air", 15 | Short: TRCLI("cli.stats.air.summary"), 16 | Long: TRCLI(`cli.stats.air.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_air_groups.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsAirCmd.AddCommand(StatsAirGroupsCmd) 10 | } 11 | 12 | // StatsAirGroupsCmd defines 'groups' subcommand 13 | var StatsAirGroupsCmd = &cobra.Command{ 14 | Use: "groups", 15 | Short: TRCLI("cli.stats.air.groups.summary"), 16 | Long: TRCLI(`cli.stats.air.groups.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_air_operators.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsAirCmd.AddCommand(StatsAirOperatorsCmd) 10 | } 11 | 12 | // StatsAirOperatorsCmd defines 'operators' subcommand 13 | var StatsAirOperatorsCmd = &cobra.Command{ 14 | Use: "operators", 15 | Short: TRCLI("cli.stats.air.operators.summary"), 16 | Long: TRCLI(`cli.stats.air.operators.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_air_sims.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsAirCmd.AddCommand(StatsAirSimsCmd) 10 | } 11 | 12 | // StatsAirSimsCmd defines 'sims' subcommand 13 | var StatsAirSimsCmd = &cobra.Command{ 14 | Use: "sims", 15 | Short: TRCLI("cli.stats.air.sims.summary"), 16 | Long: TRCLI(`cli.stats.air.sims.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_beam.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsCmd.AddCommand(StatsBeamCmd) 10 | } 11 | 12 | // StatsBeamCmd defines 'beam' subcommand 13 | var StatsBeamCmd = &cobra.Command{ 14 | Use: "beam", 15 | Short: TRCLI("cli.stats.beam.summary"), 16 | Long: TRCLI(`cli.stats.beam.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_funk.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsCmd.AddCommand(StatsFunkCmd) 10 | } 11 | 12 | // StatsFunkCmd defines 'funk' subcommand 13 | var StatsFunkCmd = &cobra.Command{ 14 | Use: "funk", 15 | Short: TRCLI("cli.stats.funk.summary"), 16 | Long: TRCLI(`cli.stats.funk.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_funnel.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsCmd.AddCommand(StatsFunnelCmd) 10 | } 11 | 12 | // StatsFunnelCmd defines 'funnel' subcommand 13 | var StatsFunnelCmd = &cobra.Command{ 14 | Use: "funnel", 15 | Short: TRCLI("cli.stats.funnel.summary"), 16 | Long: TRCLI(`cli.stats.funnel.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_harvest.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsCmd.AddCommand(StatsHarvestCmd) 10 | } 11 | 12 | // StatsHarvestCmd defines 'harvest' subcommand 13 | var StatsHarvestCmd = &cobra.Command{ 14 | Use: "harvest", 15 | Short: TRCLI("cli.stats.harvest.summary"), 16 | Long: TRCLI(`cli.stats.harvest.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_harvest_operators.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsHarvestCmd.AddCommand(StatsHarvestOperatorsCmd) 10 | } 11 | 12 | // StatsHarvestOperatorsCmd defines 'operators' subcommand 13 | var StatsHarvestOperatorsCmd = &cobra.Command{ 14 | Use: "operators", 15 | Short: TRCLI("cli.stats.harvest.operators.summary"), 16 | Long: TRCLI(`cli.stats.harvest.operators.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_harvest_subscribers.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsHarvestCmd.AddCommand(StatsHarvestSubscribersCmd) 10 | } 11 | 12 | // StatsHarvestSubscribersCmd defines 'subscribers' subcommand 13 | var StatsHarvestSubscribersCmd = &cobra.Command{ 14 | Use: "subscribers", 15 | Short: TRCLI("cli.stats.harvest.subscribers.summary"), 16 | Long: TRCLI(`cli.stats.harvest.subscribers.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_napter.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsCmd.AddCommand(StatsNapterCmd) 10 | } 11 | 12 | // StatsNapterCmd defines 'napter' subcommand 13 | var StatsNapterCmd = &cobra.Command{ 14 | Use: "napter", 15 | Short: TRCLI("cli.stats.napter.summary"), 16 | Long: TRCLI(`cli.stats.napter.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_napter_audit_logs.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | StatsNapterCmd.AddCommand(StatsNapterAuditLogsCmd) 10 | } 11 | 12 | // StatsNapterAuditLogsCmd defines 'audit-logs' subcommand 13 | var StatsNapterAuditLogsCmd = &cobra.Command{ 14 | Use: "audit-logs", 15 | Short: TRCLI("cli.stats.napter.audit-logs.summary"), 16 | Long: TRCLI(`cli.stats.napter.audit-logs.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stats_napter_audit_logs_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // StatsNapterAuditLogsGetCmdYearMonth holds value of 'year_month' option 13 | var StatsNapterAuditLogsGetCmdYearMonth string 14 | 15 | func InitStatsNapterAuditLogsGetCmd() { 16 | StatsNapterAuditLogsGetCmd.Flags().StringVar(&StatsNapterAuditLogsGetCmdYearMonth, "year-month", "", TRAPI("Specify the year and month from 18 months before the current time to the current time in the YYYYMM format.")) 17 | 18 | StatsNapterAuditLogsGetCmd.RunE = StatsNapterAuditLogsGetCmdRunE 19 | 20 | StatsNapterAuditLogsCmd.AddCommand(StatsNapterAuditLogsGetCmd) 21 | } 22 | 23 | // StatsNapterAuditLogsGetCmd defines 'get' subcommand 24 | var StatsNapterAuditLogsGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/stats/napter/audit_logs:get:summary"), 27 | Long: TRAPI(`/stats/napter/audit_logs:get:description`) + "\n\n" + createLinkToAPIReference("Stats", "getNapterAuditLogsExportedDataStats"), 28 | } 29 | 30 | func StatsNapterAuditLogsGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectStatsNapterAuditLogsGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectStatsNapterAuditLogsGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | 76 | return &apiParams{ 77 | method: "GET", 78 | path: buildPathForStatsNapterAuditLogsGetCmd("/stats/napter/audit_logs"), 79 | query: buildQueryForStatsNapterAuditLogsGetCmd(), 80 | 81 | noRetryOnError: noRetryOnError, 82 | }, nil 83 | } 84 | 85 | func buildPathForStatsNapterAuditLogsGetCmd(path string) string { 86 | 87 | return path 88 | } 89 | 90 | func buildQueryForStatsNapterAuditLogsGetCmd() url.Values { 91 | result := url.Values{} 92 | 93 | if StatsNapterAuditLogsGetCmdYearMonth != "" { 94 | result.Add("year_month", StatsNapterAuditLogsGetCmdYearMonth) 95 | } 96 | 97 | return result 98 | } 99 | -------------------------------------------------------------------------------- /soracom/generated/cmd/stringutils.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // it was difficult to use fmt.Sprintf() in template codes 9 | // because we need to import only if fmt.Sprintf() is called 10 | // but the condition was too complicated. So we separated 11 | // fmt.Sprintf() to a func which can be referenced from 12 | // inside the complicated condition. 13 | 14 | func sprintf(format string, a ...interface{}) string { 15 | return fmt.Sprintf(format, a...) 16 | } 17 | 18 | func strReplace(s, old, new string, n int) string { 19 | return strings.Replace(s, old, new, n) 20 | } 21 | -------------------------------------------------------------------------------- /soracom/generated/cmd/subscribers.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(SubscribersCmd) 10 | } 11 | 12 | // SubscribersCmd defines 'subscribers' subcommand 13 | var SubscribersCmd = &cobra.Command{ 14 | Use: "subscribers", 15 | Short: TRCLI("cli.subscribers.summary"), 16 | Long: TRCLI(`cli.subscribers.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/subscribers_export.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // SubscribersExportCmdExportMode holds value of 'export_mode' option 13 | var SubscribersExportCmdExportMode string 14 | 15 | func InitSubscribersExportCmd() { 16 | SubscribersExportCmd.Flags().StringVar(&SubscribersExportCmdExportMode, "export-mode", "sync", TRAPI("export mode (async, sync)")) 17 | 18 | SubscribersExportCmd.RunE = SubscribersExportCmdRunE 19 | 20 | SubscribersCmd.AddCommand(SubscribersExportCmd) 21 | } 22 | 23 | // SubscribersExportCmd defines 'export' subcommand 24 | var SubscribersExportCmd = &cobra.Command{ 25 | Use: "export", 26 | Short: TRAPI("/subscribers/export:post:summary"), 27 | Long: TRAPI(`/subscribers/export:post:description`) + "\n\n" + createLinkToAPIReference("Subscriber", "exportSubscribers"), 28 | } 29 | 30 | func SubscribersExportCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectSubscribersExportCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | rawOutput = true 66 | 67 | if rawOutput { 68 | _, err = os.Stdout.Write([]byte(body)) 69 | } else { 70 | return prettyPrintStringAsJSON(body) 71 | } 72 | return err 73 | } 74 | 75 | func collectSubscribersExportCmdParams(ac *apiClient) (*apiParams, error) { 76 | 77 | return &apiParams{ 78 | method: "POST", 79 | path: buildPathForSubscribersExportCmd("/subscribers/export"), 80 | query: buildQueryForSubscribersExportCmd(), 81 | 82 | noRetryOnError: noRetryOnError, 83 | }, nil 84 | } 85 | 86 | func buildPathForSubscribersExportCmd(path string) string { 87 | 88 | return path 89 | } 90 | 91 | func buildQueryForSubscribersExportCmd() url.Values { 92 | result := url.Values{} 93 | 94 | if SubscribersExportCmdExportMode != "sync" { 95 | result.Add("export_mode", SubscribersExportCmdExportMode) 96 | } 97 | 98 | return result 99 | } 100 | -------------------------------------------------------------------------------- /soracom/generated/cmd/subscribers_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // SubscribersGetCmdImsi holds value of 'imsi' option 13 | var SubscribersGetCmdImsi string 14 | 15 | func InitSubscribersGetCmd() { 16 | SubscribersGetCmd.Flags().StringVar(&SubscribersGetCmdImsi, "imsi", "", TRAPI("IMSI of the target subscriber.")) 17 | 18 | SubscribersGetCmd.RunE = SubscribersGetCmdRunE 19 | 20 | SubscribersCmd.AddCommand(SubscribersGetCmd) 21 | } 22 | 23 | // SubscribersGetCmd defines 'get' subcommand 24 | var SubscribersGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/subscribers/{imsi}:get:summary"), 27 | Long: TRAPI(`/subscribers/{imsi}:get:description`) + "\n\n" + createLinkToAPIReference("Subscriber", "getSubscriber"), 28 | } 29 | 30 | func SubscribersGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectSubscribersGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectSubscribersGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("imsi", "imsi", "path", parsedBody, SubscribersGetCmdImsi) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "GET", 84 | path: buildPathForSubscribersGetCmd("/subscribers/{imsi}"), 85 | query: buildQueryForSubscribersGetCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForSubscribersGetCmd(path string) string { 92 | 93 | escapedImsi := url.PathEscape(SubscribersGetCmdImsi) 94 | 95 | path = strReplace(path, "{"+"imsi"+"}", escapedImsi, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForSubscribersGetCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/generated/cmd/switch_user_request.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | type switchUserRequest struct { 4 | OperatorID string `json:"operatorId"` 5 | UserName string `json:"userName"` 6 | TokenTimeoutSeconds *int `json:"tokenTimeoutSeconds,omitempty"` 7 | } 8 | -------------------------------------------------------------------------------- /soracom/generated/cmd/system_notifications.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(SystemNotificationsCmd) 10 | } 11 | 12 | // SystemNotificationsCmd defines 'system-notifications' subcommand 13 | var SystemNotificationsCmd = &cobra.Command{ 14 | Use: "system-notifications", 15 | Short: TRCLI("cli.system-notifications.summary"), 16 | Long: TRCLI(`cli.system-notifications.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func init() { 10 | RootCmd.AddCommand(TestCmd) 11 | TestCmd.AddCommand(Test500Cmd) 12 | } 13 | 14 | // TestCmd defines 'test' subcommand 15 | var TestCmd = &cobra.Command{ 16 | Use: "test", 17 | Short: TRCLI("cli.test.summary"), 18 | Long: TRCLI("cli.test.description"), 19 | Hidden: true, 20 | } 21 | 22 | // Test500Cmd defines 'test 500' subcommand 23 | var Test500Cmd = &cobra.Command{ 24 | Use: "500", 25 | Short: TRCLI("cli.test._500.summary"), 26 | Long: TRCLI("cli.test._500.description"), 27 | RunE: func(cmd *cobra.Command, args []string) error { 28 | opt := &apiClientOptions{ 29 | BasePath: "/", 30 | Language: getSelectedLanguage(), 31 | } 32 | 33 | ac := newAPIClient(opt) 34 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 35 | ac.SetVerbose(true) 36 | } 37 | 38 | param := &apiParams{ 39 | method: "POST", 40 | path: "500", 41 | contentType: "application/json", 42 | body: `{"expect":"500 Internal Server Error"}`, 43 | } 44 | 45 | _, err := ac.callAPI(param) 46 | 47 | return err 48 | }, 49 | } 50 | -------------------------------------------------------------------------------- /soracom/generated/cmd/to_json.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import "encoding/json" 4 | 5 | func toJSON(x interface{}) string { 6 | bodyBytes, err := json.Marshal(x) 7 | if err != nil { 8 | return "" 9 | } 10 | return string(bodyBytes) 11 | } 12 | -------------------------------------------------------------------------------- /soracom/generated/cmd/users.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(UsersCmd) 10 | } 11 | 12 | // UsersCmd defines 'users' subcommand 13 | var UsersCmd = &cobra.Command{ 14 | Use: "users", 15 | Short: TRCLI("cli.users.summary"), 16 | Long: TRCLI(`cli.users.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/users_auth_keys.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | UsersCmd.AddCommand(UsersAuthKeysCmd) 10 | } 11 | 12 | // UsersAuthKeysCmd defines 'auth-keys' subcommand 13 | var UsersAuthKeysCmd = &cobra.Command{ 14 | Use: "auth-keys", 15 | Short: TRCLI("cli.users.auth-keys.summary"), 16 | Long: TRCLI(`cli.users.auth-keys.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/users_default_permissions.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | UsersCmd.AddCommand(UsersDefaultPermissionsCmd) 10 | } 11 | 12 | // UsersDefaultPermissionsCmd defines 'default-permissions' subcommand 13 | var UsersDefaultPermissionsCmd = &cobra.Command{ 14 | Use: "default-permissions", 15 | Short: TRCLI("cli.users.default-permissions.summary"), 16 | Long: TRCLI(`cli.users.default-permissions.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/users_mfa.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | UsersCmd.AddCommand(UsersMfaCmd) 10 | } 11 | 12 | // UsersMfaCmd defines 'mfa' subcommand 13 | var UsersMfaCmd = &cobra.Command{ 14 | Use: "mfa", 15 | Short: TRCLI("cli.users.mfa.summary"), 16 | Long: TRCLI(`cli.users.mfa.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/users_password.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | UsersCmd.AddCommand(UsersPasswordCmd) 10 | } 11 | 12 | // UsersPasswordCmd defines 'password' subcommand 13 | var UsersPasswordCmd = &cobra.Command{ 14 | Use: "password", 15 | Short: TRCLI("cli.users.password.summary"), 16 | Long: TRCLI(`cli.users.password.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/users_permissions.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | UsersCmd.AddCommand(UsersPermissionsCmd) 10 | } 11 | 12 | // UsersPermissionsCmd defines 'permissions' subcommand 13 | var UsersPermissionsCmd = &cobra.Command{ 14 | Use: "permissions", 15 | Short: TRCLI("cli.users.permissions.summary"), 16 | Long: TRCLI(`cli.users.permissions.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/users_trust_policy.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | UsersCmd.AddCommand(UsersTrustPolicyCmd) 10 | } 11 | 12 | // UsersTrustPolicyCmd defines 'trust-policy' subcommand 13 | var UsersTrustPolicyCmd = &cobra.Command{ 14 | Use: "trust-policy", 15 | Short: TRCLI("cli.users.trust-policy.summary"), 16 | Long: TRCLI(`cli.users.trust-policy.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/version.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func init() { 10 | RootCmd.AddCommand(VersionCmd) 11 | } 12 | 13 | var version string 14 | 15 | // VersionCmd defines 'version' subcommand 16 | var VersionCmd = &cobra.Command{ 17 | Use: "version", 18 | Short: TRCLI("cli.version.summary"), 19 | Long: TRCLI("cli.version.description"), 20 | Run: func(cmd *cobra.Command, args []string) { 21 | fmt.Printf("SORACOM API client v%s\n", version) 22 | }, 23 | } 24 | -------------------------------------------------------------------------------- /soracom/generated/cmd/version_checker.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "regexp" 5 | "strconv" 6 | ) 7 | 8 | // version strings are in the form of "v1.22.333" or "v0.0.1" 9 | func isNewerThanCurrentVersion(latestVersion string) bool { 10 | cv := versionInt(version) 11 | lv := versionInt(latestVersion) 12 | return cv < lv 13 | } 14 | 15 | func versionInt(ver string) uint32 { 16 | s := splitVersionString(ver) 17 | if len(s) < 3 { 18 | return 0 19 | } 20 | 21 | var n uint32 22 | shift := uint(24) 23 | for i := 0; i < 4; i++ { 24 | if len(s) <= i { 25 | break 26 | } 27 | x, err := strconv.Atoi(s[i]) 28 | if err == nil { 29 | n |= uint32((x & 0xff) << shift) 30 | } 31 | shift -= 8 32 | } 33 | return n 34 | } 35 | 36 | var versionStringRegexp = regexp.MustCompile("([[:digit:]]+)[[:^digit:]]*") 37 | 38 | func splitVersionString(ver string) []string { 39 | m := versionStringRegexp.FindAllStringSubmatch(ver, -1) 40 | if len(m) < 2 { 41 | return []string{} 42 | } 43 | result := make([]string, len(m)) 44 | for i, s := range m { 45 | result[i] = s[1] 46 | } 47 | return result 48 | } 49 | -------------------------------------------------------------------------------- /soracom/generated/cmd/version_checker_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import "testing" 4 | 5 | func TestVersionInt(t *testing.T) { 6 | var testData = []struct { 7 | Name string 8 | VerStr string 9 | VerInt uint32 10 | }{ 11 | { 12 | Name: "pattern 1", 13 | VerStr: "v0.1.2", 14 | VerInt: 0x00010200, 15 | }, 16 | { 17 | Name: "pattern 2", 18 | VerStr: "v1.22.333", // 333 == 0x14d but only 0x4d will be stored in the 3rd place 19 | VerInt: 0x01164d00, 20 | }, 21 | { 22 | Name: "pattern 3", 23 | VerStr: "1.2.3", // no "v" prefix 24 | VerInt: 0x01020300, 25 | }, 26 | { 27 | Name: "pattern 4", 28 | VerStr: "v1.2.3-special", 29 | VerInt: 0x01020300, 30 | }, 31 | { 32 | Name: "pattern 5", 33 | VerStr: "v1.2.3-special1", 34 | VerInt: 0x01020301, 35 | }, 36 | { 37 | Name: "pattern 6", 38 | VerStr: "v1.2.3.4", 39 | VerInt: 0x01020304, 40 | }, 41 | } 42 | 43 | for _, data := range testData { 44 | data := data // capture 45 | t.Run(data.Name, func(t *testing.T) { 46 | t.Parallel() 47 | 48 | v := versionInt(data.VerStr) 49 | if v != data.VerInt { 50 | t.Errorf("result of versionInt() is unmatched with expected.\nArg: %v\nExpected: %#08x\nActual: %#08x", data.VerStr, data.VerInt, v) 51 | } 52 | }) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /soracom/generated/cmd/volume_discounts.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(VolumeDiscountsCmd) 10 | } 11 | 12 | // VolumeDiscountsCmd defines 'volume-discounts' subcommand 13 | var VolumeDiscountsCmd = &cobra.Command{ 14 | Use: "volume-discounts", 15 | Short: TRCLI("cli.volume-discounts.summary"), 16 | Long: TRCLI(`cli.volume-discounts.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/volume_discounts_available_discounts.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitVolumeDiscountsAvailableDiscountsCmd() { 13 | 14 | VolumeDiscountsAvailableDiscountsCmd.RunE = VolumeDiscountsAvailableDiscountsCmdRunE 15 | 16 | VolumeDiscountsCmd.AddCommand(VolumeDiscountsAvailableDiscountsCmd) 17 | } 18 | 19 | // VolumeDiscountsAvailableDiscountsCmd defines 'available-discounts' subcommand 20 | var VolumeDiscountsAvailableDiscountsCmd = &cobra.Command{ 21 | Use: "available-discounts", 22 | Short: TRAPI("/volume_discounts/available_discounts:get:summary"), 23 | Long: TRAPI(`/volume_discounts/available_discounts:get:description`) + "\n\n" + createLinkToAPIReference("Order", "listAvailableDiscounts"), 24 | } 25 | 26 | func VolumeDiscountsAvailableDiscountsCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectVolumeDiscountsAvailableDiscountsCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectVolumeDiscountsAvailableDiscountsCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForVolumeDiscountsAvailableDiscountsCmd("/volume_discounts/available_discounts"), 75 | query: buildQueryForVolumeDiscountsAvailableDiscountsCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForVolumeDiscountsAvailableDiscountsCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForVolumeDiscountsAvailableDiscountsCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/volume_discounts_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func InitVolumeDiscountsListCmd() { 13 | 14 | VolumeDiscountsListCmd.RunE = VolumeDiscountsListCmdRunE 15 | 16 | VolumeDiscountsCmd.AddCommand(VolumeDiscountsListCmd) 17 | } 18 | 19 | // VolumeDiscountsListCmd defines 'list' subcommand 20 | var VolumeDiscountsListCmd = &cobra.Command{ 21 | Use: "list", 22 | Short: TRAPI("/volume_discounts:get:summary"), 23 | Long: TRAPI(`/volume_discounts:get:description`) + "\n\n" + createLinkToAPIReference("Payment", "listVolumeDiscounts"), 24 | } 25 | 26 | func VolumeDiscountsListCmdRunE(cmd *cobra.Command, args []string) error { 27 | 28 | if len(args) > 0 { 29 | return fmt.Errorf("unexpected arguments passed => %v", args) 30 | } 31 | 32 | opt := &apiClientOptions{ 33 | BasePath: "/v1", 34 | Language: getSelectedLanguage(), 35 | } 36 | 37 | ac := newAPIClient(opt) 38 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 39 | ac.SetVerbose(true) 40 | } 41 | err := ac.getAPICredentials() 42 | if err != nil { 43 | cmd.SilenceUsage = true 44 | return err 45 | } 46 | 47 | param, err := collectVolumeDiscountsListCmdParams(ac) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | body, err := ac.callAPI(param) 53 | if err != nil { 54 | cmd.SilenceUsage = true 55 | return err 56 | } 57 | 58 | if body == "" { 59 | return nil 60 | } 61 | 62 | if rawOutput { 63 | _, err = os.Stdout.Write([]byte(body)) 64 | } else { 65 | return prettyPrintStringAsJSON(body) 66 | } 67 | return err 68 | } 69 | 70 | func collectVolumeDiscountsListCmdParams(ac *apiClient) (*apiParams, error) { 71 | 72 | return &apiParams{ 73 | method: "GET", 74 | path: buildPathForVolumeDiscountsListCmd("/volume_discounts"), 75 | query: buildQueryForVolumeDiscountsListCmd(), 76 | 77 | noRetryOnError: noRetryOnError, 78 | }, nil 79 | } 80 | 81 | func buildPathForVolumeDiscountsListCmd(path string) string { 82 | 83 | return path 84 | } 85 | 86 | func buildQueryForVolumeDiscountsListCmd() url.Values { 87 | result := url.Values{} 88 | 89 | return result 90 | } 91 | -------------------------------------------------------------------------------- /soracom/generated/cmd/vpg.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func init() { 9 | RootCmd.AddCommand(VpgCmd) 10 | } 11 | 12 | // VpgCmd defines 'vpg' subcommand 13 | var VpgCmd = &cobra.Command{ 14 | Use: "vpg", 15 | Short: TRCLI("cli.vpg.summary"), 16 | Long: TRCLI(`cli.vpg.description`), 17 | } 18 | -------------------------------------------------------------------------------- /soracom/generated/cmd/vpg_get.go: -------------------------------------------------------------------------------- 1 | // Code generated by soracom-cli generate-cmd. DO NOT EDIT. 2 | package cmd 3 | 4 | import ( 5 | "fmt" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // VpgGetCmdVpgId holds value of 'vpg_id' option 13 | var VpgGetCmdVpgId string 14 | 15 | func InitVpgGetCmd() { 16 | VpgGetCmd.Flags().StringVar(&VpgGetCmdVpgId, "vpg-id", "", TRAPI("Target VPG ID.")) 17 | 18 | VpgGetCmd.RunE = VpgGetCmdRunE 19 | 20 | VpgCmd.AddCommand(VpgGetCmd) 21 | } 22 | 23 | // VpgGetCmd defines 'get' subcommand 24 | var VpgGetCmd = &cobra.Command{ 25 | Use: "get", 26 | Short: TRAPI("/virtual_private_gateways/{vpg_id}:get:summary"), 27 | Long: TRAPI(`/virtual_private_gateways/{vpg_id}:get:description`) + "\n\n" + createLinkToAPIReference("VirtualPrivateGateway", "getVirtualPrivateGateway"), 28 | } 29 | 30 | func VpgGetCmdRunE(cmd *cobra.Command, args []string) error { 31 | 32 | if len(args) > 0 { 33 | return fmt.Errorf("unexpected arguments passed => %v", args) 34 | } 35 | 36 | opt := &apiClientOptions{ 37 | BasePath: "/v1", 38 | Language: getSelectedLanguage(), 39 | } 40 | 41 | ac := newAPIClient(opt) 42 | if v := os.Getenv("SORACOM_VERBOSE"); v != "" { 43 | ac.SetVerbose(true) 44 | } 45 | err := ac.getAPICredentials() 46 | if err != nil { 47 | cmd.SilenceUsage = true 48 | return err 49 | } 50 | 51 | param, err := collectVpgGetCmdParams(ac) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | body, err := ac.callAPI(param) 57 | if err != nil { 58 | cmd.SilenceUsage = true 59 | return err 60 | } 61 | 62 | if body == "" { 63 | return nil 64 | } 65 | 66 | if rawOutput { 67 | _, err = os.Stdout.Write([]byte(body)) 68 | } else { 69 | return prettyPrintStringAsJSON(body) 70 | } 71 | return err 72 | } 73 | 74 | func collectVpgGetCmdParams(ac *apiClient) (*apiParams, error) { 75 | var parsedBody interface{} 76 | var err error 77 | err = checkIfRequiredStringParameterIsSupplied("vpg_id", "vpg-id", "path", parsedBody, VpgGetCmdVpgId) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | return &apiParams{ 83 | method: "GET", 84 | path: buildPathForVpgGetCmd("/virtual_private_gateways/{vpg_id}"), 85 | query: buildQueryForVpgGetCmd(), 86 | 87 | noRetryOnError: noRetryOnError, 88 | }, nil 89 | } 90 | 91 | func buildPathForVpgGetCmd(path string) string { 92 | 93 | escapedVpgId := url.PathEscape(VpgGetCmdVpgId) 94 | 95 | path = strReplace(path, "{"+"vpg_id"+"}", escapedVpgId, -1) 96 | 97 | return path 98 | } 99 | 100 | func buildQueryForVpgGetCmd() url.Values { 101 | result := url.Values{} 102 | 103 | return result 104 | } 105 | -------------------------------------------------------------------------------- /soracom/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/soracom/soracom-cli/soracom/generated/cmd" 7 | ) 8 | 9 | func main() { 10 | os.Exit(run()) 11 | } 12 | 13 | func run() int { 14 | cmd.InitRootCmd() 15 | err := cmd.RootCmd.Execute() 16 | if err != nil { 17 | return -1 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /soracom/rsrc_windows_386.syso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soracom/soracom-cli/86ff177a1904dc83ead79efe710324a20021fc74/soracom/rsrc_windows_386.syso -------------------------------------------------------------------------------- /soracom/rsrc_windows_amd64.syso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soracom/soracom-cli/86ff177a1904dc83ead79efe710324a20021fc74/soracom/rsrc_windows_amd64.syso -------------------------------------------------------------------------------- /soracom/winres/SIS0233CL_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soracom/soracom-cli/86ff177a1904dc83ead79efe710324a20021fc74/soracom/winres/SIS0233CL_256x256.png -------------------------------------------------------------------------------- /soracom/winres/winres.json: -------------------------------------------------------------------------------- 1 | { 2 | "RT_GROUP_ICON": { 3 | "APP": { 4 | "0000": [ 5 | "SIS0233CL_256x256.png" 6 | ] 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/data/gps-multi-unit.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soracom/soracom-cli/86ff177a1904dc83ead79efe710324a20021fc74/test/data/gps-multi-unit.wasm --------------------------------------------------------------------------------