From a0122fd592ad91000be4d22a2191dbe65b149fb4 Mon Sep 17 00:00:00 2001 From: Armando Belardo <11140328+armandobelardo@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:44:31 -0500 Subject: [PATCH] =?UTF-8?q?fixes:=20=F0=9F=92=8E=20Ruby:=20Fix=20typos,=20?= =?UTF-8?q?imports=20and=20several=20other=20papercuts=20within=20SDK=20ge?= =?UTF-8?q?neration=20(#2868)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * several sdk fixes * add back the ruby playground and rerun with the right seed * several fixes for SDK * several fixes for SDK --- .gitignore | 2 +- generators/ruby/codegen/src/ast/Argument.ts | 2 +- generators/ruby/codegen/src/ast/Parameter.ts | 11 + generators/ruby/codegen/src/ast/Variable.ts | 5 +- generators/ruby/codegen/src/ast/Yardoc.ts | 51 +- .../ast/abstractions/ConditionalStatement.ts | 46 +- .../ast/abstractions/DiscriminatedUnion.ts | 13 +- .../ast/abstractions/SerializableObject.ts | 15 +- .../codegen/src/ast/classes/ClassReference.ts | 139 +++- .../ruby/codegen/src/ast/classes/Class_.ts | 8 +- .../ruby/codegen/src/ast/core/AstNode.ts | 6 +- .../codegen/src/ast/expressions/Expression.ts | 11 +- .../src/ast/functions/FunctionInvocation.ts | 24 +- .../codegen/src/ast/functions/Function_.ts | 22 +- .../ruby/codegen/src/ast/gem/Gemspec.ts | 17 +- generators/ruby/codegen/src/index.ts | 1 + .../codegen/src/utils/GeneratedRubyFile.ts | 38 +- .../codegen/src/utils/LocationGenerator.ts | 41 ++ .../ruby/codegen/src/utils/RubyUtilities.ts | 42 +- generators/ruby/model/src/TypesGenerator.ts | 26 +- generators/ruby/playground/README.md | 29 +- .../ruby/playground/lib/playground/version.rb | 6 + generators/ruby/sdk/CHANGELOG.md | 6 + generators/ruby/sdk/VERSION | 2 +- .../ruby/sdk/src/AbstractionUtilities.ts | 356 ++++++---- generators/ruby/sdk/src/ClientsGenerator.ts | 57 +- .../ruby/sdk/src/utils/EndpointGenerator.ts | 67 +- .../ruby/sdk/src/utils/FileUploadUtility.ts | 13 +- .../ruby/sdk/src/utils/HeadersGenerator.ts | 35 +- .../ruby/sdk/src/utils/RequestOptionsClass.ts | 10 +- .../ruby/sdk/src/utils/RootImportsFile.ts | 23 + seed/ruby-model/alias/.rubocop.yml | 3 - seed/ruby-model/alias/lib/gemconfig.rb | 1 + .../ruby-model/alias/lib/seed_alias_client.rb | 3 +- .../alias/seed_alias_client.gemspec | 1 + .../api-wide-base-path/.rubocop.yml | 3 - .../api-wide-base-path/lib/gemconfig.rb | 1 + .../seed_api_wide_base_path_client.gemspec | 1 + seed/ruby-model/audiences/.rubocop.yml | 3 - seed/ruby-model/audiences/lib/gemconfig.rb | 1 + .../audiences/lib/seed_audiences_client.rb | 2 +- .../folder_a/service/types/response.rb | 3 +- .../folder_b/common/types/foo.rb | 3 +- .../audiences/seed_audiences_client.gemspec | 1 + .../auth-environment-variables/.rubocop.yml | 3 - .../lib/gemconfig.rb | 1 + ..._auth_environment_variables_client.gemspec | 1 + seed/ruby-model/basic-auth/.rubocop.yml | 3 - seed/ruby-model/basic-auth/lib/gemconfig.rb | 1 + .../basic-auth/seed_basic_auth_client.gemspec | 1 + .../.rubocop.yml | 3 - .../lib/gemconfig.rb | 1 + ..._token_environment_variable_client.gemspec | 1 + seed/ruby-model/bytes/.rubocop.yml | 3 - seed/ruby-model/bytes/lib/gemconfig.rb | 1 + .../bytes/seed_bytes_client.gemspec | 1 + .../circular-references/.rubocop.yml | 3 - .../circular-references/lib/gemconfig.rb | 1 + .../lib/seed_api_client.rb | 7 +- .../seed_api_client/ast/types/field_value.rb | 11 +- .../ast/types/primitive_value.rb | 4 +- .../lib/seed_api_client/types/importing_a.rb | 3 +- .../seed_api_client.gemspec | 1 + seed/ruby-model/custom-auth/.rubocop.yml | 3 - seed/ruby-model/custom-auth/lib/gemconfig.rb | 1 + .../seed_custom_auth_client.gemspec | 1 + seed/ruby-model/enum/.rubocop.yml | 3 - seed/ruby-model/enum/lib/gemconfig.rb | 1 + seed/ruby-model/enum/lib/seed_enum_client.rb | 2 + .../lib/seed_enum_client/types/operand.rb | 4 +- seed/ruby-model/enum/seed_enum_client.gemspec | 1 + seed/ruby-model/error-property/.rubocop.yml | 3 - .../error-property/lib/gemconfig.rb | 1 + .../seed_error_property_client.gemspec | 1 + seed/ruby-model/examples/.rubocop.yml | 3 - seed/ruby-model/examples/lib/gemconfig.rb | 1 + .../examples/lib/seed_examples_client.rb | 26 +- .../types/types/directory.rb | 10 +- .../types/types/extended_movie.rb | 3 +- .../types/types/metadata.rb | 3 +- .../types/types/migration.rb | 11 +- .../types/types/migration_status.rb | 4 +- .../types/types/moment.rb | 4 +- .../seed_examples_client/types/types/movie.rb | 3 +- .../seed_examples_client/types/types/node.rb | 10 +- .../seed_examples_client/types/types/tree.rb | 5 +- .../examples/seed_examples_client.gemspec | 1 + seed/ruby-model/exhaustive/.rubocop.yml | 3 - seed/ruby-model/exhaustive/lib/gemconfig.rb | 1 + .../exhaustive/lib/seed_exhaustive_client.rb | 9 +- .../types/enum/types/weather_report.rb | 4 +- .../nested_object_with_optional_field.rb | 3 +- .../nested_object_with_required_field.rb | 3 +- .../types/object_with_optional_field.rb | 9 +- .../types/union/types/animal.rb | 2 +- .../exhaustive/seed_exhaustive_client.gemspec | 1 + seed/ruby-model/extends/.rubocop.yml | 3 - seed/ruby-model/extends/lib/gemconfig.rb | 1 + .../extends/lib/seed_extends_client.rb | 4 +- .../extends/seed_extends_client.gemspec | 1 + seed/ruby-model/file-download/.rubocop.yml | 3 - .../ruby-model/file-download/lib/gemconfig.rb | 1 + .../seed_file_download_client.gemspec | 1 + seed/ruby-model/file-upload/.rubocop.yml | 3 - seed/ruby-model/file-upload/lib/gemconfig.rb | 1 + .../seed_file_upload_client.gemspec | 1 + seed/ruby-model/folders/.rubocop.yml | 3 - seed/ruby-model/folders/lib/gemconfig.rb | 1 + .../folders/seed_api_client.gemspec | 1 + .../idempotency-headers/.rubocop.yml | 3 - .../idempotency-headers/lib/gemconfig.rb | 1 + .../lib/seed_idempotency_headers_client.rb | 2 + .../payment/types/currency.rb | 4 +- .../seed_idempotency_headers_client.gemspec | 1 + seed/ruby-model/imdb/.rubocop.yml | 3 - seed/ruby-model/imdb/lib/gemconfig.rb | 1 + seed/ruby-model/imdb/lib/seed_api_client.rb | 3 +- seed/ruby-model/imdb/seed_api_client.gemspec | 1 + seed/ruby-model/literal-headers/.rubocop.yml | 3 - .../literal-headers/lib/gemconfig.rb | 1 + .../seed_literal_headers_client.gemspec | 1 + seed/ruby-model/literal/.rubocop.yml | 3 - seed/ruby-model/literal/lib/gemconfig.rb | 1 + .../literal/lib/seed_literal_client.rb | 2 +- .../literal/seed_literal_client.gemspec | 1 + .../multi-url-environment/.rubocop.yml | 3 - .../multi-url-environment/lib/gemconfig.rb | 1 + .../seed_multi_url_environment_client.gemspec | 1 + seed/ruby-model/no-environment/.rubocop.yml | 3 - .../no-environment/lib/gemconfig.rb | 1 + .../seed_no_environment_client.gemspec | 1 + seed/ruby-model/object/.rubocop.yml | 3 - seed/ruby-model/object/lib/gemconfig.rb | 1 + .../object/lib/seed_object_client.rb | 3 +- .../lib/seed_object_client/types/type.rb | 10 +- .../object/seed_object_client.gemspec | 1 + .../objects-with-imports/.rubocop.yml | 3 - .../objects-with-imports/lib/gemconfig.rb | 1 + .../lib/seed_objects_with_imports_client.rb | 7 +- .../file/directory/types/directory.rb | 10 +- .../file/types/file.rb | 11 +- .../file/types/file_info.rb | 4 +- .../types/node.rb | 3 +- .../types/tree.rb | 5 +- .../seed_objects_with_imports_client.gemspec | 1 + seed/ruby-model/optional/.rubocop.yml | 3 - seed/ruby-model/optional/lib/gemconfig.rb | 1 + .../seed_objects_with_imports_client.gemspec | 1 + seed/ruby-model/package-yml/.rubocop.yml | 3 - seed/ruby-model/package-yml/lib/gemconfig.rb | 1 + .../seed_package_yml_client.gemspec | 1 + seed/ruby-model/plain-text/.rubocop.yml | 3 - seed/ruby-model/plain-text/lib/gemconfig.rb | 1 + .../plain-text/seed_plain_text_client.gemspec | 1 + .../ruby-model/reserved-keywords/.rubocop.yml | 3 - .../reserved-keywords/lib/gemconfig.rb | 1 + .../package/types/record.rb | 2 +- .../seed_nursery_api_client.gemspec | 1 + .../ruby-model/response-property/.rubocop.yml | 3 - .../response-property/lib/gemconfig.rb | 1 + .../lib/seed_response_property_client.rb | 9 +- .../service/types/response.rb | 3 +- .../seed_response_property_client.gemspec | 1 + .../.rubocop.yml | 3 - .../lib/gemconfig.rb | 1 + ...gle_url_environment_default_client.gemspec | 1 + .../.rubocop.yml | 3 - .../lib/gemconfig.rb | 1 + ..._url_environment_no_default_client.gemspec | 1 + seed/ruby-model/streaming/.rubocop.yml | 3 - seed/ruby-model/streaming/lib/gemconfig.rb | 1 + .../streaming/seed_streaming_client.gemspec | 1 + seed/ruby-model/trace/.rubocop.yml | 3 - seed/ruby-model/trace/lib/gemconfig.rb | 1 + .../ruby-model/trace/lib/seed_trace_client.rb | 314 +++++---- .../types/binary_tree_node_and_tree_value.rb | 6 +- .../commons/types/debug_key_value_pairs.rb | 6 +- .../commons/types/debug_map_value.rb | 5 +- .../commons/types/debug_variable_value.rb | 4 +- .../doubly_linked_list_node_and_list_value.rb | 6 +- .../commons/types/key_value_pair.rb | 6 +- .../commons/types/language.rb | 4 +- .../commons/types/list_type.rb | 3 +- .../commons/types/map_type.rb | 6 +- .../commons/types/map_value.rb | 5 +- .../singly_linked_list_node_and_list_value.rb | 3 +- .../commons/types/test_case.rb | 5 +- .../types/test_case_with_expected_result.rb | 6 +- .../commons/types/variable_value.rb | 4 +- .../migration/types/migration.rb | 11 +- .../migration/types/migration_status.rb | 4 +- .../playlist/types/playlist.rb | 3 +- .../playlist/types/reserved_keyword_enum.rb | 4 +- .../problem/types/create_problem_request.rb | 30 +- .../problem/types/create_problem_response.rb | 2 +- .../get_default_starter_files_response.rb | 10 +- .../problem/types/problem_description.rb | 5 +- .../problem/types/problem_files.rb | 8 +- .../problem/types/problem_info.rb | 30 +- .../problem/types/variable_type_and_name.rb | 3 +- .../types/building_executor_response.rb | 11 +- .../submission/types/code_execution_update.rb | 12 +- .../submission/types/error_info.rb | 2 +- .../submission/types/errored_response.rb | 6 +- .../types/execution_session_response.rb | 22 +- .../types/execution_session_state.rb | 22 +- .../types/execution_session_status.rb | 4 +- .../types/get_submission_state_response.rb | 16 +- .../types/graded_test_case_update.rb | 3 +- .../submission/types/internal_error.rb | 3 +- .../submission/types/invalid_request_cause.rb | 2 +- .../types/invalid_request_response.rb | 9 +- .../types/recording_response_notification.rb | 9 +- .../submission/types/running_response.rb | 11 +- .../types/running_submission_state.rb | 4 +- .../submission/types/stack_frame.rb | 5 +- .../submission/types/stack_information.rb | 3 +- .../submission/types/submission_request.rb | 2 +- .../submission/types/submission_response.rb | 4 +- .../types/submission_status_for_test_case.rb | 2 +- .../submission/types/submission_type_enum.rb | 4 +- .../submission/types/submit_request_v_2.rb | 19 +- .../types/test_case_non_hidden_grade.rb | 6 +- .../submission/types/test_case_result.rb | 6 +- .../types/test_case_result_with_stdout.rb | 3 +- .../submission/types/test_submission_state.rb | 13 +- .../types/test_submission_status.rb | 7 +- .../types/test_submission_status_v_2.rb | 12 +- .../types/test_submission_update.rb | 5 +- .../types/test_submission_update_info.rb | 9 +- .../submission/types/trace_response.rb | 15 +- .../submission/types/trace_response_v_2.rb | 16 +- .../submission/types/trace_responses_page.rb | 11 +- .../types/trace_responses_page_v_2.rb | 11 +- .../submission/types/traced_test_case.rb | 3 +- .../types/unexpected_language_error.rb | 22 +- .../submission/types/workspace_files.rb | 8 +- .../types/workspace_ran_response.rb | 3 +- .../submission/types/workspace_run_details.rb | 9 +- .../types/workspace_starter_files_response.rb | 10 +- .../workspace_starter_files_response_v_2.rb | 10 +- .../types/workspace_submission_state.rb | 3 +- .../types/workspace_submission_status.rb | 7 +- .../types/workspace_submission_status_v_2.rb | 5 +- .../types/workspace_submission_update.rb | 5 +- .../types/workspace_submission_update_info.rb | 11 +- .../types/workspace_submit_request.rb | 19 +- .../v_2/problem/types/basic_custom_files.rb | 19 +- .../problem/types/basic_test_case_template.rb | 6 +- .../types/create_problem_request_v_2.rb | 25 +- .../v_2/problem/types/custom_files.rb | 5 +- .../problem/types/default_provided_file.rb | 11 +- .../v_2/problem/types/files.rb | 5 +- ...n_implementation_for_multiple_languages.rb | 10 +- .../v_2/problem/types/function_signature.rb | 2 +- .../v_2/problem/types/generated_files.rb | 28 +- .../types/get_basic_solution_file_request.rb | 3 +- .../types/get_basic_solution_file_response.rb | 10 +- .../types/get_function_signature_request.rb | 3 +- .../types/get_function_signature_response.rb | 10 +- .../get_generated_test_case_file_request.rb | 6 +- ...nerated_test_case_template_file_request.rb | 3 +- .../types/lightweight_problem_info_v_2.rb | 5 +- .../types/non_void_function_definition.rb | 9 +- .../types/non_void_function_signature.rb | 11 +- .../v_2/problem/types/parameter.rb | 6 +- .../v_2/problem/types/problem_info_v_2.rb | 26 +- .../problem/types/test_case_implementation.rb | 9 +- .../test_case_implementation_description.rb | 5 +- .../v_2/problem/types/test_case_template.rb | 6 +- .../v_2/problem/types/test_case_v_2.rb | 12 +- ..._case_with_actual_result_implementation.rb | 9 +- .../problem/types/void_function_definition.rb | 11 +- ...ion_definition_that_takes_actual_result.rb | 11 +- .../problem/types/void_function_signature.rb | 5 +- ...tion_signature_that_takes_actual_result.rb | 11 +- .../v_3/problem/types/basic_custom_files.rb | 19 +- .../problem/types/basic_test_case_template.rb | 6 +- .../types/create_problem_request_v_2.rb | 25 +- .../v_2/v_3/problem/types/custom_files.rb | 5 +- .../problem/types/default_provided_file.rb | 11 +- .../v_2/v_3/problem/types/files.rb | 5 +- ...n_implementation_for_multiple_languages.rb | 10 +- .../v_3/problem/types/function_signature.rb | 2 +- .../v_2/v_3/problem/types/generated_files.rb | 28 +- .../types/get_basic_solution_file_request.rb | 3 +- .../types/get_basic_solution_file_response.rb | 10 +- .../types/get_function_signature_request.rb | 3 +- .../types/get_function_signature_response.rb | 10 +- .../get_generated_test_case_file_request.rb | 6 +- ...nerated_test_case_template_file_request.rb | 3 +- .../types/lightweight_problem_info_v_2.rb | 5 +- .../types/non_void_function_definition.rb | 9 +- .../types/non_void_function_signature.rb | 11 +- .../v_2/v_3/problem/types/parameter.rb | 6 +- .../v_2/v_3/problem/types/problem_info_v_2.rb | 26 +- .../problem/types/test_case_implementation.rb | 9 +- .../test_case_implementation_description.rb | 5 +- .../v_3/problem/types/test_case_template.rb | 6 +- .../v_2/v_3/problem/types/test_case_v_2.rb | 12 +- ..._case_with_actual_result_implementation.rb | 9 +- .../problem/types/void_function_definition.rb | 11 +- ...ion_definition_that_takes_actual_result.rb | 11 +- .../problem/types/void_function_signature.rb | 5 +- ...tion_signature_that_takes_actual_result.rb | 11 +- .../trace/seed_trace_client.gemspec | 1 + .../undiscriminated-unions/.rubocop.yml | 3 - .../undiscriminated-unions/lib/gemconfig.rb | 1 + ...seed_undiscriminated_unions_client.gemspec | 1 + seed/ruby-model/unknown/.rubocop.yml | 3 - seed/ruby-model/unknown/lib/gemconfig.rb | 1 + .../seed_unknown_as_any_client.gemspec | 1 + seed/ruby-model/variables/.rubocop.yml | 3 - seed/ruby-model/variables/lib/gemconfig.rb | 1 + .../variables/seed_variables_client.gemspec | 1 + seed/ruby-sdk/alias/.rubocop.yml | 3 - seed/ruby-sdk/alias/lib/gemconfig.rb | 1 + seed/ruby-sdk/alias/lib/requests.rb | 25 +- seed/ruby-sdk/alias/lib/seed_alias_client.rb | 16 +- seed/ruby-sdk/alias/lib/types_export.rb | 5 + seed/ruby-sdk/alias/seed_alias_client.gemspec | 1 + seed/ruby-sdk/api-wide-base-path/.rubocop.yml | 3 - .../api-wide-base-path/lib/gemconfig.rb | 1 + .../api-wide-base-path/lib/requests.rb | 25 +- .../lib/seed_api_wide_base_path_client.rb | 20 +- .../service/client.rb | 75 +- .../api-wide-base-path/lib/types_export.rb | 1 + .../seed_api_wide_base_path_client.gemspec | 1 + seed/ruby-sdk/audiences/.rubocop.yml | 3 - seed/ruby-sdk/audiences/lib/gemconfig.rb | 1 + seed/ruby-sdk/audiences/lib/requests.rb | 25 +- .../audiences/lib/seed_audiences_client.rb | 34 +- .../seed_audiences_client/folder_a/client.rb | 21 +- .../folder_a/service/client.rb | 67 +- .../folder_a/service/types/response.rb | 3 +- .../folder_b/common/types/foo.rb | 3 +- .../lib/seed_audiences_client/foo/client.rb | 110 +-- seed/ruby-sdk/audiences/lib/types_export.rb | 9 + .../audiences/seed_audiences_client.gemspec | 1 + .../auth-environment-variables/.rubocop.yml | 3 - .../lib/gemconfig.rb | 1 + .../lib/requests.rb | 35 +- .../seed_auth_environment_variables_client.rb | 26 +- .../service/client.rb | 74 +- .../lib/types_export.rb | 1 + ..._auth_environment_variables_client.gemspec | 1 + seed/ruby-sdk/basic-auth/.rubocop.yml | 3 - seed/ruby-sdk/basic-auth/lib/gemconfig.rb | 1 + seed/ruby-sdk/basic-auth/lib/requests.rb | 31 +- .../basic-auth/lib/seed_basic_auth_client.rb | 27 +- .../basic_auth/client.rb | 131 ++-- seed/ruby-sdk/basic-auth/lib/types_export.rb | 3 + .../basic-auth/seed_basic_auth_client.gemspec | 1 + .../.rubocop.yml | 3 - .../lib/gemconfig.rb | 1 + .../lib/requests.rb | 31 +- ...earer_token_environment_variable_client.rb | 26 +- .../service/client.rb | 74 +- .../lib/types_export.rb | 1 + ..._token_environment_variable_client.gemspec | 1 + seed/ruby-sdk/bytes/.rubocop.yml | 3 - seed/ruby-sdk/bytes/lib/gemconfig.rb | 1 + seed/ruby-sdk/bytes/lib/requests.rb | 25 +- seed/ruby-sdk/bytes/lib/seed_bytes_client.rb | 20 +- .../lib/seed_bytes_client/service/client.rb | 75 +- seed/ruby-sdk/bytes/lib/types_export.rb | 1 + seed/ruby-sdk/bytes/seed_bytes_client.gemspec | 1 + .../ruby-sdk/circular-references/.rubocop.yml | 3 - .../circular-references/lib/gemconfig.rb | 1 + .../circular-references/lib/requests.rb | 25 +- .../lib/seed_api_client.rb | 18 +- .../seed_api_client/ast/types/field_value.rb | 11 +- .../ast/types/primitive_value.rb | 4 +- .../lib/seed_api_client/types/importing_a.rb | 3 +- .../circular-references/lib/types_export.rb | 9 + .../seed_api_client.gemspec | 1 + seed/ruby-sdk/custom-auth/.rubocop.yml | 3 - seed/ruby-sdk/custom-auth/lib/gemconfig.rb | 1 + seed/ruby-sdk/custom-auth/lib/requests.rb | 35 +- .../lib/seed_custom_auth_client.rb | 27 +- .../custom_auth/client.rb | 123 ++-- seed/ruby-sdk/custom-auth/lib/types_export.rb | 3 + .../seed_custom_auth_client.gemspec | 1 + .../enum-query-params/lib/gemconfig.rb | 1 + .../enum-query-params/lib/requests.rb | 3 +- .../enum-query-params/lib/seed_api_client.rb | 18 +- .../lib/seed_api_client/svc/client.rb | 18 +- .../lib/seed_api_client/svc/types/my_enum.rb | 2 +- .../enum-query-params/seed_api_client.gemspec | 1 + seed/ruby-sdk/enum/.rubocop.yml | 3 - seed/ruby-sdk/enum/lib/gemconfig.rb | 1 + seed/ruby-sdk/enum/lib/requests.rb | 25 +- seed/ruby-sdk/enum/lib/seed_enum_client.rb | 28 +- .../inlined_request/client.rb | 72 +- .../lib/seed_enum_client/path_param/client.rb | 68 +- .../seed_enum_client/query_param/client.rb | 110 +-- .../lib/seed_enum_client/types/operand.rb | 4 +- seed/ruby-sdk/enum/lib/types_export.rb | 3 + seed/ruby-sdk/enum/seed_enum_client.gemspec | 1 + seed/ruby-sdk/error-property/.rubocop.yml | 3 - seed/ruby-sdk/error-property/lib/gemconfig.rb | 1 + seed/ruby-sdk/error-property/lib/requests.rb | 25 +- .../lib/seed_error_property_client.rb | 21 +- .../property_based_error/client.rb | 70 +- .../error-property/lib/types_export.rb | 3 + .../seed_error_property_client.gemspec | 1 + seed/ruby-sdk/examples/.rubocop.yml | 3 - seed/ruby-sdk/examples/lib/gemconfig.rb | 1 + seed/ruby-sdk/examples/lib/requests.rb | 32 +- .../examples/lib/seed_examples_client.rb | 90 +-- .../lib/seed_examples_client/file/client.rb | 28 +- .../file/notification/client.rb | 21 +- .../file/notification/service/client.rb | 75 +- .../file/service/client.rb | 75 +- .../lib/seed_examples_client/health/client.rb | 21 +- .../health/service/client.rb | 108 +-- .../seed_examples_client/service/client.rb | 221 +++--- .../types/types/directory.rb | 10 +- .../types/types/extended_movie.rb | 3 +- .../types/types/metadata.rb | 3 +- .../types/types/migration.rb | 11 +- .../types/types/migration_status.rb | 4 +- .../types/types/moment.rb | 4 +- .../seed_examples_client/types/types/movie.rb | 3 +- .../seed_examples_client/types/types/node.rb | 10 +- .../seed_examples_client/types/types/tree.rb | 5 +- seed/ruby-sdk/examples/lib/types_export.rb | 27 + .../examples/seed_examples_client.gemspec | 1 + seed/ruby-sdk/exhaustive/.rubocop.yml | 3 - seed/ruby-sdk/exhaustive/lib/gemconfig.rb | 1 + seed/ruby-sdk/exhaustive/lib/requests.rb | 31 +- .../exhaustive/lib/seed_exhaustive_client.rb | 60 +- .../endpoints/client.rb | 45 +- .../endpoints/container/client.rb | 386 +++++----- .../endpoints/enum/client.rb | 80 +-- .../endpoints/http_methods/client.rb | 322 ++++----- .../endpoints/object/client.rb | 437 ++++++------ .../endpoints/params/client.rb | 297 ++++---- .../endpoints/primitive/client.rb | 442 ++++++------ .../endpoints/union/client.rb | 79 +-- .../inlined_requests/client.rb | 155 ++-- .../seed_exhaustive_client/no_auth/client.rb | 82 ++- .../no_req_body/client.rb | 108 +-- .../req_with_headers/client.rb | 93 ++- .../types/enum/types/weather_report.rb | 4 +- .../nested_object_with_optional_field.rb | 3 +- .../nested_object_with_required_field.rb | 3 +- .../types/object_with_optional_field.rb | 9 +- .../types/union/types/animal.rb | 2 +- seed/ruby-sdk/exhaustive/lib/types_export.rb | 12 + .../exhaustive/seed_exhaustive_client.gemspec | 1 + seed/ruby-sdk/extends/.rubocop.yml | 3 - seed/ruby-sdk/extends/lib/gemconfig.rb | 1 + seed/ruby-sdk/extends/lib/requests.rb | 25 +- .../extends/lib/seed_extends_client.rb | 16 +- seed/ruby-sdk/extends/lib/types_export.rb | 6 + .../extends/seed_extends_client.gemspec | 1 + seed/ruby-sdk/file-download/.rubocop.yml | 3 - .../file-download/lib/core/file_utilities.rb | 10 +- seed/ruby-sdk/file-download/lib/gemconfig.rb | 1 + seed/ruby-sdk/file-download/lib/requests.rb | 29 +- .../lib/seed_file_download_client.rb | 21 +- .../service/client.rb | 68 +- .../file-download/lib/types_export.rb | 1 + .../seed_file_download_client.gemspec | 3 +- seed/ruby-sdk/file-upload/.rubocop.yml | 3 - .../file-upload/lib/core/file_utilities.rb | 10 +- seed/ruby-sdk/file-upload/lib/gemconfig.rb | 1 + seed/ruby-sdk/file-upload/lib/requests.rb | 29 +- .../lib/seed_file_upload_client.rb | 24 +- .../seed_file_upload_client/service/client.rb | 304 ++++---- seed/ruby-sdk/file-upload/lib/types_export.rb | 5 + .../seed_file_upload_client.gemspec | 3 +- seed/ruby-sdk/folders/.rubocop.yml | 3 - seed/ruby-sdk/folders/lib/gemconfig.rb | 1 + seed/ruby-sdk/folders/lib/requests.rb | 25 +- seed/ruby-sdk/folders/lib/seed_api_client.rb | 63 +- .../folders/lib/seed_api_client/a/b/client.rb | 15 +- .../folders/lib/seed_api_client/a/c/client.rb | 15 +- .../folders/lib/seed_api_client/a/client.rb | 28 +- .../lib/seed_api_client/folder/client.rb | 15 +- .../seed_api_client/folder/service/client.rb | 101 ++- seed/ruby-sdk/folders/lib/types_export.rb | 3 + seed/ruby-sdk/folders/seed_api_client.gemspec | 1 + .../ruby-sdk/idempotency-headers/.rubocop.yml | 3 - .../idempotency-headers/lib/gemconfig.rb | 1 + .../idempotency-headers/lib/requests.rb | 31 +- .../lib/seed_idempotency_headers_client.rb | 26 +- .../payment/client.rb | 125 ++-- .../payment/types/currency.rb | 4 +- .../idempotency-headers/lib/types_export.rb | 3 + .../seed_idempotency_headers_client.gemspec | 1 + seed/ruby-sdk/imdb/.rubocop.yml | 3 - seed/ruby-sdk/imdb/lib/gemconfig.rb | 1 + seed/ruby-sdk/imdb/lib/requests.rb | 31 +- seed/ruby-sdk/imdb/lib/seed_api_client.rb | 30 +- .../imdb/lib/seed_api_client/imdb/client.rb | 134 ++-- seed/ruby-sdk/imdb/lib/types_export.rb | 5 + seed/ruby-sdk/imdb/seed_api_client.gemspec | 1 + seed/ruby-sdk/literal-headers/.rubocop.yml | 3 - .../ruby-sdk/literal-headers/lib/gemconfig.rb | 1 + seed/ruby-sdk/literal-headers/lib/requests.rb | 31 +- .../lib/seed_literal_headers_client.rb | 30 +- .../no_headers/client.rb | 71 +- .../only_literal_headers/client.rb | 95 ++- .../with_non_literal_headers/client.rb | 101 ++- .../literal-headers/lib/types_export.rb | 1 + .../seed_literal_headers_client.gemspec | 1 + seed/ruby-sdk/literal/.rubocop.yml | 3 - seed/ruby-sdk/literal/lib/gemconfig.rb | 1 + seed/ruby-sdk/literal/lib/requests.rb | 25 +- .../literal/lib/seed_literal_client.rb | 23 +- .../lib/seed_literal_client/literal/client.rb | 159 +++-- seed/ruby-sdk/literal/lib/types_export.rb | 5 + .../literal/seed_literal_client.gemspec | 1 + .../multi-url-environment/.rubocop.yml | 3 - .../multi-url-environment/lib/environment.rb | 4 +- .../multi-url-environment/lib/gemconfig.rb | 1 + .../multi-url-environment/lib/requests.rb | 36 +- .../lib/seed_multi_url_environment_client.rb | 31 +- .../ec_2/client.rb | 79 +-- .../s_3/client.rb | 82 +-- .../multi-url-environment/lib/types_export.rb | 1 + .../seed_multi_url_environment_client.gemspec | 1 + seed/ruby-sdk/no-environment/.rubocop.yml | 3 - seed/ruby-sdk/no-environment/lib/gemconfig.rb | 1 + seed/ruby-sdk/no-environment/lib/requests.rb | 31 +- .../lib/seed_no_environment_client.rb | 26 +- .../dummy/client.rb | 70 +- .../no-environment/lib/types_export.rb | 1 + .../seed_no_environment_client.gemspec | 1 + seed/ruby-sdk/object/.rubocop.yml | 3 - seed/ruby-sdk/object/lib/gemconfig.rb | 1 + seed/ruby-sdk/object/lib/requests.rb | 25 +- .../ruby-sdk/object/lib/seed_object_client.rb | 15 +- .../lib/seed_object_client/types/type.rb | 10 +- seed/ruby-sdk/object/lib/types_export.rb | 4 + .../object/seed_object_client.gemspec | 1 + .../objects-with-imports/.rubocop.yml | 3 - .../objects-with-imports/lib/gemconfig.rb | 1 + .../objects-with-imports/lib/requests.rb | 25 +- .../lib/seed_objects_with_imports_client.rb | 17 +- .../file/directory/types/directory.rb | 10 +- .../file/types/file.rb | 11 +- .../file/types/file_info.rb | 4 +- .../types/node.rb | 3 +- .../types/tree.rb | 5 +- .../objects-with-imports/lib/types_export.rb | 8 + .../seed_objects_with_imports_client.gemspec | 1 + seed/ruby-sdk/optional/.rubocop.yml | 3 - seed/ruby-sdk/optional/lib/gemconfig.rb | 1 + seed/ruby-sdk/optional/lib/requests.rb | 25 +- .../lib/seed_objects_with_imports_client.rb | 20 +- .../optional/client.rb | 74 +- seed/ruby-sdk/optional/lib/types_export.rb | 1 + .../seed_objects_with_imports_client.gemspec | 1 + seed/ruby-sdk/package-yml/.rubocop.yml | 3 - seed/ruby-sdk/package-yml/lib/gemconfig.rb | 1 + seed/ruby-sdk/package-yml/lib/requests.rb | 25 +- .../lib/seed_package_yml_client.rb | 38 +- .../seed_package_yml_client/service/client.rb | 71 +- seed/ruby-sdk/package-yml/lib/types_export.rb | 1 + .../seed_package_yml_client.gemspec | 1 + seed/ruby-sdk/plain-text/.rubocop.yml | 3 - seed/ruby-sdk/plain-text/lib/gemconfig.rb | 1 + seed/ruby-sdk/plain-text/lib/requests.rb | 25 +- .../plain-text/lib/seed_plain_text_client.rb | 20 +- .../seed_plain_text_client/service/client.rb | 66 +- seed/ruby-sdk/plain-text/lib/types_export.rb | 1 + .../plain-text/seed_plain_text_client.gemspec | 1 + seed/ruby-sdk/reserved-keywords/.rubocop.yml | 3 - .../reserved-keywords/lib/gemconfig.rb | 1 + .../reserved-keywords/lib/requests.rb | 25 +- .../lib/seed_nursery_api_client.rb | 22 +- .../seed_nursery_api_client/package/client.rb | 71 +- .../package/types/record.rb | 2 +- .../reserved-keywords/lib/types_export.rb | 4 + .../seed_nursery_api_client.gemspec | 1 + seed/ruby-sdk/response-property/.rubocop.yml | 3 - .../response-property/lib/gemconfig.rb | 1 + .../response-property/lib/requests.rb | 25 +- .../lib/seed_response_property_client.rb | 28 +- .../service/client.rb | 373 +++++----- .../service/types/response.rb | 3 +- .../response-property/lib/types_export.rb | 9 + .../seed_response_property_client.gemspec | 1 + .../.rubocop.yml | 3 - .../lib/gemconfig.rb | 1 + .../lib/requests.rb | 32 +- ...d_single_url_environment_default_client.rb | 27 +- .../dummy/client.rb | 70 +- .../lib/types_export.rb | 1 + ...gle_url_environment_default_client.gemspec | 1 + .../.rubocop.yml | 3 - .../lib/gemconfig.rb | 1 + .../lib/requests.rb | 32 +- ...ingle_url_environment_no_default_client.rb | 27 +- .../dummy/client.rb | 70 +- .../lib/types_export.rb | 1 + ..._url_environment_no_default_client.gemspec | 1 + seed/ruby-sdk/streaming/.rubocop.yml | 3 - seed/ruby-sdk/streaming/lib/gemconfig.rb | 1 + seed/ruby-sdk/streaming/lib/requests.rb | 25 +- .../streaming/lib/seed_streaming_client.rb | 21 +- .../lib/seed_streaming_client/dummy/client.rb | 34 +- seed/ruby-sdk/streaming/lib/types_export.rb | 3 + .../streaming/seed_streaming_client.gemspec | 1 + seed/ruby-sdk/trace/.rubocop.yml | 3 - seed/ruby-sdk/trace/lib/gemconfig.rb | 1 + seed/ruby-sdk/trace/lib/requests.rb | 34 +- seed/ruby-sdk/trace/lib/seed_trace_client.rb | 280 +------- .../lib/seed_trace_client/admin/client.rb | 665 ++++++++++-------- .../types/binary_tree_node_and_tree_value.rb | 6 +- .../commons/types/debug_key_value_pairs.rb | 6 +- .../commons/types/debug_map_value.rb | 5 +- .../commons/types/debug_variable_value.rb | 4 +- .../doubly_linked_list_node_and_list_value.rb | 6 +- .../commons/types/key_value_pair.rb | 6 +- .../commons/types/language.rb | 4 +- .../commons/types/list_type.rb | 3 +- .../commons/types/map_type.rb | 6 +- .../commons/types/map_value.rb | 5 +- .../singly_linked_list_node_and_list_value.rb | 3 +- .../commons/types/test_case.rb | 5 +- .../types/test_case_with_expected_result.rb | 6 +- .../commons/types/variable_value.rb | 4 +- .../lib/seed_trace_client/homepage/client.rb | 120 ++-- .../lib/seed_trace_client/migration/client.rb | 99 ++- .../migration/types/migration.rb | 11 +- .../migration/types/migration_status.rb | 4 +- .../lib/seed_trace_client/playlist/client.rb | 409 ++++++----- .../playlist/types/playlist.rb | 3 +- .../playlist/types/reserved_keyword_enum.rb | 4 +- .../lib/seed_trace_client/problem/client.rb | 357 +++++----- .../problem/types/create_problem_request.rb | 30 +- .../problem/types/create_problem_response.rb | 2 +- .../get_default_starter_files_response.rb | 10 +- .../problem/types/problem_description.rb | 5 +- .../problem/types/problem_files.rb | 8 +- .../problem/types/problem_info.rb | 30 +- .../problem/types/variable_type_and_name.rb | 3 +- .../seed_trace_client/submission/client.rb | 222 +++--- .../types/building_executor_response.rb | 11 +- .../submission/types/code_execution_update.rb | 12 +- .../submission/types/error_info.rb | 2 +- .../submission/types/errored_response.rb | 6 +- .../types/execution_session_response.rb | 22 +- .../types/execution_session_state.rb | 22 +- .../types/execution_session_status.rb | 4 +- .../types/get_submission_state_response.rb | 16 +- .../types/graded_test_case_update.rb | 3 +- .../submission/types/internal_error.rb | 3 +- .../submission/types/invalid_request_cause.rb | 2 +- .../types/invalid_request_response.rb | 9 +- .../types/recording_response_notification.rb | 9 +- .../submission/types/running_response.rb | 11 +- .../types/running_submission_state.rb | 4 +- .../submission/types/stack_frame.rb | 5 +- .../submission/types/stack_information.rb | 3 +- .../submission/types/submission_request.rb | 2 +- .../submission/types/submission_response.rb | 4 +- .../types/submission_status_for_test_case.rb | 2 +- .../submission/types/submission_type_enum.rb | 4 +- .../submission/types/submit_request_v_2.rb | 19 +- .../types/test_case_non_hidden_grade.rb | 6 +- .../submission/types/test_case_result.rb | 6 +- .../types/test_case_result_with_stdout.rb | 3 +- .../submission/types/test_submission_state.rb | 13 +- .../types/test_submission_status.rb | 7 +- .../types/test_submission_status_v_2.rb | 12 +- .../types/test_submission_update.rb | 5 +- .../types/test_submission_update_info.rb | 9 +- .../submission/types/trace_response.rb | 15 +- .../submission/types/trace_response_v_2.rb | 16 +- .../submission/types/trace_responses_page.rb | 11 +- .../types/trace_responses_page_v_2.rb | 11 +- .../submission/types/traced_test_case.rb | 3 +- .../types/unexpected_language_error.rb | 22 +- .../submission/types/workspace_files.rb | 8 +- .../types/workspace_ran_response.rb | 3 +- .../submission/types/workspace_run_details.rb | 9 +- .../types/workspace_starter_files_response.rb | 10 +- .../workspace_starter_files_response_v_2.rb | 10 +- .../types/workspace_submission_state.rb | 3 +- .../types/workspace_submission_status.rb | 7 +- .../types/workspace_submission_status_v_2.rb | 5 +- .../types/workspace_submission_update.rb | 5 +- .../types/workspace_submission_update_info.rb | 11 +- .../types/workspace_submit_request.rb | 19 +- .../lib/seed_trace_client/sysprop/client.rb | 134 ++-- .../trace/lib/seed_trace_client/v_2/client.rb | 26 +- .../seed_trace_client/v_2/problem/client.rb | 259 ++++--- .../v_2/problem/types/basic_custom_files.rb | 19 +- .../problem/types/basic_test_case_template.rb | 6 +- .../types/create_problem_request_v_2.rb | 25 +- .../v_2/problem/types/custom_files.rb | 5 +- .../problem/types/default_provided_file.rb | 11 +- .../v_2/problem/types/files.rb | 5 +- ...n_implementation_for_multiple_languages.rb | 10 +- .../v_2/problem/types/function_signature.rb | 2 +- .../v_2/problem/types/generated_files.rb | 28 +- .../types/get_basic_solution_file_request.rb | 3 +- .../types/get_basic_solution_file_response.rb | 10 +- .../types/get_function_signature_request.rb | 3 +- .../types/get_function_signature_response.rb | 10 +- .../get_generated_test_case_file_request.rb | 6 +- ...nerated_test_case_template_file_request.rb | 3 +- .../types/lightweight_problem_info_v_2.rb | 5 +- .../types/non_void_function_definition.rb | 9 +- .../types/non_void_function_signature.rb | 11 +- .../v_2/problem/types/parameter.rb | 6 +- .../v_2/problem/types/problem_info_v_2.rb | 26 +- .../problem/types/test_case_implementation.rb | 9 +- .../test_case_implementation_description.rb | 5 +- .../v_2/problem/types/test_case_template.rb | 6 +- .../v_2/problem/types/test_case_v_2.rb | 12 +- ..._case_with_actual_result_implementation.rb | 9 +- .../problem/types/void_function_definition.rb | 11 +- ...ion_definition_that_takes_actual_result.rb | 11 +- .../problem/types/void_function_signature.rb | 5 +- ...tion_signature_that_takes_actual_result.rb | 11 +- .../lib/seed_trace_client/v_2/v_3/client.rb | 21 +- .../v_2/v_3/problem/client.rb | 263 ++++--- .../v_3/problem/types/basic_custom_files.rb | 19 +- .../problem/types/basic_test_case_template.rb | 6 +- .../types/create_problem_request_v_2.rb | 25 +- .../v_2/v_3/problem/types/custom_files.rb | 5 +- .../problem/types/default_provided_file.rb | 11 +- .../v_2/v_3/problem/types/files.rb | 5 +- ...n_implementation_for_multiple_languages.rb | 10 +- .../v_3/problem/types/function_signature.rb | 2 +- .../v_2/v_3/problem/types/generated_files.rb | 28 +- .../types/get_basic_solution_file_request.rb | 3 +- .../types/get_basic_solution_file_response.rb | 10 +- .../types/get_function_signature_request.rb | 3 +- .../types/get_function_signature_response.rb | 10 +- .../get_generated_test_case_file_request.rb | 6 +- ...nerated_test_case_template_file_request.rb | 3 +- .../types/lightweight_problem_info_v_2.rb | 5 +- .../types/non_void_function_definition.rb | 9 +- .../types/non_void_function_signature.rb | 11 +- .../v_2/v_3/problem/types/parameter.rb | 6 +- .../v_2/v_3/problem/types/problem_info_v_2.rb | 26 +- .../problem/types/test_case_implementation.rb | 9 +- .../test_case_implementation_description.rb | 5 +- .../v_3/problem/types/test_case_template.rb | 6 +- .../v_2/v_3/problem/types/test_case_v_2.rb | 12 +- ..._case_with_actual_result_implementation.rb | 9 +- .../problem/types/void_function_definition.rb | 11 +- ...ion_definition_that_takes_actual_result.rb | 11 +- .../problem/types/void_function_signature.rb | 5 +- ...tion_signature_that_takes_actual_result.rb | 11 +- seed/ruby-sdk/trace/lib/types_export.rb | 212 ++++++ seed/ruby-sdk/trace/seed_trace_client.gemspec | 1 + .../undiscriminated-unions/.rubocop.yml | 3 - .../undiscriminated-unions/lib/gemconfig.rb | 1 + .../undiscriminated-unions/lib/requests.rb | 25 +- .../lib/seed_undiscriminated_unions_client.rb | 21 +- .../union/client.rb | 75 +- .../lib/types_export.rb | 3 + ...seed_undiscriminated_unions_client.gemspec | 1 + seed/ruby-sdk/unknown/.rubocop.yml | 3 - seed/ruby-sdk/unknown/lib/gemconfig.rb | 1 + seed/ruby-sdk/unknown/lib/requests.rb | 25 +- .../unknown/lib/seed_unknown_as_any_client.rb | 22 +- .../unknown/client.rb | 74 +- seed/ruby-sdk/unknown/lib/types_export.rb | 4 + .../seed_unknown_as_any_client.gemspec | 1 + seed/ruby-sdk/variables/.rubocop.yml | 3 - seed/ruby-sdk/variables/lib/gemconfig.rb | 1 + seed/ruby-sdk/variables/lib/requests.rb | 25 +- .../variables/lib/seed_variables_client.rb | 20 +- .../seed_variables_client/service/client.rb | 67 +- seed/ruby-sdk/variables/lib/types_export.rb | 1 + .../variables/seed_variables_client.gemspec | 1 + 775 files changed, 8979 insertions(+), 7487 deletions(-) create mode 100644 generators/ruby/codegen/src/utils/LocationGenerator.ts create mode 100644 generators/ruby/playground/lib/playground/version.rb create mode 100644 generators/ruby/sdk/src/utils/RootImportsFile.ts create mode 100644 seed/ruby-sdk/alias/lib/types_export.rb create mode 100644 seed/ruby-sdk/api-wide-base-path/lib/types_export.rb create mode 100644 seed/ruby-sdk/audiences/lib/types_export.rb create mode 100644 seed/ruby-sdk/auth-environment-variables/lib/types_export.rb create mode 100644 seed/ruby-sdk/basic-auth/lib/types_export.rb create mode 100644 seed/ruby-sdk/bearer-token-environment-variable/lib/types_export.rb create mode 100644 seed/ruby-sdk/bytes/lib/types_export.rb create mode 100644 seed/ruby-sdk/circular-references/lib/types_export.rb create mode 100644 seed/ruby-sdk/custom-auth/lib/types_export.rb create mode 100644 seed/ruby-sdk/enum/lib/types_export.rb create mode 100644 seed/ruby-sdk/error-property/lib/types_export.rb create mode 100644 seed/ruby-sdk/examples/lib/types_export.rb create mode 100644 seed/ruby-sdk/exhaustive/lib/types_export.rb create mode 100644 seed/ruby-sdk/extends/lib/types_export.rb create mode 100644 seed/ruby-sdk/file-download/lib/types_export.rb create mode 100644 seed/ruby-sdk/file-upload/lib/types_export.rb create mode 100644 seed/ruby-sdk/folders/lib/types_export.rb create mode 100644 seed/ruby-sdk/idempotency-headers/lib/types_export.rb create mode 100644 seed/ruby-sdk/imdb/lib/types_export.rb create mode 100644 seed/ruby-sdk/literal-headers/lib/types_export.rb create mode 100644 seed/ruby-sdk/literal/lib/types_export.rb create mode 100644 seed/ruby-sdk/multi-url-environment/lib/types_export.rb create mode 100644 seed/ruby-sdk/no-environment/lib/types_export.rb create mode 100644 seed/ruby-sdk/object/lib/types_export.rb create mode 100644 seed/ruby-sdk/objects-with-imports/lib/types_export.rb create mode 100644 seed/ruby-sdk/optional/lib/types_export.rb create mode 100644 seed/ruby-sdk/package-yml/lib/types_export.rb create mode 100644 seed/ruby-sdk/plain-text/lib/types_export.rb create mode 100644 seed/ruby-sdk/reserved-keywords/lib/types_export.rb create mode 100644 seed/ruby-sdk/response-property/lib/types_export.rb create mode 100644 seed/ruby-sdk/single-url-environment-default/lib/types_export.rb create mode 100644 seed/ruby-sdk/single-url-environment-no-default/lib/types_export.rb create mode 100644 seed/ruby-sdk/streaming/lib/types_export.rb create mode 100644 seed/ruby-sdk/trace/lib/types_export.rb create mode 100644 seed/ruby-sdk/undiscriminated-unions/lib/types_export.rb create mode 100644 seed/ruby-sdk/unknown/lib/types_export.rb create mode 100644 seed/ruby-sdk/variables/lib/types_export.rb diff --git a/.gitignore b/.gitignore index 707ece08fe3..bd68feec06d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ generators/**/tsconfig*tsbuildinfo generators/**/out # don't ignore the ruby lib within the playground -!packages/**/ruby/playground/lib +!generators/ruby/playground/lib # next .next diff --git a/generators/ruby/codegen/src/ast/Argument.ts b/generators/ruby/codegen/src/ast/Argument.ts index 4ce4a0ff7d9..23ca779f2ae 100644 --- a/generators/ruby/codegen/src/ast/Argument.ts +++ b/generators/ruby/codegen/src/ast/Argument.ts @@ -37,7 +37,7 @@ export class Argument extends AstNode { }); } - public fromJson(): FunctionInvocation | undefined { + public fromJson(): AstNode | undefined { return; } } diff --git a/generators/ruby/codegen/src/ast/Parameter.ts b/generators/ruby/codegen/src/ast/Parameter.ts index 57301e1b4e8..a10cd513551 100644 --- a/generators/ruby/codegen/src/ast/Parameter.ts +++ b/generators/ruby/codegen/src/ast/Parameter.ts @@ -1,3 +1,4 @@ +import { Argument } from "./Argument"; import { ClassReference, NilValue } from "./classes/ClassReference"; import { AstNode } from "./core/AstNode"; import { Import } from "./Import"; @@ -58,4 +59,14 @@ export class Parameter extends AstNode { this.type.forEach((cr) => (imports = new Set([...imports, ...cr.getImports()]))); return imports; } + + public toArgument(value: Variable | string): Argument { + return new Argument({ + name: this.name, + type: this.type, + value, + isNamed: this.isNamed, + documentation: this.documentation + }); + } } diff --git a/generators/ruby/codegen/src/ast/Variable.ts b/generators/ruby/codegen/src/ast/Variable.ts index f0ef0bf05f8..988e74dd960 100644 --- a/generators/ruby/codegen/src/ast/Variable.ts +++ b/generators/ruby/codegen/src/ast/Variable.ts @@ -1,6 +1,5 @@ import { ClassReference } from "./classes/ClassReference"; import { AstNode } from "./core/AstNode"; -import { FunctionInvocation } from "./functions/FunctionInvocation"; export enum VariableType { CLASS, @@ -45,10 +44,10 @@ export class Variable extends AstNode { this.addText({ stringContent: this.name, templateString, startingTabSpaces }); } - public fromJson(): FunctionInvocation | undefined { + public fromJson(): AstNode | undefined { const classReferences = this.type; // Do not support calling fromJson when there are multiple class references - if (classReferences.length === 0) { + if (classReferences.length <= 1) { const classReference = classReferences.at(0); return classReference !== undefined ? classReference.fromJson(this) : undefined; } diff --git a/generators/ruby/codegen/src/ast/Yardoc.ts b/generators/ruby/codegen/src/ast/Yardoc.ts index cc652602c06..327b4004fd9 100644 --- a/generators/ruby/codegen/src/ast/Yardoc.ts +++ b/generators/ruby/codegen/src/ast/Yardoc.ts @@ -1,5 +1,5 @@ import { ObjectProperty, TypeId } from "@fern-fern/ir-sdk/api"; -import { ClassReference, ClassReferenceFactory } from "./classes/ClassReference"; +import { ArrayReference, ClassReference, ClassReferenceFactory } from "./classes/ClassReference"; import { AstNode } from "./core/AstNode"; import { Parameter } from "./Parameter"; import { Property } from "./Property"; @@ -69,20 +69,45 @@ export class Yardoc extends AstNode { } } + private writeMultilineYardocComment(documentation?: string[], defaultComment?: string): void { + documentation?.forEach((doc, index) => { + const trimmedDoc = doc.trim(); + this.addText({ + stringContent: trimmedDoc.length > 0 ? trimmedDoc : undefined, + templateString: index > 0 ? "# " : undefined, + appendToLastString: index === 0 + }); + }) ?? this.addText({ stringContent: defaultComment, appendToLastString: true }); + } + private writeParameterAsHash(parameter: Parameter, startingTabSpaces: number): void { - const typeId = parameter.type[0]?.resolvedTypeId; - const properties: ObjectProperty[] | undefined = this.flattenedProperties?.get(typeId ?? ""); + // TODO: handle multitype better with hashes + if (parameter.type.length > 1) { + return this.writeParameterAsClass(parameter, startingTabSpaces); + } + + let typeId = parameter.type[0]?.resolvedTypeId; + let isArray = false; const classFactory = this.crf; + // TODO: handle nested hashes better + if (parameter.type[0] instanceof ArrayReference && parameter.type[0].innerType instanceof ClassReference) { + isArray = true; + typeId = parameter.type[0].innerType.resolvedTypeId; + } + const properties: ObjectProperty[] | undefined = this.flattenedProperties?.get(typeId ?? ""); + if (typeId === undefined || properties === undefined || classFactory === undefined) { this.writeParameterAsClass(parameter, startingTabSpaces); } else { - this.addText({ stringContent: parameter.name, templateString: "# @param %s [Hash] ", startingTabSpaces }); this.addText({ - stringContent: - parameter.documentation ?? - `Request of type ${parameter.type.map((param) => param.typeHint).join(", ")}, as a Hash`, - appendToLastString: true + stringContent: parameter.name, + templateString: isArray ? "# @param %s [Array] " : "# @param %s [Hash] ", + startingTabSpaces }); + this.writeMultilineYardocComment( + parameter.documentation, + `Request of type ${parameter.type.map((param) => param.typeHint).join(", ")}, as a Hash` + ); properties.forEach((prop) => { const classReference = classFactory.fromTypeReference(prop.valueType); this.writeHashContents( @@ -99,7 +124,7 @@ export class Yardoc extends AstNode { private writeParameterAsClass(parameter: Parameter, startingTabSpaces: number): void { if (parameter.isBlock) { this.addText({ stringContent: parameter.name, templateString: "# @yield", startingTabSpaces }); - this.addText({ stringContent: parameter.documentation, appendToLastString: true }); + this.writeMultilineYardocComment(parameter.documentation); } else { this.addText({ stringContent: parameter.name, templateString: "# @param %s", startingTabSpaces }); this.addText({ @@ -107,7 +132,7 @@ export class Yardoc extends AstNode { templateString: " [%s] ", appendToLastString: true }); - this.addText({ stringContent: parameter.documentation, appendToLastString: true }); + this.writeMultilineYardocComment(parameter.documentation); } } @@ -120,10 +145,10 @@ export class Yardoc extends AstNode { : this.reference.type instanceof ClassReference ? this.reference.type.typeHint : this.reference.type; - const documentation = - this.reference.type instanceof Property ? this.reference.type.documentation : undefined; this.addText({ stringContent: typeName, templateString: "# @type [%s] ", startingTabSpaces }); - this.addText({ stringContent: documentation, appendToLastString: true }); + this.writeMultilineYardocComment( + this.reference.type instanceof Property ? this.reference.type.documentation : [] + ); } else { this.reference.parameters.forEach((parameter) => { if (parameter.describeAsHashInYardoc) { diff --git a/generators/ruby/codegen/src/ast/abstractions/ConditionalStatement.ts b/generators/ruby/codegen/src/ast/abstractions/ConditionalStatement.ts index 4f5fe52de4d..0a9955bbc7d 100644 --- a/generators/ruby/codegen/src/ast/abstractions/ConditionalStatement.ts +++ b/generators/ruby/codegen/src/ast/abstractions/ConditionalStatement.ts @@ -1,4 +1,5 @@ import { BLOCK_END } from "../../utils/RubyConstants"; +import { Class_ } from "../classes/Class_"; import { AstNode } from "../core/AstNode"; import { Import } from "../Import"; @@ -28,23 +29,24 @@ export class ConditionalStatement extends AstNode { } private writeCondition(startingTabSpaces: number, condition: Condition, type: "if" | "elsif" | "else"): void { - if (condition.operation === "!" && condition.leftSide === undefined) { - this.addText({ - stringContent: "unless ", - startingTabSpaces - }); - } else { + const updatedType = + condition.operation === "!" && (condition.leftSide === undefined || condition.rightSide === undefined) + ? "unless" + : type; + const leftString = condition.leftSide instanceof AstNode ? condition.leftSide.write({}) : condition.leftSide; + const rightString = + condition.rightSide instanceof AstNode ? condition.rightSide.write({}) : condition.rightSide; + this.addText({ + stringContent: leftString ?? rightString, + templateString: `${updatedType} %s`, + startingTabSpaces + }); + if (condition.leftSide !== undefined && condition.rightSide !== undefined) { this.addText({ - stringContent: - condition.leftSide instanceof AstNode ? condition.leftSide.write({}) : condition.leftSide, - templateString: `${type} %s`, + stringContent: rightString, startingTabSpaces }); } - this.addText({ - stringContent: condition.rightSide instanceof AstNode ? condition.rightSide.write({}) : condition.rightSide, - appendToLastString: true - }); condition.expressions.forEach((exp) => this.addText({ stringContent: exp.write({}), startingTabSpaces: this.tabSizeSpaces + startingTabSpaces }) ); @@ -73,11 +75,19 @@ export class ConditionalStatement extends AstNode { public getImports(): Set { let imports = new Set(); - [ - ...this.if_.expressions, - ...Array.from(this.elseIf?.values() ?? []).flatMap((condition) => condition.expressions), - ...(this.else_ ?? []) - ].forEach((exp) => (imports = new Set([...imports, ...exp.getImports()]))); + ( + [ + this.if_.leftSide, + this.if_.rightSide, + ...this.if_.expressions, + ...Array.from(this.elseIf?.values() ?? []).flatMap((condition) => [ + condition.leftSide, + condition.rightSide, + ...condition.expressions + ]), + ...(this.else_ ?? []) + ].filter((node) => node instanceof AstNode && !(node instanceof Class_)) as AstNode[] + ).forEach((exp) => (imports = new Set([...imports, ...exp.getImports()]))); return imports; } } diff --git a/generators/ruby/codegen/src/ast/abstractions/DiscriminatedUnion.ts b/generators/ruby/codegen/src/ast/abstractions/DiscriminatedUnion.ts index a56f0058117..55be0cac32b 100644 --- a/generators/ruby/codegen/src/ast/abstractions/DiscriminatedUnion.ts +++ b/generators/ruby/codegen/src/ast/abstractions/DiscriminatedUnion.ts @@ -11,6 +11,7 @@ import { VoidClassReference } from "../classes/ClassReference"; import { Class_ } from "../classes/Class_"; +import { AstNode } from "../core/AstNode"; import { Expression } from "../expressions/Expression"; import { FunctionInvocation } from "../functions/FunctionInvocation"; import { Function_ } from "../functions/Function_"; @@ -78,7 +79,7 @@ export class DiscriminatedUnion extends Class_ { memberProperty: Property, unionSubclass: DiscriminatedUnion.Subclass ): Expression { - const rightSide = unionSubclass.unionPropertiesType._visit({ + const rightSide = unionSubclass.unionPropertiesType._visit({ samePropertiesAsObject: () => unionSubclass.classReference?.fromJson(jsonParameter) ?? jsonParameter, singleProperty: (sutp: SingleUnionTypeProperty) => unionSubclass.classReference?.fromJson(`${jsonParameter}.${sutp.name.wireValue}`) ?? @@ -175,10 +176,12 @@ export class DiscriminatedUnion extends Class_ { contents: new Map([[discriminantField, discriminantProperty.toVariable()]]), // Take the member property and spread it into this hash that includes the discriminant additionalHashes: [ - new FunctionInvocation({ - baseFunction: new Function_({ name: "to_json", functionBody: [] }), - onObject: memberProperty.toVariable() - }) + { + value: new FunctionInvocation({ + baseFunction: new Function_({ name: "to_json", functionBody: [] }), + onObject: memberProperty.toVariable() + }) + } ] }), singleProperty: (sutp: SingleUnionTypeProperty) => diff --git a/generators/ruby/codegen/src/ast/abstractions/SerializableObject.ts b/generators/ruby/codegen/src/ast/abstractions/SerializableObject.ts index bda8fef39b3..b5637682c73 100644 --- a/generators/ruby/codegen/src/ast/abstractions/SerializableObject.ts +++ b/generators/ruby/codegen/src/ast/abstractions/SerializableObject.ts @@ -3,6 +3,7 @@ import { ArrayReference, ClassReference, DateReference, + EnumReference, GenericClassReference, HashInstance, HashReference, @@ -77,9 +78,9 @@ export class SerializableObject extends Class_ { const hasFromJson = variable.fromJson() !== undefined && - !(prop.type instanceof ArrayReference) && - !(prop.type instanceof HashReference) && - !(prop.type instanceof DateReference); + !(prop.type[0] instanceof ArrayReference) && + !(prop.type[0] instanceof HashReference) && + !(prop.type[0] instanceof DateReference); if (hasFromJson) { // If there's a special fromJson, then cast the object back to JSON before proceeding const variable = new Variable({ @@ -141,7 +142,13 @@ export class SerializableObject extends Class_ { baseFunction: new Function_({ name: "to_json", functionBody: [] }), onObject: new HashInstance({ contents: new Map( - properties?.map((prop) => [`"${prop.wireValue ?? prop.name}"`, prop.toVariable()]) + properties?.map((prop) => { + if (prop.type[0] instanceof EnumReference) { + return [`"${prop.wireValue ?? prop.name}"`, prop.type[0].toJson(prop.toVariable())]; + } + // TODO: confirm enums are the only special case here + return [`"${prop.wireValue ?? prop.name}"`, prop.toVariable()]; + }) ) }) }) diff --git a/generators/ruby/codegen/src/ast/classes/ClassReference.ts b/generators/ruby/codegen/src/ast/classes/ClassReference.ts index 87221f63877..5bf48f708ee 100644 --- a/generators/ruby/codegen/src/ast/classes/ClassReference.ts +++ b/generators/ruby/codegen/src/ast/classes/ClassReference.ts @@ -13,7 +13,7 @@ import { TypeReference } from "@fern-fern/ir-sdk/api"; import { format } from "util"; -import { getLocationForTypeDeclaration } from "../../utils/RubyUtilities"; +import { LocationGenerator } from "../../utils/LocationGenerator"; import { Argument } from "../Argument"; import { AstNode } from "../core/AstNode"; import { Expression } from "../expressions/Expression"; @@ -80,7 +80,7 @@ export class ClassReference extends AstNode { this.addText({ stringContent: this.qualifiedName, startingTabSpaces }); } - public fromJson(_variable: Variable | string): FunctionInvocation | undefined { + public fromJson(_variable: Variable | string): AstNode | undefined { return; } @@ -135,7 +135,7 @@ export class SerializableObjectReference extends ClassReference { super({ ...init }); } - public fromJson(variable: string | Variable): FunctionInvocation | undefined { + public fromJson(variable: string | Variable): AstNode | undefined { return new FunctionInvocation({ baseFunction: new Function_({ name: "from_json", functionBody: [] }), onObject: this.qualifiedName, @@ -168,8 +168,11 @@ export class SerializableObjectReference extends ClassReference { }); } - static fromDeclaredTypeName(declaredTypeName: DeclaredTypeName): ClassReference { - const location = getLocationForTypeDeclaration(declaredTypeName); + static fromDeclaredTypeName( + declaredTypeName: DeclaredTypeName, + locationGenerator: LocationGenerator + ): ClassReference { + const location = locationGenerator.getLocationForTypeDeclaration(declaredTypeName); const moduleBreadcrumbs = Module_.getModulePathFromTypeName(declaredTypeName.fernFilepath, true); return new SerializableObjectReference({ name: declaredTypeName.name.pascalCase.safeName, @@ -192,7 +195,7 @@ export class AliasReference extends ClassReference { this.aliasOf = aliasOf; } - public fromJson(variable: string | Variable): FunctionInvocation | undefined { + public fromJson(variable: string | Variable): AstNode | undefined { return this.aliasOf.fromJson(variable); } @@ -203,9 +206,10 @@ export class AliasReference extends ClassReference { static fromDeclaredTypeName( declaredTypeName: DeclaredTypeName, aliasOf: ClassReference, - resolvedTypeId: string | undefined + resolvedTypeId: string | undefined, + locationGenerator: LocationGenerator ): ClassReference { - const location = getLocationForTypeDeclaration(declaredTypeName); + const location = locationGenerator.getLocationForTypeDeclaration(declaredTypeName); const moduleBreadcrumbs = Module_.getModulePathFromTypeName(declaredTypeName.fernFilepath, true); return new AliasReference({ aliasOf, @@ -226,7 +230,7 @@ export declare namespace ArrayReference { } } export class ArrayReference extends ClassReference { - private innerType: ClassReference | string; + public innerType: ClassReference | string; constructor({ innerType, ...rest }: ArrayReference.InitReference) { const typeName = innerType instanceof ClassReference ? innerType.qualifiedName : innerType; super({ @@ -239,7 +243,7 @@ export class ArrayReference extends ClassReference { this.innerType = innerType; } - public fromJson(variable: string | Variable): FunctionInvocation | undefined { + public fromJson(variable: string | Variable): AstNode | undefined { const valueFromJsonFunction = this.innerType instanceof ClassReference ? this.innerType.fromJson("v") : undefined; return valueFromJsonFunction !== undefined @@ -283,29 +287,30 @@ export class ArrayInstance extends AstNode { export declare namespace Hash_ { export interface InitReference extends Omit { name?: string; + typeHint?: string; keyType: ClassReference | string; valueType: ClassReference | string; } export interface InitInstance extends AstNode.Init { contents?: Map; // allow for spreading additional hashes into this hash. - additionalHashes?: (AstNode | string)[]; + additionalHashes?: DefaultingExpandableHash[]; isFrozen?: boolean; shouldCompact?: boolean; } } export class HashReference extends ClassReference { valueType: ClassReference | string; - constructor({ name, keyType, valueType, ...rest }: Hash_.InitReference) { + constructor({ name, typeHint, keyType, valueType, ...rest }: Hash_.InitReference) { const keyTypeName = keyType instanceof ClassReference ? keyType.qualifiedName : keyType; const valueTypeName = valueType instanceof ClassReference ? valueType.qualifiedName : valueType; - const typeHint = `Hash{${keyTypeName} => ${valueTypeName}}`; + const typeHintDefaulted = typeHint ?? `Hash{${keyTypeName} => ${valueTypeName}}`; const nameDefaulted = name ?? "Hash"; - super({ name: nameDefaulted, typeHint, ...rest }); + super({ name: nameDefaulted, typeHint: typeHintDefaulted, ...rest }); this.valueType = valueType; } - public fromJson(variable: string | Variable): FunctionInvocation | undefined { + public fromJson(variable: string | Variable): AstNode | undefined { const valueFromJsonFunction = this.valueType instanceof ClassReference ? this.valueType.fromJson("v") : undefined; return valueFromJsonFunction !== undefined @@ -331,9 +336,14 @@ export class HashReference extends ClassReference { } } +interface DefaultingExpandableHash { + value: AstNode | string; + defaultValue?: AstNode | string; +} + export class HashInstance extends AstNode { public contents: Map; - public additionalHashes: (AstNode | string)[]; + public additionalHashes: DefaultingExpandableHash[]; public shouldCompact: boolean; public isFrozen: boolean; @@ -354,15 +364,43 @@ export class HashInstance extends AstNode { public writeInternal(): void { const hashContents = Array.from(this.contents.entries()); + const expandingHashes = this.additionalHashes + .map((ah) => { + const hashString = ah.value instanceof AstNode ? ah.value.write({}) : ah.value; + return ah.defaultValue !== undefined + ? format( + "**(%s || %s)", + hashString, + ah.defaultValue instanceof AstNode ? ah.defaultValue.write({}) : ah.defaultValue + ) + : format("**%s", hashString); + }) + .join(", "); this.addText({ - stringContent: `{ ${this.additionalHashes - .map((ah) => format("**%s", ah instanceof AstNode ? ah.write({}) : ah)) - .join(", ")}${hashContents.length > 0 && this.additionalHashes.length > 0 ? ", " : ""}${hashContents - .map(([k, v]) => k + ": " + (v instanceof AstNode ? v.write({}) : `'${v}'`)) - .join(", ")} }` + stringContent: `{ ${expandingHashes}${ + hashContents.length > 0 && this.additionalHashes.length > 0 ? ", " : "" + }${hashContents.map(([k, v]) => k + ": " + (v instanceof AstNode ? v.write({}) : `'${v}'`)).join(", ")} }` }); this.addText({ stringContent: this.shouldCompact ? ".compact" : undefined, appendToLastString: true }); - this.addText({ stringContent: this.isFrozen ? ".frozen" : undefined, appendToLastString: true }); + this.addText({ stringContent: this.isFrozen ? ".freeze" : undefined, appendToLastString: true }); + } + + public getImports(): Set { + let imports = new Set(); + Array.from(this.contents.values()).forEach((param) => { + if (param instanceof AstNode) { + imports = new Set([...imports, ...param.getImports()]); + } + }); + this.additionalHashes.forEach((ah) => { + if (ah.value instanceof AstNode) { + imports = new Set([...imports, ...ah.value.getImports()]); + } + if (ah.defaultValue instanceof AstNode) { + imports = new Set([...imports, ...ah.defaultValue.getImports()]); + } + }); + return imports; } } @@ -383,20 +421,35 @@ export class Enum extends HashInstance { } export class EnumReference extends HashReference { - constructor({ name }: Enum.ReferenceInit) { - super({ name, keyType: "String", valueType: "String" }); + constructor({ name, ...rest }: Enum.ReferenceInit) { + super({ name, ...rest, typeHint: name, keyType: "String", valueType: "String" }); } - public fromJson(variable: Variable | string): FunctionInvocation | undefined { - return new FunctionInvocation({ - baseFunction: new Function_({ name: "key", functionBody: [] }), - onObject: this, - arguments_: [new Argument({ value: variable, isNamed: false, type: GenericClassReference })] + public fromJson(variable: Variable | string): AstNode | undefined { + return new Expression({ + leftSide: new FunctionInvocation({ + baseFunction: new Function_({ name: "key", functionBody: [] }), + onObject: this, + arguments_: [new Argument({ value: variable, isNamed: false, type: GenericClassReference })] + }), + rightSide: variable, + operation: "||" }); } - static fromDeclaredTypeName(declaredTypeName: DeclaredTypeName): EnumReference { - const location = getLocationForTypeDeclaration(declaredTypeName); + public toJson(variable: Variable | string): AstNode { + return new Expression({ + leftSide: `${this.qualifiedName}[${variable instanceof AstNode ? variable.write({}) : variable}]`, + rightSide: variable, + operation: "||" + }); + } + + static fromDeclaredTypeName( + declaredTypeName: DeclaredTypeName, + locationGenerator: LocationGenerator + ): EnumReference { + const location = locationGenerator.getLocationForTypeDeclaration(declaredTypeName); const moduleBreadcrumbs = Module_.getModulePathFromTypeName(declaredTypeName.fernFilepath, true); return new EnumReference({ name: declaredTypeName.name.screamingSnakeCase.safeName, @@ -425,7 +478,7 @@ export class SetReference extends ClassReference { }); } - public fromJson(variable: Variable | string): FunctionInvocation | undefined { + public fromJson(variable: Variable | string): AstNode | undefined { return new FunctionInvocation({ baseFunction: new Function_({ name: "new", functionBody: [] }), onObject: new ClassReference({ name: "Set", import_: new Import({ from: "set", isExternal: true }) }), @@ -466,7 +519,7 @@ export class DateReference extends ClassReference { }); } - public fromJson(variable: Variable | string): FunctionInvocation | undefined { + public fromJson(variable: Variable | string): AstNode | undefined { return new FunctionInvocation({ baseFunction: new Function_({ name: "parse", functionBody: [] }), onObject: this, @@ -476,10 +529,12 @@ export class DateReference extends ClassReference { } export class ClassReferenceFactory { + private locationGenerator: LocationGenerator; private typeDeclarations: Map; public generatedReferences: Map; - constructor(typeDeclarations: Map) { + constructor(typeDeclarations: Map, locationGenerator: LocationGenerator) { + this.locationGenerator = locationGenerator; this.typeDeclarations = typeDeclarations; this.generatedReferences = new Map(); for (const [_, type] of typeDeclarations) { @@ -501,12 +556,18 @@ export class ClassReferenceFactory { unknown: () => undefined, _other: () => undefined }); - return AliasReference.fromDeclaredTypeName(type.name, aliasOfCr, resolvedTypeId); + return AliasReference.fromDeclaredTypeName( + type.name, + aliasOfCr, + resolvedTypeId, + this.locationGenerator + ); }, - enum: () => EnumReference.fromDeclaredTypeName(type.name), - object: () => SerializableObjectReference.fromDeclaredTypeName(type.name), - union: () => SerializableObjectReference.fromDeclaredTypeName(type.name), - undiscriminatedUnion: () => SerializableObjectReference.fromDeclaredTypeName(type.name), + enum: () => EnumReference.fromDeclaredTypeName(type.name, this.locationGenerator), + object: () => SerializableObjectReference.fromDeclaredTypeName(type.name, this.locationGenerator), + union: () => SerializableObjectReference.fromDeclaredTypeName(type.name, this.locationGenerator), + undiscriminatedUnion: () => + SerializableObjectReference.fromDeclaredTypeName(type.name, this.locationGenerator), _other: () => { throw new Error("Attempting to generate a class reference for an unknown type."); } diff --git a/generators/ruby/codegen/src/ast/classes/Class_.ts b/generators/ruby/codegen/src/ast/classes/Class_.ts index f9b22b27591..dc0a58421c7 100644 --- a/generators/ruby/codegen/src/ast/classes/Class_.ts +++ b/generators/ruby/codegen/src/ast/classes/Class_.ts @@ -58,7 +58,8 @@ export class Class_ extends AstNode { isAssignment: true, yardoc }); - }) + }), + invocationName: "new" }); functions = [this.initializer, ...functions]; } else if (initializerOverride !== undefined) { @@ -70,7 +71,9 @@ export class Class_ extends AstNode { } public writeInternal(startingTabSpaces: number): void { - this.addText({ stringContent: this.documentation, templateString: "# %s", startingTabSpaces }); + this.documentation?.forEach((doc) => + this.addText({ stringContent: doc, templateString: "# %s", startingTabSpaces }) + ); this.addText({ stringContent: this.classReference.name, templateString: "class %s", startingTabSpaces }); const classVariableAccessors = this.properties.length > 0 @@ -94,7 +97,6 @@ export class Class_ extends AstNode { this.functions.forEach((fun) => (imports = new Set([...imports, ...fun.getImports()]))); this.properties.forEach((prop) => (imports = new Set([...imports, ...prop.getImports()]))); this.expressions.forEach((exp) => (imports = new Set([...imports, ...exp.getImports()]))); - // Do not import self return new Set([...imports].filter((i) => i !== this.classReference.import_)); } diff --git a/generators/ruby/codegen/src/ast/core/AstNode.ts b/generators/ruby/codegen/src/ast/core/AstNode.ts index 1f411f558ad..83ee484ffb7 100644 --- a/generators/ruby/codegen/src/ast/core/AstNode.ts +++ b/generators/ruby/codegen/src/ast/core/AstNode.ts @@ -9,7 +9,7 @@ export enum NewLinePlacement { } export declare namespace AstNode { export interface Init { - documentation?: string; + documentation?: string[] | string; contentOverride?: string; writeImports?: boolean; // Where is this node, since any node can be written loose to a file @@ -26,7 +26,7 @@ export declare namespace AstNode { export abstract class AstNode { // We could also track line length, but we'd likely be better off running Rubocop to format the code after it's written public tabSizeSpaces = 2; - public documentation: string | undefined; + public documentation: string[] | undefined; // This field takes precedence over the node's write function, this // should be used if you know exactly the content you'd like to generate public contentOverride: string | undefined; @@ -38,7 +38,7 @@ export abstract class AstNode { constructor({ documentation, contentOverride, writeImports = false }: AstNode.Init) { // TODO: Make documentation a list of strings split by returns then make them multi-line comments - this.documentation = documentation?.replace("\n", " "); + this.documentation = documentation instanceof Array ? documentation : documentation?.split("\n"); this.contentOverride = contentOverride; this.writeImports = writeImports; } diff --git a/generators/ruby/codegen/src/ast/expressions/Expression.ts b/generators/ruby/codegen/src/ast/expressions/Expression.ts index 78309a3017e..20d5bbf142b 100644 --- a/generators/ruby/codegen/src/ast/expressions/Expression.ts +++ b/generators/ruby/codegen/src/ast/expressions/Expression.ts @@ -5,7 +5,7 @@ import { Yardoc } from "../Yardoc"; export declare namespace Expression { export interface Init extends AstNode.Init { leftSide?: AstNode | string; - rightSide: AstNode | string; + rightSide?: AstNode | string; isAssignment?: boolean; operation?: string; yardoc?: Yardoc; @@ -13,7 +13,7 @@ export declare namespace Expression { } export class Expression extends AstNode { public leftSide: AstNode | string | undefined; - public rightSide: AstNode | string; + public rightSide: AstNode | string | undefined; public isAssignment: boolean; public yardoc: Yardoc | undefined; public operation?: string; @@ -31,11 +31,11 @@ export class Expression extends AstNode { this.addText({ stringContent: this.yardoc?.write({ startingTabSpaces }) }); const leftString = this.leftSide instanceof AstNode ? this.leftSide.write({}) : this.leftSide; const rightString = this.rightSide instanceof AstNode ? this.rightSide.write({}) : this.rightSide; - if (this.leftSide !== undefined) { + if (leftString !== undefined && rightString !== undefined) { this.addText({ stringContent: leftString, startingTabSpaces }); } this.addText({ - stringContent: rightString, + stringContent: rightString ?? leftString, templateString: this.operation !== undefined ? ` ${this.operation} %s` : leftString === undefined ? undefined : " %s", appendToLastString: true, @@ -48,6 +48,9 @@ export class Expression extends AstNode { if (this.rightSide instanceof AstNode) { imports = new Set([...imports, ...this.rightSide.getImports()]); } + if (this.leftSide instanceof AstNode) { + imports = new Set([...imports, ...this.leftSide.getImports()]); + } return imports; } } diff --git a/generators/ruby/codegen/src/ast/functions/FunctionInvocation.ts b/generators/ruby/codegen/src/ast/functions/FunctionInvocation.ts index 71841199ddf..5e3114850ba 100644 --- a/generators/ruby/codegen/src/ast/functions/FunctionInvocation.ts +++ b/generators/ruby/codegen/src/ast/functions/FunctionInvocation.ts @@ -1,5 +1,6 @@ import { BLOCK_END } from "../../utils/RubyConstants"; import { Argument } from "../Argument"; +import { Class_ } from "../classes/Class_"; import { AstNode } from "../core/AstNode"; import { Import } from "../Import"; import { Variable } from "../Variable"; @@ -63,30 +64,37 @@ export class FunctionInvocation extends AstNode { } } - private writeArgmuments(): string { - return `(${this.arguments_.map((a) => a.write({})).join(", ")})`; + private writeArgmuments(): string | undefined { + return this.arguments_.length > 0 ? `(${this.arguments_.map((a) => a.write({})).join(", ")})` : undefined; } // When writing the definition public writeInternal(startingTabSpaces: number): void { - const className = this.onObject instanceof AstNode ? this.onObject.write({}) : this.onObject; + const onObject = this.onObject instanceof AstNode ? this.onObject.write({}) : this.onObject; this.addText({ - stringContent: className, - templateString: this.optionalSafeCall ? "%s&." : "%s.", + stringContent: onObject, startingTabSpaces }); - this.addText({ stringContent: this.baseFunction?.name, startingTabSpaces, appendToLastString: true }); + this.addText({ + stringContent: this.baseFunction?.invocationName ?? this.baseFunction?.name, + templateString: onObject === undefined ? undefined : this.optionalSafeCall ? "&.%s" : ".%s", + startingTabSpaces, + appendToLastString: true + }); this.addText({ stringContent: this.writeArgmuments(), appendToLastString: true }); this.writeBlock(startingTabSpaces); } public getImports(): Set { - let imports = this.baseFunction?.getImports() ?? new Set(); + let imports = new Set(); if (this.onObject instanceof AstNode) { imports = new Set([...imports, ...this.onObject.getImports()]); } + this.arguments_.forEach((arg) => (imports = new Set([...imports, ...arg.getImports()]))); - this.block?.expressions.forEach((exp) => (imports = new Set([...imports, ...exp.getImports()]))); + this.block?.expressions + .filter((exp) => !(exp instanceof Class_)) + .forEach((exp) => (imports = new Set([...imports, ...exp.getImports()]))); return imports; } } diff --git a/generators/ruby/codegen/src/ast/functions/Function_.ts b/generators/ruby/codegen/src/ast/functions/Function_.ts index aa6b4420ccc..788b8fcec52 100644 --- a/generators/ruby/codegen/src/ast/functions/Function_.ts +++ b/generators/ruby/codegen/src/ast/functions/Function_.ts @@ -1,6 +1,7 @@ import { ObjectProperty, TypeId } from "@fern-fern/ir-sdk/api"; import { BLOCK_END } from "../../utils/RubyConstants"; import { ClassReference, ClassReferenceFactory } from "../classes/ClassReference"; +import { Class_ } from "../classes/Class_"; import { AstNode } from "../core/AstNode"; import { Import } from "../Import"; import { Parameter } from "../Parameter"; @@ -16,6 +17,7 @@ export declare namespace Function_ { returnValue?: ClassReference | ClassReference[]; flattenedProperties?: Map; crf?: ClassReferenceFactory; + invocationName?: string; } } export class Function_ extends AstNode { @@ -29,6 +31,8 @@ export class Function_ extends AstNode { public isStatic: boolean; public yardoc: Yardoc; + public invocationName: string | undefined; + constructor({ name, functionBody, @@ -38,6 +42,7 @@ export class Function_ extends AstNode { isAsync = false, isStatic = false, returnValue, + invocationName, ...rest }: Function_.Init) { super(rest); @@ -47,6 +52,7 @@ export class Function_ extends AstNode { this.functionBody = functionBody; this.isAsync = isAsync; this.isStatic = isStatic; + this.invocationName = invocationName; this.yardoc = new Yardoc({ reference: { name: "docString", parameters, returnValue: this.returnValue }, @@ -60,11 +66,13 @@ export class Function_ extends AstNode { } public writeInternal(startingTabSpaces: number): void { - this.addText({ stringContent: this.documentation, templateString: "# %s", startingTabSpaces }); + this.documentation?.forEach((doc) => + this.addText({ stringContent: doc, templateString: "# %s", startingTabSpaces }) + ); this.addText({ stringContent: this.yardoc.write({ startingTabSpaces }), - templateString: this.documentation !== undefined ? "#\n%s" : undefined, - startingTabSpaces: this.documentation !== undefined ? startingTabSpaces : 0 + templateString: this.documentation !== undefined && this.documentation.length > 0 ? "#\n%s" : undefined, + startingTabSpaces: this.documentation !== undefined && this.documentation.length > 0 ? startingTabSpaces : 0 }); this.addText({ stringContent: this.isStatic ? `self.${this.name}` : this.name, @@ -82,7 +90,13 @@ export class Function_ extends AstNode { let imports = new Set(); this.parameters.forEach((param) => (imports = new Set([...imports, ...param.getImports()]))); this.returnValue.forEach((rv) => (imports = new Set([...imports, ...rv.getImports()]))); - this.functionBody.forEach((exp) => (imports = new Set([...imports, ...exp.getImports()]))); + + this.functionBody.forEach((exp) => { + if (exp instanceof Class_) { + return; + } + imports = new Set([...imports, ...exp.getImports()]); + }); return imports; } } diff --git a/generators/ruby/codegen/src/ast/gem/Gemspec.ts b/generators/ruby/codegen/src/ast/gem/Gemspec.ts index 4e541dd79c5..5ca7fa32b71 100644 --- a/generators/ruby/codegen/src/ast/gem/Gemspec.ts +++ b/generators/ruby/codegen/src/ast/gem/Gemspec.ts @@ -1,5 +1,6 @@ // Note a gemspec for us is just a Ruby class and we configure +import { MINIMUM_RUBY_VERSION } from "../../utils/RubyUtilities"; import { ClassReference } from "../classes/ClassReference"; import { Expression } from "../expressions/Expression"; import { ExternalDependency } from "../ExternalDependency"; @@ -27,7 +28,7 @@ export class Gemspec extends FunctionInvocation { globalDependencies.push( ...[ new ExternalDependency({ packageName: "mini_mime", specifier: "~>", version: "1.1" }), - new ExternalDependency({ packageName: "farady-multipart", specifier: "~>", version: "1.0" }) + new ExternalDependency({ packageName: "faraday-multipart", specifier: "~>", version: "1.0" }) ] ); } @@ -53,6 +54,18 @@ export class Gemspec extends FunctionInvocation { isAssignment: true }) ); + } else { + // Allow for people to use the gemconfig if no version is found + gemBlock.push( + new Expression({ + leftSide: "spec.version", + rightSide: new ClassReference({ + name: `${clientName}::Gemconfig::VERSION`, + import_: new Import({ from: "lib/gemconfig" }) + }), + isAssignment: true + }) + ); } super({ @@ -104,7 +117,7 @@ export class Gemspec extends FunctionInvocation { }), new Expression({ leftSide: "spec.required_ruby_version", - rightSide: '">= 2.7.0"', + rightSide: `">= ${MINIMUM_RUBY_VERSION}.0"`, isAssignment: true }), new Expression({ diff --git a/generators/ruby/codegen/src/index.ts b/generators/ruby/codegen/src/index.ts index 36c6ae736ec..e5ec0108991 100644 --- a/generators/ruby/codegen/src/index.ts +++ b/generators/ruby/codegen/src/index.ts @@ -23,5 +23,6 @@ export * from "./ast/Variable"; export { Yardoc } from "./ast/Yardoc"; export * from "./utils/GeneratedFile"; export * from "./utils/GeneratedRubyFile"; +export * from "./utils/LocationGenerator"; export * from "./utils/RubyConstants"; export * from "./utils/RubyUtilities"; diff --git a/generators/ruby/codegen/src/utils/GeneratedRubyFile.ts b/generators/ruby/codegen/src/utils/GeneratedRubyFile.ts index d4d4732ebe8..14385b7ce73 100644 --- a/generators/ruby/codegen/src/utils/GeneratedRubyFile.ts +++ b/generators/ruby/codegen/src/utils/GeneratedRubyFile.ts @@ -1,28 +1,17 @@ import { AbsoluteFilePath, join, RelativeFilePath } from "@fern-api/fs-utils"; -import { DeclaredServiceName, DeclaredTypeName, FernFilepath } from "@fern-fern/ir-sdk/api"; import { snakeCase } from "lodash-es"; import path from "path"; import { AstNode } from "../ast/core/AstNode"; import { GeneratedFile } from "./GeneratedFile"; import { FROZEN_STRING_PREFIX } from "./RubyConstants"; -import { - getLocationForServiceDeclaration, - getLocationForTypeDeclaration, - getLocationFromFernFilepath -} from "./RubyUtilities"; export declare namespace GeneratedRubyFile { export interface Init { rootNode: AstNode | AstNode[]; - directoryPrefix: RelativeFilePath; - name: string | DeclaredTypeName | DeclaredServiceName; - location?: FernFilepath; + fullPath: string; isTestFile?: boolean; isConfigurationFile?: boolean; fileExtension?: string; - // TODO: This is a temporary solution to allow for the generation of the imports within a subdir - // DO NOT USE - nestImportsInDirectory?: RelativeFilePath; } } export class GeneratedRubyFile extends GeneratedFile { @@ -30,44 +19,31 @@ export class GeneratedRubyFile extends GeneratedFile { constructor({ rootNode, - directoryPrefix, - name, - location, + fullPath, isTestFile = false, isConfigurationFile = false, - fileExtension = "rb", - nestImportsInDirectory + fileExtension = "rb" }: GeneratedRubyFile.Init) { // Path needs lib or test, if test: test/ is relative path // otherwise, relative path is: // lib/client_class_name.rb or request_client.rb or environment.rb or exception.rb OR // /lib/client_class_name/package_name/services/service_name.rb OR /lib/client_class_name/package_name/types/type_name.rb const updatedPrefix = isConfigurationFile ? "" : isTestFile ? "test" : "lib"; - let filePathFull = - typeof name === "string" - ? name - : "name" in name - ? getLocationForTypeDeclaration(name) - : getLocationForServiceDeclaration(name); - filePathFull = - location !== undefined ? `${getLocationFromFernFilepath(location)}/${filePathFull}` : filePathFull; // Make sure the filename is snakecase - const fileName = `${snakeCase(path.parse(filePathFull).base)}.${fileExtension}`; - const filePath = path.parse(filePathFull).dir; + const fileName = `${snakeCase(path.parse(fullPath).base)}.${fileExtension}`; + const filePath = path.parse(fullPath).dir; const nodesToWrite = rootNode instanceof Array ? rootNode : [rootNode]; super( fileName, - join(RelativeFilePath.of(updatedPrefix), directoryPrefix, RelativeFilePath.of(filePath)), + join(RelativeFilePath.of(updatedPrefix), RelativeFilePath.of(filePath)), FROZEN_STRING_PREFIX + nodesToWrite .map((node) => node.write({ startingTabSpaces: 0, - filePath: - nestImportsInDirectory === undefined ? AbsoluteFilePath.of("/" + filePath) : undefined, - pathPrefix: nestImportsInDirectory + filePath: AbsoluteFilePath.of("/" + filePath) }) ) .join("\n") diff --git a/generators/ruby/codegen/src/utils/LocationGenerator.ts b/generators/ruby/codegen/src/utils/LocationGenerator.ts new file mode 100644 index 00000000000..0172925e82b --- /dev/null +++ b/generators/ruby/codegen/src/utils/LocationGenerator.ts @@ -0,0 +1,41 @@ +import { DeclaredServiceName, DeclaredTypeName, FernFilepath } from "@fern-fern/ir-sdk/api"; +import { snakeCase } from "lodash-es"; +import { TYPES_DIRECTORY } from "./RubyConstants"; + +export class LocationGenerator { + private directoryPrefix: string; + constructor(directoryPrefix: string) { + this.directoryPrefix = directoryPrefix; + } + + public getLocationForTypeDeclaration(declaredTypeName: DeclaredTypeName): string { + return [ + snakeCase(this.directoryPrefix), + ...declaredTypeName.fernFilepath.allParts.map((pathPart) => pathPart.snakeCase.safeName), + TYPES_DIRECTORY, + declaredTypeName.name.snakeCase.safeName + ].join("/"); + } + + public getLocationForServiceDeclaration(declaredServiceName: DeclaredServiceName): string { + return [ + snakeCase(this.directoryPrefix), + ...declaredServiceName.fernFilepath.packagePath.map((pathPart) => pathPart.snakeCase.safeName), + declaredServiceName.fernFilepath.file?.snakeCase.safeName, + "client" + ] + .filter((p) => p !== undefined) + .join("/"); + } + + // Note: this assumes the file is in a directory of the same name + public getLocationFromFernFilepath(fernFilepath: FernFilepath, fileName?: string): string { + return [ + snakeCase(this.directoryPrefix), + ...fernFilepath.allParts.map((pathPart) => pathPart.snakeCase.safeName), + fileName + ] + .filter((p) => p !== undefined) + .join("/"); + } +} diff --git a/generators/ruby/codegen/src/utils/RubyUtilities.ts b/generators/ruby/codegen/src/utils/RubyUtilities.ts index c869e2d2ede..e38e4f5613f 100644 --- a/generators/ruby/codegen/src/utils/RubyUtilities.ts +++ b/generators/ruby/codegen/src/utils/RubyUtilities.ts @@ -1,5 +1,5 @@ import { RelativeFilePath } from "@fern-api/fs-utils"; -import { DeclaredServiceName, DeclaredTypeName, FernFilepath } from "@fern-fern/ir-sdk/api"; +import { FernFilepath } from "@fern-fern/ir-sdk/api"; import { camelCase, snakeCase, upperFirst } from "lodash-es"; import { Expression } from "../ast/expressions/Expression"; import { ExternalDependency } from "../ast/ExternalDependency"; @@ -7,7 +7,8 @@ import { Gemspec } from "../ast/gem/Gemspec"; import { Module_ } from "../ast/Module_"; import { GeneratedFile } from "./GeneratedFile"; import { GeneratedRubyFile } from "./GeneratedRubyFile"; -import { TYPES_DIRECTORY } from "./RubyConstants"; + +export const MINIMUM_RUBY_VERSION = "2.7"; export function getGemName(organization: string, apiName: string, clientClassName?: string, gemName?: string): string { return gemName ?? snakeCase(getClientName(organization, apiName, clientClassName)); @@ -17,27 +18,10 @@ export function getClientName(organization: string, apiName: string, clientClass return clientClassName ?? upperFirst(camelCase(organization)) + upperFirst(camelCase(apiName)) + "Client"; } -export function getLocationForTypeDeclaration(declaredTypeName: DeclaredTypeName): string { - return [ - ...declaredTypeName.fernFilepath.allParts.map((pathPart) => pathPart.snakeCase.safeName), - TYPES_DIRECTORY, - declaredTypeName.name.snakeCase.safeName - ].join("/"); -} - -export function getLocationForServiceDeclaration(declaredServiceName: DeclaredServiceName): string { - return [ - ...declaredServiceName.fernFilepath.packagePath.map((pathPart) => pathPart.snakeCase.safeName), - declaredServiceName.fernFilepath.file?.snakeCase.safeName, - "client" - ] - .filter((p) => p !== undefined) - .join("/"); -} - -// Note: this assumes the file is in a directory of the same name -export function getLocationFromFernFilepath(fernFilepath: FernFilepath): string { - return [...fernFilepath.allParts.map((pathPart) => pathPart.snakeCase.safeName)].join("/"); +export function getBreadcrumbsFromFilepath(fernFilepath: FernFilepath, includeFullPath?: boolean): string[] { + return (includeFullPath === true ? fernFilepath.allParts : fernFilepath.packagePath).map( + (pathPart) => pathPart.pascalCase.safeName + ); } export function generateGemspec( @@ -56,8 +40,7 @@ export function generateGemspec( }); return new GeneratedRubyFile({ rootNode: gemspec, - directoryPrefix: RelativeFilePath.of("."), - name: `${gemName}`, + fullPath: `${gemName}`, fileExtension: "gemspec", isConfigurationFile: true }); @@ -71,6 +54,7 @@ export function generateGemConfig(clientName: string): GeneratedRubyFile { child: new Module_({ name: "Gemconfig", child: [ + new Expression({ leftSide: "VERSION", rightSide: '""', isAssignment: true }), new Expression({ leftSide: "AUTHORS", rightSide: '[""].freeze', isAssignment: true }), new Expression({ leftSide: "EMAIL", rightSide: '""', isAssignment: true }), new Expression({ leftSide: "SUMMARY", rightSide: '""', isAssignment: true }), @@ -96,8 +80,7 @@ export function generateGemConfig(clientName: string): GeneratedRubyFile { }); return new GeneratedRubyFile({ rootNode: gemspec, - directoryPrefix: RelativeFilePath.of("."), - name: "gemconfig" + fullPath: "gemconfig" }); } @@ -118,14 +101,11 @@ export function generateGitignore(): GeneratedFile { export function generateRubocopConfig(): GeneratedFile { const content = `AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: ${MINIMUM_RUBY_VERSION} Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/generators/ruby/model/src/TypesGenerator.ts b/generators/ruby/model/src/TypesGenerator.ts index 58f4b030dcb..b9bcc391018 100644 --- a/generators/ruby/model/src/TypesGenerator.ts +++ b/generators/ruby/model/src/TypesGenerator.ts @@ -1,6 +1,5 @@ -import { RelativeFilePath } from "@fern-api/fs-utils"; import { GeneratorContext } from "@fern-api/generator-commons"; -import { ClassReferenceFactory, Class_, GeneratedRubyFile, Module_ } from "@fern-api/ruby-codegen"; +import { ClassReferenceFactory, Class_, GeneratedRubyFile, LocationGenerator, Module_ } from "@fern-api/ruby-codegen"; import { AliasTypeDeclaration, DeclaredTypeName, @@ -33,6 +32,7 @@ export class TypesGenerator { private types: Map; private gc: GeneratorContext; private classReferenceFactory: ClassReferenceFactory; + private locationGenerator: LocationGenerator; private gemName: string; private clientName: string; @@ -61,7 +61,8 @@ export class TypesGenerator { this.flattenedProperties.set(typeId, this.getFlattenedProperties(typeId)); } - this.classReferenceFactory = new ClassReferenceFactory(this.types); + this.locationGenerator = new LocationGenerator(this.clientName); + this.classReferenceFactory = new ClassReferenceFactory(this.types, this.locationGenerator); } // We pull all inherited properties onto the object because Ruby @@ -117,9 +118,7 @@ export class TypesGenerator { private generateRootFile(): GeneratedRubyFile { return new GeneratedRubyFile({ rootNode: new RootFile(Array.from(this.classReferenceFactory.generatedReferences.values())), - directoryPrefix: RelativeFilePath.of("."), - nestImportsInDirectory: RelativeFilePath.of(this.gemName), - name: this.gemName + fullPath: this.gemName }); } @@ -154,8 +153,7 @@ export class TypesGenerator { const rootNode = Module_.wrapInModules(this.clientName, aliasExpression, typeDeclaration.name.fernFilepath); return new GeneratedRubyFile({ rootNode, - directoryPrefix: RelativeFilePath.of(this.gemName), - name: typeDeclaration.name + fullPath: this.locationGenerator.getLocationForTypeDeclaration(typeDeclaration.name) }); } private generateEnumFile( @@ -166,8 +164,7 @@ export class TypesGenerator { const rootNode = Module_.wrapInModules(this.clientName, enumExpression, typeDeclaration.name.fernFilepath); return new GeneratedRubyFile({ rootNode, - directoryPrefix: RelativeFilePath.of(this.gemName), - name: typeDeclaration.name + fullPath: this.locationGenerator.getLocationForTypeDeclaration(typeDeclaration.name) }); } private generateObjectFile( @@ -186,8 +183,7 @@ export class TypesGenerator { const rootNode = Module_.wrapInModules(this.clientName, serializableObject, typeDeclaration.name.fernFilepath); return new GeneratedRubyFile({ rootNode, - directoryPrefix: RelativeFilePath.of(this.gemName), - name: typeDeclaration.name + fullPath: this.locationGenerator.getLocationForTypeDeclaration(typeDeclaration.name) }); } private generateUnionFile( @@ -206,8 +202,7 @@ export class TypesGenerator { const rootNode = Module_.wrapInModules(this.clientName, unionObject, typeDeclaration.name.fernFilepath); return new GeneratedRubyFile({ rootNode, - directoryPrefix: RelativeFilePath.of(this.gemName), - name: typeDeclaration.name + fullPath: this.locationGenerator.getLocationForTypeDeclaration(typeDeclaration.name) }); } private generateUndiscriminatedUnionFile( @@ -225,8 +220,7 @@ export class TypesGenerator { const rootNode = Module_.wrapInModules(this.clientName, unionObject, typeDeclaration.name.fernFilepath); return new GeneratedRubyFile({ rootNode, - directoryPrefix: RelativeFilePath.of(this.gemName), - name: typeDeclaration.name + fullPath: this.locationGenerator.getLocationForTypeDeclaration(typeDeclaration.name) }); } private generateUnkownFile(shape: Type): GeneratedRubyFile | undefined { diff --git a/generators/ruby/playground/README.md b/generators/ruby/playground/README.md index 1cc154af0eb..6b45f3a0152 100644 --- a/generators/ruby/playground/README.md +++ b/generators/ruby/playground/README.md @@ -3,21 +3,48 @@ Welcome to the Fern Ruby playground, here are steps to set up your Ruby environment and playaround with codegen. ## Setting up Ruby + https://www.ruby-lang.org/en/documentation/installation/#homebrew + ```sh brew install ruby ``` ### rbenv - Ruby Version Management + https://github.com/rbenv/rbenv + ```sh brew install rbenv ruby-build ``` - ## CLI testing + Similar to running `python` you can pull up an interactive Ruby shall by running `irb`, with this you can now run Ruby commands, import Gems, etc.! +To test the gem end to end, you can build, install and then use the gem all locally: + +```sh +gem build playground.gemspec + +gem install playground-0.0.0.gem + +irb +~ irb(main):001> +~ irb(main):002> +~ ... +``` + +## Running tests + +If you are looking to run any tests you run within the `test/` directory, you can do so by running: + +```sh +bundle exec ruby test/test_playground.rb +``` + +Similar to Poetry for Python, Bundler is running the command listed after `exec` within a virtual environment with the specified dependencies. +Note that these tests already depend on the `playground` gem, so you will need to build and install it locally if you have not done so already. Instructions to do so can be found above in **CLI testing**. ## Installation for this Gem diff --git a/generators/ruby/playground/lib/playground/version.rb b/generators/ruby/playground/lib/playground/version.rb new file mode 100644 index 00000000000..7e5fe042ff1 --- /dev/null +++ b/generators/ruby/playground/lib/playground/version.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +module Playground + VERSION = "0.0.0" +end + \ No newline at end of file diff --git a/generators/ruby/sdk/CHANGELOG.md b/generators/ruby/sdk/CHANGELOG.md index a92b5a68292..68f74ed45c0 100644 --- a/generators/ruby/sdk/CHANGELOG.md +++ b/generators/ruby/sdk/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [0.0.3] - 2024-02-02 + +- This release contains no changes to the API. + +- Bug fixes: addresses a number of typos and other issues previously contained within the generation code. + ## [0.0.2] - 2024-02-01 - Improvement: Consolidate imports into the main file for easier gem usage, as opposed to directly importing the specific file (e.g. `require "fern" vs. require "fern/types/folder_a/object"`) diff --git a/generators/ruby/sdk/VERSION b/generators/ruby/sdk/VERSION index 7bcd0e3612d..6812f8122ef 100644 --- a/generators/ruby/sdk/VERSION +++ b/generators/ruby/sdk/VERSION @@ -1 +1 @@ -0.0.2 \ No newline at end of file +0.0.3 \ No newline at end of file diff --git a/generators/ruby/sdk/src/AbstractionUtilities.ts b/generators/ruby/sdk/src/AbstractionUtilities.ts index 121b3bb6c8d..ffe55dbc3c7 100644 --- a/generators/ruby/sdk/src/AbstractionUtilities.ts +++ b/generators/ruby/sdk/src/AbstractionUtilities.ts @@ -1,4 +1,3 @@ -import { RelativeFilePath } from "@fern-api/fs-utils"; import { generatePathTemplate } from "@fern-api/generator-commons"; import { Argument, @@ -12,11 +11,11 @@ import { Function_, GeneratedRubyFile, GenericClassReference, - getLocationForServiceDeclaration, - getLocationFromFernFilepath, + getBreadcrumbsFromFilepath, HashInstance, HashReference, Import, + LocationGenerator, LongClassReference, Module_, Parameter, @@ -47,6 +46,7 @@ import { HeadersGenerator } from "./utils/HeadersGenerator"; import { RequestOptions } from "./utils/RequestOptionsClass"; export interface ClientClassPair { + subpackageName: string; syncClientClass: Class_; asyncClientClass: Class_; } @@ -96,6 +96,7 @@ export function generateEndpoints( fileUploadUtility ); + const shouldOverwriteUrl = endpoint.baseUrl !== undefined; const functionCore: AstNode[] = [ new Expression({ leftSide: responseVariable, @@ -103,8 +104,10 @@ export function generateEndpoints( // TODO: Do this field access on the client better onObject: `${requestClientVariable.write({})}.conn`, baseFunction: new Function_({ name: endpoint.method.toLowerCase(), functionBody: [] }), - arguments_: [new Argument({ isNamed: false, value: `"/${path}"`, type: StringClassReference })], - block: generator.getFaradayBlock(requestClientVariable) + arguments_: shouldOverwriteUrl + ? [] + : [new Argument({ isNamed: false, value: `"/${path}"`, type: StringClassReference })], + block: generator.getFaradayBlock(requestClientVariable, path, shouldOverwriteUrl) }), isAssignment: true }), @@ -136,7 +139,8 @@ export function generateEndpoints( : functionCore, returnValue: generator.getResponseType(), crf, - flattenedProperties + flattenedProperties, + documentation: endpoint.docs }); }) .filter((fun) => fun !== undefined) as Function_[]; @@ -149,12 +153,14 @@ export function generateRootPackage( asyncRequestClient: Class_, requestOptions: RequestOptions, crf: ClassReferenceFactory, - syncSubpackages: Class_[], - asyncSubpackages: Class_[], + syncSubpackages: Map, + asyncSubpackages: Map, irBasePath: string, generatedClasses: Map, flattenedProperties: Map, fileUploadUtility: FileUploadUtility, + typeExporterLocation: string, + environmentClass?: ClassReference, rootService?: HttpService ): GeneratedRubyFile { const classReference = new ClassReference({ @@ -166,10 +172,13 @@ export function generateRootPackage( const requestClientVariable = new Variable({ name: "request_client", type: requestClient.classReference, - variableType: VariableType.LOCAL + variableType: VariableType.INSTANCE }); const clientClass = new Class_({ classReference, + properties: Array.from(syncSubpackages.entries()).map( + ([spName, sp]) => new Property({ name: snakeCase(spName), type: sp.classReference }) + ), functions: rootService ? generateEndpoints( crf, @@ -187,19 +196,20 @@ export function generateRootPackage( includeInitializer: false, initializerOverride: new Function_({ name: "initialize", + invocationName: "new", functionBody: [ new Expression({ leftSide: requestClientVariable, rightSide: new FunctionInvocation({ onObject: requestClient.classReference, baseFunction: requestClient.initializer, - arguments_: requestClient.properties.map((prop) => prop.toArgument(prop.name, true)) + arguments_: requestClient.initializer?.parameters.map((param) => param.toArgument(param.name)) }), isAssignment: true }), - ...syncSubpackages.map((sp) => { + ...Array.from(syncSubpackages.entries()).map(([spName, sp]) => { const spInstanceVar = new Variable({ - name: snakeCase(sp.classReference.name), + name: snakeCase(spName), type: sp.classReference, variableType: VariableType.INSTANCE }); @@ -208,13 +218,16 @@ export function generateRootPackage( rightSide: new FunctionInvocation({ onObject: sp.classReference, baseFunction: sp.initializer, - arguments_: sp.properties.map((prop) => prop.toArgument(requestClientVariable, true)) + arguments_: sp.initializer?.parameters.map((param) => + param.toArgument(requestClientVariable) + ) }), isAssignment: true }); }) ], - parameters: requestClient.initializer?.parameters + parameters: requestClient.initializer?.parameters, + returnValue: classReference }) }); @@ -222,17 +235,21 @@ export function generateRootPackage( const asyncRequestClientVariable = new Variable({ name: "async_request_client", type: asyncRequestClient.classReference, - variableType: VariableType.LOCAL + variableType: VariableType.INSTANCE + }); + const asyncClassReference = new ClassReference({ + name: "AsyncClient", + import_: new Import({ from: gemName, isExternal: false }) }); const asyncClientClass = new Class_({ - classReference: new ClassReference({ - name: "AsyncClient", - import_: new Import({ from: gemName, isExternal: false }) - }), + classReference: asyncClassReference, + properties: Array.from(asyncSubpackages.entries()).map( + ([spName, sp]) => new Property({ name: snakeCase(spName), type: sp.classReference }) + ), functions: rootService ? generateEndpoints( crf, - requestClientVariable, + asyncRequestClientVariable, rootService.endpoints, requestOptions, false, @@ -246,19 +263,22 @@ export function generateRootPackage( includeInitializer: false, initializerOverride: new Function_({ name: "initialize", + invocationName: "new", functionBody: [ new Expression({ leftSide: asyncRequestClientVariable, rightSide: new FunctionInvocation({ onObject: asyncRequestClient.classReference, baseFunction: asyncRequestClient.initializer, - arguments_: asyncRequestClient.properties.map((prop) => prop.toArgument(prop.name, true)) + arguments_: asyncRequestClient.initializer?.parameters.map((param) => + param.toArgument(param.name) + ) }), isAssignment: true }), - ...asyncSubpackages.map((sp) => { + ...Array.from(asyncSubpackages.entries()).map(([spName, sp]) => { const spInstanceVar = new Variable({ - name: snakeCase(sp.classReference.name), + name: snakeCase(spName), type: sp.classReference, variableType: VariableType.INSTANCE }); @@ -267,58 +287,63 @@ export function generateRootPackage( rightSide: new FunctionInvocation({ onObject: sp.classReference, baseFunction: sp.initializer, - arguments_: sp.properties.map((prop) => prop.toArgument(requestClientVariable, true)) + arguments_: sp.initializer?.parameters.map((param) => + param.toArgument(asyncRequestClientVariable) + ) }), isAssignment: true }); }) ], - parameters: asyncRequestClient.initializer?.parameters + parameters: asyncRequestClient.initializer?.parameters, + returnValue: asyncClassReference }) }); - const allTypeImports = Array.from(crf.generatedReferences.entries()) - .map(([_, cr]) => cr.import_) - .filter((i) => i !== undefined) as Import[]; + const maybeEnvironmentImport = environmentClass?.import_; + const typeExporterImport = new Import({ from: typeExporterLocation, isExternal: false }); const rootNode = Module_.wrapInModules( clientName, [clientClass, asyncClientClass], undefined, true, - allTypeImports + maybeEnvironmentImport !== undefined ? [maybeEnvironmentImport, typeExporterImport] : [typeExporterImport] ); return new GeneratedRubyFile({ rootNode, - directoryPrefix: RelativeFilePath.of("."), - nestImportsInDirectory: RelativeFilePath.of(gemName), - name: `${gemName}` + fullPath: `${gemName}` }); } export function generateSubpackage( + subpackageName: Name, package_: Package, requestClientCr: ClassReference, asyncRequestClientCr: ClassReference, - subpackages: Class_[] = [], - asyncSubpackages: Class_[] = [] + locationGenerator: LocationGenerator, + subpackages: Map = new Map(), + asyncSubpackages: Map = new Map() ): ClientClassPair { - const location = getLocationFromFernFilepath(package_.fernFilepath) + "client"; + const location = locationGenerator.getLocationFromFernFilepath(package_.fernFilepath, "client"); + const moduleBreadcrumbs = getBreadcrumbsFromFilepath(package_.fernFilepath); // Add Client class const requestClientProperty = new Property({ name: "request_client", type: requestClientCr }); + const syncClassReference = new ClassReference({ + name: "Client", + import_: new Import({ from: location, isExternal: false }), + moduleBreadcrumbs + }); const syncClientClass = new Class_({ - classReference: new ClassReference({ - name: "Client", - import_: new Import({ from: location, isExternal: false }) - }), - properties: [requestClientProperty], + classReference: syncClassReference, includeInitializer: false, initializerOverride: new Function_({ name: "initialize", + invocationName: "new", // Initialize each subpackage - functionBody: subpackages.map((sp) => { + functionBody: Array.from(subpackages.entries()).map(([spName, sp]) => { const subpackageClassVariable = new Variable({ - name: snakeCase(sp.classReference.name), + name: snakeCase(spName), type: sp.classReference, variableType: VariableType.INSTANCE }); @@ -330,32 +355,36 @@ export function generateSubpackage( onObject: sp.classReference, baseFunction: sp.initializer, arguments_: sp.properties.map((prop) => - prop.toArgument(requestClientProperty.toVariable(), true) + prop.toArgument(requestClientProperty.toVariable(VariableType.LOCAL), true) ) }) : sp.classReference, isAssignment: true }); }), - parameters: [new Parameter({ name: "client", type: requestClientCr })] + parameters: [requestClientProperty.toParameter({})], + returnValue: syncClassReference, + documentation: package_.docs }) }); // Add Async Client class const asyncRequestClientProperty = new Property({ name: "request_client", type: asyncRequestClientCr }); + const asyncClassReference = new ClassReference({ + name: "AsyncClient", + import_: new Import({ from: location, isExternal: false }), + moduleBreadcrumbs + }); const asyncClientClass = new Class_({ - classReference: new ClassReference({ - name: "AsyncClient", - import_: new Import({ from: location, isExternal: false }) - }), - properties: [new Property({ name: "client", type: asyncRequestClientCr })], + classReference: asyncClassReference, includeInitializer: false, initializerOverride: new Function_({ name: "initialize", + invocationName: "new", // Initialize each subpackage - functionBody: asyncSubpackages.map((sp) => { + functionBody: Array.from(asyncSubpackages.entries()).map(([spName, sp]) => { const subpackageClassVariable = new Variable({ - name: snakeCase(sp.classReference.name), + name: snakeCase(spName), type: sp.classReference, variableType: VariableType.INSTANCE }); @@ -367,18 +396,19 @@ export function generateSubpackage( onObject: sp.classReference, baseFunction: sp.initializer, arguments_: sp.properties.map((prop) => - prop.toArgument(asyncRequestClientProperty.toVariable(), true) + prop.toArgument(asyncRequestClientProperty.toVariable(VariableType.LOCAL), true) ) }) : sp.classReference, isAssignment: true }); }), - parameters: [new Parameter({ name: "client", type: asyncRequestClientCr })] + parameters: [requestClientProperty.toParameter({})], + returnValue: asyncClassReference }) }); - return { syncClientClass, asyncClientClass }; + return { subpackageName: subpackageName.pascalCase.safeName, syncClientClass, asyncClientClass }; } export function generateService( @@ -390,10 +420,15 @@ export function generateService( irBasePath: string, generatedClasses: Map, flattenedProperties: Map, - fileUploadUtility: FileUploadUtility + fileUploadUtility: FileUploadUtility, + locationGenerator: LocationGenerator ): ClientClassPair { const serviceName = service.name.fernFilepath.file?.pascalCase.safeName ?? ""; - const import_ = new Import({ from: getLocationForServiceDeclaration(service.name), isExternal: false }); + const import_ = new Import({ + from: locationGenerator.getLocationForServiceDeclaration(service.name), + isExternal: false + }); + const moduleBreadcrumbs = getBreadcrumbsFromFilepath(service.name.fernFilepath); // Add Client class const serviceBasePath = generateRubyPathTemplate(service.pathParameters, service.basePath); @@ -401,7 +436,8 @@ export function generateService( const syncClientClass = new Class_({ classReference: new ClassReference({ name: `${serviceName}Client`, - import_ + import_, + moduleBreadcrumbs }), properties: [requestClientProperty], includeInitializer: true, @@ -424,7 +460,8 @@ export function generateService( const asyncClientClass = new Class_({ classReference: new ClassReference({ name: `Async${serviceName}Client`, - import_ + import_, + moduleBreadcrumbs }), properties: [asyncRequestClientProperty], includeInitializer: true, @@ -442,7 +479,7 @@ export function generateService( ) }); - return { syncClientClass, asyncClientClass }; + return { subpackageName: serviceName, syncClientClass, asyncClientClass }; } // Need to create the environment file and then reference back to them via default_env@specified_url @@ -470,7 +507,10 @@ export function getDefaultEnvironmentUrl(environmentsConfig?: EnvironmentsConfig // Actually might just be: be able to reference the default + create the files, it looks like endpoints export function generateEnvironmentConstants(environmentsConfig: EnvironmentsConfig): Class_ { return new Class_({ - classReference: new ClassReference({ name: "Environment", location: "environment" }), + classReference: new ClassReference({ + name: "Environment", + import_: new Import({ from: "environment", isExternal: false }) + }), expressions: environmentsConfig.environments._visit({ singleBaseUrl: (sbue: SingleBaseUrlEnvironments) => sbue.environments.map( @@ -516,9 +556,7 @@ function generateRequestClientInitializer( const allHeaders = new Map([ // SDK Default Headers [`"${sdkConfig.platformHeaders.language}"`, "Ruby"], - [`"${sdkConfig.platformHeaders.sdkName}"`, clientName], - // Auth Default Headers - ...headersGenerator.getAuthHeaders() + [`"${sdkConfig.platformHeaders.sdkName}"`, clientName] ]); if (sdkVersion !== undefined) { allHeaders.set(sdkConfig.platformHeaders.sdkVersion, sdkVersion); @@ -527,72 +565,72 @@ function generateRequestClientInitializer( // If "all" then require the param and always put it in, if optional // just add the header if it's there headers["name"] = value if value let authHeaders = new Map(); - const authHeaderSetters: Expression[] = []; - - const authHeaderProperties = headersGenerator.getAuthHeadersAsProperties(); - + const authHeaderSetters: AstNode[] = []; + let headersToSet = headersGenerator.getAdditionalHeadersAsProperties(); if (headersGenerator.isAuthRequired) { authHeaders = new Map(headersGenerator.getAuthHeaders()); } else { - // Make an if statement for each auth scheme that adds the header if present - authHeaderProperties.forEach( - (prop) => - new ConditionalStatement({ - if_: { - rightSide: new FunctionInvocation({ - onObject: prop.name, - baseFunction: new Function_({ name: "nil?", functionBody: [] }) - }), - operation: "!", - expressions: [ - new FunctionInvocation({ - onObject: "@headers", - baseFunction: new Function_({ name: "store", functionBody: [] }), - arguments_: [ - new Argument({ - isNamed: false, - value: prop.wireValue ?? prop.name, - type: StringClassReference - }), - new Argument({ isNamed: false, value: prop.name, type: StringClassReference }) - ] - }) - ] - } - }) - ); + headersToSet = [...headersGenerator.getAuthHeadersAsProperties(), ...headersToSet]; } + // Make an if statement for each auth scheme that adds the header if present + headersToSet.forEach((prop) => + authHeaderSetters.push( + new ConditionalStatement({ + if_: { + rightSide: new FunctionInvocation({ + onObject: prop.name, + baseFunction: new Function_({ name: "nil?", functionBody: [] }) + }), + operation: "!", + expressions: [ + new Expression({ + leftSide: `@headers["${prop.wireValue ?? prop.name}"]`, + rightSide: prop.name, + isAssignment: true + }) + ] + } + }) + ) + ); - const retriesVariable = new Variable({ + const retriesProperty = new Property({ name: "max_retries", type: LongClassReference, isOptional: true, - variableType: VariableType.LOCAL + documentation: "The number of times to retry a failed request, defaults to 2." }); + const timeoutProperty = new Property({ name: "timeout_in_seconds", type: LongClassReference, isOptional: true }); - const retryOptions = new HashInstance({ contents: new Map([["max", retriesVariable]]) }); - const faradayConfiguration = [ - new Expression({ leftSide: "faraday.request", rightSide: ":json", isAssignment: false }), - new Expression({ - leftSide: "faraday.request", - rightSide: new Expression({ - leftSide: new ClassReference({ - name: ":retry", - import_: new Import({ from: "faraday/retry", isExternal: true }) + const retryOptions = new HashInstance({ + contents: new Map([["max", retriesProperty.toVariable(VariableType.LOCAL)]]) + }); + const faradayConfiguration = []; + if (hasFileBasedDependencies) { + faradayConfiguration.push( + new Expression({ + leftSide: "faraday.request", + rightSide: new Expression({ + rightSide: new ClassReference({ + name: ":multipart", + import_: new Import({ from: "faraday/multipart", isExternal: true }) + }) }), - rightSide: retryOptions, - operation: ", " - }), - isAssignment: false - }), - // TODO: parse and throw the custom exception within the endpoint function. Disable this faraday middleware that does this generically. - new Expression({ - leftSide: "faraday.response", - rightSide: ":raise_error, include_request: true", - isAssignment: false - }), - new Expression({ leftSide: "faraday.options.timeout", rightSide: "timeout_in_seconds", isAssignment: true }) - ]; + isAssignment: false + }) + ); + } + faradayConfiguration.push( + ...[ + new Expression({ leftSide: "faraday.request", rightSide: ":json", isAssignment: false }), + // TODO: parse and throw the custom exception within the endpoint function. Disable this faraday middleware that does this generically. + new Expression({ + leftSide: "faraday.response", + rightSide: ":raise_error, include_request: true", + isAssignment: false + }) + ] + ); if (isAsync) { faradayConfiguration.push( @@ -602,25 +640,57 @@ function generateRequestClientInitializer( name: ":async_http", import_: new Import({ from: "async/http/faraday", isExternal: true }) }), - isAssignment: true + isAssignment: false }) ); } - if (hasFileBasedDependencies) { - faradayConfiguration.push( - new Expression({ - leftSide: "faraday.request", - rightSide: new Expression({ - rightSide: new ClassReference({ - name: ":multipart", - import_: new Import({ from: "faraday/multipart", isExternal: true }) + const initialRequestOverrides: Property[] = [retriesProperty, timeoutProperty]; + faradayConfiguration.push( + new ConditionalStatement({ + if_: { + rightSide: new FunctionInvocation({ + // TODO: Do this field access on the client better + onObject: retriesProperty.toVariable(VariableType.LOCAL).write({}), + baseFunction: new Function_({ name: "nil?", functionBody: [] }) + }), + operation: "!", + expressions: [ + new Expression({ + leftSide: "faraday.request", + rightSide: new Expression({ + leftSide: new ClassReference({ + name: ":retry", + import_: new Import({ from: "faraday/retry", isExternal: true }) + }), + rightSide: retryOptions, + operation: ", " + }), + isAssignment: false }) + ] + } + }) + ); + faradayConfiguration.push( + new ConditionalStatement({ + if_: { + rightSide: new FunctionInvocation({ + // TODO: Do this field access on the client better + onObject: timeoutProperty.toVariable(VariableType.LOCAL).write({}), + baseFunction: new Function_({ name: "nil?", functionBody: [] }) }), - isAssignment: false - }) - ); - } + operation: "!", + expressions: [ + new Expression({ + leftSide: "faraday.options.timeout", + rightSide: timeoutProperty.toVariable(VariableType.LOCAL).write({}), + isAssignment: true + }) + ] + } + }) + ); const functionParams = []; const functionBody = []; @@ -657,16 +727,11 @@ function generateRequestClientInitializer( return new Function_({ name: "initialize", + invocationName: "new", parameters: [ ...functionParams, // Select sample of the request overrides object properties - new Parameter({ - name: "max_retries", - type: LongClassReference, - isOptional: true, - documentation: "The number of times to retry a failed request, defaults to 2." - }), - new Parameter({ name: "timeout_in_seconds", type: LongClassReference, isOptional: true }), + ...initialRequestOverrides.map((prop) => prop.toParameter({})), // Auth headers ...headersGenerator.getAuthHeadersAsParameters(), // Global headers @@ -728,11 +793,17 @@ export function generateRequestClients( name: "headers", type: new HashReference({ keyType: StringClassReference, valueType: StringClassReference }) }), - new Property({ name: "base_url", type: StringClassReference }), + new Property({ + name: isMultiBaseUrlEnvironments ? "default_environment" : "base_url", + type: StringClassReference + }), new Property({ name: "conn", type: faradayReference }) ]; // Add Client class - const clientClassReference = new ClassReference({ name: "RequestClient", location: "requests" }); + const clientClassReference = new ClassReference({ + name: "RequestClient", + import_: new Import({ from: "requests", isExternal: false }) + }); const clientClass = new Class_({ classReference: clientClassReference, properties: clientProperties, @@ -752,7 +823,10 @@ export function generateRequestClients( }); // Add Async Client class - const asyncClientClassReference = new ClassReference({ name: "AsyncRequestClient", location: "requests" }); + const asyncClientClassReference = new ClassReference({ + name: "AsyncRequestClient", + import_: new Import({ from: "requests", isExternal: false }) + }); const asyncClientClass = new Class_({ classReference: asyncClientClassReference, properties: clientProperties, diff --git a/generators/ruby/sdk/src/ClientsGenerator.ts b/generators/ruby/sdk/src/ClientsGenerator.ts index 4d1f6673c4d..c9847cb5a1e 100644 --- a/generators/ruby/sdk/src/ClientsGenerator.ts +++ b/generators/ruby/sdk/src/ClientsGenerator.ts @@ -1,9 +1,9 @@ -import { RelativeFilePath } from "@fern-api/fs-utils"; import { GeneratorContext } from "@fern-api/generator-commons"; -import { ClassReferenceFactory, Class_, GeneratedRubyFile, Module_ } from "@fern-api/ruby-codegen"; +import { ClassReferenceFactory, Class_, GeneratedRubyFile, LocationGenerator, Module_ } from "@fern-api/ruby-codegen"; import { HttpService, IntermediateRepresentation, + Name, ObjectProperty, Package, ServiceId, @@ -25,6 +25,7 @@ import { import { FileUploadUtility } from "./utils/FileUploadUtility"; import { HeadersGenerator } from "./utils/HeadersGenerator"; import { RequestOptions } from "./utils/RequestOptionsClass"; +import { RootImportsFile } from "./utils/RootImportsFile"; // TODO: This (as an abstract class) will probably be used across CLIs export class ClientsGenerator { @@ -43,6 +44,7 @@ export class ClientsGenerator { private intermediateRepresentation: IntermediateRepresentation; private crf: ClassReferenceFactory; private headersGenerator: HeadersGenerator; + private locationGenerator: LocationGenerator; // TODO: should this be an object instead of a string private defaultEnvironment: string | undefined; @@ -77,7 +79,8 @@ export class ClientsGenerator { this.services = new Map(Object.entries(intermediateRepresentation.services)); this.subpackages = new Map(Object.entries(intermediateRepresentation.subpackages)); - this.crf = new ClassReferenceFactory(this.types); + this.locationGenerator = new LocationGenerator(this.clientName); + this.crf = new ClassReferenceFactory(this.types, this.locationGenerator); this.headersGenerator = new HeadersGenerator( this.intermediateRepresentation.headers, this.crf, @@ -101,8 +104,7 @@ export class ClientsGenerator { clientFiles.push( new GeneratedRubyFile({ rootNode: environmentsModule, - directoryPrefix: RelativeFilePath.of("."), - name: "environment" + fullPath: "environment" }) ); } @@ -126,8 +128,7 @@ export class ClientsGenerator { clientFiles.push( new GeneratedRubyFile({ rootNode: requestsModule, - directoryPrefix: RelativeFilePath.of("."), - name: "requests" + fullPath: "requests" }) ); @@ -137,13 +138,13 @@ export class ClientsGenerator { clientFiles.push( new GeneratedRubyFile({ rootNode: fileUtilityModule, - directoryPrefix: RelativeFilePath.of("core"), - name: fileUtilityClass.classReference.name + fullPath: `core/${fileUtilityClass.classReference.name}` }) ); } const subpackageClassReferences = new Map(); + const locationGenerator = this.locationGenerator; // 1. Generate service files, these are the classes that query the endpoints // and do the heavy lifting for API calls. While we iterate over endpoints here, // we should also generate an Example object, with a client and a function invocation (takes in an IR example). @@ -155,7 +156,6 @@ export class ClientsGenerator { package_: Package, services: Map, clientName: string, - gemName: string, crf: ClassReferenceFactory, irBasePath: string, generatedClasses: Map, @@ -178,18 +178,18 @@ export class ClientsGenerator { irBasePath, generatedClasses, flattenedProperties, - fileUtilityClass + fileUtilityClass, + locationGenerator ); const serviceModule = Module_.wrapInModules( clientName, [serviceClasses.syncClientClass, serviceClasses.asyncClientClass], - package_.fernFilepath + package_.fernFilepath, + false ); const serviceFile = new GeneratedRubyFile({ rootNode: serviceModule, - directoryPrefix: RelativeFilePath.of(gemName), - location: package_.fernFilepath, - name: "client" + fullPath: locationGenerator.getLocationFromFernFilepath(package_.fernFilepath, "client") }); clientFiles.push(serviceFile); @@ -198,6 +198,7 @@ export class ClientsGenerator { } function getSubpackageClasses( + subpackageName: Name, packageId: SubpackageId, package_: Package, services: Map, @@ -215,7 +216,6 @@ export class ClientsGenerator { package_, services, clientName, - gemName, crf, irBasePath, generatedClasses, @@ -235,6 +235,7 @@ export class ClientsGenerator { const classPair = subpackageClassReferences.get(subpackageId); if (classPair === undefined) { return getSubpackageClasses( + subpackageName, subpackageId, subpackage, services, @@ -252,11 +253,13 @@ export class ClientsGenerator { .filter((cp) => cp !== undefined) as ClientClassPair[]; const subpackageClasses = generateSubpackage( + subpackageName, package_, syncClientClass.classReference, asyncClientClass.classReference, - classPairs.map((cp) => cp.syncClientClass), - classPairs.map((cp) => cp.asyncClientClass) + locationGenerator, + new Map(classPairs.map((cp) => [cp.subpackageName, cp.syncClientClass])), + new Map(classPairs.map((cp) => [cp.subpackageName, cp.asyncClientClass])) ); const subpackageModule = Module_.wrapInModules( @@ -266,9 +269,7 @@ export class ClientsGenerator { ); const subpackageFile = new GeneratedRubyFile({ rootNode: subpackageModule, - directoryPrefix: RelativeFilePath.of(gemName), - location: package_.fernFilepath, - name: "client" + fullPath: locationGenerator.getLocationFromFernFilepath(package_.fernFilepath, "client") }); clientFiles.push(subpackageFile); subpackageClassReferences.set(packageId, subpackageClasses); @@ -281,6 +282,7 @@ export class ClientsGenerator { Array.from(this.subpackages.entries()).forEach(([packageId, package_]) => getSubpackageClasses( + package_.name, packageId, package_, this.services, @@ -298,7 +300,12 @@ export class ClientsGenerator { const rootSubpackageClasses = this.intermediateRepresentation.rootPackage.subpackages .map((sp) => subpackageClassReferences.get(sp)) .filter((cp) => cp !== undefined) as ClientClassPair[]; - // TODO: this should also exist in some form for the model gen to consolidate imports + // TODO: see if there's a better way to "export" all types + const allTypeImports = Array.from(this.crf.generatedReferences.values()); + const typeExporter = new RootImportsFile(allTypeImports); + const typeExporterLocation = "types_export"; + clientFiles.push(new GeneratedRubyFile({ rootNode: typeExporter, fullPath: typeExporterLocation })); + clientFiles.push( generateRootPackage( this.gemName, @@ -307,12 +314,14 @@ export class ClientsGenerator { asyncClientClass, requestOptionsClass, this.crf, - rootSubpackageClasses.map((sp) => sp.syncClientClass), - rootSubpackageClasses.map((sp) => sp.asyncClientClass), + new Map(rootSubpackageClasses.map((sp) => [sp.subpackageName, sp.syncClientClass])), + new Map(rootSubpackageClasses.map((sp) => [sp.subpackageName, sp.asyncClientClass])), this.irBasePath, this.generatedClasses, this.flattenedProperties, fileUtilityClass, + typeExporterLocation, + environmentClass?.classReference, this.services.get(this.intermediateRepresentation.rootPackage.service ?? "") ) ); diff --git a/generators/ruby/sdk/src/utils/EndpointGenerator.ts b/generators/ruby/sdk/src/utils/EndpointGenerator.ts index 65b3c91a00f..c1d22ea688e 100644 --- a/generators/ruby/sdk/src/utils/EndpointGenerator.ts +++ b/generators/ruby/sdk/src/utils/EndpointGenerator.ts @@ -112,7 +112,7 @@ export class EndpointGenerator { wireValue: prop.name.wireValue, type: crf.fromTypeReference(prop.valueType), isOptional: isTypeOptional(prop.valueType), - documentation: prop instanceof Property ? prop.documentation : undefined + documentation: prop instanceof Property ? prop.documentation : prop.docs }); }) ]; @@ -185,9 +185,13 @@ export class EndpointGenerator { public getEndpointParameters(): Parameter[] { const params = [ - ...this.pathParametersAsProperties.map((pathProp) => pathProp.toParameter({})), - ...this.queryParametersAsProperties.map((queryProp) => queryProp.toParameter({})), - ...this.headersAsProperties.map((headerProp) => headerProp.toParameter({})), + ...this.headersAsProperties.map((headerProp) => headerProp.toParameter({ describeAsHashInYardoc: true })), + ...this.pathParametersAsProperties.map((pathProp) => + pathProp.toParameter({ describeAsHashInYardoc: true }) + ), + ...this.queryParametersAsProperties.map((queryProp) => + queryProp.toParameter({ describeAsHashInYardoc: true }) + ), ...this.bodyAsProperties.map((bodyProp) => bodyProp.toParameter({ describeAsHashInYardoc: true })) ]; if (this.streamProcessingBlock !== undefined) { @@ -210,7 +214,7 @@ export class EndpointGenerator { ]) ), // Expand the existing headers hash, then the additionalheaders params - additionalHashes: ["req.headers", additionalHeadersProperty], + additionalHashes: [{ value: "req.headers" }, { value: additionalHeadersProperty, defaultValue: "{}" }], shouldCompact: true }), isAssignment: true @@ -229,7 +233,7 @@ export class EndpointGenerator { qp.toVariable(VariableType.LOCAL) ]) ), - additionalHashes: [additionalQueryProperty], + additionalHashes: [{ value: additionalQueryProperty, defaultValue: "{}" }], shouldCompact: true }), isAssignment: true @@ -244,7 +248,10 @@ export class EndpointGenerator { } const referenceBodyHash = new HashInstance({ - additionalHashes: [prop.name, additionalBodyProperty], + additionalHashes: [ + { value: prop.name, defaultValue: "{}" }, + { value: additionalBodyProperty, defaultValue: "{}" } + ], shouldCompact: true }); return [ @@ -267,7 +274,7 @@ export class EndpointGenerator { prop.toVariable(VariableType.LOCAL) ]) ), - additionalHashes: [additionalBodyProperty], + additionalHashes: [{ value: additionalBodyProperty, defaultValue: "{}" }], shouldCompact: true }); return [ @@ -323,7 +330,7 @@ export class EndpointGenerator { return [prop.wireValue ?? prop.name, prop.toVariable(VariableType.LOCAL)]; }) ), - additionalHashes: [additionalBodyProperty], + additionalHashes: [{ value: additionalBodyProperty, defaultValue: "{}" }], shouldCompact: true }); @@ -353,23 +360,27 @@ export class EndpointGenerator { return; } - public getFaradayBlock(requestClientVariable: Variable): BlockConfiguration { + public getFaradayBlock( + requestClientVariable: Variable, + path: string, + shouldOverwriteUrl: boolean + ): BlockConfiguration { const expressions: AstNode[] = [ ...this.requestOptions.getAdditionalRequestOverrides(this.requestOptionsVariable, this.blockArg), ...this.requestOptions.headerProperties.map( (prop) => new ConditionalStatement({ if_: { - leftSide: new FunctionInvocation({ + rightSide: new FunctionInvocation({ // TODO: Do this field access on the client better - onObject: `${requestClientVariable.write({})}.${prop.name}`, + onObject: `${this.requestOptionsVariable.write({})}&.${prop.name}`, baseFunction: new Function_({ name: "nil?", functionBody: [] }) }), operation: "!", expressions: [ new Expression({ leftSide: `${this.blockArg}.headers["${prop.wireValue ?? prop.name}"]`, - rightSide: `${requestClientVariable.write({})}.${prop.name}`, + rightSide: `${this.requestOptionsVariable.write({})}.${prop.name}`, isAssignment: true }) ] @@ -398,14 +409,15 @@ export class EndpointGenerator { if (body !== undefined) { expressions.push(...body); } - const url = - this.endpoint.baseUrl !== undefined - ? new Expression({ - leftSide: `${this.blockArg}.url`, - rightSide: `${requestClientVariable.write({})}.default_environment[${this.endpoint.baseUrl}]`, - isAssignment: true - }) - : undefined; + const url = shouldOverwriteUrl + ? new Expression({ + leftSide: `${this.blockArg}.url`, + rightSide: `"#{${requestClientVariable.write({})}.default_environment[:${ + this.endpoint.baseUrl + }]}/${path}"`, + isAssignment: false + }) + : undefined; if (url !== undefined) { expressions.push(url); } @@ -444,11 +456,16 @@ export class EndpointGenerator { } public getResponseExpressions(responseVariable: Variable): AstNode[] | undefined { + const responseVariableBody = new Variable({ + name: `${responseVariable.name}.body`, + type: GenericClassReference, + variableType: VariableType.LOCAL + }); return this.endpoint.response?._visit({ json: (jr: JsonResponse) => { const responseCr = this.crf.fromTypeReference(jr.responseBodyType); return jr._visit({ - response: () => [responseCr.fromJson(responseVariable) ?? responseVariable], + response: () => [responseCr.fromJson(responseVariableBody) ?? responseVariableBody], nestedPropertyAsResponse: (jrbwp: JsonResponseBodyWithProperty) => { if (jrbwp.responseProperty !== undefined) { // Turn to struct, then get the field, then reconvert to JSON (to_h.to_json) @@ -466,7 +483,7 @@ export class EndpointGenerator { baseFunction: new Function_({ name: "parse", functionBody: [] }), arguments_: [ new Argument({ - value: "json_object", + value: responseVariableBody, type: GenericClassReference, isNamed: false }), @@ -487,7 +504,7 @@ export class EndpointGenerator { responseCr.fromJson(nestedResponseValueVariable) ?? nestedResponseValueVariable ]; } else { - return [responseCr.fromJson(responseVariable) ?? responseVariable]; + return [responseCr.fromJson(responseVariableBody) ?? responseVariableBody]; } }, _other: () => { @@ -499,7 +516,7 @@ export class EndpointGenerator { streaming: () => { throw new Error("Streaming not yet supported."); }, - text: () => [responseVariable], + text: () => [responseVariableBody], _other: () => { throw new Error("Unknown response type."); } diff --git a/generators/ruby/sdk/src/utils/FileUploadUtility.ts b/generators/ruby/sdk/src/utils/FileUploadUtility.ts index 80a3bf295c5..faf26d27e73 100644 --- a/generators/ruby/sdk/src/utils/FileUploadUtility.ts +++ b/generators/ruby/sdk/src/utils/FileUploadUtility.ts @@ -45,11 +45,12 @@ export class FileUploadUtility extends Class_ { // Get file path in conditional new ConditionalStatement({ if_: { - leftSide: new FunctionInvocation({ + rightSide: new FunctionInvocation({ onObject: fileVariable, - baseFunction: new Function_({ name: "has_attribute?", functionBody: [] }), - arguments_: [new Argument({ value: "path", type: StringClassReference, isNamed: false })] + baseFunction: new Function_({ name: "is_a?", functionBody: [] }), + arguments_: [new Argument({ value: "String", type: GenericClassReference, isNamed: false })] }), + operation: "!", expressions: [ new Expression({ leftSide: pathVariable, @@ -82,7 +83,7 @@ export class FileUploadUtility extends Class_ { // Default mimetype new ConditionalStatement({ if_: { - leftSide: new FunctionInvocation({ + rightSide: new FunctionInvocation({ onObject: mimeTypeVariable, baseFunction: new Function_({ name: "nil?", functionBody: [] }) }), @@ -98,7 +99,7 @@ export class FileUploadUtility extends Class_ { else_: [ new Expression({ leftSide: mimeTypeVariable, - rightSide: "application/octet-stream", + rightSide: '"application/octet-stream"', isAssignment: true }) ] @@ -127,7 +128,7 @@ export class FileUploadUtility extends Class_ { super({ classReference: new ClassReference({ name: "FileUtilities", - import_: new Import({ from: "core/file_utilties", isExternal: false }) + import_: new Import({ from: "core/file_utilities", isExternal: false }) }), includeInitializer: false, properties: [], diff --git a/generators/ruby/sdk/src/utils/HeadersGenerator.ts b/generators/ruby/sdk/src/utils/HeadersGenerator.ts index 8a588d84e9a..d4bbc91e394 100644 --- a/generators/ruby/sdk/src/utils/HeadersGenerator.ts +++ b/generators/ruby/sdk/src/utils/HeadersGenerator.ts @@ -71,26 +71,26 @@ export class HeadersGenerator { new Parameter({ name: bas.token.snakeCase.safeName, type: StringClassReference, - isOptional: this.isAuthRequired + isOptional: !this.isAuthRequired }) ], basic: (bas: BasicAuthScheme) => [ new Parameter({ name: bas.username.snakeCase.safeName, type: StringClassReference, - isOptional: this.isAuthRequired + isOptional: !this.isAuthRequired }), new Parameter({ name: bas.password.snakeCase.safeName, type: StringClassReference, - isOptional: this.isAuthRequired + isOptional: !this.isAuthRequired }) ], header: (has: HeaderAuthScheme) => [ new Parameter({ name: has.name.name.snakeCase.safeName, type: StringClassReference, - isOptional: this.isAuthRequired + isOptional: !this.isAuthRequired }) ], _other: () => { @@ -114,14 +114,14 @@ export class HeadersGenerator { ); } - public getAuthHeadersAsProperties(requireAuthOverride?: boolean): Property[] { + public getAuthHeadersAsProperties(isOptionalOverride?: boolean): Property[] { return this.auth.schemes.flatMap((scheme) => scheme._visit({ bearer: (bas: BearerAuthScheme) => [ new Property({ name: bas.token.snakeCase.safeName, type: StringClassReference, - isOptional: requireAuthOverride ?? this.isAuthRequired, + isOptional: isOptionalOverride ?? this.isAuthRequired, wireValue: "Authorization" }) ], @@ -129,19 +129,19 @@ export class HeadersGenerator { new Property({ name: bas.username.snakeCase.safeName, type: StringClassReference, - isOptional: requireAuthOverride ?? this.isAuthRequired + isOptional: isOptionalOverride ?? this.isAuthRequired }), new Property({ name: bas.password.snakeCase.safeName, type: StringClassReference, - isOptional: requireAuthOverride ?? this.isAuthRequired + isOptional: isOptionalOverride ?? this.isAuthRequired }) ], header: (has: HeaderAuthScheme) => [ new Property({ name: has.name.name.snakeCase.safeName, type: StringClassReference, - isOptional: requireAuthOverride ?? this.isAuthRequired, + isOptional: isOptionalOverride ?? this.isAuthRequired, wireValue: has.name.wireValue }) ], @@ -209,23 +209,26 @@ export class HeadersGenerator { // TODO: I don't love how this works, ideally it's a string to expression hash instead, but we don't // have string templates in the AST right now which is necessary for header prefixes private getCustomAuthorizationHeader(has: HeaderAuthScheme): [string, string] { - const jsonValue = new FunctionInvocation({ - onObject: has.name.name.snakeCase.safeName, - baseFunction: new Function_({ name: "to_json", functionBody: [] }) - }); + // TODO(P0): fix this, we need to know what actually needs to_json, strings do not + // What other objects can go here, what would that look like? + + // const jsonValue = new FunctionInvocation({ + // onObject: has.name.name.snakeCase.safeName, + // baseFunction: new Function_({ name: "to_json", functionBody: [] }) + // }); const headerValue = has.headerEnvVar !== undefined ? new Expression({ - leftSide: jsonValue, + leftSide: has.name.name.snakeCase.safeName, rightSide: new EnvironmentVariable({ variableName: has.headerEnvVar }), isAssignment: false, operation: "||" }) - : new Expression({ rightSide: jsonValue, isAssignment: false }); + : new Expression({ rightSide: has.name.name.snakeCase.safeName, isAssignment: false }); return [ `"${has.name.wireValue}"`, - `${has.prefix !== undefined ? has.prefix + " " : ""} #{${headerValue.write({})}}` + `${has.prefix !== undefined ? has.prefix + " " : ""}#{${headerValue.write({})}}` ]; } diff --git a/generators/ruby/sdk/src/utils/RequestOptionsClass.ts b/generators/ruby/sdk/src/utils/RequestOptionsClass.ts index bca1c0fa897..508b39e29b9 100644 --- a/generators/ruby/sdk/src/utils/RequestOptionsClass.ts +++ b/generators/ruby/sdk/src/utils/RequestOptionsClass.ts @@ -35,9 +35,9 @@ export class RequestOptions extends Class_ { }); const headerProperties = [ // Auth headers - ...headersGenerator.getAuthHeadersAsProperties(false), + ...headersGenerator.getAuthHeadersAsProperties(true), // Global headers - ...headersGenerator.getAdditionalHeadersAsProperties(false) + ...headersGenerator.getAdditionalHeadersAsProperties(true) ]; // Generic overrides const additionalHeaderProperty = new Property({ @@ -60,11 +60,11 @@ export class RequestOptions extends Class_ { classReference: new ClassReference({ name: "RequestOptions", location: "requests" }), includeInitializer: true, properties: [ - timeoutProperty, ...headerProperties, additionalHeaderProperty, additionalQueryProperty, - additionalBodyProperty + additionalBodyProperty, + timeoutProperty ], documentation: "Additional options for request-specific configuration when calling APIs via the SDK." }); @@ -86,7 +86,7 @@ export class RequestOptions extends Class_ { if_: { rightSide: new FunctionInvocation({ // TODO: Do this field access on the client better - onObject: `${requestOptionsVariable.write({})}.${this.timeoutProperty.name}`, + onObject: `${requestOptionsVariable.write({})}&.${this.timeoutProperty.name}`, baseFunction: new Function_({ name: "nil?", functionBody: [] }) }), operation: "!", diff --git a/generators/ruby/sdk/src/utils/RootImportsFile.ts b/generators/ruby/sdk/src/utils/RootImportsFile.ts new file mode 100644 index 00000000000..7ee5d9034bc --- /dev/null +++ b/generators/ruby/sdk/src/utils/RootImportsFile.ts @@ -0,0 +1,23 @@ +import { AstNode, ClassReference, Import } from "@fern-api/ruby-codegen"; + +// The root file is just a container of imports for easy access +// to the different modules. +export class RootImportsFile extends AstNode { + classReferences: ClassReference[]; + constructor(classReferences: ClassReference[]) { + super({ writeImports: true }); + this.classReferences = classReferences; + } + + public writeInternal(_startingTabSpaces: number): void { + return; + } + + public getImports(): Set { + return new Set( + Array.from(this.classReferences.entries()) + .map(([_, cr]) => cr.import_) + .filter((i) => i !== undefined) as Import[] + ); + } +} diff --git a/seed/ruby-model/alias/.rubocop.yml b/seed/ruby-model/alias/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/alias/.rubocop.yml +++ b/seed/ruby-model/alias/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/alias/lib/gemconfig.rb b/seed/ruby-model/alias/lib/gemconfig.rb index 4038bce2de3..88c45f7609f 100644 --- a/seed/ruby-model/alias/lib/gemconfig.rb +++ b/seed/ruby-model/alias/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedAliasClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/alias/lib/seed_alias_client.rb b/seed/ruby-model/alias/lib/seed_alias_client.rb index e7d75809f11..1ace288e8e3 100644 --- a/seed/ruby-model/alias/lib/seed_alias_client.rb +++ b/seed/ruby-model/alias/lib/seed_alias_client.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true +require_relative "seed_alias_client/types/type_id" require_relative "seed_alias_client/types/type" - require_relative "seed_alias_client/types/object" -require_relative "seed_alias_client/types/type_id" diff --git a/seed/ruby-model/alias/seed_alias_client.gemspec b/seed/ruby-model/alias/seed_alias_client.gemspec index 847b13763ba..0a02b984f94 100644 --- a/seed/ruby-model/alias/seed_alias_client.gemspec +++ b/seed/ruby-model/alias/seed_alias_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_alias_client" + spec.version = SeedAliasClient::Gemconfig::VERSION spec.authors = SeedAliasClient::Gemconfig::AUTHORS spec.email = SeedAliasClient::Gemconfig::EMAIL spec.summary = SeedAliasClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/api-wide-base-path/.rubocop.yml b/seed/ruby-model/api-wide-base-path/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/api-wide-base-path/.rubocop.yml +++ b/seed/ruby-model/api-wide-base-path/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/api-wide-base-path/lib/gemconfig.rb b/seed/ruby-model/api-wide-base-path/lib/gemconfig.rb index f8f82622889..f5d3fca8c46 100644 --- a/seed/ruby-model/api-wide-base-path/lib/gemconfig.rb +++ b/seed/ruby-model/api-wide-base-path/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiWideBasePathClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/api-wide-base-path/seed_api_wide_base_path_client.gemspec b/seed/ruby-model/api-wide-base-path/seed_api_wide_base_path_client.gemspec index 8af14977365..acd3afd1973 100644 --- a/seed/ruby-model/api-wide-base-path/seed_api_wide_base_path_client.gemspec +++ b/seed/ruby-model/api-wide-base-path/seed_api_wide_base_path_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_wide_base_path_client" + spec.version = SeedApiWideBasePathClient::Gemconfig::VERSION spec.authors = SeedApiWideBasePathClient::Gemconfig::AUTHORS spec.email = SeedApiWideBasePathClient::Gemconfig::EMAIL spec.summary = SeedApiWideBasePathClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/audiences/.rubocop.yml b/seed/ruby-model/audiences/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/audiences/.rubocop.yml +++ b/seed/ruby-model/audiences/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/audiences/lib/gemconfig.rb b/seed/ruby-model/audiences/lib/gemconfig.rb index 46b8e4cf90d..64ebd00ed33 100644 --- a/seed/ruby-model/audiences/lib/gemconfig.rb +++ b/seed/ruby-model/audiences/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedAudiencesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/audiences/lib/seed_audiences_client.rb b/seed/ruby-model/audiences/lib/seed_audiences_client.rb index 94d25c9dbe3..fe375717abb 100644 --- a/seed/ruby-model/audiences/lib/seed_audiences_client.rb +++ b/seed/ruby-model/audiences/lib/seed_audiences_client.rb @@ -4,6 +4,6 @@ require_relative "seed_audiences_client/folder_a/service/types/response" require_relative "seed_audiences_client/folder_b/common/types/foo" require_relative "seed_audiences_client/folder_c/common/types/foo" -require_relative "seed_audiences_client/foo/types/filtered_type" require_relative "seed_audiences_client/foo/types/importing_type" require_relative "seed_audiences_client/foo/types/optional_string" +require_relative "seed_audiences_client/foo/types/filtered_type" diff --git a/seed/ruby-model/audiences/lib/seed_audiences_client/folder_a/service/types/response.rb b/seed/ruby-model/audiences/lib/seed_audiences_client/folder_a/service/types/response.rb index b4dcab2100a..cb9512bd783 100644 --- a/seed/ruby-model/audiences/lib/seed_audiences_client/folder_a/service/types/response.rb +++ b/seed/ruby-model/audiences/lib/seed_audiences_client/folder_a/service/types/response.rb @@ -25,7 +25,8 @@ def initialize(foo: nil, additional_properties: nil) # @return [FolderA::Service::Response] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - foo = struct.foo + foo = struct.foo.to_h.to_json + foo = FolderB::Common::Foo.from_json(json_object: foo) new(foo: foo, additional_properties: struct) end diff --git a/seed/ruby-model/audiences/lib/seed_audiences_client/folder_b/common/types/foo.rb b/seed/ruby-model/audiences/lib/seed_audiences_client/folder_b/common/types/foo.rb index 01fbc4bf319..878a01330f0 100644 --- a/seed/ruby-model/audiences/lib/seed_audiences_client/folder_b/common/types/foo.rb +++ b/seed/ruby-model/audiences/lib/seed_audiences_client/folder_b/common/types/foo.rb @@ -25,7 +25,8 @@ def initialize(foo: nil, additional_properties: nil) # @return [FolderB::Common::Foo] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - foo = struct.foo + foo = struct.foo.to_h.to_json + foo = FolderC::Common::Foo.from_json(json_object: foo) new(foo: foo, additional_properties: struct) end diff --git a/seed/ruby-model/audiences/seed_audiences_client.gemspec b/seed/ruby-model/audiences/seed_audiences_client.gemspec index 8ac7509155c..d9804f6f240 100644 --- a/seed/ruby-model/audiences/seed_audiences_client.gemspec +++ b/seed/ruby-model/audiences/seed_audiences_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_audiences_client" + spec.version = SeedAudiencesClient::Gemconfig::VERSION spec.authors = SeedAudiencesClient::Gemconfig::AUTHORS spec.email = SeedAudiencesClient::Gemconfig::EMAIL spec.summary = SeedAudiencesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/auth-environment-variables/.rubocop.yml b/seed/ruby-model/auth-environment-variables/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/auth-environment-variables/.rubocop.yml +++ b/seed/ruby-model/auth-environment-variables/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/auth-environment-variables/lib/gemconfig.rb b/seed/ruby-model/auth-environment-variables/lib/gemconfig.rb index d6e2db31dd5..624288e2221 100644 --- a/seed/ruby-model/auth-environment-variables/lib/gemconfig.rb +++ b/seed/ruby-model/auth-environment-variables/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedAuthEnvironmentVariablesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/auth-environment-variables/seed_auth_environment_variables_client.gemspec b/seed/ruby-model/auth-environment-variables/seed_auth_environment_variables_client.gemspec index ad6fb0e6c39..1a74ecef95e 100644 --- a/seed/ruby-model/auth-environment-variables/seed_auth_environment_variables_client.gemspec +++ b/seed/ruby-model/auth-environment-variables/seed_auth_environment_variables_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_auth_environment_variables_client" + spec.version = SeedAuthEnvironmentVariablesClient::Gemconfig::VERSION spec.authors = SeedAuthEnvironmentVariablesClient::Gemconfig::AUTHORS spec.email = SeedAuthEnvironmentVariablesClient::Gemconfig::EMAIL spec.summary = SeedAuthEnvironmentVariablesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/basic-auth/.rubocop.yml b/seed/ruby-model/basic-auth/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/basic-auth/.rubocop.yml +++ b/seed/ruby-model/basic-auth/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/basic-auth/lib/gemconfig.rb b/seed/ruby-model/basic-auth/lib/gemconfig.rb index e99b2e23c46..e8c8e98a635 100644 --- a/seed/ruby-model/basic-auth/lib/gemconfig.rb +++ b/seed/ruby-model/basic-auth/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedBasicAuthClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/basic-auth/seed_basic_auth_client.gemspec b/seed/ruby-model/basic-auth/seed_basic_auth_client.gemspec index 0ad723c6ff6..1f9e11e9c99 100644 --- a/seed/ruby-model/basic-auth/seed_basic_auth_client.gemspec +++ b/seed/ruby-model/basic-auth/seed_basic_auth_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_basic_auth_client" + spec.version = SeedBasicAuthClient::Gemconfig::VERSION spec.authors = SeedBasicAuthClient::Gemconfig::AUTHORS spec.email = SeedBasicAuthClient::Gemconfig::EMAIL spec.summary = SeedBasicAuthClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/bearer-token-environment-variable/.rubocop.yml b/seed/ruby-model/bearer-token-environment-variable/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/bearer-token-environment-variable/.rubocop.yml +++ b/seed/ruby-model/bearer-token-environment-variable/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/bearer-token-environment-variable/lib/gemconfig.rb b/seed/ruby-model/bearer-token-environment-variable/lib/gemconfig.rb index c341ff69285..b2060c7d99c 100644 --- a/seed/ruby-model/bearer-token-environment-variable/lib/gemconfig.rb +++ b/seed/ruby-model/bearer-token-environment-variable/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedBearerTokenEnvironmentVariableClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/bearer-token-environment-variable/seed_bearer_token_environment_variable_client.gemspec b/seed/ruby-model/bearer-token-environment-variable/seed_bearer_token_environment_variable_client.gemspec index ac4a5d3a1c6..478c9fe18b5 100644 --- a/seed/ruby-model/bearer-token-environment-variable/seed_bearer_token_environment_variable_client.gemspec +++ b/seed/ruby-model/bearer-token-environment-variable/seed_bearer_token_environment_variable_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_bearer_token_environment_variable_client" + spec.version = SeedBearerTokenEnvironmentVariableClient::Gemconfig::VERSION spec.authors = SeedBearerTokenEnvironmentVariableClient::Gemconfig::AUTHORS spec.email = SeedBearerTokenEnvironmentVariableClient::Gemconfig::EMAIL spec.summary = SeedBearerTokenEnvironmentVariableClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/bytes/.rubocop.yml b/seed/ruby-model/bytes/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/bytes/.rubocop.yml +++ b/seed/ruby-model/bytes/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/bytes/lib/gemconfig.rb b/seed/ruby-model/bytes/lib/gemconfig.rb index e472d03dc9f..db2ae89f0d5 100644 --- a/seed/ruby-model/bytes/lib/gemconfig.rb +++ b/seed/ruby-model/bytes/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedBytesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/bytes/seed_bytes_client.gemspec b/seed/ruby-model/bytes/seed_bytes_client.gemspec index 9aca1dec3ff..3521f251878 100644 --- a/seed/ruby-model/bytes/seed_bytes_client.gemspec +++ b/seed/ruby-model/bytes/seed_bytes_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_bytes_client" + spec.version = SeedBytesClient::Gemconfig::VERSION spec.authors = SeedBytesClient::Gemconfig::AUTHORS spec.email = SeedBytesClient::Gemconfig::EMAIL spec.summary = SeedBytesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/circular-references/.rubocop.yml b/seed/ruby-model/circular-references/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/circular-references/.rubocop.yml +++ b/seed/ruby-model/circular-references/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/circular-references/lib/gemconfig.rb b/seed/ruby-model/circular-references/lib/gemconfig.rb index ca0b8ab5623..b4c1f83d5b0 100644 --- a/seed/ruby-model/circular-references/lib/gemconfig.rb +++ b/seed/ruby-model/circular-references/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/circular-references/lib/seed_api_client.rb b/seed/ruby-model/circular-references/lib/seed_api_client.rb index f8df8fd351b..1d71cd54d35 100644 --- a/seed/ruby-model/circular-references/lib/seed_api_client.rb +++ b/seed/ruby-model/circular-references/lib/seed_api_client.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true +require_relative "seed_api_client/types/importing_a" +require_relative "seed_api_client/types/root_type" require_relative "seed_api_client/a/types/a" -require_relative "seed_api_client/ast/types/container_value" require_relative "seed_api_client/ast/types/field_value" +require_relative "seed_api_client/ast/types/container_value" +require_relative "seed_api_client/ast/types/primitive_value" require_relative "seed_api_client/ast/types/object_value" -require_relative "seed_api_client/types/importing_a" -require_relative "seed_api_client/types/root_type" diff --git a/seed/ruby-model/circular-references/lib/seed_api_client/ast/types/field_value.rb b/seed/ruby-model/circular-references/lib/seed_api_client/ast/types/field_value.rb index 3298b28a712..f926e5db520 100644 --- a/seed/ruby-model/circular-references/lib/seed_api_client/ast/types/field_value.rb +++ b/seed/ruby-model/circular-references/lib/seed_api_client/ast/types/field_value.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true require "json" -require_relative "container_value" +require_relative "primitive_value" require_relative "object_value" +require_relative "container_value" module SeedApiClient module Ast @@ -29,13 +30,13 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "primitive_value" - PRIMITIVE_VALUE.key(json_object.value) + Ast::PRIMITIVE_VALUE.key(json_object.value) || json_object.value when "object_value" Ast::ObjectValue.from_json(json_object: json_object) when "container_value" Ast::ContainerValue.from_json(json_object: json_object.value) else - PRIMITIVE_VALUE.key(json_object) + Ast::PRIMITIVE_VALUE.key(json_object) || json_object end new(member: member, discriminant: struct.type) end @@ -64,7 +65,7 @@ def to_json(*_args) def self.validate_raw(obj:) case obj.type when "primitive_value" - obj.is_a?(PRIMITIVE_VALUE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Ast::PRIMITIVE_VALUE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "object_value" Ast::ObjectValue.validate_raw(obj: obj) when "container_value" @@ -82,7 +83,7 @@ def is_a?(obj) @member.is_a?(obj) end - # @param member [Hash{String => String}] + # @param member [PRIMITIVE_VALUE] # @return [Ast::FieldValue] def self.primitive_value(member:) new(member: member, discriminant: "primitive_value") diff --git a/seed/ruby-model/circular-references/lib/seed_api_client/ast/types/primitive_value.rb b/seed/ruby-model/circular-references/lib/seed_api_client/ast/types/primitive_value.rb index 1b1affb4f0a..37de347e0a2 100644 --- a/seed/ruby-model/circular-references/lib/seed_api_client/ast/types/primitive_value.rb +++ b/seed/ruby-model/circular-references/lib/seed_api_client/ast/types/primitive_value.rb @@ -2,7 +2,7 @@ module SeedApiClient module Ast - # @type [Hash{String => String}] - PRIMITIVE_VALUE = { string: "STRING", number: "NUMBER" }.frozen + # @type [PRIMITIVE_VALUE] + PRIMITIVE_VALUE = { string: "STRING", number: "NUMBER" }.freeze end end diff --git a/seed/ruby-model/circular-references/lib/seed_api_client/types/importing_a.rb b/seed/ruby-model/circular-references/lib/seed_api_client/types/importing_a.rb index 871bf022714..8fbb1b6f12c 100644 --- a/seed/ruby-model/circular-references/lib/seed_api_client/types/importing_a.rb +++ b/seed/ruby-model/circular-references/lib/seed_api_client/types/importing_a.rb @@ -23,7 +23,8 @@ def initialize(a: nil, additional_properties: nil) # @return [ImportingA] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - a = struct.a + a = struct.a.to_h.to_json + a = A::A.from_json(json_object: a) new(a: a, additional_properties: struct) end diff --git a/seed/ruby-model/circular-references/seed_api_client.gemspec b/seed/ruby-model/circular-references/seed_api_client.gemspec index e3108090020..f2bc0cddd0a 100644 --- a/seed/ruby-model/circular-references/seed_api_client.gemspec +++ b/seed/ruby-model/circular-references/seed_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_client" + spec.version = SeedApiClient::Gemconfig::VERSION spec.authors = SeedApiClient::Gemconfig::AUTHORS spec.email = SeedApiClient::Gemconfig::EMAIL spec.summary = SeedApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/custom-auth/.rubocop.yml b/seed/ruby-model/custom-auth/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/custom-auth/.rubocop.yml +++ b/seed/ruby-model/custom-auth/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/custom-auth/lib/gemconfig.rb b/seed/ruby-model/custom-auth/lib/gemconfig.rb index 11aad45bca6..52ab11a736c 100644 --- a/seed/ruby-model/custom-auth/lib/gemconfig.rb +++ b/seed/ruby-model/custom-auth/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedCustomAuthClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/custom-auth/seed_custom_auth_client.gemspec b/seed/ruby-model/custom-auth/seed_custom_auth_client.gemspec index 20c23d10ee0..3c1e5a1dd8c 100644 --- a/seed/ruby-model/custom-auth/seed_custom_auth_client.gemspec +++ b/seed/ruby-model/custom-auth/seed_custom_auth_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_custom_auth_client" + spec.version = SeedCustomAuthClient::Gemconfig::VERSION spec.authors = SeedCustomAuthClient::Gemconfig::AUTHORS spec.email = SeedCustomAuthClient::Gemconfig::EMAIL spec.summary = SeedCustomAuthClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/enum/.rubocop.yml b/seed/ruby-model/enum/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/enum/.rubocop.yml +++ b/seed/ruby-model/enum/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/enum/lib/gemconfig.rb b/seed/ruby-model/enum/lib/gemconfig.rb index 5658239e1c3..a615fe6448a 100644 --- a/seed/ruby-model/enum/lib/gemconfig.rb +++ b/seed/ruby-model/enum/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedEnumClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/enum/lib/seed_enum_client.rb b/seed/ruby-model/enum/lib/seed_enum_client.rb index 8e9b8f90fa4..f257522c215 100644 --- a/seed/ruby-model/enum/lib/seed_enum_client.rb +++ b/seed/ruby-model/enum/lib/seed_enum_client.rb @@ -1 +1,3 @@ # frozen_string_literal: true + +require_relative "seed_enum_client/types/operand" diff --git a/seed/ruby-model/enum/lib/seed_enum_client/types/operand.rb b/seed/ruby-model/enum/lib/seed_enum_client/types/operand.rb index 5045ea714d6..f0d518b621c 100644 --- a/seed/ruby-model/enum/lib/seed_enum_client/types/operand.rb +++ b/seed/ruby-model/enum/lib/seed_enum_client/types/operand.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true module SeedEnumClient - # @type [Hash{String => String}] - OPERAND = { greater_than: ">", equal_to: "=", less_than: "less_than" }.frozen + # @type [OPERAND] + OPERAND = { greater_than: ">", equal_to: "=", less_than: "less_than" }.freeze end diff --git a/seed/ruby-model/enum/seed_enum_client.gemspec b/seed/ruby-model/enum/seed_enum_client.gemspec index 3f6b5af29bf..fd30df60984 100644 --- a/seed/ruby-model/enum/seed_enum_client.gemspec +++ b/seed/ruby-model/enum/seed_enum_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_enum_client" + spec.version = SeedEnumClient::Gemconfig::VERSION spec.authors = SeedEnumClient::Gemconfig::AUTHORS spec.email = SeedEnumClient::Gemconfig::EMAIL spec.summary = SeedEnumClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/error-property/.rubocop.yml b/seed/ruby-model/error-property/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/error-property/.rubocop.yml +++ b/seed/ruby-model/error-property/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/error-property/lib/gemconfig.rb b/seed/ruby-model/error-property/lib/gemconfig.rb index 12c8bedeac1..aee244ffbf4 100644 --- a/seed/ruby-model/error-property/lib/gemconfig.rb +++ b/seed/ruby-model/error-property/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedErrorPropertyClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/error-property/seed_error_property_client.gemspec b/seed/ruby-model/error-property/seed_error_property_client.gemspec index 57e466df7be..c5f5c9aa25f 100644 --- a/seed/ruby-model/error-property/seed_error_property_client.gemspec +++ b/seed/ruby-model/error-property/seed_error_property_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_error_property_client" + spec.version = SeedErrorPropertyClient::Gemconfig::VERSION spec.authors = SeedErrorPropertyClient::Gemconfig::AUTHORS spec.email = SeedErrorPropertyClient::Gemconfig::EMAIL spec.summary = SeedErrorPropertyClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/examples/.rubocop.yml b/seed/ruby-model/examples/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/examples/.rubocop.yml +++ b/seed/ruby-model/examples/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/examples/lib/gemconfig.rb b/seed/ruby-model/examples/lib/gemconfig.rb index 3096258f1bb..da9515ea405 100644 --- a/seed/ruby-model/examples/lib/gemconfig.rb +++ b/seed/ruby-model/examples/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedExamplesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/examples/lib/seed_examples_client.rb b/seed/ruby-model/examples/lib/seed_examples_client.rb index 82de39b0f53..04c75400e5b 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true +require_relative "seed_examples_client/commons/types/types/tag" require_relative "seed_examples_client/commons/types/types/metadata" - -require_relative "seed_examples_client/commons/types/types/data" require_relative "seed_examples_client/commons/types/types/event_info" -require_relative "seed_examples_client/commons/types/types/tag" +require_relative "seed_examples_client/commons/types/types/data" require_relative "seed_examples_client/file/service/types/filename" +require_relative "seed_examples_client/types/types/movie_id" +require_relative "seed_examples_client/types/types/movie" +require_relative "seed_examples_client/types/types/cast_member" require_relative "seed_examples_client/types/types/actor" require_relative "seed_examples_client/types/types/actress" -require_relative "seed_examples_client/types/types/cast_member" -require_relative "seed_examples_client/types/types/directory" -require_relative "seed_examples_client/types/types/exception" -require_relative "seed_examples_client/types/types/exception_info" +require_relative "seed_examples_client/types/types/stunt_double" require_relative "seed_examples_client/types/types/extended_movie" +require_relative "seed_examples_client/types/types/moment" require_relative "seed_examples_client/types/types/file" +require_relative "seed_examples_client/types/types/directory" +require_relative "seed_examples_client/types/types/node" +require_relative "seed_examples_client/types/types/tree" require_relative "seed_examples_client/types/types/metadata" +require_relative "seed_examples_client/types/types/exception" +require_relative "seed_examples_client/types/types/exception_info" +require_relative "seed_examples_client/types/types/migration_status" require_relative "seed_examples_client/types/types/migration" -require_relative "seed_examples_client/types/types/moment" -require_relative "seed_examples_client/types/types/movie" -require_relative "seed_examples_client/types/types/movie_id" -require_relative "seed_examples_client/types/types/node" require_relative "seed_examples_client/types/types/request" require_relative "seed_examples_client/types/types/response" -require_relative "seed_examples_client/types/types/stunt_double" require_relative "seed_examples_client/types/types/test" -require_relative "seed_examples_client/types/types/tree" diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/directory.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/directory.rb index 1c1afdfd6f4..7348965f779 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/directory.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/directory.rb @@ -31,8 +31,14 @@ def initialize(name:, files: nil, directories: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - files = struct.files - directories = struct.directories + files = struct.files.map do |v| + v = v.to_h.to_json + Types::File.from_json(json_object: v) + end + directories = struct.directories.map do |v| + v = v.to_h.to_json + Types::Directory.from_json(json_object: v) + end new(name: name, files: files, directories: directories, additional_properties: struct) end diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/extended_movie.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/extended_movie.rb index 63678f77e58..9b6c917b71b 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/extended_movie.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/extended_movie.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../commons/types/types/tag" - require_relative "movie_id" +require_relative "../../commons/types/types/tag" require "json" module SeedExamplesClient diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/metadata.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/metadata.rb index b3c7d2ce490..03e9e64bc2a 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/metadata.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/metadata.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require "json" - require "set" +require "json" module SeedExamplesClient module Types diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/migration.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/migration.rb index 08f4ddd8ac7..b00b93de864 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/migration.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/migration.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "migration_status" require "json" module SeedExamplesClient @@ -8,13 +9,13 @@ class Migration attr_reader :name, :status, :additional_properties # @param name [String] - # @param status [Hash{String => String}] + # @param status [MIGRATION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Types::Migration] def initialize(name:, status:, additional_properties: nil) # @type [String] @name = name - # @type [Hash{String => String}] + # @type [MIGRATION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -27,7 +28,7 @@ def initialize(name:, status:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - status = struct.status + status = Types::MIGRATION_STATUS.key(struct.status) || struct.status new(name: name, status: status, additional_properties: struct) end @@ -35,7 +36,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "name": @name, "status": @status }.to_json + { "name": @name, "status": Types::MIGRATION_STATUS[@status] || @status }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -44,7 +45,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") - obj.status.is_a?(MIGRATION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.status.is_a?(Types::MIGRATION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/migration_status.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/migration_status.rb index e41566d81f2..8cec6b89727 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/migration_status.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/migration_status.rb @@ -2,7 +2,7 @@ module SeedExamplesClient module Types - # @type [Hash{String => String}] - MIGRATION_STATUS = { running: "RUNNING", failed: "FAILED", finished: "FINISHED" }.frozen + # @type [MIGRATION_STATUS] + MIGRATION_STATUS = { running: "RUNNING", failed: "FAILED", finished: "FINISHED" }.freeze end end diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/moment.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/moment.rb index 1c3f5cebbff..62f1fd192cc 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/moment.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/moment.rb @@ -31,8 +31,8 @@ def initialize(id:, date:, datetime:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) id = struct.id - date = struct.date - datetime = struct.datetime + date = Date.parse(struct.date) + datetime = DateTime.parse(struct.datetime) new(id: id, date: date, datetime: datetime, additional_properties: struct) end diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/movie.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/movie.rb index 9f96d24c94d..9e02038c3e2 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/movie.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/movie.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../commons/types/types/tag" - require_relative "movie_id" +require_relative "../../commons/types/types/tag" require "json" module SeedExamplesClient diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/node.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/node.rb index 2968af9b90a..eb03bed2ebd 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/node.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/node.rb @@ -31,8 +31,14 @@ def initialize(name:, nodes: nil, trees: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - nodes = struct.nodes - trees = struct.trees + nodes = struct.nodes.map do |v| + v = v.to_h.to_json + Types::Node.from_json(json_object: v) + end + trees = struct.trees.map do |v| + v = v.to_h.to_json + Types::Tree.from_json(json_object: v) + end new(name: name, nodes: nodes, trees: trees, additional_properties: struct) end diff --git a/seed/ruby-model/examples/lib/seed_examples_client/types/types/tree.rb b/seed/ruby-model/examples/lib/seed_examples_client/types/types/tree.rb index 3d1f0693f59..4892a76d221 100644 --- a/seed/ruby-model/examples/lib/seed_examples_client/types/types/tree.rb +++ b/seed/ruby-model/examples/lib/seed_examples_client/types/types/tree.rb @@ -24,7 +24,10 @@ def initialize(nodes: nil, additional_properties: nil) # @return [Types::Tree] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - nodes = struct.nodes + nodes = struct.nodes.map do |v| + v = v.to_h.to_json + Types::Node.from_json(json_object: v) + end new(nodes: nodes, additional_properties: struct) end diff --git a/seed/ruby-model/examples/seed_examples_client.gemspec b/seed/ruby-model/examples/seed_examples_client.gemspec index 1bc4bbc686c..ad5bcbead44 100644 --- a/seed/ruby-model/examples/seed_examples_client.gemspec +++ b/seed/ruby-model/examples/seed_examples_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_examples_client" + spec.version = SeedExamplesClient::Gemconfig::VERSION spec.authors = SeedExamplesClient::Gemconfig::AUTHORS spec.email = SeedExamplesClient::Gemconfig::EMAIL spec.summary = SeedExamplesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/exhaustive/.rubocop.yml b/seed/ruby-model/exhaustive/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/exhaustive/.rubocop.yml +++ b/seed/ruby-model/exhaustive/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/exhaustive/lib/gemconfig.rb b/seed/ruby-model/exhaustive/lib/gemconfig.rb index fd926713a39..878fe59accb 100644 --- a/seed/ruby-model/exhaustive/lib/gemconfig.rb +++ b/seed/ruby-model/exhaustive/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedExhaustiveClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client.rb b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client.rb index 260f79d9834..73691c77f72 100644 --- a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client.rb +++ b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true require_relative "seed_exhaustive_client/general_errors/types/bad_object_request_info" -require_relative "seed_exhaustive_client/types/object/types/nested_object_with_optional_field" -require_relative "seed_exhaustive_client/types/object/types/nested_object_with_required_field" -require_relative "seed_exhaustive_client/types/object/types/object_with_map_of_map" +require_relative "seed_exhaustive_client/types/enum/types/weather_report" require_relative "seed_exhaustive_client/types/object/types/object_with_optional_field" require_relative "seed_exhaustive_client/types/object/types/object_with_required_field" +require_relative "seed_exhaustive_client/types/object/types/object_with_map_of_map" +require_relative "seed_exhaustive_client/types/object/types/nested_object_with_optional_field" +require_relative "seed_exhaustive_client/types/object/types/nested_object_with_required_field" require_relative "seed_exhaustive_client/types/union/types/animal" -require_relative "seed_exhaustive_client/types/union/types/cat" require_relative "seed_exhaustive_client/types/union/types/dog" +require_relative "seed_exhaustive_client/types/union/types/cat" diff --git a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/enum/types/weather_report.rb b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/enum/types/weather_report.rb index 118fda4146a..c284452cc44 100644 --- a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/enum/types/weather_report.rb +++ b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/enum/types/weather_report.rb @@ -3,8 +3,8 @@ module SeedExhaustiveClient module Types module Enum - # @type [Hash{String => String}] - WEATHER_REPORT = { sunny: "SUNNY", cloudy: "CLOUDY", raining: "RAINING", snowing: "SNOWING" }.frozen + # @type [WEATHER_REPORT] + WEATHER_REPORT = { sunny: "SUNNY", cloudy: "CLOUDY", raining: "RAINING", snowing: "SNOWING" }.freeze end end end diff --git a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_optional_field.rb b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_optional_field.rb index 63f065955a3..ce82504ff1f 100644 --- a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_optional_field.rb +++ b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_optional_field.rb @@ -29,7 +29,8 @@ def initialize(string: nil, nested_object: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) string = struct.string - nested_object = struct.NestedObject + nested_object = struct.NestedObject.to_h.to_json + nested_object = Types::Object::ObjectWithOptionalField.from_json(json_object: nested_object) new(string: string, nested_object: nested_object, additional_properties: struct) end diff --git a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_required_field.rb b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_required_field.rb index e9d353c06d9..7fc1f77d743 100644 --- a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_required_field.rb +++ b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_required_field.rb @@ -29,7 +29,8 @@ def initialize(string:, nested_object:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) string = struct.string - nested_object = struct.NestedObject + nested_object = struct.NestedObject.to_h.to_json + nested_object = Types::Object::ObjectWithOptionalField.from_json(json_object: nested_object) new(string: string, nested_object: nested_object, additional_properties: struct) end diff --git a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/object_with_optional_field.rb b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/object_with_optional_field.rb index d84c55b56ae..0c14e36b363 100644 --- a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/object_with_optional_field.rb +++ b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/object/types/object_with_optional_field.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "date" -require "json" require "set" +require "json" module SeedExhaustiveClient module Types @@ -66,12 +66,13 @@ def self.from_json(json_object:) long = struct.long double = struct.double bool = struct.bool - datetime = struct.datetime - date = struct.date + datetime = DateTime.parse(struct.datetime) + date = Date.parse(struct.date) uuid = struct.uuid base_64 = struct.base64 list = struct.list - set = struct.set + set = struct.set.to_h.to_json + set = Set.new(set) map = struct.map new(string: string, integer: integer, long: long, double: double, bool: bool, datetime: datetime, date: date, uuid: uuid, base_64: base_64, list: list, set: set, map: map, additional_properties: struct) diff --git a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/union/types/animal.rb b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/union/types/animal.rb index 413b429d535..e765a78ae07 100644 --- a/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/union/types/animal.rb +++ b/seed/ruby-model/exhaustive/lib/seed_exhaustive_client/types/union/types/animal.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "cat" require_relative "dog" +require_relative "cat" module SeedExhaustiveClient module Types diff --git a/seed/ruby-model/exhaustive/seed_exhaustive_client.gemspec b/seed/ruby-model/exhaustive/seed_exhaustive_client.gemspec index 2cdeea5c2ee..ad46b0330ef 100644 --- a/seed/ruby-model/exhaustive/seed_exhaustive_client.gemspec +++ b/seed/ruby-model/exhaustive/seed_exhaustive_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_exhaustive_client" + spec.version = SeedExhaustiveClient::Gemconfig::VERSION spec.authors = SeedExhaustiveClient::Gemconfig::AUTHORS spec.email = SeedExhaustiveClient::Gemconfig::EMAIL spec.summary = SeedExhaustiveClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/extends/.rubocop.yml b/seed/ruby-model/extends/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/extends/.rubocop.yml +++ b/seed/ruby-model/extends/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/extends/lib/gemconfig.rb b/seed/ruby-model/extends/lib/gemconfig.rb index e541320cd06..f5e3603f16b 100644 --- a/seed/ruby-model/extends/lib/gemconfig.rb +++ b/seed/ruby-model/extends/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedExtendsClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/extends/lib/seed_extends_client.rb b/seed/ruby-model/extends/lib/seed_extends_client.rb index 3b3c159809b..27ca0c060b2 100644 --- a/seed/ruby-model/extends/lib/seed_extends_client.rb +++ b/seed/ruby-model/extends/lib/seed_extends_client.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative "seed_extends_client/types/docs" require_relative "seed_extends_client/types/example_type" -require_relative "seed_extends_client/types/json" require_relative "seed_extends_client/types/nested_type" +require_relative "seed_extends_client/types/docs" +require_relative "seed_extends_client/types/json" diff --git a/seed/ruby-model/extends/seed_extends_client.gemspec b/seed/ruby-model/extends/seed_extends_client.gemspec index 3c0d0683527..a7c4b766eaa 100644 --- a/seed/ruby-model/extends/seed_extends_client.gemspec +++ b/seed/ruby-model/extends/seed_extends_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_extends_client" + spec.version = SeedExtendsClient::Gemconfig::VERSION spec.authors = SeedExtendsClient::Gemconfig::AUTHORS spec.email = SeedExtendsClient::Gemconfig::EMAIL spec.summary = SeedExtendsClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/file-download/.rubocop.yml b/seed/ruby-model/file-download/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/file-download/.rubocop.yml +++ b/seed/ruby-model/file-download/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/file-download/lib/gemconfig.rb b/seed/ruby-model/file-download/lib/gemconfig.rb index 311ac5cc6e3..f32dab34836 100644 --- a/seed/ruby-model/file-download/lib/gemconfig.rb +++ b/seed/ruby-model/file-download/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedFileDownloadClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/file-download/seed_file_download_client.gemspec b/seed/ruby-model/file-download/seed_file_download_client.gemspec index 09c76c1207d..65d93f837f9 100644 --- a/seed/ruby-model/file-download/seed_file_download_client.gemspec +++ b/seed/ruby-model/file-download/seed_file_download_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_file_download_client" + spec.version = SeedFileDownloadClient::Gemconfig::VERSION spec.authors = SeedFileDownloadClient::Gemconfig::AUTHORS spec.email = SeedFileDownloadClient::Gemconfig::EMAIL spec.summary = SeedFileDownloadClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/file-upload/.rubocop.yml b/seed/ruby-model/file-upload/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/file-upload/.rubocop.yml +++ b/seed/ruby-model/file-upload/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/file-upload/lib/gemconfig.rb b/seed/ruby-model/file-upload/lib/gemconfig.rb index 60dddb888cd..a796b1aa978 100644 --- a/seed/ruby-model/file-upload/lib/gemconfig.rb +++ b/seed/ruby-model/file-upload/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedFileUploadClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/file-upload/seed_file_upload_client.gemspec b/seed/ruby-model/file-upload/seed_file_upload_client.gemspec index 57bf3a1a498..87d322abe59 100644 --- a/seed/ruby-model/file-upload/seed_file_upload_client.gemspec +++ b/seed/ruby-model/file-upload/seed_file_upload_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_file_upload_client" + spec.version = SeedFileUploadClient::Gemconfig::VERSION spec.authors = SeedFileUploadClient::Gemconfig::AUTHORS spec.email = SeedFileUploadClient::Gemconfig::EMAIL spec.summary = SeedFileUploadClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/folders/.rubocop.yml b/seed/ruby-model/folders/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/folders/.rubocop.yml +++ b/seed/ruby-model/folders/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/folders/lib/gemconfig.rb b/seed/ruby-model/folders/lib/gemconfig.rb index ca0b8ab5623..b4c1f83d5b0 100644 --- a/seed/ruby-model/folders/lib/gemconfig.rb +++ b/seed/ruby-model/folders/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/folders/seed_api_client.gemspec b/seed/ruby-model/folders/seed_api_client.gemspec index e3108090020..f2bc0cddd0a 100644 --- a/seed/ruby-model/folders/seed_api_client.gemspec +++ b/seed/ruby-model/folders/seed_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_client" + spec.version = SeedApiClient::Gemconfig::VERSION spec.authors = SeedApiClient::Gemconfig::AUTHORS spec.email = SeedApiClient::Gemconfig::EMAIL spec.summary = SeedApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/idempotency-headers/.rubocop.yml b/seed/ruby-model/idempotency-headers/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/idempotency-headers/.rubocop.yml +++ b/seed/ruby-model/idempotency-headers/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/idempotency-headers/lib/gemconfig.rb b/seed/ruby-model/idempotency-headers/lib/gemconfig.rb index 1fef07848b7..048480e4ec1 100644 --- a/seed/ruby-model/idempotency-headers/lib/gemconfig.rb +++ b/seed/ruby-model/idempotency-headers/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedIdempotencyHeadersClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/idempotency-headers/lib/seed_idempotency_headers_client.rb b/seed/ruby-model/idempotency-headers/lib/seed_idempotency_headers_client.rb index 8e9b8f90fa4..c74d9641133 100644 --- a/seed/ruby-model/idempotency-headers/lib/seed_idempotency_headers_client.rb +++ b/seed/ruby-model/idempotency-headers/lib/seed_idempotency_headers_client.rb @@ -1 +1,3 @@ # frozen_string_literal: true + +require_relative "seed_idempotency_headers_client/payment/types/currency" diff --git a/seed/ruby-model/idempotency-headers/lib/seed_idempotency_headers_client/payment/types/currency.rb b/seed/ruby-model/idempotency-headers/lib/seed_idempotency_headers_client/payment/types/currency.rb index 77882b8a0a3..5941abcb538 100644 --- a/seed/ruby-model/idempotency-headers/lib/seed_idempotency_headers_client/payment/types/currency.rb +++ b/seed/ruby-model/idempotency-headers/lib/seed_idempotency_headers_client/payment/types/currency.rb @@ -2,7 +2,7 @@ module SeedIdempotencyHeadersClient module Payment - # @type [Hash{String => String}] - CURRENCY = { usd: "USD", yen: "YEN" }.frozen + # @type [CURRENCY] + CURRENCY = { usd: "USD", yen: "YEN" }.freeze end end diff --git a/seed/ruby-model/idempotency-headers/seed_idempotency_headers_client.gemspec b/seed/ruby-model/idempotency-headers/seed_idempotency_headers_client.gemspec index 0b1a30d3507..5d3f8bc61ad 100644 --- a/seed/ruby-model/idempotency-headers/seed_idempotency_headers_client.gemspec +++ b/seed/ruby-model/idempotency-headers/seed_idempotency_headers_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_idempotency_headers_client" + spec.version = SeedIdempotencyHeadersClient::Gemconfig::VERSION spec.authors = SeedIdempotencyHeadersClient::Gemconfig::AUTHORS spec.email = SeedIdempotencyHeadersClient::Gemconfig::EMAIL spec.summary = SeedIdempotencyHeadersClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/imdb/.rubocop.yml b/seed/ruby-model/imdb/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/imdb/.rubocop.yml +++ b/seed/ruby-model/imdb/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/imdb/lib/gemconfig.rb b/seed/ruby-model/imdb/lib/gemconfig.rb index ca0b8ab5623..b4c1f83d5b0 100644 --- a/seed/ruby-model/imdb/lib/gemconfig.rb +++ b/seed/ruby-model/imdb/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/imdb/lib/seed_api_client.rb b/seed/ruby-model/imdb/lib/seed_api_client.rb index 3dac742de9b..4dbe7ba677c 100644 --- a/seed/ruby-model/imdb/lib/seed_api_client.rb +++ b/seed/ruby-model/imdb/lib/seed_api_client.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true +require_relative "seed_api_client/imdb/types/movie_id" require_relative "seed_api_client/imdb/types/movie" - require_relative "seed_api_client/imdb/types/create_movie_request" -require_relative "seed_api_client/imdb/types/movie_id" diff --git a/seed/ruby-model/imdb/seed_api_client.gemspec b/seed/ruby-model/imdb/seed_api_client.gemspec index e3108090020..f2bc0cddd0a 100644 --- a/seed/ruby-model/imdb/seed_api_client.gemspec +++ b/seed/ruby-model/imdb/seed_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_client" + spec.version = SeedApiClient::Gemconfig::VERSION spec.authors = SeedApiClient::Gemconfig::AUTHORS spec.email = SeedApiClient::Gemconfig::EMAIL spec.summary = SeedApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/literal-headers/.rubocop.yml b/seed/ruby-model/literal-headers/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/literal-headers/.rubocop.yml +++ b/seed/ruby-model/literal-headers/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/literal-headers/lib/gemconfig.rb b/seed/ruby-model/literal-headers/lib/gemconfig.rb index f3be0556677..30cda88a6cf 100644 --- a/seed/ruby-model/literal-headers/lib/gemconfig.rb +++ b/seed/ruby-model/literal-headers/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedLiteralHeadersClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/literal-headers/seed_literal_headers_client.gemspec b/seed/ruby-model/literal-headers/seed_literal_headers_client.gemspec index fed87a4c05e..32eeda67391 100644 --- a/seed/ruby-model/literal-headers/seed_literal_headers_client.gemspec +++ b/seed/ruby-model/literal-headers/seed_literal_headers_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_literal_headers_client" + spec.version = SeedLiteralHeadersClient::Gemconfig::VERSION spec.authors = SeedLiteralHeadersClient::Gemconfig::AUTHORS spec.email = SeedLiteralHeadersClient::Gemconfig::EMAIL spec.summary = SeedLiteralHeadersClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/literal/.rubocop.yml b/seed/ruby-model/literal/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/literal/.rubocop.yml +++ b/seed/ruby-model/literal/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/literal/lib/gemconfig.rb b/seed/ruby-model/literal/lib/gemconfig.rb index 8d858b47a0b..fb36a4c1b5b 100644 --- a/seed/ruby-model/literal/lib/gemconfig.rb +++ b/seed/ruby-model/literal/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedLiteralClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/literal/lib/seed_literal_client.rb b/seed/ruby-model/literal/lib/seed_literal_client.rb index 949b1059da2..83b1e9b5dca 100644 --- a/seed/ruby-model/literal/lib/seed_literal_client.rb +++ b/seed/ruby-model/literal/lib/seed_literal_client.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative "seed_literal_client/literal/types/create_options_response" require_relative "seed_literal_client/literal/types/options" require_relative "seed_literal_client/literal/types/undiscriminated_options" +require_relative "seed_literal_client/literal/types/create_options_response" diff --git a/seed/ruby-model/literal/seed_literal_client.gemspec b/seed/ruby-model/literal/seed_literal_client.gemspec index ca43e95e5bc..cf597877a3f 100644 --- a/seed/ruby-model/literal/seed_literal_client.gemspec +++ b/seed/ruby-model/literal/seed_literal_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_literal_client" + spec.version = SeedLiteralClient::Gemconfig::VERSION spec.authors = SeedLiteralClient::Gemconfig::AUTHORS spec.email = SeedLiteralClient::Gemconfig::EMAIL spec.summary = SeedLiteralClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/multi-url-environment/.rubocop.yml b/seed/ruby-model/multi-url-environment/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/multi-url-environment/.rubocop.yml +++ b/seed/ruby-model/multi-url-environment/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/multi-url-environment/lib/gemconfig.rb b/seed/ruby-model/multi-url-environment/lib/gemconfig.rb index b01e6fdbc1d..a2e658fbd42 100644 --- a/seed/ruby-model/multi-url-environment/lib/gemconfig.rb +++ b/seed/ruby-model/multi-url-environment/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedMultiUrlEnvironmentClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/multi-url-environment/seed_multi_url_environment_client.gemspec b/seed/ruby-model/multi-url-environment/seed_multi_url_environment_client.gemspec index babdccf716e..62832ccf76a 100644 --- a/seed/ruby-model/multi-url-environment/seed_multi_url_environment_client.gemspec +++ b/seed/ruby-model/multi-url-environment/seed_multi_url_environment_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_multi_url_environment_client" + spec.version = SeedMultiUrlEnvironmentClient::Gemconfig::VERSION spec.authors = SeedMultiUrlEnvironmentClient::Gemconfig::AUTHORS spec.email = SeedMultiUrlEnvironmentClient::Gemconfig::EMAIL spec.summary = SeedMultiUrlEnvironmentClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/no-environment/.rubocop.yml b/seed/ruby-model/no-environment/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/no-environment/.rubocop.yml +++ b/seed/ruby-model/no-environment/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/no-environment/lib/gemconfig.rb b/seed/ruby-model/no-environment/lib/gemconfig.rb index 56440982bf6..02528d851ad 100644 --- a/seed/ruby-model/no-environment/lib/gemconfig.rb +++ b/seed/ruby-model/no-environment/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedNoEnvironmentClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/no-environment/seed_no_environment_client.gemspec b/seed/ruby-model/no-environment/seed_no_environment_client.gemspec index 23101701046..333ad891de1 100644 --- a/seed/ruby-model/no-environment/seed_no_environment_client.gemspec +++ b/seed/ruby-model/no-environment/seed_no_environment_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_no_environment_client" + spec.version = SeedNoEnvironmentClient::Gemconfig::VERSION spec.authors = SeedNoEnvironmentClient::Gemconfig::AUTHORS spec.email = SeedNoEnvironmentClient::Gemconfig::EMAIL spec.summary = SeedNoEnvironmentClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/object/.rubocop.yml b/seed/ruby-model/object/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/object/.rubocop.yml +++ b/seed/ruby-model/object/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/object/lib/gemconfig.rb b/seed/ruby-model/object/lib/gemconfig.rb index e0dbd9394da..d90831f0fcd 100644 --- a/seed/ruby-model/object/lib/gemconfig.rb +++ b/seed/ruby-model/object/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedObjectClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/object/lib/seed_object_client.rb b/seed/ruby-model/object/lib/seed_object_client.rb index 0064a76b0ab..1b3ca4b4858 100644 --- a/seed/ruby-model/object/lib/seed_object_client.rb +++ b/seed/ruby-model/object/lib/seed_object_client.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require_relative "seed_object_client/types/name" - require_relative "seed_object_client/types/type" +require_relative "seed_object_client/types/name" diff --git a/seed/ruby-model/object/lib/seed_object_client/types/type.rb b/seed/ruby-model/object/lib/seed_object_client/types/type.rb index aed6e318304..fac3c68f648 100644 --- a/seed/ruby-model/object/lib/seed_object_client/types/type.rb +++ b/seed/ruby-model/object/lib/seed_object_client/types/type.rb @@ -87,12 +87,13 @@ def self.from_json(json_object:) three = struct.three four = struct.four five = struct.five - six = struct.six - seven = struct.seven + six = DateTime.parse(struct.six) + seven = Date.parse(struct.seven) eight = struct.eight nine = struct.nine ten = struct.ten - eleven = struct.eleven + eleven = struct.eleven.to_h.to_json + eleven = Set.new(eleven) twelve = struct.twelve thirteen = struct.thirteen fourteen = struct.fourteen @@ -100,7 +101,8 @@ def self.from_json(json_object:) sixteen = struct.sixteen seventeen = struct.seventeen eighteen = struct.eighteen - nineteen = struct.nineteen + nineteen = struct.nineteen.to_h.to_json + nineteen = Name.from_json(json_object: nineteen) new(one: one, two: two, three: three, four: four, five: five, six: six, seven: seven, eight: eight, nine: nine, ten: ten, eleven: eleven, twelve: twelve, thirteen: thirteen, fourteen: fourteen, fifteen: fifteen, sixteen: sixteen, seventeen: seventeen, eighteen: eighteen, nineteen: nineteen, additional_properties: struct) end diff --git a/seed/ruby-model/object/seed_object_client.gemspec b/seed/ruby-model/object/seed_object_client.gemspec index a83b5af0bfa..4d452b6f3c4 100644 --- a/seed/ruby-model/object/seed_object_client.gemspec +++ b/seed/ruby-model/object/seed_object_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_object_client" + spec.version = SeedObjectClient::Gemconfig::VERSION spec.authors = SeedObjectClient::Gemconfig::AUTHORS spec.email = SeedObjectClient::Gemconfig::EMAIL spec.summary = SeedObjectClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/objects-with-imports/.rubocop.yml b/seed/ruby-model/objects-with-imports/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/objects-with-imports/.rubocop.yml +++ b/seed/ruby-model/objects-with-imports/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/objects-with-imports/lib/gemconfig.rb b/seed/ruby-model/objects-with-imports/lib/gemconfig.rb index de75cda39db..89ca60b7620 100644 --- a/seed/ruby-model/objects-with-imports/lib/gemconfig.rb +++ b/seed/ruby-model/objects-with-imports/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedObjectsWithImportsClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client.rb b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client.rb index 5b00e18c92f..b65d280cd2a 100644 --- a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client.rb +++ b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require_relative "seed_objects_with_imports_client/commons/metadata/types/metadata" -require_relative "seed_objects_with_imports_client/file/directory/types/directory" -require_relative "seed_objects_with_imports_client/file/types/file" require_relative "seed_objects_with_imports_client/types/node" require_relative "seed_objects_with_imports_client/types/tree" +require_relative "seed_objects_with_imports_client/commons/metadata/types/metadata" +require_relative "seed_objects_with_imports_client/file/types/file" +require_relative "seed_objects_with_imports_client/file/types/file_info" +require_relative "seed_objects_with_imports_client/file/directory/types/directory" diff --git a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/directory/types/directory.rb b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/directory/types/directory.rb index 3cdabe96792..45ad4bc3057 100644 --- a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/directory/types/directory.rb +++ b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/directory/types/directory.rb @@ -32,8 +32,14 @@ def initialize(name:, files: nil, directories: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - files = struct.files - directories = struct.directories + files = struct.files.map do |v| + v = v.to_h.to_json + File::File.from_json(json_object: v) + end + directories = struct.directories.map do |v| + v = v.to_h.to_json + File::Directory::Directory.from_json(json_object: v) + end new(name: name, files: files, directories: directories, additional_properties: struct) end diff --git a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file.rb b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file.rb index 3bb482dd503..1b308f0021d 100644 --- a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file.rb +++ b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "file_info" require "json" module SeedObjectsWithImportsClient @@ -9,7 +10,7 @@ class File # @param name [String] # @param contents [String] - # @param info [Hash{String => String}] + # @param info [FILE_INFO] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [File::File] def initialize(name:, contents:, info:, additional_properties: nil) @@ -17,7 +18,7 @@ def initialize(name:, contents:, info:, additional_properties: nil) @name = name # @type [String] @contents = contents - # @type [Hash{String => String}] + # @type [FILE_INFO] @info = info # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -31,7 +32,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name contents = struct.contents - info = struct.info + info = File::FILE_INFO.key(struct.info) || struct.info new(name: name, contents: contents, info: info, additional_properties: struct) end @@ -39,7 +40,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "name": @name, "contents": @contents, "info": @info }.to_json + { "name": @name, "contents": @contents, "info": File::FILE_INFO[@info] || @info }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -49,7 +50,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.contents.is_a?(String) != false || raise("Passed value for field obj.contents is not the expected type, validation failed.") - obj.info.is_a?(FILE_INFO) != false || raise("Passed value for field obj.info is not the expected type, validation failed.") + obj.info.is_a?(File::FILE_INFO) != false || raise("Passed value for field obj.info is not the expected type, validation failed.") end end end diff --git a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file_info.rb b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file_info.rb index 3e96b61e14b..fea223200d3 100644 --- a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file_info.rb +++ b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file_info.rb @@ -2,7 +2,7 @@ module SeedObjectsWithImportsClient module File - # @type [Hash{String => String}] - FILE_INFO = { regular: "REGULAR", directory: "DIRECTORY" }.frozen + # @type [FILE_INFO] + FILE_INFO = { regular: "REGULAR", directory: "DIRECTORY" }.freeze end end diff --git a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/types/node.rb b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/types/node.rb index 64c7e0aa8f1..9324c3334dc 100644 --- a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/types/node.rb +++ b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/types/node.rb @@ -31,7 +31,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) id = struct.id label = struct.label - metadata = struct.metadata + metadata = struct.metadata.to_h.to_json + metadata = Commons::Metadata::Metadata.from_json(json_object: metadata) new(id: id, label: label, metadata: metadata, additional_properties: struct) end diff --git a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/types/tree.rb b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/types/tree.rb index 507638bb91a..fe14a67df9c 100644 --- a/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/types/tree.rb +++ b/seed/ruby-model/objects-with-imports/lib/seed_objects_with_imports_client/types/tree.rb @@ -23,7 +23,10 @@ def initialize(nodes: nil, additional_properties: nil) # @return [Tree] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - nodes = struct.nodes + nodes = struct.nodes.map do |v| + v = v.to_h.to_json + Node.from_json(json_object: v) + end new(nodes: nodes, additional_properties: struct) end diff --git a/seed/ruby-model/objects-with-imports/seed_objects_with_imports_client.gemspec b/seed/ruby-model/objects-with-imports/seed_objects_with_imports_client.gemspec index 8f645624054..5be8f3ef82a 100644 --- a/seed/ruby-model/objects-with-imports/seed_objects_with_imports_client.gemspec +++ b/seed/ruby-model/objects-with-imports/seed_objects_with_imports_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_objects_with_imports_client" + spec.version = SeedObjectsWithImportsClient::Gemconfig::VERSION spec.authors = SeedObjectsWithImportsClient::Gemconfig::AUTHORS spec.email = SeedObjectsWithImportsClient::Gemconfig::EMAIL spec.summary = SeedObjectsWithImportsClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/optional/.rubocop.yml b/seed/ruby-model/optional/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/optional/.rubocop.yml +++ b/seed/ruby-model/optional/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/optional/lib/gemconfig.rb b/seed/ruby-model/optional/lib/gemconfig.rb index de75cda39db..89ca60b7620 100644 --- a/seed/ruby-model/optional/lib/gemconfig.rb +++ b/seed/ruby-model/optional/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedObjectsWithImportsClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/optional/seed_objects_with_imports_client.gemspec b/seed/ruby-model/optional/seed_objects_with_imports_client.gemspec index 8f645624054..5be8f3ef82a 100644 --- a/seed/ruby-model/optional/seed_objects_with_imports_client.gemspec +++ b/seed/ruby-model/optional/seed_objects_with_imports_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_objects_with_imports_client" + spec.version = SeedObjectsWithImportsClient::Gemconfig::VERSION spec.authors = SeedObjectsWithImportsClient::Gemconfig::AUTHORS spec.email = SeedObjectsWithImportsClient::Gemconfig::EMAIL spec.summary = SeedObjectsWithImportsClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/package-yml/.rubocop.yml b/seed/ruby-model/package-yml/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/package-yml/.rubocop.yml +++ b/seed/ruby-model/package-yml/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/package-yml/lib/gemconfig.rb b/seed/ruby-model/package-yml/lib/gemconfig.rb index b0a16bebd62..aca258854f5 100644 --- a/seed/ruby-model/package-yml/lib/gemconfig.rb +++ b/seed/ruby-model/package-yml/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedPackageYmlClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/package-yml/seed_package_yml_client.gemspec b/seed/ruby-model/package-yml/seed_package_yml_client.gemspec index 37fcee41959..5577d5a0217 100644 --- a/seed/ruby-model/package-yml/seed_package_yml_client.gemspec +++ b/seed/ruby-model/package-yml/seed_package_yml_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_package_yml_client" + spec.version = SeedPackageYmlClient::Gemconfig::VERSION spec.authors = SeedPackageYmlClient::Gemconfig::AUTHORS spec.email = SeedPackageYmlClient::Gemconfig::EMAIL spec.summary = SeedPackageYmlClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/plain-text/.rubocop.yml b/seed/ruby-model/plain-text/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/plain-text/.rubocop.yml +++ b/seed/ruby-model/plain-text/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/plain-text/lib/gemconfig.rb b/seed/ruby-model/plain-text/lib/gemconfig.rb index ab188e2b775..66cad302ffe 100644 --- a/seed/ruby-model/plain-text/lib/gemconfig.rb +++ b/seed/ruby-model/plain-text/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedPlainTextClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/plain-text/seed_plain_text_client.gemspec b/seed/ruby-model/plain-text/seed_plain_text_client.gemspec index fa1147d2f58..8290ac037b7 100644 --- a/seed/ruby-model/plain-text/seed_plain_text_client.gemspec +++ b/seed/ruby-model/plain-text/seed_plain_text_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_plain_text_client" + spec.version = SeedPlainTextClient::Gemconfig::VERSION spec.authors = SeedPlainTextClient::Gemconfig::AUTHORS spec.email = SeedPlainTextClient::Gemconfig::EMAIL spec.summary = SeedPlainTextClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/reserved-keywords/.rubocop.yml b/seed/ruby-model/reserved-keywords/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/reserved-keywords/.rubocop.yml +++ b/seed/ruby-model/reserved-keywords/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/reserved-keywords/lib/gemconfig.rb b/seed/ruby-model/reserved-keywords/lib/gemconfig.rb index 96d9cde5b9b..5f7be76ba0b 100644 --- a/seed/ruby-model/reserved-keywords/lib/gemconfig.rb +++ b/seed/ruby-model/reserved-keywords/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedNurseryApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/reserved-keywords/lib/seed_nursery_api_client/package/types/record.rb b/seed/ruby-model/reserved-keywords/lib/seed_nursery_api_client/package/types/record.rb index 837c12a6b97..6909c10a354 100644 --- a/seed/ruby-model/reserved-keywords/lib/seed_nursery_api_client/package/types/record.rb +++ b/seed/ruby-model/reserved-keywords/lib/seed_nursery_api_client/package/types/record.rb @@ -31,7 +31,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json - { "foo": @foo, "3d": @_3_d }.to_json() + { "foo": @foo, "3d": @_3_d }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. # diff --git a/seed/ruby-model/reserved-keywords/seed_nursery_api_client.gemspec b/seed/ruby-model/reserved-keywords/seed_nursery_api_client.gemspec index 5026db06049..c352f7731ac 100644 --- a/seed/ruby-model/reserved-keywords/seed_nursery_api_client.gemspec +++ b/seed/ruby-model/reserved-keywords/seed_nursery_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_nursery_api_client" + spec.version = SeedNurseryApiClient::Gemconfig::VERSION spec.authors = SeedNurseryApiClient::Gemconfig::AUTHORS spec.email = SeedNurseryApiClient::Gemconfig::EMAIL spec.summary = SeedNurseryApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/response-property/.rubocop.yml b/seed/ruby-model/response-property/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/response-property/.rubocop.yml +++ b/seed/ruby-model/response-property/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/response-property/lib/gemconfig.rb b/seed/ruby-model/response-property/lib/gemconfig.rb index 5e8d7c4034a..3be4f14d97b 100644 --- a/seed/ruby-model/response-property/lib/gemconfig.rb +++ b/seed/ruby-model/response-property/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedResponsePropertyClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/response-property/lib/seed_response_property_client.rb b/seed/ruby-model/response-property/lib/seed_response_property_client.rb index 6636626bb46..e3175d7e4e3 100644 --- a/seed/ruby-model/response-property/lib/seed_response_property_client.rb +++ b/seed/ruby-model/response-property/lib/seed_response_property_client.rb @@ -1,10 +1,9 @@ # frozen_string_literal: true +require_relative "seed_response_property_client/types/string_response" require_relative "seed_response_property_client/types/optional_string_response" - -require_relative "seed_response_property_client/service/types/movie" +require_relative "seed_response_property_client/types/with_metadata" +require_relative "seed_response_property_client/service/types/with_docs" require_relative "seed_response_property_client/service/types/optional_with_docs" +require_relative "seed_response_property_client/service/types/movie" require_relative "seed_response_property_client/service/types/response" -require_relative "seed_response_property_client/service/types/with_docs" -require_relative "seed_response_property_client/types/string_response" -require_relative "seed_response_property_client/types/with_metadata" diff --git a/seed/ruby-model/response-property/lib/seed_response_property_client/service/types/response.rb b/seed/ruby-model/response-property/lib/seed_response_property_client/service/types/response.rb index 8bc9f1b7bac..a87f54c6b4e 100644 --- a/seed/ruby-model/response-property/lib/seed_response_property_client/service/types/response.rb +++ b/seed/ruby-model/response-property/lib/seed_response_property_client/service/types/response.rb @@ -30,7 +30,8 @@ def initialize(data:, metadata:, docs:, additional_properties: nil) # @return [Service::Response] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - data = struct.data + data = struct.data.to_h.to_json + data = Service::Movie.from_json(json_object: data) metadata = struct.metadata docs = struct.docs new(data: data, metadata: metadata, docs: docs, additional_properties: struct) diff --git a/seed/ruby-model/response-property/seed_response_property_client.gemspec b/seed/ruby-model/response-property/seed_response_property_client.gemspec index 2921d06631d..5f925e0b44a 100644 --- a/seed/ruby-model/response-property/seed_response_property_client.gemspec +++ b/seed/ruby-model/response-property/seed_response_property_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_response_property_client" + spec.version = SeedResponsePropertyClient::Gemconfig::VERSION spec.authors = SeedResponsePropertyClient::Gemconfig::AUTHORS spec.email = SeedResponsePropertyClient::Gemconfig::EMAIL spec.summary = SeedResponsePropertyClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/single-url-environment-default/.rubocop.yml b/seed/ruby-model/single-url-environment-default/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/single-url-environment-default/.rubocop.yml +++ b/seed/ruby-model/single-url-environment-default/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/single-url-environment-default/lib/gemconfig.rb b/seed/ruby-model/single-url-environment-default/lib/gemconfig.rb index c57e951bfa7..584b397d5ca 100644 --- a/seed/ruby-model/single-url-environment-default/lib/gemconfig.rb +++ b/seed/ruby-model/single-url-environment-default/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedSingleUrlEnvironmentDefaultClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/single-url-environment-default/seed_single_url_environment_default_client.gemspec b/seed/ruby-model/single-url-environment-default/seed_single_url_environment_default_client.gemspec index 61107f5b6e0..f9e5ef2cc42 100644 --- a/seed/ruby-model/single-url-environment-default/seed_single_url_environment_default_client.gemspec +++ b/seed/ruby-model/single-url-environment-default/seed_single_url_environment_default_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_single_url_environment_default_client" + spec.version = SeedSingleUrlEnvironmentDefaultClient::Gemconfig::VERSION spec.authors = SeedSingleUrlEnvironmentDefaultClient::Gemconfig::AUTHORS spec.email = SeedSingleUrlEnvironmentDefaultClient::Gemconfig::EMAIL spec.summary = SeedSingleUrlEnvironmentDefaultClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/single-url-environment-no-default/.rubocop.yml b/seed/ruby-model/single-url-environment-no-default/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/single-url-environment-no-default/.rubocop.yml +++ b/seed/ruby-model/single-url-environment-no-default/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/single-url-environment-no-default/lib/gemconfig.rb b/seed/ruby-model/single-url-environment-no-default/lib/gemconfig.rb index b37b448f7cb..9cdcbf122f7 100644 --- a/seed/ruby-model/single-url-environment-no-default/lib/gemconfig.rb +++ b/seed/ruby-model/single-url-environment-no-default/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedSingleUrlEnvironmentNoDefaultClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/single-url-environment-no-default/seed_single_url_environment_no_default_client.gemspec b/seed/ruby-model/single-url-environment-no-default/seed_single_url_environment_no_default_client.gemspec index 476917d0fdc..95867483322 100644 --- a/seed/ruby-model/single-url-environment-no-default/seed_single_url_environment_no_default_client.gemspec +++ b/seed/ruby-model/single-url-environment-no-default/seed_single_url_environment_no_default_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_single_url_environment_no_default_client" + spec.version = SeedSingleUrlEnvironmentNoDefaultClient::Gemconfig::VERSION spec.authors = SeedSingleUrlEnvironmentNoDefaultClient::Gemconfig::AUTHORS spec.email = SeedSingleUrlEnvironmentNoDefaultClient::Gemconfig::EMAIL spec.summary = SeedSingleUrlEnvironmentNoDefaultClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/streaming/.rubocop.yml b/seed/ruby-model/streaming/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/streaming/.rubocop.yml +++ b/seed/ruby-model/streaming/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/streaming/lib/gemconfig.rb b/seed/ruby-model/streaming/lib/gemconfig.rb index c7e96f46d9e..f776f7bd6cb 100644 --- a/seed/ruby-model/streaming/lib/gemconfig.rb +++ b/seed/ruby-model/streaming/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedStreamingClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/streaming/seed_streaming_client.gemspec b/seed/ruby-model/streaming/seed_streaming_client.gemspec index 0a10cb65432..2e631631cd4 100644 --- a/seed/ruby-model/streaming/seed_streaming_client.gemspec +++ b/seed/ruby-model/streaming/seed_streaming_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_streaming_client" + spec.version = SeedStreamingClient::Gemconfig::VERSION spec.authors = SeedStreamingClient::Gemconfig::AUTHORS spec.email = SeedStreamingClient::Gemconfig::EMAIL spec.summary = SeedStreamingClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/trace/.rubocop.yml b/seed/ruby-model/trace/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/trace/.rubocop.yml +++ b/seed/ruby-model/trace/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/trace/lib/gemconfig.rb b/seed/ruby-model/trace/lib/gemconfig.rb index 3f41146dd35..0e809dcecd7 100644 --- a/seed/ruby-model/trace/lib/gemconfig.rb +++ b/seed/ruby-model/trace/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedTraceClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/trace/lib/seed_trace_client.rb b/seed/ruby-model/trace/lib/seed_trace_client.rb index 55c789a4699..429fa75cd1e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client.rb @@ -1,206 +1,212 @@ # frozen_string_literal: true require_relative "seed_trace_client/admin/types/test" -require_relative "seed_trace_client/commons/types/binary_tree_node_and_tree_value" -require_relative "seed_trace_client/commons/types/binary_tree_node_value" -require_relative "seed_trace_client/commons/types/binary_tree_value" -require_relative "seed_trace_client/commons/types/debug_key_value_pairs" -require_relative "seed_trace_client/commons/types/debug_map_value" -require_relative "seed_trace_client/commons/types/debug_variable_value" -require_relative "seed_trace_client/commons/types/doubly_linked_list_node_and_list_value" -require_relative "seed_trace_client/commons/types/doubly_linked_list_node_value" -require_relative "seed_trace_client/commons/types/doubly_linked_list_value" -require_relative "seed_trace_client/commons/types/file_info" -require_relative "seed_trace_client/commons/types/generic_value" -require_relative "seed_trace_client/commons/types/key_value_pair" +require_relative "seed_trace_client/commons/types/user_id" +require_relative "seed_trace_client/commons/types/problem_id" +require_relative "seed_trace_client/commons/types/node_id" +require_relative "seed_trace_client/commons/types/variable_type" require_relative "seed_trace_client/commons/types/list_type" require_relative "seed_trace_client/commons/types/map_type" +require_relative "seed_trace_client/commons/types/variable_value" +require_relative "seed_trace_client/commons/types/debug_variable_value" +require_relative "seed_trace_client/commons/types/generic_value" require_relative "seed_trace_client/commons/types/map_value" -require_relative "seed_trace_client/commons/types/node_id" -require_relative "seed_trace_client/commons/types/problem_id" -require_relative "seed_trace_client/commons/types/singly_linked_list_node_and_list_value" -require_relative "seed_trace_client/commons/types/singly_linked_list_node_value" +require_relative "seed_trace_client/commons/types/key_value_pair" +require_relative "seed_trace_client/commons/types/binary_tree_value" +require_relative "seed_trace_client/commons/types/binary_tree_node_value" +require_relative "seed_trace_client/commons/types/binary_tree_node_and_tree_value" require_relative "seed_trace_client/commons/types/singly_linked_list_value" +require_relative "seed_trace_client/commons/types/singly_linked_list_node_value" +require_relative "seed_trace_client/commons/types/singly_linked_list_node_and_list_value" +require_relative "seed_trace_client/commons/types/doubly_linked_list_value" +require_relative "seed_trace_client/commons/types/doubly_linked_list_node_value" +require_relative "seed_trace_client/commons/types/doubly_linked_list_node_and_list_value" +require_relative "seed_trace_client/commons/types/debug_map_value" +require_relative "seed_trace_client/commons/types/debug_key_value_pairs" require_relative "seed_trace_client/commons/types/test_case" require_relative "seed_trace_client/commons/types/test_case_with_expected_result" -require_relative "seed_trace_client/commons/types/user_id" -require_relative "seed_trace_client/commons/types/variable_type" -require_relative "seed_trace_client/commons/types/variable_value" +require_relative "seed_trace_client/commons/types/file_info" +require_relative "seed_trace_client/commons/types/language" require_relative "seed_trace_client/lang_server/types/lang_server_request" require_relative "seed_trace_client/lang_server/types/lang_server_response" +require_relative "seed_trace_client/migration/types/migration_status" require_relative "seed_trace_client/migration/types/migration" +require_relative "seed_trace_client/playlist/types/playlist_id" require_relative "seed_trace_client/playlist/types/playlist" require_relative "seed_trace_client/playlist/types/playlist_create_request" -require_relative "seed_trace_client/playlist/types/playlist_id" -require_relative "seed_trace_client/playlist/types/playlist_id_not_found_error_body" require_relative "seed_trace_client/playlist/types/update_playlist_request" -require_relative "seed_trace_client/problem/types/create_problem_error" -require_relative "seed_trace_client/problem/types/create_problem_request" -require_relative "seed_trace_client/problem/types/create_problem_response" -require_relative "seed_trace_client/problem/types/generic_create_problem_error" -require_relative "seed_trace_client/problem/types/get_default_starter_files_response" +require_relative "seed_trace_client/playlist/types/playlist_id_not_found_error_body" +require_relative "seed_trace_client/playlist/types/reserved_keyword_enum" +require_relative "seed_trace_client/problem/types/problem_info" require_relative "seed_trace_client/problem/types/problem_description" require_relative "seed_trace_client/problem/types/problem_description_board" require_relative "seed_trace_client/problem/types/problem_files" -require_relative "seed_trace_client/problem/types/problem_info" -require_relative "seed_trace_client/problem/types/update_problem_response" require_relative "seed_trace_client/problem/types/variable_type_and_name" -require_relative "seed_trace_client/submission/types/actual_result" -require_relative "seed_trace_client/submission/types/building_executor_response" -require_relative "seed_trace_client/submission/types/code_execution_update" -require_relative "seed_trace_client/submission/types/compile_error" -require_relative "seed_trace_client/submission/types/custom_test_cases_unsupported" -require_relative "seed_trace_client/submission/types/error_info" -require_relative "seed_trace_client/submission/types/errored_response" -require_relative "seed_trace_client/submission/types/exception_info" -require_relative "seed_trace_client/submission/types/exception_v_2" -require_relative "seed_trace_client/submission/types/execution_session_response" -require_relative "seed_trace_client/submission/types/execution_session_state" -require_relative "seed_trace_client/submission/types/existing_submission_executing" -require_relative "seed_trace_client/submission/types/expression_location" -require_relative "seed_trace_client/submission/types/finished_response" -require_relative "seed_trace_client/submission/types/get_execution_session_state_response" -require_relative "seed_trace_client/submission/types/get_submission_state_response" -require_relative "seed_trace_client/submission/types/get_trace_responses_page_request" -require_relative "seed_trace_client/submission/types/graded_response" -require_relative "seed_trace_client/submission/types/graded_response_v_2" -require_relative "seed_trace_client/submission/types/graded_test_case_update" +require_relative "seed_trace_client/problem/types/create_problem_request" +require_relative "seed_trace_client/problem/types/create_problem_response" +require_relative "seed_trace_client/problem/types/update_problem_response" +require_relative "seed_trace_client/problem/types/create_problem_error" +require_relative "seed_trace_client/problem/types/generic_create_problem_error" +require_relative "seed_trace_client/problem/types/get_default_starter_files_response" +require_relative "seed_trace_client/submission/types/submission_id" +require_relative "seed_trace_client/submission/types/share_id" +require_relative "seed_trace_client/submission/types/submission_request" require_relative "seed_trace_client/submission/types/initialize_problem_request" -require_relative "seed_trace_client/submission/types/internal_error" -require_relative "seed_trace_client/submission/types/invalid_request_cause" -require_relative "seed_trace_client/submission/types/invalid_request_response" -require_relative "seed_trace_client/submission/types/lightweight_stackframe_information" -require_relative "seed_trace_client/submission/types/recorded_response_notification" -require_relative "seed_trace_client/submission/types/recorded_test_case_update" -require_relative "seed_trace_client/submission/types/recording_response_notification" +require_relative "seed_trace_client/submission/types/submit_request_v_2" +require_relative "seed_trace_client/submission/types/workspace_submit_request" +require_relative "seed_trace_client/submission/types/submission_file_info" +require_relative "seed_trace_client/submission/types/submission_type_enum" +require_relative "seed_trace_client/submission/types/stop_request" +require_relative "seed_trace_client/submission/types/submission_response" +require_relative "seed_trace_client/submission/types/code_execution_update" +require_relative "seed_trace_client/submission/types/building_executor_response" require_relative "seed_trace_client/submission/types/running_response" +require_relative "seed_trace_client/submission/types/running_submission_state" +require_relative "seed_trace_client/submission/types/errored_response" +require_relative "seed_trace_client/submission/types/error_info" +require_relative "seed_trace_client/submission/types/compile_error" require_relative "seed_trace_client/submission/types/runtime_error" -require_relative "seed_trace_client/submission/types/scope" -require_relative "seed_trace_client/submission/types/share_id" -require_relative "seed_trace_client/submission/types/stack_frame" -require_relative "seed_trace_client/submission/types/stack_information" -require_relative "seed_trace_client/submission/types/stderr_response" -require_relative "seed_trace_client/submission/types/stdout_response" -require_relative "seed_trace_client/submission/types/stop_request" +require_relative "seed_trace_client/submission/types/internal_error" require_relative "seed_trace_client/submission/types/stopped_response" -require_relative "seed_trace_client/submission/types/submission_file_info" -require_relative "seed_trace_client/submission/types/submission_id" -require_relative "seed_trace_client/submission/types/submission_id_not_found" -require_relative "seed_trace_client/submission/types/submission_request" -require_relative "seed_trace_client/submission/types/submission_response" -require_relative "seed_trace_client/submission/types/submission_status_for_test_case" -require_relative "seed_trace_client/submission/types/submission_status_v_2" -require_relative "seed_trace_client/submission/types/submission_type_state" -require_relative "seed_trace_client/submission/types/submit_request_v_2" -require_relative "seed_trace_client/submission/types/terminated_response" +require_relative "seed_trace_client/submission/types/workspace_ran_response" +require_relative "seed_trace_client/submission/types/workspace_run_details" +require_relative "seed_trace_client/submission/types/graded_response" +require_relative "seed_trace_client/submission/types/graded_response_v_2" require_relative "seed_trace_client/submission/types/test_case_grade" require_relative "seed_trace_client/submission/types/test_case_hidden_grade" require_relative "seed_trace_client/submission/types/test_case_non_hidden_grade" -require_relative "seed_trace_client/submission/types/test_case_result" +require_relative "seed_trace_client/submission/types/recorded_response_notification" +require_relative "seed_trace_client/submission/types/recording_response_notification" +require_relative "seed_trace_client/submission/types/lightweight_stackframe_information" require_relative "seed_trace_client/submission/types/test_case_result_with_stdout" -require_relative "seed_trace_client/submission/types/test_submission_state" -require_relative "seed_trace_client/submission/types/test_submission_status" -require_relative "seed_trace_client/submission/types/test_submission_status_v_2" -require_relative "seed_trace_client/submission/types/test_submission_update" -require_relative "seed_trace_client/submission/types/test_submission_update_info" +require_relative "seed_trace_client/submission/types/test_case_result" +require_relative "seed_trace_client/submission/types/actual_result" +require_relative "seed_trace_client/submission/types/exception_v_2" +require_relative "seed_trace_client/submission/types/exception_info" +require_relative "seed_trace_client/submission/types/invalid_request_response" +require_relative "seed_trace_client/submission/types/invalid_request_cause" +require_relative "seed_trace_client/submission/types/existing_submission_executing" +require_relative "seed_trace_client/submission/types/submission_id_not_found" +require_relative "seed_trace_client/submission/types/custom_test_cases_unsupported" +require_relative "seed_trace_client/submission/types/unexpected_language_error" +require_relative "seed_trace_client/submission/types/terminated_response" +require_relative "seed_trace_client/submission/types/finished_response" +require_relative "seed_trace_client/submission/types/stdout_response" +require_relative "seed_trace_client/submission/types/stderr_response" require_relative "seed_trace_client/submission/types/trace_response" require_relative "seed_trace_client/submission/types/trace_response_v_2" -require_relative "seed_trace_client/submission/types/trace_responses_page" -require_relative "seed_trace_client/submission/types/trace_responses_page_v_2" require_relative "seed_trace_client/submission/types/traced_file" -require_relative "seed_trace_client/submission/types/traced_test_case" -require_relative "seed_trace_client/submission/types/unexpected_language_error" -require_relative "seed_trace_client/submission/types/workspace_files" -require_relative "seed_trace_client/submission/types/workspace_ran_response" -require_relative "seed_trace_client/submission/types/workspace_run_details" -require_relative "seed_trace_client/submission/types/workspace_starter_files_response" -require_relative "seed_trace_client/submission/types/workspace_starter_files_response_v_2" -require_relative "seed_trace_client/submission/types/workspace_submission_state" -require_relative "seed_trace_client/submission/types/workspace_submission_status" +require_relative "seed_trace_client/submission/types/expression_location" +require_relative "seed_trace_client/submission/types/stack_information" +require_relative "seed_trace_client/submission/types/stack_frame" +require_relative "seed_trace_client/submission/types/scope" +require_relative "seed_trace_client/submission/types/execution_session_response" +require_relative "seed_trace_client/submission/types/execution_session_status" +require_relative "seed_trace_client/submission/types/submission_status_v_2" +require_relative "seed_trace_client/submission/types/test_submission_status_v_2" require_relative "seed_trace_client/submission/types/workspace_submission_status_v_2" +require_relative "seed_trace_client/submission/types/test_submission_update" +require_relative "seed_trace_client/submission/types/test_submission_update_info" require_relative "seed_trace_client/submission/types/workspace_submission_update" require_relative "seed_trace_client/submission/types/workspace_submission_update_info" -require_relative "seed_trace_client/submission/types/workspace_submit_request" +require_relative "seed_trace_client/submission/types/graded_test_case_update" +require_relative "seed_trace_client/submission/types/recorded_test_case_update" require_relative "seed_trace_client/submission/types/workspace_traced_update" -require_relative "seed_trace_client/v_2/problem/types/assert_correctness_check" -require_relative "seed_trace_client/v_2/problem/types/basic_custom_files" -require_relative "seed_trace_client/v_2/problem/types/basic_test_case_template" -require_relative "seed_trace_client/v_2/problem/types/create_problem_request_v_2" -require_relative "seed_trace_client/v_2/problem/types/custom_files" -require_relative "seed_trace_client/v_2/problem/types/deep_equality_correctness_check" -require_relative "seed_trace_client/v_2/problem/types/default_provided_file" -require_relative "seed_trace_client/v_2/problem/types/file_info_v_2" -require_relative "seed_trace_client/v_2/problem/types/files" -require_relative "seed_trace_client/v_2/problem/types/function_implementation" -require_relative "seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages" -require_relative "seed_trace_client/v_2/problem/types/function_signature" -require_relative "seed_trace_client/v_2/problem/types/generated_files" -require_relative "seed_trace_client/v_2/problem/types/get_basic_solution_file_request" -require_relative "seed_trace_client/v_2/problem/types/get_basic_solution_file_response" -require_relative "seed_trace_client/v_2/problem/types/get_function_signature_request" -require_relative "seed_trace_client/v_2/problem/types/get_function_signature_response" -require_relative "seed_trace_client/v_2/problem/types/get_generated_test_case_file_request" -require_relative "seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request" -require_relative "seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2" -require_relative "seed_trace_client/v_2/problem/types/non_void_function_definition" -require_relative "seed_trace_client/v_2/problem/types/non_void_function_signature" -require_relative "seed_trace_client/v_2/problem/types/parameter" +require_relative "seed_trace_client/submission/types/submission_type_state" +require_relative "seed_trace_client/submission/types/workspace_submission_state" +require_relative "seed_trace_client/submission/types/workspace_submission_status" +require_relative "seed_trace_client/submission/types/test_submission_state" +require_relative "seed_trace_client/submission/types/test_submission_status" +require_relative "seed_trace_client/submission/types/submission_status_for_test_case" +require_relative "seed_trace_client/submission/types/traced_test_case" +require_relative "seed_trace_client/submission/types/trace_responses_page" +require_relative "seed_trace_client/submission/types/trace_responses_page_v_2" +require_relative "seed_trace_client/submission/types/get_trace_responses_page_request" +require_relative "seed_trace_client/submission/types/workspace_starter_files_response" +require_relative "seed_trace_client/submission/types/workspace_starter_files_response_v_2" +require_relative "seed_trace_client/submission/types/workspace_files" +require_relative "seed_trace_client/submission/types/execution_session_state" +require_relative "seed_trace_client/submission/types/get_execution_session_state_response" +require_relative "seed_trace_client/submission/types/get_submission_state_response" +require_relative "seed_trace_client/v_2/problem/types/test_case_template_id" +require_relative "seed_trace_client/v_2/problem/types/test_case_id" require_relative "seed_trace_client/v_2/problem/types/parameter_id" require_relative "seed_trace_client/v_2/problem/types/problem_info_v_2" +require_relative "seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2" +require_relative "seed_trace_client/v_2/problem/types/create_problem_request_v_2" +require_relative "seed_trace_client/v_2/problem/types/test_case_v_2" require_relative "seed_trace_client/v_2/problem/types/test_case_expects" -require_relative "seed_trace_client/v_2/problem/types/test_case_function" -require_relative "seed_trace_client/v_2/problem/types/test_case_id" -require_relative "seed_trace_client/v_2/problem/types/test_case_implementation" -require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_description" -require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_description_board" require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_reference" -require_relative "seed_trace_client/v_2/problem/types/test_case_metadata" +require_relative "seed_trace_client/v_2/problem/types/basic_test_case_template" require_relative "seed_trace_client/v_2/problem/types/test_case_template" -require_relative "seed_trace_client/v_2/problem/types/test_case_template_id" -require_relative "seed_trace_client/v_2/problem/types/test_case_v_2" +require_relative "seed_trace_client/v_2/problem/types/test_case_implementation" +require_relative "seed_trace_client/v_2/problem/types/test_case_function" require_relative "seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation" require_relative "seed_trace_client/v_2/problem/types/void_function_definition" -require_relative "seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result" +require_relative "seed_trace_client/v_2/problem/types/parameter" +require_relative "seed_trace_client/v_2/problem/types/non_void_function_definition" require_relative "seed_trace_client/v_2/problem/types/void_function_signature" +require_relative "seed_trace_client/v_2/problem/types/non_void_function_signature" require_relative "seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result" -require_relative "seed_trace_client/v_2/v_3/problem/types/assert_correctness_check" -require_relative "seed_trace_client/v_2/v_3/problem/types/basic_custom_files" -require_relative "seed_trace_client/v_2/v_3/problem/types/basic_test_case_template" -require_relative "seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2" -require_relative "seed_trace_client/v_2/v_3/problem/types/custom_files" -require_relative "seed_trace_client/v_2/v_3/problem/types/deep_equality_correctness_check" -require_relative "seed_trace_client/v_2/v_3/problem/types/default_provided_file" -require_relative "seed_trace_client/v_2/v_3/problem/types/file_info_v_2" -require_relative "seed_trace_client/v_2/v_3/problem/types/files" -require_relative "seed_trace_client/v_2/v_3/problem/types/function_implementation" -require_relative "seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages" -require_relative "seed_trace_client/v_2/v_3/problem/types/function_signature" -require_relative "seed_trace_client/v_2/v_3/problem/types/generated_files" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_function_signature_request" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_function_signature_response" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request" -require_relative "seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2" -require_relative "seed_trace_client/v_2/v_3/problem/types/non_void_function_definition" -require_relative "seed_trace_client/v_2/v_3/problem/types/non_void_function_signature" -require_relative "seed_trace_client/v_2/v_3/problem/types/parameter" +require_relative "seed_trace_client/v_2/problem/types/assert_correctness_check" +require_relative "seed_trace_client/v_2/problem/types/deep_equality_correctness_check" +require_relative "seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result" +require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_description" +require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_description_board" +require_relative "seed_trace_client/v_2/problem/types/test_case_metadata" +require_relative "seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages" +require_relative "seed_trace_client/v_2/problem/types/function_implementation" +require_relative "seed_trace_client/v_2/problem/types/generated_files" +require_relative "seed_trace_client/v_2/problem/types/custom_files" +require_relative "seed_trace_client/v_2/problem/types/basic_custom_files" +require_relative "seed_trace_client/v_2/problem/types/files" +require_relative "seed_trace_client/v_2/problem/types/file_info_v_2" +require_relative "seed_trace_client/v_2/problem/types/default_provided_file" +require_relative "seed_trace_client/v_2/problem/types/function_signature" +require_relative "seed_trace_client/v_2/problem/types/get_function_signature_request" +require_relative "seed_trace_client/v_2/problem/types/get_function_signature_response" +require_relative "seed_trace_client/v_2/problem/types/get_basic_solution_file_request" +require_relative "seed_trace_client/v_2/problem/types/get_basic_solution_file_response" +require_relative "seed_trace_client/v_2/problem/types/get_generated_test_case_file_request" +require_relative "seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_template_id" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_id" require_relative "seed_trace_client/v_2/v_3/problem/types/parameter_id" require_relative "seed_trace_client/v_2/v_3/problem/types/problem_info_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_v_2" require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_expects" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_function" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_id" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description_board" require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_reference" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_metadata" +require_relative "seed_trace_client/v_2/v_3/problem/types/basic_test_case_template" require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_template" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_template_id" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_function" require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation" require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_definition" -require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result" +require_relative "seed_trace_client/v_2/v_3/problem/types/parameter" +require_relative "seed_trace_client/v_2/v_3/problem/types/non_void_function_definition" require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_signature" +require_relative "seed_trace_client/v_2/v_3/problem/types/non_void_function_signature" require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result" +require_relative "seed_trace_client/v_2/v_3/problem/types/assert_correctness_check" +require_relative "seed_trace_client/v_2/v_3/problem/types/deep_equality_correctness_check" +require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description_board" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_metadata" +require_relative "seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages" +require_relative "seed_trace_client/v_2/v_3/problem/types/function_implementation" +require_relative "seed_trace_client/v_2/v_3/problem/types/generated_files" +require_relative "seed_trace_client/v_2/v_3/problem/types/custom_files" +require_relative "seed_trace_client/v_2/v_3/problem/types/basic_custom_files" +require_relative "seed_trace_client/v_2/v_3/problem/types/files" +require_relative "seed_trace_client/v_2/v_3/problem/types/file_info_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/default_provided_file" +require_relative "seed_trace_client/v_2/v_3/problem/types/function_signature" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_function_signature_request" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_function_signature_response" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request" diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/binary_tree_node_and_tree_value.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/binary_tree_node_and_tree_value.rb index 47739fba726..bd40c7c3121 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/binary_tree_node_and_tree_value.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/binary_tree_node_and_tree_value.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "binary_tree_value" - require_relative "node_id" +require_relative "binary_tree_value" require "json" module SeedTraceClient @@ -30,7 +29,8 @@ def initialize(node_id:, full_tree:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) node_id = struct.nodeId - full_tree = struct.fullTree + full_tree = struct.fullTree.to_h.to_json + full_tree = Commons::BinaryTreeValue.from_json(json_object: full_tree) new(node_id: node_id, full_tree: full_tree, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_key_value_pairs.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_key_value_pairs.rb index 90ed46516c2..a72d6290f71 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_key_value_pairs.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_key_value_pairs.rb @@ -27,8 +27,10 @@ def initialize(key:, value:, additional_properties: nil) # @return [Commons::DebugKeyValuePairs] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key = struct.key - value = struct.value + key = struct.key.to_h.to_json + key = Commons::DebugVariableValue.from_json(json_object: key) + value = struct.value.to_h.to_json + value = Commons::DebugVariableValue.from_json(json_object: value) new(key: key, value: value, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_map_value.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_map_value.rb index 5a1df63da87..403e1948bfb 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_map_value.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_map_value.rb @@ -24,7 +24,10 @@ def initialize(key_value_pairs:, additional_properties: nil) # @return [Commons::DebugMapValue] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key_value_pairs = struct.keyValuePairs + key_value_pairs = struct.keyValuePairs.map do |v| + v = v.to_h.to_json + Commons::DebugKeyValuePairs.from_json(json_object: v) + end new(key_value_pairs: key_value_pairs, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_variable_value.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_variable_value.rb index 213d0e06d09..c2fcc39f206 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_variable_value.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/debug_variable_value.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true require "json" -require_relative "binary_tree_node_and_tree_value" require_relative "debug_map_value" +require_relative "binary_tree_node_and_tree_value" +require_relative "singly_linked_list_node_and_list_value" require_relative "doubly_linked_list_node_and_list_value" require_relative "generic_value" -require_relative "singly_linked_list_node_and_list_value" module SeedTraceClient module Commons diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/doubly_linked_list_node_and_list_value.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/doubly_linked_list_node_and_list_value.rb index 319c3599a22..e714c43090e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/doubly_linked_list_node_and_list_value.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/doubly_linked_list_node_and_list_value.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "doubly_linked_list_value" - require_relative "node_id" +require_relative "doubly_linked_list_value" require "json" module SeedTraceClient @@ -30,7 +29,8 @@ def initialize(node_id:, full_list:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) node_id = struct.nodeId - full_list = struct.fullList + full_list = struct.fullList.to_h.to_json + full_list = Commons::DoublyLinkedListValue.from_json(json_object: full_list) new(node_id: node_id, full_list: full_list, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/key_value_pair.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/key_value_pair.rb index 085fa8390eb..5bf076b8399 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/key_value_pair.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/key_value_pair.rb @@ -27,8 +27,10 @@ def initialize(key:, value:, additional_properties: nil) # @return [Commons::KeyValuePair] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key = struct.key - value = struct.value + key = struct.key.to_h.to_json + key = Commons::VariableValue.from_json(json_object: key) + value = struct.value.to_h.to_json + value = Commons::VariableValue.from_json(json_object: value) new(key: key, value: value, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/language.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/language.rb index cb58775bb40..75298c6aa53 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/language.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/language.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Commons - # @type [Hash{String => String}] - LANGUAGE = { java: "JAVA", javascript: "JAVASCRIPT", python: "PYTHON" }.frozen + # @type [LANGUAGE] + LANGUAGE = { java: "JAVA", javascript: "JAVASCRIPT", python: "PYTHON" }.freeze end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/list_type.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/list_type.rb index a3d53b70226..604c73075d7 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/list_type.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/list_type.rb @@ -27,7 +27,8 @@ def initialize(value_type:, is_fixed_length: nil, additional_properties: nil) # @return [Commons::ListType] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - value_type = struct.valueType + value_type = struct.valueType.to_h.to_json + value_type = Commons::VariableType.from_json(json_object: value_type) is_fixed_length = struct.isFixedLength new(value_type: value_type, is_fixed_length: is_fixed_length, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/map_type.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/map_type.rb index 774cf0e8aa4..2703fb744b3 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/map_type.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/map_type.rb @@ -27,8 +27,10 @@ def initialize(key_type:, value_type:, additional_properties: nil) # @return [Commons::MapType] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key_type = struct.keyType - value_type = struct.valueType + key_type = struct.keyType.to_h.to_json + key_type = Commons::VariableType.from_json(json_object: key_type) + value_type = struct.valueType.to_h.to_json + value_type = Commons::VariableType.from_json(json_object: value_type) new(key_type: key_type, value_type: value_type, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/map_value.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/map_value.rb index 447e50bcc5c..7449673da55 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/map_value.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/map_value.rb @@ -24,7 +24,10 @@ def initialize(key_value_pairs:, additional_properties: nil) # @return [Commons::MapValue] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key_value_pairs = struct.keyValuePairs + key_value_pairs = struct.keyValuePairs.map do |v| + v = v.to_h.to_json + Commons::KeyValuePair.from_json(json_object: v) + end new(key_value_pairs: key_value_pairs, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/singly_linked_list_node_and_list_value.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/singly_linked_list_node_and_list_value.rb index 78734fe2ec0..d12a56af980 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/singly_linked_list_node_and_list_value.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/singly_linked_list_node_and_list_value.rb @@ -29,7 +29,8 @@ def initialize(node_id:, full_list:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) node_id = struct.nodeId - full_list = struct.fullList + full_list = struct.fullList.to_h.to_json + full_list = Commons::SinglyLinkedListValue.from_json(json_object: full_list) new(node_id: node_id, full_list: full_list, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/test_case.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/test_case.rb index ee4841e1e0b..7296c588518 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/test_case.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/test_case.rb @@ -28,7 +28,10 @@ def initialize(id:, params:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) id = struct.id - params = struct.params + params = struct.params.map do |v| + v = v.to_h.to_json + Commons::VariableValue.from_json(json_object: v) + end new(id: id, params: params, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/test_case_with_expected_result.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/test_case_with_expected_result.rb index f932260d050..b86532449a1 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/test_case_with_expected_result.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/test_case_with_expected_result.rb @@ -28,8 +28,10 @@ def initialize(test_case:, expected_result:, additional_properties: nil) # @return [Commons::TestCaseWithExpectedResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - test_case = struct.testCase - expected_result = struct.expectedResult + test_case = struct.testCase.to_h.to_json + test_case = Commons::TestCase.from_json(json_object: test_case) + expected_result = struct.expectedResult.to_h.to_json + expected_result = Commons::VariableValue.from_json(json_object: expected_result) new(test_case: test_case, expected_result: expected_result, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/variable_value.rb b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/variable_value.rb index 18ff971bee8..2b9047579d1 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/commons/types/variable_value.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/commons/types/variable_value.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true require "json" -require_relative "binary_tree_value" -require_relative "doubly_linked_list_value" require_relative "map_value" +require_relative "binary_tree_value" require_relative "singly_linked_list_value" +require_relative "doubly_linked_list_value" module SeedTraceClient module Commons diff --git a/seed/ruby-model/trace/lib/seed_trace_client/migration/types/migration.rb b/seed/ruby-model/trace/lib/seed_trace_client/migration/types/migration.rb index c68b0fa4c1b..39d3342f99f 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/migration/types/migration.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/migration/types/migration.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "migration_status" require "json" module SeedTraceClient @@ -8,13 +9,13 @@ class Migration attr_reader :name, :status, :additional_properties # @param name [String] - # @param status [Hash{String => String}] + # @param status [MIGRATION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Migration::Migration] def initialize(name:, status:, additional_properties: nil) # @type [String] @name = name - # @type [Hash{String => String}] + # @type [MIGRATION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -27,7 +28,7 @@ def initialize(name:, status:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - status = struct.status + status = Migration::MIGRATION_STATUS.key(struct.status) || struct.status new(name: name, status: status, additional_properties: struct) end @@ -35,7 +36,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "name": @name, "status": @status }.to_json + { "name": @name, "status": Migration::MIGRATION_STATUS[@status] || @status }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -44,7 +45,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") - obj.status.is_a?(MIGRATION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.status.is_a?(Migration::MIGRATION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/migration/types/migration_status.rb b/seed/ruby-model/trace/lib/seed_trace_client/migration/types/migration_status.rb index c09ec788ca5..91a0ca00e81 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/migration/types/migration_status.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/migration/types/migration_status.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Migration - # @type [Hash{String => String}] - MIGRATION_STATUS = { running: "RUNNING", failed: "FAILED", finished: "FINISHED" }.frozen + # @type [MIGRATION_STATUS] + MIGRATION_STATUS = { running: "RUNNING", failed: "FAILED", finished: "FINISHED" }.freeze end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/playlist/types/playlist.rb b/seed/ruby-model/trace/lib/seed_trace_client/playlist/types/playlist.rb index 92fb82ad914..a8e023f16f1 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/playlist/types/playlist.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/playlist/types/playlist.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "playlist_id" require_relative "../../commons/types/user_id" - require_relative "../../commons/types/problem_id" -require_relative "playlist_id" require "json" module SeedTraceClient diff --git a/seed/ruby-model/trace/lib/seed_trace_client/playlist/types/reserved_keyword_enum.rb b/seed/ruby-model/trace/lib/seed_trace_client/playlist/types/reserved_keyword_enum.rb index 6c1edf96411..b613fa99527 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/playlist/types/reserved_keyword_enum.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/playlist/types/reserved_keyword_enum.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Playlist - # @type [Hash{String => String}] - RESERVED_KEYWORD_ENUM = { is: "is", as: "as" }.frozen + # @type [RESERVED_KEYWORD_ENUM] + RESERVED_KEYWORD_ENUM = { is: "is", as: "as" }.freeze end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/create_problem_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/create_problem_request.rb index 8b0711b6950..ee206714719 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/create_problem_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/create_problem_request.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -require_relative "../../commons/types/test_case_with_expected_result" -require_relative "../../commons/types/variable_type" require_relative "problem_description" require_relative "variable_type_and_name" +require_relative "../../commons/types/variable_type" +require_relative "../../commons/types/test_case_with_expected_result" require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Problem @@ -14,7 +15,7 @@ class CreateProblemRequest # @param problem_name [String] # @param problem_description [Problem::ProblemDescription] - # @param files [Hash{LANGUAGE => LANGUAGE}] + # @param files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param input_params [Array] # @param output_type [Commons::VariableType] # @param testcases [Array] @@ -27,7 +28,7 @@ def initialize(problem_name:, problem_description:, files:, input_params:, outpu @problem_name = problem_name # @type [Problem::ProblemDescription] @problem_description = problem_description - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files = files # @type [Array] @input_params = input_params @@ -48,11 +49,22 @@ def initialize(problem_name:, problem_description:, files:, input_params:, outpu def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_name = struct.problemName - problem_description = struct.problemDescription - files = struct.files - input_params = struct.inputParams - output_type = struct.outputType - testcases = struct.testcases + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) + files = struct.files.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + input_params = struct.inputParams.map do |v| + v = v.to_h.to_json + Problem::VariableTypeAndName.from_json(json_object: v) + end + output_type = struct.outputType.to_h.to_json + output_type = Commons::VariableType.from_json(json_object: output_type) + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + Commons::TestCaseWithExpectedResult.from_json(json_object: v) + end method_name = struct.methodName new(problem_name: problem_name, problem_description: problem_description, files: files, input_params: input_params, output_type: output_type, testcases: testcases, method_name: method_name, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/create_problem_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/create_problem_response.rb index fda2aaa4f05..6641ee90ffd 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/create_problem_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/create_problem_response.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "../../commons/types/problem_id" require_relative "create_problem_error" +require_relative "../../commons/types/problem_id" module SeedTraceClient module Problem diff --git a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/get_default_starter_files_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/get_default_starter_files_response.rb index 6122bbd6a3c..15790505c9d 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/get_default_starter_files_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/get_default_starter_files_response.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Problem class GetDefaultStarterFilesResponse attr_reader :files, :additional_properties - # @param files [Hash{LANGUAGE => LANGUAGE}] + # @param files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Problem::GetDefaultStarterFilesResponse] def initialize(files:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files = files # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -23,7 +24,10 @@ def initialize(files:, additional_properties: nil) # @return [Problem::GetDefaultStarterFilesResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files = struct.files + files = struct.files.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(files: files, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_description.rb b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_description.rb index 684d205c60d..c134078496a 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_description.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_description.rb @@ -24,7 +24,10 @@ def initialize(boards:, additional_properties: nil) # @return [Problem::ProblemDescription] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - boards = struct.boards + boards = struct.boards.map do |v| + v = v.to_h.to_json + Problem::ProblemDescriptionBoard.from_json(json_object: v) + end new(boards: boards, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_files.rb b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_files.rb index 6ebdb21fe77..aa326f0cc2f 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_files.rb @@ -27,8 +27,12 @@ def initialize(solution_file:, read_only_files:, additional_properties: nil) # @return [Problem::ProblemFiles] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - solution_file = struct.solutionFile - read_only_files = struct.readOnlyFiles + solution_file = struct.solutionFile.to_h.to_json + solution_file = Commons::FileInfo.from_json(json_object: solution_file) + read_only_files = struct.readOnlyFiles.map do |v| + v = v.to_h.to_json + Commons::FileInfo.from_json(json_object: v) + end new(solution_file: solution_file, read_only_files: read_only_files, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_info.rb b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_info.rb index 59f5333ad3f..f302f25baf4 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_info.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/problem_info.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true require_relative "../../commons/types/problem_id" -require_relative "../../commons/types/test_case_with_expected_result" -require_relative "../../commons/types/variable_type" require_relative "problem_description" require_relative "variable_type_and_name" +require_relative "../../commons/types/variable_type" +require_relative "../../commons/types/test_case_with_expected_result" require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Problem @@ -17,7 +18,7 @@ class ProblemInfo # @param problem_description [Problem::ProblemDescription] # @param problem_name [String] # @param problem_version [Integer] - # @param files [Hash{LANGUAGE => LANGUAGE}] + # @param files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param input_params [Array] # @param output_type [Commons::VariableType] # @param testcases [Array] @@ -35,7 +36,7 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version @problem_name = problem_name # @type [Integer] @problem_version = problem_version - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files = files # @type [Array] @input_params = input_params @@ -58,13 +59,24 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_id = struct.problemId - problem_description = struct.problemDescription + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) problem_name = struct.problemName problem_version = struct.problemVersion - files = struct.files - input_params = struct.inputParams - output_type = struct.outputType - testcases = struct.testcases + files = struct.files.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + input_params = struct.inputParams.map do |v| + v = v.to_h.to_json + Problem::VariableTypeAndName.from_json(json_object: v) + end + output_type = struct.outputType.to_h.to_json + output_type = Commons::VariableType.from_json(json_object: output_type) + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + Commons::TestCaseWithExpectedResult.from_json(json_object: v) + end method_name = struct.methodName supports_custom_test_cases = struct.supportsCustomTestCases new(problem_id: problem_id, problem_description: problem_description, problem_name: problem_name, diff --git a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/variable_type_and_name.rb b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/variable_type_and_name.rb index feef3828cc7..a2434f333fa 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/problem/types/variable_type_and_name.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/problem/types/variable_type_and_name.rb @@ -27,7 +27,8 @@ def initialize(variable_type:, name:, additional_properties: nil) # @return [Problem::VariableTypeAndName] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - variable_type = struct.variableType + variable_type = struct.variableType.to_h.to_json + variable_type = Commons::VariableType.from_json(json_object: variable_type) name = struct.name new(variable_type: variable_type, name: name, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/building_executor_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/building_executor_response.rb index d512c01bbc1..1acff8e0732 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/building_executor_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/building_executor_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "submission_id" +require_relative "execution_session_status" require "json" module SeedTraceClient @@ -9,13 +10,13 @@ class BuildingExecutorResponse attr_reader :submission_id, :status, :additional_properties # @param submission_id [Submission::SUBMISSION_ID] - # @param status [Hash{String => String}] + # @param status [EXECUTION_SESSION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::BuildingExecutorResponse] def initialize(submission_id:, status:, additional_properties: nil) # @type [Submission::SUBMISSION_ID] @submission_id = submission_id - # @type [Hash{String => String}] + # @type [EXECUTION_SESSION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -28,7 +29,7 @@ def initialize(submission_id:, status:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - status = struct.status + status = Submission::EXECUTION_SESSION_STATUS.key(struct.status) || struct.status new(submission_id: submission_id, status: status, additional_properties: struct) end @@ -36,7 +37,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "submissionId": @submission_id, "status": @status }.to_json + { "submissionId": @submission_id, "status": Submission::EXECUTION_SESSION_STATUS[@status] || @status }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -45,7 +46,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.submission_id.is_a?(UUID) != false || raise("Passed value for field obj.submission_id is not the expected type, validation failed.") - obj.status.is_a?(EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.status.is_a?(Submission::EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/code_execution_update.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/code_execution_update.rb index d1cb54aee13..6e26b4bff49 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/code_execution_update.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/code_execution_update.rb @@ -2,16 +2,16 @@ require "json" require_relative "building_executor_response" +require_relative "running_response" require_relative "errored_response" -require_relative "finished_response" +require_relative "stopped_response" require_relative "graded_response" require_relative "graded_response_v_2" -require_relative "invalid_request_response" -require_relative "recorded_response_notification" -require_relative "recording_response_notification" -require_relative "running_response" -require_relative "stopped_response" require_relative "workspace_ran_response" +require_relative "recording_response_notification" +require_relative "recorded_response_notification" +require_relative "invalid_request_response" +require_relative "finished_response" module SeedTraceClient module Submission diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/error_info.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/error_info.rb index b99a1cfad6a..edfbdeb15b3 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/error_info.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/error_info.rb @@ -2,8 +2,8 @@ require "json" require_relative "compile_error" -require_relative "internal_error" require_relative "runtime_error" +require_relative "internal_error" module SeedTraceClient module Submission diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/errored_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/errored_response.rb index ee807ba5383..248366e10ee 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/errored_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/errored_response.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "error_info" - require_relative "submission_id" +require_relative "error_info" require "json" module SeedTraceClient @@ -30,7 +29,8 @@ def initialize(submission_id:, error_info:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - error_info = struct.errorInfo + error_info = struct.errorInfo.to_h.to_json + error_info = Submission::ErrorInfo.from_json(json_object: error_info) new(submission_id: submission_id, error_info: error_info, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_response.rb index 9d79f932c7f..3d9fa239666 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_response.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative "../../commons/types/language" +require_relative "execution_session_status" require "json" module SeedTraceClient @@ -9,8 +11,8 @@ class ExecutionSessionResponse # @param session_id [String] # @param execution_session_url [String] - # @param language [Hash{String => String}] - # @param status [Hash{String => String}] + # @param language [LANGUAGE] + # @param status [EXECUTION_SESSION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::ExecutionSessionResponse] def initialize(session_id:, language:, status:, execution_session_url: nil, additional_properties: nil) @@ -18,9 +20,9 @@ def initialize(session_id:, language:, status:, execution_session_url: nil, addi @session_id = session_id # @type [String] @execution_session_url = execution_session_url - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language - # @type [Hash{String => String}] + # @type [EXECUTION_SESSION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -34,8 +36,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) session_id = struct.sessionId execution_session_url = struct.executionSessionUrl - language = struct.language - status = struct.status + language = Commons::LANGUAGE.key(struct.language) || struct.language + status = Submission::EXECUTION_SESSION_STATUS.key(struct.status) || struct.status new(session_id: session_id, execution_session_url: execution_session_url, language: language, status: status, additional_properties: struct) end @@ -47,8 +49,8 @@ def to_json(*_args) { "sessionId": @session_id, "executionSessionUrl": @execution_session_url, - "language": @language, - "status": @status + "language": Commons::LANGUAGE[@language] || @language, + "status": Submission::EXECUTION_SESSION_STATUS[@status] || @status }.to_json end @@ -59,8 +61,8 @@ def to_json(*_args) def self.validate_raw(obj:) obj.session_id.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.") obj.execution_session_url&.is_a?(String) != false || raise("Passed value for field obj.execution_session_url is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") - obj.status.is_a?(EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.status.is_a?(Submission::EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_state.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_state.rb index 8d93a43eb06..6b58bce65f0 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_state.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_state.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative "../../commons/types/language" +require_relative "execution_session_status" require "json" module SeedTraceClient @@ -12,8 +14,8 @@ class ExecutionSessionState # @param session_id [String] The auto-generated session id. Formatted as a uuid. # @param is_warm_instance [Boolean] # @param aws_task_id [String] - # @param language [Hash{String => String}] - # @param status [Hash{String => String}] + # @param language [LANGUAGE] + # @param status [EXECUTION_SESSION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::ExecutionSessionState] def initialize(session_id:, is_warm_instance:, language:, status:, last_time_contacted: nil, aws_task_id: nil, @@ -26,9 +28,9 @@ def initialize(session_id:, is_warm_instance:, language:, status:, last_time_con @is_warm_instance = is_warm_instance # @type [String] @aws_task_id = aws_task_id - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language - # @type [Hash{String => String}] + # @type [EXECUTION_SESSION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -44,8 +46,8 @@ def self.from_json(json_object:) session_id = struct.sessionId is_warm_instance = struct.isWarmInstance aws_task_id = struct.awsTaskId - language = struct.language - status = struct.status + language = Commons::LANGUAGE.key(struct.language) || struct.language + status = Submission::EXECUTION_SESSION_STATUS.key(struct.status) || struct.status new(last_time_contacted: last_time_contacted, session_id: session_id, is_warm_instance: is_warm_instance, aws_task_id: aws_task_id, language: language, status: status, additional_properties: struct) end @@ -59,8 +61,8 @@ def to_json(*_args) "sessionId": @session_id, "isWarmInstance": @is_warm_instance, "awsTaskId": @aws_task_id, - "language": @language, - "status": @status + "language": Commons::LANGUAGE[@language] || @language, + "status": Submission::EXECUTION_SESSION_STATUS[@status] || @status }.to_json end @@ -73,8 +75,8 @@ def self.validate_raw(obj:) obj.session_id.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.") obj.is_warm_instance.is_a?(Boolean) != false || raise("Passed value for field obj.is_warm_instance is not the expected type, validation failed.") obj.aws_task_id&.is_a?(String) != false || raise("Passed value for field obj.aws_task_id is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") - obj.status.is_a?(EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.status.is_a?(Submission::EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_status.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_status.rb index 2b8411d144f..92e4e7e56ea 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_status.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/execution_session_status.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Submission - # @type [Hash{String => String}] + # @type [EXECUTION_SESSION_STATUS] EXECUTION_SESSION_STATUS = { creating_container: "CREATING_CONTAINER", provisioning_container: "PROVISIONING_CONTAINER", @@ -10,6 +10,6 @@ module Submission running_container: "RUNNING_CONTAINER", live_container: "LIVE_CONTAINER", failed_to_launch: "FAILED_TO_LAUNCH" - }.frozen + }.freeze end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/get_submission_state_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/get_submission_state_response.rb index b6edb2bb8c6..253253c3a03 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/get_submission_state_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/get_submission_state_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "date" +require_relative "../../commons/types/language" require_relative "submission_type_state" require "json" @@ -11,7 +12,7 @@ class GetSubmissionStateResponse # @param time_submitted [DateTime] # @param submission [String] - # @param language [Hash{String => String}] + # @param language [LANGUAGE] # @param submission_type_state [Submission::SubmissionTypeState] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::GetSubmissionStateResponse] @@ -20,7 +21,7 @@ def initialize(submission:, language:, submission_type_state:, time_submitted: n @time_submitted = time_submitted # @type [String] @submission = submission - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language # @type [Submission::SubmissionTypeState] @submission_type_state = submission_type_state @@ -34,10 +35,11 @@ def initialize(submission:, language:, submission_type_state:, time_submitted: n # @return [Submission::GetSubmissionStateResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - time_submitted = struct.timeSubmitted + time_submitted = DateTime.parse(struct.timeSubmitted) submission = struct.submission - language = struct.language - submission_type_state = struct.submissionTypeState + language = Commons::LANGUAGE.key(struct.language) || struct.language + submission_type_state = struct.submissionTypeState.to_h.to_json + submission_type_state = Submission::SubmissionTypeState.from_json(json_object: submission_type_state) new(time_submitted: time_submitted, submission: submission, language: language, submission_type_state: submission_type_state, additional_properties: struct) end @@ -49,7 +51,7 @@ def to_json(*_args) { "timeSubmitted": @time_submitted, "submission": @submission, - "language": @language, + "language": Commons::LANGUAGE[@language] || @language, "submissionTypeState": @submission_type_state }.to_json end @@ -61,7 +63,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.time_submitted&.is_a?(DateTime) != false || raise("Passed value for field obj.time_submitted is not the expected type, validation failed.") obj.submission.is_a?(String) != false || raise("Passed value for field obj.submission is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") Submission::SubmissionTypeState.validate_raw(obj: obj.submission_type_state) end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/graded_test_case_update.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/graded_test_case_update.rb index 08ae0de2290..2969ef56432 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/graded_test_case_update.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/graded_test_case_update.rb @@ -29,7 +29,8 @@ def initialize(test_case_id:, grade:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) test_case_id = struct.testCaseId - grade = struct.grade + grade = struct.grade.to_h.to_json + grade = Submission::TestCaseGrade.from_json(json_object: grade) new(test_case_id: test_case_id, grade: grade, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/internal_error.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/internal_error.rb index 6002d36c919..e75196b9175 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/internal_error.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/internal_error.rb @@ -24,7 +24,8 @@ def initialize(exception_info:, additional_properties: nil) # @return [Submission::InternalError] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - exception_info = struct.exceptionInfo + exception_info = struct.exceptionInfo.to_h.to_json + exception_info = Submission::ExceptionInfo.from_json(json_object: exception_info) new(exception_info: exception_info, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/invalid_request_cause.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/invalid_request_cause.rb index 28d1a22a74e..71896b6a2f5 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/invalid_request_cause.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/invalid_request_cause.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "custom_test_cases_unsupported" require_relative "submission_id_not_found" +require_relative "custom_test_cases_unsupported" require_relative "unexpected_language_error" module SeedTraceClient diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/invalid_request_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/invalid_request_response.rb index 63c29bafcf5..47d3a90a0a3 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/invalid_request_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/invalid_request_response.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "invalid_request_cause" - require_relative "submission_request" +require_relative "invalid_request_cause" require "json" module SeedTraceClient @@ -29,8 +28,10 @@ def initialize(request:, cause:, additional_properties: nil) # @return [Submission::InvalidRequestResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - request = struct.request - cause = struct.cause + request = struct.request.to_h.to_json + request = Submission::SubmissionRequest.from_json(json_object: request) + cause = struct.cause.to_h.to_json + cause = Submission::InvalidRequestCause.from_json(json_object: cause) new(request: request, cause: cause, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/recording_response_notification.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/recording_response_notification.rb index de2c5e3b58e..8719216d1c6 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/recording_response_notification.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/recording_response_notification.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "lightweight_stackframe_information" - require_relative "submission_id" +require_relative "lightweight_stackframe_information" require_relative "traced_file" require "json" @@ -44,8 +43,10 @@ def self.from_json(json_object:) submission_id = struct.submissionId test_case_id = struct.testCaseId line_number = struct.lineNumber - lightweight_stack_info = struct.lightweightStackInfo - traced_file = struct.tracedFile + lightweight_stack_info = struct.lightweightStackInfo.to_h.to_json + lightweight_stack_info = Submission::LightweightStackframeInformation.from_json(json_object: lightweight_stack_info) + traced_file = struct.tracedFile.to_h.to_json + traced_file = Submission::TracedFile.from_json(json_object: traced_file) new(submission_id: submission_id, test_case_id: test_case_id, line_number: line_number, lightweight_stack_info: lightweight_stack_info, traced_file: traced_file, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/running_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/running_response.rb index d356ffb7a3b..7b7aac1cd02 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/running_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/running_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "submission_id" +require_relative "running_submission_state" require "json" module SeedTraceClient @@ -9,13 +10,13 @@ class RunningResponse attr_reader :submission_id, :state, :additional_properties # @param submission_id [Submission::SUBMISSION_ID] - # @param state [Hash{String => String}] + # @param state [RUNNING_SUBMISSION_STATE] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::RunningResponse] def initialize(submission_id:, state:, additional_properties: nil) # @type [Submission::SUBMISSION_ID] @submission_id = submission_id - # @type [Hash{String => String}] + # @type [RUNNING_SUBMISSION_STATE] @state = state # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -28,7 +29,7 @@ def initialize(submission_id:, state:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - state = struct.state + state = Submission::RUNNING_SUBMISSION_STATE.key(struct.state) || struct.state new(submission_id: submission_id, state: state, additional_properties: struct) end @@ -36,7 +37,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "submissionId": @submission_id, "state": @state }.to_json + { "submissionId": @submission_id, "state": Submission::RUNNING_SUBMISSION_STATE[@state] || @state }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -45,7 +46,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.submission_id.is_a?(UUID) != false || raise("Passed value for field obj.submission_id is not the expected type, validation failed.") - obj.state.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + obj.state.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") end end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/running_submission_state.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/running_submission_state.rb index b5d99001fa1..02a9639a2c2 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/running_submission_state.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/running_submission_state.rb @@ -2,13 +2,13 @@ module SeedTraceClient module Submission - # @type [Hash{String => String}] + # @type [RUNNING_SUBMISSION_STATE] RUNNING_SUBMISSION_STATE = { queueing_submission: "QUEUEING_SUBMISSION", killing_historical_submissions: "KILLING_HISTORICAL_SUBMISSIONS", writing_submission_to_file: "WRITING_SUBMISSION_TO_FILE", compiling_submission: "COMPILING_SUBMISSION", running_submission: "RUNNING_SUBMISSION" - }.frozen + }.freeze end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/stack_frame.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/stack_frame.rb index ebbc68a9d5b..b5e16a1bf54 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/stack_frame.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/stack_frame.rb @@ -32,7 +32,10 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName line_number = struct.lineNumber - scopes = struct.scopes + scopes = struct.scopes.map do |v| + v = v.to_h.to_json + Submission::Scope.from_json(json_object: v) + end new(method_name: method_name, line_number: line_number, scopes: scopes, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/stack_information.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/stack_information.rb index 7d53af8d36b..ef86285ad47 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/stack_information.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/stack_information.rb @@ -28,7 +28,8 @@ def initialize(num_stack_frames:, top_stack_frame: nil, additional_properties: n def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) num_stack_frames = struct.numStackFrames - top_stack_frame = struct.topStackFrame + top_stack_frame = struct.topStackFrame.to_h.to_json + top_stack_frame = Submission::StackFrame.from_json(json_object: top_stack_frame) new(num_stack_frames: num_stack_frames, top_stack_frame: top_stack_frame, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_request.rb index 22bae1f0ab0..fce3f7896d2 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_request.rb @@ -2,9 +2,9 @@ require "json" require_relative "initialize_problem_request" -require_relative "stop_request" require_relative "submit_request_v_2" require_relative "workspace_submit_request" +require_relative "stop_request" module SeedTraceClient module Submission diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_response.rb index 9f586bde038..1cc4c68c922 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_response.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true require "json" -require_relative "../../commons/types/problem_id" -require_relative "code_execution_update" require_relative "exception_info" +require_relative "code_execution_update" require_relative "terminated_response" +require_relative "../../commons/types/problem_id" module SeedTraceClient module Submission diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_status_for_test_case.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_status_for_test_case.rb index 6511c7c0a03..40611c58132 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_status_for_test_case.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_status_for_test_case.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "test_case_grade" require_relative "test_case_result_with_stdout" +require_relative "test_case_grade" require_relative "traced_test_case" module SeedTraceClient diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_type_enum.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_type_enum.rb index f3bbb990916..af19d36818c 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_type_enum.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submission_type_enum.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Submission - # @type [Hash{String => String}] - SUBMISSION_TYPE_ENUM = { test: "TEST" }.frozen + # @type [SUBMISSION_TYPE_ENUM] + SUBMISSION_TYPE_ENUM = { test: "TEST" }.freeze end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submit_request_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submit_request_v_2.rb index 962d8676eed..f0abf162bf6 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submit_request_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/submit_request_v_2.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true +require_relative "submission_id" +require_relative "../../commons/types/language" require_relative "submission_file_info" - require_relative "../../commons/types/problem_id" -require_relative "submission_id" require "json" module SeedTraceClient @@ -13,7 +13,7 @@ class SubmitRequestV2 :additional_properties # @param submission_id [Submission::SUBMISSION_ID] - # @param language [Hash{String => String}] + # @param language [LANGUAGE] # @param submission_files [Array] # @param problem_id [Commons::PROBLEM_ID] # @param problem_version [Integer] @@ -24,7 +24,7 @@ def initialize(submission_id:, language:, submission_files:, problem_id:, proble additional_properties: nil) # @type [Submission::SUBMISSION_ID] @submission_id = submission_id - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language # @type [Array] @submission_files = submission_files @@ -45,8 +45,11 @@ def initialize(submission_id:, language:, submission_files:, problem_id:, proble def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - language = struct.language - submission_files = struct.submissionFiles + language = Commons::LANGUAGE.key(struct.language) || struct.language + submission_files = struct.submissionFiles.map do |v| + v = v.to_h.to_json + Submission::SubmissionFileInfo.from_json(json_object: v) + end problem_id = struct.problemId problem_version = struct.problemVersion user_id = struct.userId @@ -60,7 +63,7 @@ def self.from_json(json_object:) def to_json(*_args) { "submissionId": @submission_id, - "language": @language, + "language": Commons::LANGUAGE[@language] || @language, "submissionFiles": @submission_files, "problemId": @problem_id, "problemVersion": @problem_version, @@ -74,7 +77,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.submission_id.is_a?(UUID) != false || raise("Passed value for field obj.submission_id is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") obj.submission_files.is_a?(Array) != false || raise("Passed value for field obj.submission_files is not the expected type, validation failed.") obj.problem_id.is_a?(String) != false || raise("Passed value for field obj.problem_id is not the expected type, validation failed.") obj.problem_version&.is_a?(Integer) != false || raise("Passed value for field obj.problem_version is not the expected type, validation failed.") diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_non_hidden_grade.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_non_hidden_grade.rb index e6b51384410..e4d3b015bd1 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_non_hidden_grade.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_non_hidden_grade.rb @@ -35,8 +35,10 @@ def initialize(passed:, stdout:, actual_result: nil, exception: nil, additional_ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) passed = struct.passed - actual_result = struct.actualResult - exception = struct.exception + actual_result = struct.actualResult.to_h.to_json + actual_result = Commons::VariableValue.from_json(json_object: actual_result) + exception = struct.exception.to_h.to_json + exception = Submission::ExceptionV2.from_json(json_object: exception) stdout = struct.stdout new(passed: passed, actual_result: actual_result, exception: exception, stdout: stdout, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_result.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_result.rb index be30049e998..46b838960c4 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_result.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_result.rb @@ -31,8 +31,10 @@ def initialize(expected_result:, actual_result:, passed:, additional_properties: # @return [Submission::TestCaseResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - expected_result = struct.expectedResult - actual_result = struct.actualResult + expected_result = struct.expectedResult.to_h.to_json + expected_result = Commons::VariableValue.from_json(json_object: expected_result) + actual_result = struct.actualResult.to_h.to_json + actual_result = Submission::ActualResult.from_json(json_object: actual_result) passed = struct.passed new(expected_result: expected_result, actual_result: actual_result, passed: passed, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_result_with_stdout.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_result_with_stdout.rb index 76f93c2ef7e..b5fe336d281 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_result_with_stdout.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_case_result_with_stdout.rb @@ -27,7 +27,8 @@ def initialize(result:, stdout:, additional_properties: nil) # @return [Submission::TestCaseResultWithStdout] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - result = struct.result + result = struct.result.to_h.to_json + result = Submission::TestCaseResult.from_json(json_object: result) stdout = struct.stdout new(result: result, stdout: stdout, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_state.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_state.rb index d274d84a1b8..0e2731ef1f4 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_state.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_state.rb @@ -36,9 +36,16 @@ def initialize(problem_id:, default_test_cases:, custom_test_cases:, status:, ad def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_id = struct.problemId - default_test_cases = struct.defaultTestCases - custom_test_cases = struct.customTestCases - status = struct.status + default_test_cases = struct.defaultTestCases.map do |v| + v = v.to_h.to_json + Commons::TestCase.from_json(json_object: v) + end + custom_test_cases = struct.customTestCases.map do |v| + v = v.to_h.to_json + Commons::TestCase.from_json(json_object: v) + end + status = struct.status.to_h.to_json + status = Submission::TestSubmissionStatus.from_json(json_object: status) new(problem_id: problem_id, default_test_cases: default_test_cases, custom_test_cases: custom_test_cases, status: status, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_status.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_status.rb index 5a930c95886..03101755c0b 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_status.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_status.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "running_submission_state" require_relative "error_info" module SeedTraceClient @@ -32,7 +33,7 @@ def self.from_json(json_object:) when "errored" Submission::ErrorInfo.from_json(json_object: json_object.value) when "running" - RUNNING_SUBMISSION_STATE.key(json_object.value) + Submission::RUNNING_SUBMISSION_STATE.key(json_object.value) || json_object.value when "testCaseIdToState" json_object.value else @@ -71,7 +72,7 @@ def self.validate_raw(obj:) when "errored" Submission::ErrorInfo.validate_raw(obj: obj) when "running" - obj.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "testCaseIdToState" obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") else @@ -98,7 +99,7 @@ def self.errored(member:) new(member: member, discriminant: "errored") end - # @param member [Hash{String => String}] + # @param member [RUNNING_SUBMISSION_STATE] # @return [Submission::TestSubmissionStatus] def self.running(member:) new(member: member, discriminant: "running") diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_status_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_status_v_2.rb index e6b9c96e0d0..af768ebaf85 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_status_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_status_v_2.rb @@ -1,10 +1,8 @@ # frozen_string_literal: true +require_relative "test_submission_update" require_relative "../../commons/types/problem_id" - require_relative "../../v_2/problem/types/problem_info_v_2" - -require_relative "test_submission_update" require "json" module SeedTraceClient @@ -37,10 +35,14 @@ def initialize(updates:, problem_id:, problem_version:, problem_info:, additiona # @return [Submission::TestSubmissionStatusV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - updates = struct.updates + updates = struct.updates.map do |v| + v = v.to_h.to_json + Submission::TestSubmissionUpdate.from_json(json_object: v) + end problem_id = struct.problemId problem_version = struct.problemVersion - problem_info = struct.problemInfo + problem_info = struct.problemInfo.to_h.to_json + problem_info = V2::Problem::ProblemInfoV2.from_json(json_object: problem_info) new(updates: updates, problem_id: problem_id, problem_version: problem_version, problem_info: problem_info, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_update.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_update.rb index 3b5ec1ff562..e0217670f77 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_update.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_update.rb @@ -28,8 +28,9 @@ def initialize(update_time:, update_info:, additional_properties: nil) # @return [Submission::TestSubmissionUpdate] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - update_time = struct.updateTime - update_info = struct.updateInfo + update_time = DateTime.parse(struct.updateTime) + update_info = struct.updateInfo.to_h.to_json + update_info = Submission::TestSubmissionUpdateInfo.from_json(json_object: update_info) new(update_time: update_time, update_info: update_info, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_update_info.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_update_info.rb index 8e4c44b3e65..87af634a3af 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_update_info.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/test_submission_update_info.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "running_submission_state" require_relative "error_info" require_relative "graded_test_case_update" require_relative "recorded_test_case_update" @@ -30,7 +31,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "running" - RUNNING_SUBMISSION_STATE.key(json_object.value) + Submission::RUNNING_SUBMISSION_STATE.key(json_object.value) || json_object.value when "stopped" nil when "errored" @@ -42,7 +43,7 @@ def self.from_json(json_object:) when "finished" nil else - RUNNING_SUBMISSION_STATE.key(json_object) + Submission::RUNNING_SUBMISSION_STATE.key(json_object) || json_object end new(member: member, discriminant: struct.type) end @@ -77,7 +78,7 @@ def to_json(*_args) def self.validate_raw(obj:) case obj.type when "running" - obj.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "stopped" # noop when "errored" @@ -101,7 +102,7 @@ def is_a?(obj) @member.is_a?(obj) end - # @param member [Hash{String => String}] + # @param member [RUNNING_SUBMISSION_STATE] # @return [Submission::TestSubmissionUpdateInfo] def self.running(member:) new(member: member, discriminant: "running") diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_response.rb index 20e4fc6a036..17905708161 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_response.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require_relative "expression_location" - +require_relative "submission_id" require_relative "../../commons/types/debug_variable_value" +require_relative "expression_location" require_relative "stack_information" - -require_relative "submission_id" require "json" module SeedTraceClient @@ -48,9 +46,12 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId line_number = struct.lineNumber - return_value = struct.returnValue - expression_location = struct.expressionLocation - stack = struct.stack + return_value = struct.returnValue.to_h.to_json + return_value = Commons::DebugVariableValue.from_json(json_object: return_value) + expression_location = struct.expressionLocation.to_h.to_json + expression_location = Submission::ExpressionLocation.from_json(json_object: expression_location) + stack = struct.stack.to_h.to_json + stack = Submission::StackInformation.from_json(json_object: stack) stdout = struct.stdout new(submission_id: submission_id, line_number: line_number, return_value: return_value, expression_location: expression_location, stack: stack, stdout: stdout, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_response_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_response_v_2.rb index 4d886bffd9b..e491aaf9216 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_response_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_response_v_2.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true +require_relative "submission_id" +require_relative "traced_file" require_relative "../../commons/types/debug_variable_value" require_relative "expression_location" require_relative "stack_information" -require_relative "submission_id" -require_relative "traced_file" require "json" module SeedTraceClient @@ -50,10 +50,14 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId line_number = struct.lineNumber - file = struct.file - return_value = struct.returnValue - expression_location = struct.expressionLocation - stack = struct.stack + file = struct.file.to_h.to_json + file = Submission::TracedFile.from_json(json_object: file) + return_value = struct.returnValue.to_h.to_json + return_value = Commons::DebugVariableValue.from_json(json_object: return_value) + expression_location = struct.expressionLocation.to_h.to_json + expression_location = Submission::ExpressionLocation.from_json(json_object: expression_location) + stack = struct.stack.to_h.to_json + stack = Submission::StackInformation.from_json(json_object: stack) stdout = struct.stdout new(submission_id: submission_id, line_number: line_number, file: file, return_value: return_value, expression_location: expression_location, stack: stack, stdout: stdout, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_responses_page.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_responses_page.rb index 231045d7300..65c79ab70c0 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_responses_page.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_responses_page.rb @@ -8,12 +8,14 @@ module Submission class TraceResponsesPage attr_reader :offset, :trace_responses, :additional_properties - # @param offset [Integer] If present, use this to load subseqent pages. The offset is the id of the next trace response to load. + # @param offset [Integer] If present, use this to load subseqent pages. + # The offset is the id of the next trace response to load. # @param trace_responses [Array] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::TraceResponsesPage] def initialize(trace_responses:, offset: nil, additional_properties: nil) - # @type [Integer] If present, use this to load subseqent pages. The offset is the id of the next trace response to load. + # @type [Integer] If present, use this to load subseqent pages. + # The offset is the id of the next trace response to load. @offset = offset # @type [Array] @trace_responses = trace_responses @@ -28,7 +30,10 @@ def initialize(trace_responses:, offset: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) offset = struct.offset - trace_responses = struct.traceResponses + trace_responses = struct.traceResponses.map do |v| + v = v.to_h.to_json + Submission::TraceResponse.from_json(json_object: v) + end new(offset: offset, trace_responses: trace_responses, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_responses_page_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_responses_page_v_2.rb index e79e8e8d8d7..f86b3b6669d 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_responses_page_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/trace_responses_page_v_2.rb @@ -8,12 +8,14 @@ module Submission class TraceResponsesPageV2 attr_reader :offset, :trace_responses, :additional_properties - # @param offset [Integer] If present, use this to load subseqent pages. The offset is the id of the next trace response to load. + # @param offset [Integer] If present, use this to load subseqent pages. + # The offset is the id of the next trace response to load. # @param trace_responses [Array] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::TraceResponsesPageV2] def initialize(trace_responses:, offset: nil, additional_properties: nil) - # @type [Integer] If present, use this to load subseqent pages. The offset is the id of the next trace response to load. + # @type [Integer] If present, use this to load subseqent pages. + # The offset is the id of the next trace response to load. @offset = offset # @type [Array] @trace_responses = trace_responses @@ -28,7 +30,10 @@ def initialize(trace_responses:, offset: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) offset = struct.offset - trace_responses = struct.traceResponses + trace_responses = struct.traceResponses.map do |v| + v = v.to_h.to_json + Submission::TraceResponseV2.from_json(json_object: v) + end new(offset: offset, trace_responses: trace_responses, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/traced_test_case.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/traced_test_case.rb index 6645efd0f46..aa9b92cb4ed 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/traced_test_case.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/traced_test_case.rb @@ -27,7 +27,8 @@ def initialize(result:, trace_responses_size:, additional_properties: nil) # @return [Submission::TracedTestCase] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - result = struct.result + result = struct.result.to_h.to_json + result = Submission::TestCaseResultWithStdout.from_json(json_object: result) trace_responses_size = struct.traceResponsesSize new(result: result, trace_responses_size: trace_responses_size, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/unexpected_language_error.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/unexpected_language_error.rb index e1a746da62f..fd5fb524278 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/unexpected_language_error.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/unexpected_language_error.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "../../commons/types/language" require "json" module SeedTraceClient @@ -7,14 +8,14 @@ module Submission class UnexpectedLanguageError attr_reader :expected_language, :actual_language, :additional_properties - # @param expected_language [Hash{String => String}] - # @param actual_language [Hash{String => String}] + # @param expected_language [LANGUAGE] + # @param actual_language [LANGUAGE] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::UnexpectedLanguageError] def initialize(expected_language:, actual_language:, additional_properties: nil) - # @type [Hash{String => String}] + # @type [LANGUAGE] @expected_language = expected_language - # @type [Hash{String => String}] + # @type [LANGUAGE] @actual_language = actual_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -26,8 +27,8 @@ def initialize(expected_language:, actual_language:, additional_properties: nil) # @return [Submission::UnexpectedLanguageError] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - expected_language = struct.expectedLanguage - actual_language = struct.actualLanguage + expected_language = Commons::LANGUAGE.key(struct.expectedLanguage) || struct.expectedLanguage + actual_language = Commons::LANGUAGE.key(struct.actualLanguage) || struct.actualLanguage new(expected_language: expected_language, actual_language: actual_language, additional_properties: struct) end @@ -35,7 +36,10 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "expectedLanguage": @expected_language, "actualLanguage": @actual_language }.to_json + { + "expectedLanguage": Commons::LANGUAGE[@expected_language] || @expected_language, + "actualLanguage": Commons::LANGUAGE[@actual_language] || @actual_language + }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -43,8 +47,8 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - obj.expected_language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.expected_language is not the expected type, validation failed.") - obj.actual_language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.actual_language is not the expected type, validation failed.") + obj.expected_language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.expected_language is not the expected type, validation failed.") + obj.actual_language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.actual_language is not the expected type, validation failed.") end end end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_files.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_files.rb index ad225a9134f..08122be7159 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_files.rb @@ -27,8 +27,12 @@ def initialize(main_file:, read_only_files:, additional_properties: nil) # @return [Submission::WorkspaceFiles] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - main_file = struct.mainFile - read_only_files = struct.readOnlyFiles + main_file = struct.mainFile.to_h.to_json + main_file = Commons::FileInfo.from_json(json_object: main_file) + read_only_files = struct.readOnlyFiles.map do |v| + v = v.to_h.to_json + Commons::FileInfo.from_json(json_object: v) + end new(main_file: main_file, read_only_files: read_only_files, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_ran_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_ran_response.rb index 558e6cdf18e..f90a9c4e9cc 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_ran_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_ran_response.rb @@ -29,7 +29,8 @@ def initialize(submission_id:, run_details:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - run_details = struct.runDetails + run_details = struct.runDetails.to_h.to_json + run_details = Submission::WorkspaceRunDetails.from_json(json_object: run_details) new(submission_id: submission_id, run_details: run_details, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_run_details.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_run_details.rb index a0e3bdd0815..eb9cbe65256 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_run_details.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_run_details.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "exception_info" - require_relative "exception_v_2" +require_relative "exception_info" require "json" module SeedTraceClient @@ -32,8 +31,10 @@ def initialize(stdout:, exception_v_2: nil, exception: nil, additional_propertie # @return [Submission::WorkspaceRunDetails] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - exception_v_2 = struct.exceptionV2 - exception = struct.exception + exception_v_2 = struct.exceptionV2.to_h.to_json + exception_v_2 = Submission::ExceptionV2.from_json(json_object: exception_v_2) + exception = struct.exception.to_h.to_json + exception = Submission::ExceptionInfo.from_json(json_object: exception) stdout = struct.stdout new(exception_v_2: exception_v_2, exception: exception, stdout: stdout, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response.rb index 03c2bbdc4b4..714e811730e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Submission class WorkspaceStarterFilesResponse attr_reader :files, :additional_properties - # @param files [Hash{LANGUAGE => LANGUAGE}] + # @param files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::WorkspaceStarterFilesResponse] def initialize(files:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files = files # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -23,7 +24,10 @@ def initialize(files:, additional_properties: nil) # @return [Submission::WorkspaceStarterFilesResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files = struct.files + files = struct.files.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(files: files, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response_v_2.rb index 8500420e9c6..2c2f8ffda59 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response_v_2.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Submission class WorkspaceStarterFilesResponseV2 attr_reader :files_by_language, :additional_properties - # @param files_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param files_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::WorkspaceStarterFilesResponseV2] def initialize(files_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files_by_language = files_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -23,7 +24,10 @@ def initialize(files_by_language:, additional_properties: nil) # @return [Submission::WorkspaceStarterFilesResponseV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files_by_language = struct.filesByLanguage + files_by_language = struct.filesByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(files_by_language: files_by_language, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_state.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_state.rb index c53c5bb31d5..fd0ea0d6640 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_state.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_state.rb @@ -24,7 +24,8 @@ def initialize(status:, additional_properties: nil) # @return [Submission::WorkspaceSubmissionState] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - status = struct.status + status = struct.status.to_h.to_json + status = Submission::WorkspaceSubmissionStatus.from_json(json_object: status) new(status: status, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_status.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_status.rb index 6c965475ac5..727557d50ac 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_status.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_status.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "running_submission_state" require_relative "error_info" require_relative "workspace_run_details" @@ -33,7 +34,7 @@ def self.from_json(json_object:) when "errored" Submission::ErrorInfo.from_json(json_object: json_object.value) when "running" - RUNNING_SUBMISSION_STATE.key(json_object.value) + Submission::RUNNING_SUBMISSION_STATE.key(json_object.value) || json_object.value when "ran" Submission::WorkspaceRunDetails.from_json(json_object: json_object) when "traced" @@ -76,7 +77,7 @@ def self.validate_raw(obj:) when "errored" Submission::ErrorInfo.validate_raw(obj: obj) when "running" - obj.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "ran" Submission::WorkspaceRunDetails.validate_raw(obj: obj) when "traced" @@ -105,7 +106,7 @@ def self.errored(member:) new(member: member, discriminant: "errored") end - # @param member [Hash{String => String}] + # @param member [RUNNING_SUBMISSION_STATE] # @return [Submission::WorkspaceSubmissionStatus] def self.running(member:) new(member: member, discriminant: "running") diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_status_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_status_v_2.rb index 61befce906d..e8aa587cfe4 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_status_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_status_v_2.rb @@ -24,7 +24,10 @@ def initialize(updates:, additional_properties: nil) # @return [Submission::WorkspaceSubmissionStatusV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - updates = struct.updates + updates = struct.updates.map do |v| + v = v.to_h.to_json + Submission::WorkspaceSubmissionUpdate.from_json(json_object: v) + end new(updates: updates, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_update.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_update.rb index 3161122a470..d2fc6b9fb1d 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_update.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_update.rb @@ -28,8 +28,9 @@ def initialize(update_time:, update_info:, additional_properties: nil) # @return [Submission::WorkspaceSubmissionUpdate] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - update_time = struct.updateTime - update_info = struct.updateInfo + update_time = DateTime.parse(struct.updateTime) + update_info = struct.updateInfo.to_h.to_json + update_info = Submission::WorkspaceSubmissionUpdateInfo.from_json(json_object: update_info) new(update_time: update_time, update_info: update_info, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_update_info.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_update_info.rb index 90fd464857d..c48defc3ce1 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_update_info.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submission_update_info.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true require "json" -require_relative "error_info" +require_relative "running_submission_state" require_relative "workspace_run_details" require_relative "workspace_traced_update" +require_relative "error_info" module SeedTraceClient module Submission @@ -30,7 +31,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "running" - RUNNING_SUBMISSION_STATE.key(json_object.value) + Submission::RUNNING_SUBMISSION_STATE.key(json_object.value) || json_object.value when "ran" Submission::WorkspaceRunDetails.from_json(json_object: json_object) when "stopped" @@ -44,7 +45,7 @@ def self.from_json(json_object:) when "finished" nil else - RUNNING_SUBMISSION_STATE.key(json_object) + Submission::RUNNING_SUBMISSION_STATE.key(json_object) || json_object end new(member: member, discriminant: struct.type) end @@ -81,7 +82,7 @@ def to_json(*_args) def self.validate_raw(obj:) case obj.type when "running" - obj.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "ran" Submission::WorkspaceRunDetails.validate_raw(obj: obj) when "stopped" @@ -107,7 +108,7 @@ def is_a?(obj) @member.is_a?(obj) end - # @param member [Hash{String => String}] + # @param member [RUNNING_SUBMISSION_STATE] # @return [Submission::WorkspaceSubmissionUpdateInfo] def self.running(member:) new(member: member, discriminant: "running") diff --git a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submit_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submit_request.rb index 8150d900134..40bc5d29284 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submit_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/submission/types/workspace_submit_request.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative "submission_file_info" - require_relative "submission_id" +require_relative "../../commons/types/language" +require_relative "submission_file_info" require "json" module SeedTraceClient @@ -11,7 +11,7 @@ class WorkspaceSubmitRequest attr_reader :submission_id, :language, :submission_files, :user_id, :additional_properties # @param submission_id [Submission::SUBMISSION_ID] - # @param language [Hash{String => String}] + # @param language [LANGUAGE] # @param submission_files [Array] # @param user_id [String] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition @@ -19,7 +19,7 @@ class WorkspaceSubmitRequest def initialize(submission_id:, language:, submission_files:, user_id: nil, additional_properties: nil) # @type [Submission::SUBMISSION_ID] @submission_id = submission_id - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language # @type [Array] @submission_files = submission_files @@ -36,8 +36,11 @@ def initialize(submission_id:, language:, submission_files:, user_id: nil, addit def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - language = struct.language - submission_files = struct.submissionFiles + language = Commons::LANGUAGE.key(struct.language) || struct.language + submission_files = struct.submissionFiles.map do |v| + v = v.to_h.to_json + Submission::SubmissionFileInfo.from_json(json_object: v) + end user_id = struct.userId new(submission_id: submission_id, language: language, submission_files: submission_files, user_id: user_id, additional_properties: struct) @@ -49,7 +52,7 @@ def self.from_json(json_object:) def to_json(*_args) { "submissionId": @submission_id, - "language": @language, + "language": Commons::LANGUAGE[@language] || @language, "submissionFiles": @submission_files, "userId": @user_id }.to_json @@ -61,7 +64,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.submission_id.is_a?(UUID) != false || raise("Passed value for field obj.submission_id is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") obj.submission_files.is_a?(Array) != false || raise("Passed value for field obj.submission_files is not the expected type, validation failed.") obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.") end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/basic_custom_files.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/basic_custom_files.rb index b12160e9d52..cf94b1b8879 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/basic_custom_files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/basic_custom_files.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative "basic_test_case_template" - require_relative "non_void_function_signature" +require_relative "basic_test_case_template" require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -13,7 +13,7 @@ class BasicCustomFiles # @param method_name [String] # @param signature [V2::Problem::NonVoidFunctionSignature] - # @param additional_files [Hash{LANGUAGE => LANGUAGE}] + # @param additional_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param basic_test_case_template [V2::Problem::BasicTestCaseTemplate] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::BasicCustomFiles] @@ -23,7 +23,7 @@ def initialize(method_name:, signature:, additional_files:, basic_test_case_temp @method_name = method_name # @type [V2::Problem::NonVoidFunctionSignature] @signature = signature - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @additional_files = additional_files # @type [V2::Problem::BasicTestCaseTemplate] @basic_test_case_template = basic_test_case_template @@ -38,9 +38,14 @@ def initialize(method_name:, signature:, additional_files:, basic_test_case_temp def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName - signature = struct.signature - additional_files = struct.additionalFiles - basic_test_case_template = struct.basicTestCaseTemplate + signature = struct.signature.to_h.to_json + signature = V2::Problem::NonVoidFunctionSignature.from_json(json_object: signature) + additional_files = struct.additionalFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + basic_test_case_template = struct.basicTestCaseTemplate.to_h.to_json + basic_test_case_template = V2::Problem::BasicTestCaseTemplate.from_json(json_object: basic_test_case_template) new(method_name: method_name, signature: signature, additional_files: additional_files, basic_test_case_template: basic_test_case_template, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/basic_test_case_template.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/basic_test_case_template.rb index d1679527841..a546d554d05 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/basic_test_case_template.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/basic_test_case_template.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "test_case_template_id" require_relative "test_case_implementation_description" - require_relative "parameter_id" -require_relative "test_case_template_id" require "json" module SeedTraceClient @@ -39,7 +38,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) template_id = struct.templateId name = struct.name - description = struct.description + description = struct.description.to_h.to_json + description = V2::Problem::TestCaseImplementationDescription.from_json(json_object: description) expected_value_parameter_id = struct.expectedValueParameterId new(template_id: template_id, name: name, description: description, expected_value_parameter_id: expected_value_parameter_id, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/create_problem_request_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/create_problem_request_v_2.rb index 5ce4796e727..ed60a903ead 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/create_problem_request_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/create_problem_request_v_2.rb @@ -4,8 +4,8 @@ require_relative "custom_files" require_relative "test_case_template" require_relative "test_case_v_2" -require "json" require "set" +require "json" module SeedTraceClient module V2 @@ -19,7 +19,7 @@ class CreateProblemRequestV2 # @param custom_files [V2::Problem::CustomFiles] # @param custom_test_case_templates [Array] # @param testcases [Array] - # @param supported_languages [Set] + # @param supported_languages [Set] # @param is_public [Boolean] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::CreateProblemRequestV2] @@ -35,7 +35,7 @@ def initialize(problem_name:, problem_description:, custom_files:, custom_test_c @custom_test_case_templates = custom_test_case_templates # @type [Array] @testcases = testcases - # @type [Set] + # @type [Set] @supported_languages = supported_languages # @type [Boolean] @is_public = is_public @@ -50,11 +50,20 @@ def initialize(problem_name:, problem_description:, custom_files:, custom_test_c def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_name = struct.problemName - problem_description = struct.problemDescription - custom_files = struct.customFiles - custom_test_case_templates = struct.customTestCaseTemplates - testcases = struct.testcases - supported_languages = struct.supportedLanguages + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) + custom_files = struct.customFiles.to_h.to_json + custom_files = V2::Problem::CustomFiles.from_json(json_object: custom_files) + custom_test_case_templates = struct.customTestCaseTemplates.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseTemplate.from_json(json_object: v) + end + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseV2.from_json(json_object: v) + end + supported_languages = struct.supportedLanguages.to_h.to_json + supported_languages = Set.new(supported_languages) is_public = struct.isPublic new(problem_name: problem_name, problem_description: problem_description, custom_files: custom_files, custom_test_case_templates: custom_test_case_templates, testcases: testcases, supported_languages: supported_languages, is_public: is_public, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/custom_files.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/custom_files.rb index 22fc3bcc243..95e9ecdad63 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/custom_files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/custom_files.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" require_relative "basic_custom_files" module SeedTraceClient @@ -33,7 +34,7 @@ def self.from_json(json_object:) when "custom" json_object.value.transform_values do |_k, v| v = v.to_h.to_json - LANGUAGE.key(v) + Commons::LANGUAGE.key(v) || v end else V2::Problem::BasicCustomFiles.from_json(json_object: json_object) @@ -85,7 +86,7 @@ def self.basic(member:) new(member: member, discriminant: "basic") end - # @param member [Hash{LANGUAGE => LANGUAGE}] + # @param member [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @return [V2::Problem::CustomFiles] def self.custom(member:) new(member: member, discriminant: "custom") diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/default_provided_file.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/default_provided_file.rb index 24ca644752e..1b04dd4a9dc 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/default_provided_file.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/default_provided_file.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../commons/types/variable_type" - require_relative "file_info_v_2" +require_relative "../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -30,8 +29,12 @@ def initialize(file:, related_types:, additional_properties: nil) # @return [V2::Problem::DefaultProvidedFile] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - file = struct.file - related_types = struct.relatedTypes + file = struct.file.to_h.to_json + file = V2::Problem::FileInfoV2.from_json(json_object: file) + related_types = struct.relatedTypes.map do |v| + v = v.to_h.to_json + Commons::VariableType.from_json(json_object: v) + end new(file: file, related_types: related_types, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/files.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/files.rb index 423725f6318..28526b0c2f0 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/files.rb @@ -25,7 +25,10 @@ def initialize(files:, additional_properties: nil) # @return [V2::Problem::Files] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files = struct.files + files = struct.files.map do |v| + v = v.to_h.to_json + V2::Problem::FileInfoV2.from_json(json_object: v) + end new(files: files, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages.rb index 6bd1413d3d2..6a2b8007148 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -8,11 +9,11 @@ module Problem class FunctionImplementationForMultipleLanguages attr_reader :code_by_language, :additional_properties - # @param code_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param code_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::FunctionImplementationForMultipleLanguages] def initialize(code_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @code_by_language = code_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -24,7 +25,10 @@ def initialize(code_by_language:, additional_properties: nil) # @return [V2::Problem::FunctionImplementationForMultipleLanguages] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - code_by_language = struct.codeByLanguage + code_by_language = struct.codeByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(code_by_language: code_by_language, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/function_signature.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/function_signature.rb index cec46add7e7..2f50061e45b 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/function_signature.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/function_signature.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "non_void_function_signature" require_relative "void_function_signature" +require_relative "non_void_function_signature" require_relative "void_function_signature_that_takes_actual_result" module SeedTraceClient diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/generated_files.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/generated_files.rb index 5e0b174418b..c4bd5145b7a 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/generated_files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/generated_files.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -8,17 +9,17 @@ module Problem class GeneratedFiles attr_reader :generated_test_case_files, :generated_template_files, :other, :additional_properties - # @param generated_test_case_files [Hash{LANGUAGE => LANGUAGE}] - # @param generated_template_files [Hash{LANGUAGE => LANGUAGE}] - # @param other [Hash{LANGUAGE => LANGUAGE}] + # @param generated_test_case_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + # @param generated_template_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + # @param other [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::GeneratedFiles] def initialize(generated_test_case_files:, generated_template_files:, other:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @generated_test_case_files = generated_test_case_files - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @generated_template_files = generated_template_files - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @other = other # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -30,9 +31,18 @@ def initialize(generated_test_case_files:, generated_template_files:, other:, ad # @return [V2::Problem::GeneratedFiles] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - generated_test_case_files = struct.generatedTestCaseFiles - generated_template_files = struct.generatedTemplateFiles - other = struct.other + generated_test_case_files = struct.generatedTestCaseFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + generated_template_files = struct.generatedTemplateFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + other = struct.other.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(generated_test_case_files: generated_test_case_files, generated_template_files: generated_template_files, other: other, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_request.rb index b95db88246c..117bc773b1d 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_request.rb @@ -29,7 +29,8 @@ def initialize(method_name:, signature:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName - signature = struct.signature + signature = struct.signature.to_h.to_json + signature = V2::Problem::NonVoidFunctionSignature.from_json(json_object: signature) new(method_name: method_name, signature: signature, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_response.rb index 305e0fecb0d..63c699c2e75 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -8,11 +9,11 @@ module Problem class GetBasicSolutionFileResponse attr_reader :solution_file_by_language, :additional_properties - # @param solution_file_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param solution_file_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::GetBasicSolutionFileResponse] def initialize(solution_file_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @solution_file_by_language = solution_file_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -24,7 +25,10 @@ def initialize(solution_file_by_language:, additional_properties: nil) # @return [V2::Problem::GetBasicSolutionFileResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - solution_file_by_language = struct.solutionFileByLanguage + solution_file_by_language = struct.solutionFileByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(solution_file_by_language: solution_file_by_language, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_request.rb index 5340b0ee43e..1bc7e57b9e4 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_request.rb @@ -25,7 +25,8 @@ def initialize(function_signature:, additional_properties: nil) # @return [V2::Problem::GetFunctionSignatureRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - function_signature = struct.functionSignature + function_signature = struct.functionSignature.to_h.to_json + function_signature = V2::Problem::FunctionSignature.from_json(json_object: function_signature) new(function_signature: function_signature, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_response.rb index 61ba6f1e705..c56d8438b0a 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -8,11 +9,11 @@ module Problem class GetFunctionSignatureResponse attr_reader :function_by_language, :additional_properties - # @param function_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param function_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::GetFunctionSignatureResponse] def initialize(function_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @function_by_language = function_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -24,7 +25,10 @@ def initialize(function_by_language:, additional_properties: nil) # @return [V2::Problem::GetFunctionSignatureResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - function_by_language = struct.functionByLanguage + function_by_language = struct.functionByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(function_by_language: function_by_language, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_file_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_file_request.rb index 0f6c3ac704f..cfce4000133 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_file_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_file_request.rb @@ -29,8 +29,10 @@ def initialize(test_case:, template: nil, additional_properties: nil) # @return [V2::Problem::GetGeneratedTestCaseFileRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - template = struct.template - test_case = struct.testCase + template = struct.template.to_h.to_json + template = V2::Problem::TestCaseTemplate.from_json(json_object: template) + test_case = struct.testCase.to_h.to_json + test_case = V2::Problem::TestCaseV2.from_json(json_object: test_case) new(template: template, test_case: test_case, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request.rb index 2ecb7683285..8ba5a6ad4a3 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request.rb @@ -25,7 +25,8 @@ def initialize(template:, additional_properties: nil) # @return [V2::Problem::GetGeneratedTestCaseTemplateFileRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - template = struct.template + template = struct.template.to_h.to_json + template = V2::Problem::TestCaseTemplate.from_json(json_object: template) new(template: template, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2.rb index 8bad0d2dcd7..f0d59f057d3 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require_relative "../../../commons/types/problem_id" -require "json" require "set" +require "json" module SeedTraceClient module V2 @@ -38,7 +38,8 @@ def self.from_json(json_object:) problem_id = struct.problemId problem_name = struct.problemName problem_version = struct.problemVersion - variable_types = struct.variableTypes + variable_types = struct.variableTypes.to_h.to_json + variable_types = Set.new(variable_types) new(problem_id: problem_id, problem_name: problem_name, problem_version: problem_version, variable_types: variable_types, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_definition.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_definition.rb index f8c4e57345c..7d04109f0c1 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_definition.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_definition.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "non_void_function_signature" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -30,8 +29,10 @@ def initialize(signature:, code:, additional_properties: nil) # @return [V2::Problem::NonVoidFunctionDefinition] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - signature = struct.signature - code = struct.code + signature = struct.signature.to_h.to_json + signature = V2::Problem::NonVoidFunctionSignature.from_json(json_object: signature) + code = struct.code.to_h.to_json + code = V2::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(signature: signature, code: code, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_signature.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_signature.rb index 7f53bfa0423..96e81c06a2f 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_signature.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_signature.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../commons/types/variable_type" - require_relative "parameter" +require_relative "../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -30,8 +29,12 @@ def initialize(parameters:, return_type:, additional_properties: nil) # @return [V2::Problem::NonVoidFunctionSignature] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - return_type = struct.returnType + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end + return_type = struct.returnType.to_h.to_json + return_type = Commons::VariableType.from_json(json_object: return_type) new(parameters: parameters, return_type: return_type, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/parameter.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/parameter.rb index c1c30bed814..96d2a6f2783 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/parameter.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/parameter.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../commons/types/variable_type" - require_relative "parameter_id" +require_relative "../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -35,7 +34,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parameter_id = struct.parameterId name = struct.name - variable_type = struct.variableType + variable_type = struct.variableType.to_h.to_json + variable_type = Commons::VariableType.from_json(json_object: variable_type) new(parameter_id: parameter_id, name: name, variable_type: variable_type, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/problem_info_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/problem_info_v_2.rb index 81d538cb067..7990ce625b0 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/problem_info_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/problem_info_v_2.rb @@ -20,7 +20,7 @@ class ProblemInfoV2 # @param problem_description [Problem::ProblemDescription] # @param problem_name [String] # @param problem_version [Integer] - # @param supported_languages [Set] + # @param supported_languages [Set] # @param custom_files [V2::Problem::CustomFiles] # @param generated_files [V2::Problem::GeneratedFiles] # @param custom_test_case_templates [Array] @@ -38,7 +38,7 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version @problem_name = problem_name # @type [Integer] @problem_version = problem_version - # @type [Set] + # @type [Set] @supported_languages = supported_languages # @type [V2::Problem::CustomFiles] @custom_files = custom_files @@ -61,14 +61,24 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_id = struct.problemId - problem_description = struct.problemDescription + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) problem_name = struct.problemName problem_version = struct.problemVersion - supported_languages = struct.supportedLanguages - custom_files = struct.customFiles - generated_files = struct.generatedFiles - custom_test_case_templates = struct.customTestCaseTemplates - testcases = struct.testcases + supported_languages = struct.supportedLanguages.to_h.to_json + supported_languages = Set.new(supported_languages) + custom_files = struct.customFiles.to_h.to_json + custom_files = V2::Problem::CustomFiles.from_json(json_object: custom_files) + generated_files = struct.generatedFiles.to_h.to_json + generated_files = V2::Problem::GeneratedFiles.from_json(json_object: generated_files) + custom_test_case_templates = struct.customTestCaseTemplates.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseTemplate.from_json(json_object: v) + end + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseV2.from_json(json_object: v) + end is_public = struct.isPublic new(problem_id: problem_id, problem_description: problem_description, problem_name: problem_name, problem_version: problem_version, supported_languages: supported_languages, custom_files: custom_files, generated_files: generated_files, custom_test_case_templates: custom_test_case_templates, testcases: testcases, is_public: is_public, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation.rb index c452d516190..53dee0c4deb 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "test_case_function" - require_relative "test_case_implementation_description" +require_relative "test_case_function" require "json" module SeedTraceClient @@ -30,8 +29,10 @@ def initialize(description:, function:, additional_properties: nil) # @return [V2::Problem::TestCaseImplementation] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - description = struct.description - function = struct.function + description = struct.description.to_h.to_json + description = V2::Problem::TestCaseImplementationDescription.from_json(json_object: description) + function = struct.function.to_h.to_json + function = V2::Problem::TestCaseFunction.from_json(json_object: function) new(description: description, function: function, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation_description.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation_description.rb index 45f7df54ccf..e6196f66dbd 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation_description.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation_description.rb @@ -25,7 +25,10 @@ def initialize(boards:, additional_properties: nil) # @return [V2::Problem::TestCaseImplementationDescription] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - boards = struct.boards + boards = struct.boards.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseImplementationDescriptionBoard.from_json(json_object: v) + end new(boards: boards, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_template.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_template.rb index c597fda32be..760bb47cb34 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_template.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_template.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "test_case_implementation" - require_relative "test_case_template_id" +require_relative "test_case_implementation" require "json" module SeedTraceClient @@ -35,7 +34,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) template_id = struct.templateId name = struct.name - implementation = struct.implementation + implementation = struct.implementation.to_h.to_json + implementation = V2::Problem::TestCaseImplementation.from_json(json_object: implementation) new(template_id: template_id, name: name, implementation: implementation, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_v_2.rb index 47d19c9cf35..4d4d332c223 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_v_2.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "test_case_metadata" require_relative "test_case_implementation_reference" - require_relative "test_case_expects" -require_relative "test_case_metadata" require "json" module SeedTraceClient @@ -37,10 +36,13 @@ def initialize(metadata:, implementation:, arguments:, expects: nil, additional_ # @return [V2::Problem::TestCaseV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - metadata = struct.metadata - implementation = struct.implementation + metadata = struct.metadata.to_h.to_json + metadata = V2::Problem::TestCaseMetadata.from_json(json_object: metadata) + implementation = struct.implementation.to_h.to_json + implementation = V2::Problem::TestCaseImplementationReference.from_json(json_object: implementation) arguments = struct.arguments - expects = struct.expects + expects = struct.expects.to_h.to_json + expects = V2::Problem::TestCaseExpects.from_json(json_object: expects) new(metadata: metadata, implementation: implementation, arguments: arguments, expects: expects, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation.rb index c63348ac4c2..8a775905a1f 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "assert_correctness_check" - require_relative "non_void_function_definition" +require_relative "assert_correctness_check" require "json" module SeedTraceClient @@ -30,8 +29,10 @@ def initialize(get_actual_result:, assert_correctness_check:, additional_propert # @return [V2::Problem::TestCaseWithActualResultImplementation] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - get_actual_result = struct.getActualResult - assert_correctness_check = struct.assertCorrectnessCheck + get_actual_result = struct.getActualResult.to_h.to_json + get_actual_result = V2::Problem::NonVoidFunctionDefinition.from_json(json_object: get_actual_result) + assert_correctness_check = struct.assertCorrectnessCheck.to_h.to_json + assert_correctness_check = V2::Problem::AssertCorrectnessCheck.from_json(json_object: assert_correctness_check) new(get_actual_result: get_actual_result, assert_correctness_check: assert_correctness_check, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition.rb index 8b098156c06..6ac0082945e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "parameter" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -30,8 +29,12 @@ def initialize(parameters:, code:, additional_properties: nil) # @return [V2::Problem::VoidFunctionDefinition] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - code = struct.code + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end + code = struct.code.to_h.to_json + code = V2::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(parameters: parameters, code: code, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result.rb index 449a4baf964..aa6c5eaa372 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "parameter" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(additional_parameters:, code:, additional_properties: nil) # @return [V2::Problem::VoidFunctionDefinitionThatTakesActualResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - additional_parameters = struct.additionalParameters - code = struct.code + additional_parameters = struct.additionalParameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end + code = struct.code.to_h.to_json + code = V2::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(additional_parameters: additional_parameters, code: code, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature.rb index 252e77ac96c..34d3a12a93d 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature.rb @@ -25,7 +25,10 @@ def initialize(parameters:, additional_properties: nil) # @return [V2::Problem::VoidFunctionSignature] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end new(parameters: parameters, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result.rb index f092b347788..b1974f7ae9a 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../commons/types/variable_type" - require_relative "parameter" +require_relative "../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -30,8 +29,12 @@ def initialize(parameters:, actual_result_type:, additional_properties: nil) # @return [V2::Problem::VoidFunctionSignatureThatTakesActualResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - actual_result_type = struct.actualResultType + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end + actual_result_type = struct.actualResultType.to_h.to_json + actual_result_type = Commons::VariableType.from_json(json_object: actual_result_type) new(parameters: parameters, actual_result_type: actual_result_type, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_custom_files.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_custom_files.rb index b27bcfd063b..48dafd6541b 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_custom_files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_custom_files.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative "basic_test_case_template" - require_relative "non_void_function_signature" +require_relative "basic_test_case_template" require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -14,7 +14,7 @@ class BasicCustomFiles # @param method_name [String] # @param signature [V2::V3::Problem::NonVoidFunctionSignature] - # @param additional_files [Hash{LANGUAGE => LANGUAGE}] + # @param additional_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param basic_test_case_template [V2::V3::Problem::BasicTestCaseTemplate] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::BasicCustomFiles] @@ -24,7 +24,7 @@ def initialize(method_name:, signature:, additional_files:, basic_test_case_temp @method_name = method_name # @type [V2::V3::Problem::NonVoidFunctionSignature] @signature = signature - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @additional_files = additional_files # @type [V2::V3::Problem::BasicTestCaseTemplate] @basic_test_case_template = basic_test_case_template @@ -39,9 +39,14 @@ def initialize(method_name:, signature:, additional_files:, basic_test_case_temp def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName - signature = struct.signature - additional_files = struct.additionalFiles - basic_test_case_template = struct.basicTestCaseTemplate + signature = struct.signature.to_h.to_json + signature = V2::V3::Problem::NonVoidFunctionSignature.from_json(json_object: signature) + additional_files = struct.additionalFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + basic_test_case_template = struct.basicTestCaseTemplate.to_h.to_json + basic_test_case_template = V2::V3::Problem::BasicTestCaseTemplate.from_json(json_object: basic_test_case_template) new(method_name: method_name, signature: signature, additional_files: additional_files, basic_test_case_template: basic_test_case_template, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_test_case_template.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_test_case_template.rb index d80a2135b69..5c56e3a71d3 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_test_case_template.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_test_case_template.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "test_case_template_id" require_relative "test_case_implementation_description" - require_relative "parameter_id" -require_relative "test_case_template_id" require "json" module SeedTraceClient @@ -40,7 +39,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) template_id = struct.templateId name = struct.name - description = struct.description + description = struct.description.to_h.to_json + description = V2::V3::Problem::TestCaseImplementationDescription.from_json(json_object: description) expected_value_parameter_id = struct.expectedValueParameterId new(template_id: template_id, name: name, description: description, expected_value_parameter_id: expected_value_parameter_id, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2.rb index 7a27afd7c82..fc141b10c99 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2.rb @@ -4,8 +4,8 @@ require_relative "custom_files" require_relative "test_case_template" require_relative "test_case_v_2" -require "json" require "set" +require "json" module SeedTraceClient module V2 @@ -20,7 +20,7 @@ class CreateProblemRequestV2 # @param custom_files [V2::V3::Problem::CustomFiles] # @param custom_test_case_templates [Array] # @param testcases [Array] - # @param supported_languages [Set] + # @param supported_languages [Set] # @param is_public [Boolean] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::CreateProblemRequestV2] @@ -36,7 +36,7 @@ def initialize(problem_name:, problem_description:, custom_files:, custom_test_c @custom_test_case_templates = custom_test_case_templates # @type [Array] @testcases = testcases - # @type [Set] + # @type [Set] @supported_languages = supported_languages # @type [Boolean] @is_public = is_public @@ -51,11 +51,20 @@ def initialize(problem_name:, problem_description:, custom_files:, custom_test_c def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_name = struct.problemName - problem_description = struct.problemDescription - custom_files = struct.customFiles - custom_test_case_templates = struct.customTestCaseTemplates - testcases = struct.testcases - supported_languages = struct.supportedLanguages + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) + custom_files = struct.customFiles.to_h.to_json + custom_files = V2::V3::Problem::CustomFiles.from_json(json_object: custom_files) + custom_test_case_templates = struct.customTestCaseTemplates.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseTemplate.from_json(json_object: v) + end + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseV2.from_json(json_object: v) + end + supported_languages = struct.supportedLanguages.to_h.to_json + supported_languages = Set.new(supported_languages) is_public = struct.isPublic new(problem_name: problem_name, problem_description: problem_description, custom_files: custom_files, custom_test_case_templates: custom_test_case_templates, testcases: testcases, supported_languages: supported_languages, is_public: is_public, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/custom_files.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/custom_files.rb index 4f17c77a803..98a281ba9d3 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/custom_files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/custom_files.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" require_relative "basic_custom_files" module SeedTraceClient @@ -34,7 +35,7 @@ def self.from_json(json_object:) when "custom" json_object.value.transform_values do |_k, v| v = v.to_h.to_json - LANGUAGE.key(v) + Commons::LANGUAGE.key(v) || v end else V2::V3::Problem::BasicCustomFiles.from_json(json_object: json_object) @@ -86,7 +87,7 @@ def self.basic(member:) new(member: member, discriminant: "basic") end - # @param member [Hash{LANGUAGE => LANGUAGE}] + # @param member [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @return [V2::V3::Problem::CustomFiles] def self.custom(member:) new(member: member, discriminant: "custom") diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/default_provided_file.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/default_provided_file.rb index f16a1567aed..9afb7280ee2 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/default_provided_file.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/default_provided_file.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../../commons/types/variable_type" - require_relative "file_info_v_2" +require_relative "../../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(file:, related_types:, additional_properties: nil) # @return [V2::V3::Problem::DefaultProvidedFile] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - file = struct.file - related_types = struct.relatedTypes + file = struct.file.to_h.to_json + file = V2::V3::Problem::FileInfoV2.from_json(json_object: file) + related_types = struct.relatedTypes.map do |v| + v = v.to_h.to_json + Commons::VariableType.from_json(json_object: v) + end new(file: file, related_types: related_types, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/files.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/files.rb index b6e584cec41..0a3373ec24d 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/files.rb @@ -26,7 +26,10 @@ def initialize(files:, additional_properties: nil) # @return [V2::V3::Problem::Files] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files = struct.files + files = struct.files.map do |v| + v = v.to_h.to_json + V2::V3::Problem::FileInfoV2.from_json(json_object: v) + end new(files: files, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb index 38ededfd429..954d1c7ec9d 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -9,11 +10,11 @@ module Problem class FunctionImplementationForMultipleLanguages attr_reader :code_by_language, :additional_properties - # @param code_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param code_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::FunctionImplementationForMultipleLanguages] def initialize(code_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @code_by_language = code_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -25,7 +26,10 @@ def initialize(code_by_language:, additional_properties: nil) # @return [V2::V3::Problem::FunctionImplementationForMultipleLanguages] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - code_by_language = struct.codeByLanguage + code_by_language = struct.codeByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(code_by_language: code_by_language, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_signature.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_signature.rb index ecf58560440..5e3d211d979 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_signature.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_signature.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "non_void_function_signature" require_relative "void_function_signature" +require_relative "non_void_function_signature" require_relative "void_function_signature_that_takes_actual_result" module SeedTraceClient diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/generated_files.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/generated_files.rb index b7c2cedd8a6..261f18ec439 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/generated_files.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/generated_files.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -9,17 +10,17 @@ module Problem class GeneratedFiles attr_reader :generated_test_case_files, :generated_template_files, :other, :additional_properties - # @param generated_test_case_files [Hash{LANGUAGE => LANGUAGE}] - # @param generated_template_files [Hash{LANGUAGE => LANGUAGE}] - # @param other [Hash{LANGUAGE => LANGUAGE}] + # @param generated_test_case_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + # @param generated_template_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + # @param other [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::GeneratedFiles] def initialize(generated_test_case_files:, generated_template_files:, other:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @generated_test_case_files = generated_test_case_files - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @generated_template_files = generated_template_files - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @other = other # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -31,9 +32,18 @@ def initialize(generated_test_case_files:, generated_template_files:, other:, ad # @return [V2::V3::Problem::GeneratedFiles] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - generated_test_case_files = struct.generatedTestCaseFiles - generated_template_files = struct.generatedTemplateFiles - other = struct.other + generated_test_case_files = struct.generatedTestCaseFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + generated_template_files = struct.generatedTemplateFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + other = struct.other.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(generated_test_case_files: generated_test_case_files, generated_template_files: generated_template_files, other: other, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request.rb index 0fa5c6c4f6e..3a1d24854da 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request.rb @@ -30,7 +30,8 @@ def initialize(method_name:, signature:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName - signature = struct.signature + signature = struct.signature.to_h.to_json + signature = V2::V3::Problem::NonVoidFunctionSignature.from_json(json_object: signature) new(method_name: method_name, signature: signature, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response.rb index d50a74cc303..28b16757b4e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -9,11 +10,11 @@ module Problem class GetBasicSolutionFileResponse attr_reader :solution_file_by_language, :additional_properties - # @param solution_file_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param solution_file_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::GetBasicSolutionFileResponse] def initialize(solution_file_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @solution_file_by_language = solution_file_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -25,7 +26,10 @@ def initialize(solution_file_by_language:, additional_properties: nil) # @return [V2::V3::Problem::GetBasicSolutionFileResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - solution_file_by_language = struct.solutionFileByLanguage + solution_file_by_language = struct.solutionFileByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(solution_file_by_language: solution_file_by_language, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_request.rb index 38d3009c2ab..3f81b49e6ef 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_request.rb @@ -26,7 +26,8 @@ def initialize(function_signature:, additional_properties: nil) # @return [V2::V3::Problem::GetFunctionSignatureRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - function_signature = struct.functionSignature + function_signature = struct.functionSignature.to_h.to_json + function_signature = V2::V3::Problem::FunctionSignature.from_json(json_object: function_signature) new(function_signature: function_signature, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_response.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_response.rb index 3b5e07b3478..91dca9a1159 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_response.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -9,11 +10,11 @@ module Problem class GetFunctionSignatureResponse attr_reader :function_by_language, :additional_properties - # @param function_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param function_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::GetFunctionSignatureResponse] def initialize(function_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @function_by_language = function_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -25,7 +26,10 @@ def initialize(function_by_language:, additional_properties: nil) # @return [V2::V3::Problem::GetFunctionSignatureResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - function_by_language = struct.functionByLanguage + function_by_language = struct.functionByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(function_by_language: function_by_language, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request.rb index ec8d2cab576..bf38759990e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request.rb @@ -30,8 +30,10 @@ def initialize(test_case:, template: nil, additional_properties: nil) # @return [V2::V3::Problem::GetGeneratedTestCaseFileRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - template = struct.template - test_case = struct.testCase + template = struct.template.to_h.to_json + template = V2::V3::Problem::TestCaseTemplate.from_json(json_object: template) + test_case = struct.testCase.to_h.to_json + test_case = V2::V3::Problem::TestCaseV2.from_json(json_object: test_case) new(template: template, test_case: test_case, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request.rb index a590e0aa3a2..20d3460e126 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request.rb @@ -26,7 +26,8 @@ def initialize(template:, additional_properties: nil) # @return [V2::V3::Problem::GetGeneratedTestCaseTemplateFileRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - template = struct.template + template = struct.template.to_h.to_json + template = V2::V3::Problem::TestCaseTemplate.from_json(json_object: template) new(template: template, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb index 72b225abab4..afd08ac6c22 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require_relative "../../../../commons/types/problem_id" -require "json" require "set" +require "json" module SeedTraceClient module V2 @@ -39,7 +39,8 @@ def self.from_json(json_object:) problem_id = struct.problemId problem_name = struct.problemName problem_version = struct.problemVersion - variable_types = struct.variableTypes + variable_types = struct.variableTypes.to_h.to_json + variable_types = Set.new(variable_types) new(problem_id: problem_id, problem_name: problem_name, problem_version: problem_version, variable_types: variable_types, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_definition.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_definition.rb index fc5f7e71b83..f3db2d63caf 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_definition.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_definition.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "non_void_function_signature" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -31,8 +30,10 @@ def initialize(signature:, code:, additional_properties: nil) # @return [V2::V3::Problem::NonVoidFunctionDefinition] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - signature = struct.signature - code = struct.code + signature = struct.signature.to_h.to_json + signature = V2::V3::Problem::NonVoidFunctionSignature.from_json(json_object: signature) + code = struct.code.to_h.to_json + code = V2::V3::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(signature: signature, code: code, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_signature.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_signature.rb index e879fbbe8ac..c67c1414b49 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_signature.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_signature.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../../commons/types/variable_type" - require_relative "parameter" +require_relative "../../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(parameters:, return_type:, additional_properties: nil) # @return [V2::V3::Problem::NonVoidFunctionSignature] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - return_type = struct.returnType + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end + return_type = struct.returnType.to_h.to_json + return_type = Commons::VariableType.from_json(json_object: return_type) new(parameters: parameters, return_type: return_type, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/parameter.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/parameter.rb index e9fe721aad7..9d5a9607a2e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/parameter.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/parameter.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../../commons/types/variable_type" - require_relative "parameter_id" +require_relative "../../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -36,7 +35,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parameter_id = struct.parameterId name = struct.name - variable_type = struct.variableType + variable_type = struct.variableType.to_h.to_json + variable_type = Commons::VariableType.from_json(json_object: variable_type) new(parameter_id: parameter_id, name: name, variable_type: variable_type, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/problem_info_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/problem_info_v_2.rb index 644fc5a8698..e8a0a9e4a53 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/problem_info_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/problem_info_v_2.rb @@ -21,7 +21,7 @@ class ProblemInfoV2 # @param problem_description [Problem::ProblemDescription] # @param problem_name [String] # @param problem_version [Integer] - # @param supported_languages [Set] + # @param supported_languages [Set] # @param custom_files [V2::V3::Problem::CustomFiles] # @param generated_files [V2::V3::Problem::GeneratedFiles] # @param custom_test_case_templates [Array] @@ -39,7 +39,7 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version @problem_name = problem_name # @type [Integer] @problem_version = problem_version - # @type [Set] + # @type [Set] @supported_languages = supported_languages # @type [V2::V3::Problem::CustomFiles] @custom_files = custom_files @@ -62,14 +62,24 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_id = struct.problemId - problem_description = struct.problemDescription + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) problem_name = struct.problemName problem_version = struct.problemVersion - supported_languages = struct.supportedLanguages - custom_files = struct.customFiles - generated_files = struct.generatedFiles - custom_test_case_templates = struct.customTestCaseTemplates - testcases = struct.testcases + supported_languages = struct.supportedLanguages.to_h.to_json + supported_languages = Set.new(supported_languages) + custom_files = struct.customFiles.to_h.to_json + custom_files = V2::V3::Problem::CustomFiles.from_json(json_object: custom_files) + generated_files = struct.generatedFiles.to_h.to_json + generated_files = V2::V3::Problem::GeneratedFiles.from_json(json_object: generated_files) + custom_test_case_templates = struct.customTestCaseTemplates.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseTemplate.from_json(json_object: v) + end + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseV2.from_json(json_object: v) + end is_public = struct.isPublic new(problem_id: problem_id, problem_description: problem_description, problem_name: problem_name, problem_version: problem_version, supported_languages: supported_languages, custom_files: custom_files, generated_files: generated_files, custom_test_case_templates: custom_test_case_templates, testcases: testcases, is_public: is_public, additional_properties: struct) diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation.rb index 32943b7d2df..1585f07224a 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "test_case_function" - require_relative "test_case_implementation_description" +require_relative "test_case_function" require "json" module SeedTraceClient @@ -31,8 +30,10 @@ def initialize(description:, function:, additional_properties: nil) # @return [V2::V3::Problem::TestCaseImplementation] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - description = struct.description - function = struct.function + description = struct.description.to_h.to_json + description = V2::V3::Problem::TestCaseImplementationDescription.from_json(json_object: description) + function = struct.function.to_h.to_json + function = V2::V3::Problem::TestCaseFunction.from_json(json_object: function) new(description: description, function: function, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description.rb index e06c055afaa..f38667971e9 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description.rb @@ -26,7 +26,10 @@ def initialize(boards:, additional_properties: nil) # @return [V2::V3::Problem::TestCaseImplementationDescription] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - boards = struct.boards + boards = struct.boards.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseImplementationDescriptionBoard.from_json(json_object: v) + end new(boards: boards, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_template.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_template.rb index c6316487013..51da6190aa7 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_template.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_template.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "test_case_implementation" - require_relative "test_case_template_id" +require_relative "test_case_implementation" require "json" module SeedTraceClient @@ -36,7 +35,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) template_id = struct.templateId name = struct.name - implementation = struct.implementation + implementation = struct.implementation.to_h.to_json + implementation = V2::V3::Problem::TestCaseImplementation.from_json(json_object: implementation) new(template_id: template_id, name: name, implementation: implementation, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_v_2.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_v_2.rb index 72a05cec0ae..af628708248 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_v_2.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_v_2.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "test_case_metadata" require_relative "test_case_implementation_reference" - require_relative "test_case_expects" -require_relative "test_case_metadata" require "json" module SeedTraceClient @@ -38,10 +37,13 @@ def initialize(metadata:, implementation:, arguments:, expects: nil, additional_ # @return [V2::V3::Problem::TestCaseV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - metadata = struct.metadata - implementation = struct.implementation + metadata = struct.metadata.to_h.to_json + metadata = V2::V3::Problem::TestCaseMetadata.from_json(json_object: metadata) + implementation = struct.implementation.to_h.to_json + implementation = V2::V3::Problem::TestCaseImplementationReference.from_json(json_object: implementation) arguments = struct.arguments - expects = struct.expects + expects = struct.expects.to_h.to_json + expects = V2::V3::Problem::TestCaseExpects.from_json(json_object: expects) new(metadata: metadata, implementation: implementation, arguments: arguments, expects: expects, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb index d0ec5cfb68a..67d025fb24e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "assert_correctness_check" - require_relative "non_void_function_definition" +require_relative "assert_correctness_check" require "json" module SeedTraceClient @@ -31,8 +30,10 @@ def initialize(get_actual_result:, assert_correctness_check:, additional_propert # @return [V2::V3::Problem::TestCaseWithActualResultImplementation] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - get_actual_result = struct.getActualResult - assert_correctness_check = struct.assertCorrectnessCheck + get_actual_result = struct.getActualResult.to_h.to_json + get_actual_result = V2::V3::Problem::NonVoidFunctionDefinition.from_json(json_object: get_actual_result) + assert_correctness_check = struct.assertCorrectnessCheck.to_h.to_json + assert_correctness_check = V2::V3::Problem::AssertCorrectnessCheck.from_json(json_object: assert_correctness_check) new(get_actual_result: get_actual_result, assert_correctness_check: assert_correctness_check, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition.rb index 82b0021611d..7b017a4a563 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "parameter" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(parameters:, code:, additional_properties: nil) # @return [V2::V3::Problem::VoidFunctionDefinition] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - code = struct.code + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end + code = struct.code.to_h.to_json + code = V2::V3::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(parameters: parameters, code: code, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb index 40c5ebc86e6..cacc38cffee 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "parameter" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -32,8 +31,12 @@ def initialize(additional_parameters:, code:, additional_properties: nil) # @return [V2::V3::Problem::VoidFunctionDefinitionThatTakesActualResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - additional_parameters = struct.additionalParameters - code = struct.code + additional_parameters = struct.additionalParameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end + code = struct.code.to_h.to_json + code = V2::V3::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(additional_parameters: additional_parameters, code: code, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature.rb index 2f492cfd05f..c30b073c76f 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature.rb @@ -26,7 +26,10 @@ def initialize(parameters:, additional_properties: nil) # @return [V2::V3::Problem::VoidFunctionSignature] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end new(parameters: parameters, additional_properties: struct) end diff --git a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb index 633c9ec83f1..66730c7ef1e 100644 --- a/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb +++ b/seed/ruby-model/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../../commons/types/variable_type" - require_relative "parameter" +require_relative "../../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(parameters:, actual_result_type:, additional_properties: nil) # @return [V2::V3::Problem::VoidFunctionSignatureThatTakesActualResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - actual_result_type = struct.actualResultType + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end + actual_result_type = struct.actualResultType.to_h.to_json + actual_result_type = Commons::VariableType.from_json(json_object: actual_result_type) new(parameters: parameters, actual_result_type: actual_result_type, additional_properties: struct) end diff --git a/seed/ruby-model/trace/seed_trace_client.gemspec b/seed/ruby-model/trace/seed_trace_client.gemspec index 98f9448cd92..e590a1d0cc2 100644 --- a/seed/ruby-model/trace/seed_trace_client.gemspec +++ b/seed/ruby-model/trace/seed_trace_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_trace_client" + spec.version = SeedTraceClient::Gemconfig::VERSION spec.authors = SeedTraceClient::Gemconfig::AUTHORS spec.email = SeedTraceClient::Gemconfig::EMAIL spec.summary = SeedTraceClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/undiscriminated-unions/.rubocop.yml b/seed/ruby-model/undiscriminated-unions/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/undiscriminated-unions/.rubocop.yml +++ b/seed/ruby-model/undiscriminated-unions/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/undiscriminated-unions/lib/gemconfig.rb b/seed/ruby-model/undiscriminated-unions/lib/gemconfig.rb index 6e6daafd733..3da2832afc4 100644 --- a/seed/ruby-model/undiscriminated-unions/lib/gemconfig.rb +++ b/seed/ruby-model/undiscriminated-unions/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedUndiscriminatedUnionsClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/undiscriminated-unions/seed_undiscriminated_unions_client.gemspec b/seed/ruby-model/undiscriminated-unions/seed_undiscriminated_unions_client.gemspec index c72daa283ff..c95c0ae5598 100644 --- a/seed/ruby-model/undiscriminated-unions/seed_undiscriminated_unions_client.gemspec +++ b/seed/ruby-model/undiscriminated-unions/seed_undiscriminated_unions_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_undiscriminated_unions_client" + spec.version = SeedUndiscriminatedUnionsClient::Gemconfig::VERSION spec.authors = SeedUndiscriminatedUnionsClient::Gemconfig::AUTHORS spec.email = SeedUndiscriminatedUnionsClient::Gemconfig::EMAIL spec.summary = SeedUndiscriminatedUnionsClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/unknown/.rubocop.yml b/seed/ruby-model/unknown/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/unknown/.rubocop.yml +++ b/seed/ruby-model/unknown/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/unknown/lib/gemconfig.rb b/seed/ruby-model/unknown/lib/gemconfig.rb index b8016256780..e8f5bfe739c 100644 --- a/seed/ruby-model/unknown/lib/gemconfig.rb +++ b/seed/ruby-model/unknown/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedUnknownAsAnyClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/unknown/seed_unknown_as_any_client.gemspec b/seed/ruby-model/unknown/seed_unknown_as_any_client.gemspec index 39ed6273fdc..b1b9bb71e7b 100644 --- a/seed/ruby-model/unknown/seed_unknown_as_any_client.gemspec +++ b/seed/ruby-model/unknown/seed_unknown_as_any_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_unknown_as_any_client" + spec.version = SeedUnknownAsAnyClient::Gemconfig::VERSION spec.authors = SeedUnknownAsAnyClient::Gemconfig::AUTHORS spec.email = SeedUnknownAsAnyClient::Gemconfig::EMAIL spec.summary = SeedUnknownAsAnyClient::Gemconfig::SUMMARY diff --git a/seed/ruby-model/variables/.rubocop.yml b/seed/ruby-model/variables/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-model/variables/.rubocop.yml +++ b/seed/ruby-model/variables/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-model/variables/lib/gemconfig.rb b/seed/ruby-model/variables/lib/gemconfig.rb index 87961957426..4fcc169da55 100644 --- a/seed/ruby-model/variables/lib/gemconfig.rb +++ b/seed/ruby-model/variables/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedVariablesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-model/variables/seed_variables_client.gemspec b/seed/ruby-model/variables/seed_variables_client.gemspec index 73bfd4faa36..be164abe73c 100644 --- a/seed/ruby-model/variables/seed_variables_client.gemspec +++ b/seed/ruby-model/variables/seed_variables_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_variables_client" + spec.version = SeedVariablesClient::Gemconfig::VERSION spec.authors = SeedVariablesClient::Gemconfig::AUTHORS spec.email = SeedVariablesClient::Gemconfig::EMAIL spec.summary = SeedVariablesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/alias/.rubocop.yml b/seed/ruby-sdk/alias/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/alias/.rubocop.yml +++ b/seed/ruby-sdk/alias/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/alias/lib/gemconfig.rb b/seed/ruby-sdk/alias/lib/gemconfig.rb index 4038bce2de3..88c45f7609f 100644 --- a/seed/ruby-sdk/alias/lib/gemconfig.rb +++ b/seed/ruby-sdk/alias/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedAliasClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/alias/lib/requests.rb b/seed/ruby-sdk/alias/lib/requests.rb index 1dd738b2813..b90d7f5270b 100644 --- a/seed/ruby-sdk/alias/lib/requests.rb +++ b/seed/ruby-sdk/alias/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedAliasClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedAliasClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedAliasClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/alias/lib/seed_alias_client.rb b/seed/ruby-sdk/alias/lib/seed_alias_client.rb index ba86eac2b6c..9b9fbc4358d 100644 --- a/seed/ruby-sdk/alias/lib/seed_alias_client.rb +++ b/seed/ruby-sdk/alias/lib/seed_alias_client.rb @@ -1,28 +1,24 @@ # frozen_string_literal: true -require_relative "seed_alias_client/types/type" - -require_relative "seed_alias_client/types/object" -require_relative "seed_alias_client/types/type_id" -require "async/http/faraday" -require "faraday" +require_relative "types_export" +require_relative "requests" module SeedAliasClient class Client # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end class AsyncClient # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end end diff --git a/seed/ruby-sdk/alias/lib/types_export.rb b/seed/ruby-sdk/alias/lib/types_export.rb new file mode 100644 index 00000000000..1ace288e8e3 --- /dev/null +++ b/seed/ruby-sdk/alias/lib/types_export.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require_relative "seed_alias_client/types/type_id" +require_relative "seed_alias_client/types/type" +require_relative "seed_alias_client/types/object" diff --git a/seed/ruby-sdk/alias/seed_alias_client.gemspec b/seed/ruby-sdk/alias/seed_alias_client.gemspec index 847b13763ba..0a02b984f94 100644 --- a/seed/ruby-sdk/alias/seed_alias_client.gemspec +++ b/seed/ruby-sdk/alias/seed_alias_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_alias_client" + spec.version = SeedAliasClient::Gemconfig::VERSION spec.authors = SeedAliasClient::Gemconfig::AUTHORS spec.email = SeedAliasClient::Gemconfig::EMAIL spec.summary = SeedAliasClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/api-wide-base-path/.rubocop.yml b/seed/ruby-sdk/api-wide-base-path/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/api-wide-base-path/.rubocop.yml +++ b/seed/ruby-sdk/api-wide-base-path/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/api-wide-base-path/lib/gemconfig.rb b/seed/ruby-sdk/api-wide-base-path/lib/gemconfig.rb index f8f82622889..f5d3fca8c46 100644 --- a/seed/ruby-sdk/api-wide-base-path/lib/gemconfig.rb +++ b/seed/ruby-sdk/api-wide-base-path/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiWideBasePathClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/api-wide-base-path/lib/requests.rb b/seed/ruby-sdk/api-wide-base-path/lib/requests.rb index 1e9f7f91036..209c00ecbed 100644 --- a/seed/ruby-sdk/api-wide-base-path/lib/requests.rb +++ b/seed/ruby-sdk/api-wide-base-path/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedApiWideBasePathClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedApiWideBasePathClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedApiWideBasePathClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/api-wide-base-path/lib/seed_api_wide_base_path_client.rb b/seed/ruby-sdk/api-wide-base-path/lib/seed_api_wide_base_path_client.rb index 3f42b025142..fdcc298c091 100644 --- a/seed/ruby-sdk/api-wide-base-path/lib/seed_api_wide_base_path_client.rb +++ b/seed/ruby-sdk/api-wide-base-path/lib/seed_api_wide_base_path_client.rb @@ -1,27 +1,31 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_api_wide_base_path_client/service/client" -require "async/http/faraday" module SeedApiWideBasePathClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/api-wide-base-path/lib/seed_api_wide_base_path_client/service/client.rb b/seed/ruby-sdk/api-wide-base-path/lib/seed_api_wide_base_path_client/service/client.rb index f0a218cb307..5a532312f7f 100644 --- a/seed/ruby-sdk/api-wide-base-path/lib/seed_api_wide_base_path_client/service/client.rb +++ b/seed/ruby-sdk/api-wide-base-path/lib/seed_api_wide_base_path_client/service/client.rb @@ -1,53 +1,52 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedApiWideBasePathClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param path_param [String] - # @param service_param [String] - # @param endpoint_param [Integer] - # @param request_options [RequestOptions] - # @return [Void] - def post(path_param:, service_param:, endpoint_param:, request_options: nil) - @request_client.conn.post("/test/#{path_param}/#{service_param}/#{endpoint_param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param path_param [String] + # @param service_param [String] + # @param endpoint_param [Integer] + # @param request_options [RequestOptions] + # @return [Void] + def post(path_param:, service_param:, endpoint_param:, request_options: nil) + @request_client.conn.post("/test/#{path_param}/#{service_param}/#{endpoint_param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param path_param [String] - # @param service_param [String] - # @param endpoint_param [Integer] - # @param request_options [RequestOptions] - # @return [Void] - def post(path_param:, service_param:, endpoint_param:, request_options: nil) - Async.call do - @request_client.conn.post("/test/#{path_param}/#{service_param}/#{endpoint_param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param path_param [String] + # @param service_param [String] + # @param endpoint_param [Integer] + # @param request_options [RequestOptions] + # @return [Void] + def post(path_param:, service_param:, endpoint_param:, request_options: nil) + Async do + @request_client.conn.post("/test/#{path_param}/#{service_param}/#{endpoint_param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/api-wide-base-path/lib/types_export.rb b/seed/ruby-sdk/api-wide-base-path/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/api-wide-base-path/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/api-wide-base-path/seed_api_wide_base_path_client.gemspec b/seed/ruby-sdk/api-wide-base-path/seed_api_wide_base_path_client.gemspec index 8af14977365..acd3afd1973 100644 --- a/seed/ruby-sdk/api-wide-base-path/seed_api_wide_base_path_client.gemspec +++ b/seed/ruby-sdk/api-wide-base-path/seed_api_wide_base_path_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_wide_base_path_client" + spec.version = SeedApiWideBasePathClient::Gemconfig::VERSION spec.authors = SeedApiWideBasePathClient::Gemconfig::AUTHORS spec.email = SeedApiWideBasePathClient::Gemconfig::EMAIL spec.summary = SeedApiWideBasePathClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/audiences/.rubocop.yml b/seed/ruby-sdk/audiences/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/audiences/.rubocop.yml +++ b/seed/ruby-sdk/audiences/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/audiences/lib/gemconfig.rb b/seed/ruby-sdk/audiences/lib/gemconfig.rb index 46b8e4cf90d..64ebd00ed33 100644 --- a/seed/ruby-sdk/audiences/lib/gemconfig.rb +++ b/seed/ruby-sdk/audiences/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedAudiencesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/audiences/lib/requests.rb b/seed/ruby-sdk/audiences/lib/requests.rb index d6fcafc9591..501c7d6cd56 100644 --- a/seed/ruby-sdk/audiences/lib/requests.rb +++ b/seed/ruby-sdk/audiences/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedAudiencesClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedAudiencesClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedAudiencesClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/audiences/lib/seed_audiences_client.rb b/seed/ruby-sdk/audiences/lib/seed_audiences_client.rb index 2b3797ddb82..eb1c60b6958 100644 --- a/seed/ruby-sdk/audiences/lib/seed_audiences_client.rb +++ b/seed/ruby-sdk/audiences/lib/seed_audiences_client.rb @@ -1,38 +1,34 @@ # frozen_string_literal: true -require_relative "seed_audiences_client/commons/types/imported" -require_relative "seed_audiences_client/folder_a/service/types/response" -require_relative "seed_audiences_client/folder_b/common/types/foo" -require_relative "seed_audiences_client/folder_c/common/types/foo" -require_relative "seed_audiences_client/foo/types/filtered_type" -require_relative "seed_audiences_client/foo/types/importing_type" -require_relative "seed_audiences_client/foo/types/optional_string" -require "faraday" -require_relative "seed_audiences_client/folder_a/service/client" -require_relative "seed_audiences_client/folder_aclient" +require_relative "types_export" +require_relative "requests" +require_relative "seed_audiences_client/folder_a/client" require_relative "seed_audiences_client/foo/client" -require "async/http/faraday" module SeedAudiencesClient class Client + attr_reader :folder_a, :foo + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @client = Client.initialize(request_client: request_client) - @foo_client = FooClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @folder_a = FolderA::Client.new(request_client: @request_client) + @foo = FooClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :folder_a, :foo + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_client = AsyncClient.initialize(client: request_client) - @async_foo_client = AsyncFooClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @folder_a = FolderA::AsyncClient.new(request_client: @async_request_client) + @foo = AsyncFooClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/client.rb b/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/client.rb index 5492c1956bb..eb6d522a472 100644 --- a/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/client.rb +++ b/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/client.rb @@ -1,26 +1,23 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "service/client" module SeedAudiencesClient module FolderA class Client - attr_reader :request_client - - # @param client [RequestClient] - # @return [] - def initialize(client:) - @service_client = ServiceClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [FolderA::Client] + def initialize(request_client:) + @service = FolderA::ServiceClient.new(request_client: request_client) end end class AsyncClient - attr_reader :client - - # @param client [AsyncRequestClient] - # @return [] - def initialize(client:) - @async_service_client = AsyncServiceClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [FolderA::AsyncClient] + def initialize(request_client:) + @service = FolderA::AsyncServiceClient.new(request_client: request_client) end end end diff --git a/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/service/client.rb b/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/service/client.rb index 67801d50967..8c7377f7a34 100644 --- a/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/service/client.rb +++ b/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/service/client.rb @@ -1,52 +1,51 @@ # frozen_string_literal: true +require_relative "../../../requests" require_relative "types/response" require "async" module SeedAudiencesClient module FolderA - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [FolderA::ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [FolderA::Service::Response] - def get_direct_thread(request_options: nil) - response = @request_client.conn.get("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - FolderA::Service::Response.from_json(json_object: response) + # @param request_options [RequestOptions] + # @return [FolderA::Service::Response] + def get_direct_thread(request_options: nil) + response = @request_client.conn.get("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + FolderA::Service::Response.from_json(json_object: response.body) end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [FolderA::AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [FolderA::Service::Response] - def get_direct_thread(request_options: nil) - Async.call do - response = @request_client.conn.get("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - FolderA::Service::Response.from_json(json_object: response) + # @param request_options [RequestOptions] + # @return [FolderA::Service::Response] + def get_direct_thread(request_options: nil) + Async do + response = @request_client.conn.get("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + FolderA::Service::Response.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/service/types/response.rb b/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/service/types/response.rb index b4dcab2100a..cb9512bd783 100644 --- a/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/service/types/response.rb +++ b/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_a/service/types/response.rb @@ -25,7 +25,8 @@ def initialize(foo: nil, additional_properties: nil) # @return [FolderA::Service::Response] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - foo = struct.foo + foo = struct.foo.to_h.to_json + foo = FolderB::Common::Foo.from_json(json_object: foo) new(foo: foo, additional_properties: struct) end diff --git a/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_b/common/types/foo.rb b/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_b/common/types/foo.rb index 01fbc4bf319..878a01330f0 100644 --- a/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_b/common/types/foo.rb +++ b/seed/ruby-sdk/audiences/lib/seed_audiences_client/folder_b/common/types/foo.rb @@ -25,7 +25,8 @@ def initialize(foo: nil, additional_properties: nil) # @return [FolderB::Common::Foo] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - foo = struct.foo + foo = struct.foo.to_h.to_json + foo = FolderC::Common::Foo.from_json(json_object: foo) new(foo: foo, additional_properties: struct) end diff --git a/seed/ruby-sdk/audiences/lib/seed_audiences_client/foo/client.rb b/seed/ruby-sdk/audiences/lib/seed_audiences_client/foo/client.rb index 5b9e641a3dc..bb3998235d9 100644 --- a/seed/ruby-sdk/audiences/lib/seed_audiences_client/foo/client.rb +++ b/seed/ruby-sdk/audiences/lib/seed_audiences_client/foo/client.rb @@ -1,71 +1,75 @@ # frozen_string_literal: true -require_relative "types/importing_type" - +require_relative "../../requests" require_relative "types/optional_string" +require_relative "types/importing_type" require "async" module SeedAudiencesClient - module Foo - class FooClient - attr_reader :request_client + class FooClient + attr_reader :request_client + + # @param request_client [RequestClient] + # @return [FooClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_client [RequestClient] - # @return [FooClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client + # @param optional_string [Foo::OPTIONAL_STRING] + # @param public_property [String] + # @param private_property [Integer] + # @param request_options [RequestOptions] + # @return [Foo::ImportingType] + def find(optional_string:, public_property: nil, private_property: nil, request_options: nil) + response = @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "optionalString": optional_string + }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + publicProperty: public_property, + privateProperty: private_property + }.compact end + Foo::ImportingType.from_json(json_object: response.body) + end + end + + class AsyncFooClient + attr_reader :request_client + + # @param request_client [AsyncRequestClient] + # @return [AsyncFooClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param optional_string [Foo::OPTIONAL_STRING] - # @param public_property [String] - # @param private_property [Integer] - # @param request_options [RequestOptions] - # @return [Foo::ImportingType] - def find(optional_string:, public_property: nil, private_property: nil, request_options: nil) + # @param optional_string [Foo::OPTIONAL_STRING] + # @param public_property [String] + # @param private_property [Integer] + # @param request_options [RequestOptions] + # @return [Foo::ImportingType] + def find(optional_string:, public_property: nil, private_property: nil, request_options: nil) + Async do response = @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "optionalString": optional_string }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "optionalString": optional_string + }.compact req.body = { - **request_options&.additional_body_parameters, + **(request_options&.additional_body_parameters || {}), publicProperty: public_property, privateProperty: private_property }.compact end - Foo::ImportingType.from_json(json_object: response) - end - end - - class AsyncFooClient - attr_reader :request_client - - # @param request_client [AsyncRequestClient] - # @return [AsyncFooClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - - # @param optional_string [Foo::OPTIONAL_STRING] - # @param public_property [String] - # @param private_property [Integer] - # @param request_options [RequestOptions] - # @return [Foo::ImportingType] - def find(optional_string:, public_property: nil, private_property: nil, request_options: nil) - Async.call do - response = @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "optionalString": optional_string }.compact - req.body = { - **request_options&.additional_body_parameters, - publicProperty: public_property, - privateProperty: private_property - }.compact - end - Foo::ImportingType.from_json(json_object: response) - end + Foo::ImportingType.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/audiences/lib/types_export.rb b/seed/ruby-sdk/audiences/lib/types_export.rb new file mode 100644 index 00000000000..fe375717abb --- /dev/null +++ b/seed/ruby-sdk/audiences/lib/types_export.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require_relative "seed_audiences_client/commons/types/imported" +require_relative "seed_audiences_client/folder_a/service/types/response" +require_relative "seed_audiences_client/folder_b/common/types/foo" +require_relative "seed_audiences_client/folder_c/common/types/foo" +require_relative "seed_audiences_client/foo/types/importing_type" +require_relative "seed_audiences_client/foo/types/optional_string" +require_relative "seed_audiences_client/foo/types/filtered_type" diff --git a/seed/ruby-sdk/audiences/seed_audiences_client.gemspec b/seed/ruby-sdk/audiences/seed_audiences_client.gemspec index 8ac7509155c..d9804f6f240 100644 --- a/seed/ruby-sdk/audiences/seed_audiences_client.gemspec +++ b/seed/ruby-sdk/audiences/seed_audiences_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_audiences_client" + spec.version = SeedAudiencesClient::Gemconfig::VERSION spec.authors = SeedAudiencesClient::Gemconfig::AUTHORS spec.email = SeedAudiencesClient::Gemconfig::EMAIL spec.summary = SeedAudiencesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/auth-environment-variables/.rubocop.yml b/seed/ruby-sdk/auth-environment-variables/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/auth-environment-variables/.rubocop.yml +++ b/seed/ruby-sdk/auth-environment-variables/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/auth-environment-variables/lib/gemconfig.rb b/seed/ruby-sdk/auth-environment-variables/lib/gemconfig.rb index d6e2db31dd5..624288e2221 100644 --- a/seed/ruby-sdk/auth-environment-variables/lib/gemconfig.rb +++ b/seed/ruby-sdk/auth-environment-variables/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedAuthEnvironmentVariablesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/auth-environment-variables/lib/requests.rb b/seed/ruby-sdk/auth-environment-variables/lib/requests.rb index 87b9c22324b..0b06b41ab11 100644 --- a/seed/ruby-sdk/auth-environment-variables/lib/requests.rb +++ b/seed/ruby-sdk/auth-environment-variables/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedAuthEnvironmentVariablesClient class RequestClient @@ -11,17 +12,17 @@ class RequestClient # @param timeout_in_seconds [Long] # @param api_key [String] # @return [RequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) + def initialize(api_key:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedAuthEnvironmentVariablesClient", - "X-FERN-API-KEY": %( #{api_key.to_json || ENV["FERN_API_KEY"]}) + "X-FERN-API-KEY": (api_key || ENV["FERN_API_KEY"]).to_s } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -33,37 +34,35 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param api_key [String] # @return [AsyncRequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) + def initialize(api_key:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedAuthEnvironmentVariablesClient", - "X-FERN-API-KEY": %( #{api_key.to_json || ENV["FERN_API_KEY"]}) + "X-FERN-API-KEY": (api_key || ENV["FERN_API_KEY"]).to_s } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :api_key, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :api_key, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param api_key [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(api_key:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(api_key: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @api_key = api_key # @type [Hash{String => Object}] @@ -72,6 +71,8 @@ def initialize(api_key:, timeout_in_seconds: nil, additional_headers: nil, addit @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/auth-environment-variables/lib/seed_auth_environment_variables_client.rb b/seed/ruby-sdk/auth-environment-variables/lib/seed_auth_environment_variables_client.rb index ccd6d63850b..55c9190ae19 100644 --- a/seed/ruby-sdk/auth-environment-variables/lib/seed_auth_environment_variables_client.rb +++ b/seed/ruby-sdk/auth-environment-variables/lib/seed_auth_environment_variables_client.rb @@ -1,29 +1,35 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_auth_environment_variables_client/service/client" -require "async/http/faraday" module SeedAuthEnvironmentVariablesClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param api_key [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + # @return [Client] + def initialize(api_key:, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + api_key: api_key) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param api_key [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(api_key:, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + api_key: api_key) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/auth-environment-variables/lib/seed_auth_environment_variables_client/service/client.rb b/seed/ruby-sdk/auth-environment-variables/lib/seed_auth_environment_variables_client/service/client.rb index 032d0813f36..2850db7b2d3 100644 --- a/seed/ruby-sdk/auth-environment-variables/lib/seed_auth_environment_variables_client/service/client.rb +++ b/seed/ruby-sdk/auth-environment-variables/lib/seed_auth_environment_variables_client/service/client.rb @@ -1,51 +1,55 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedAuthEnvironmentVariablesClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_with_api_key(request_options: nil) - @request_client.conn.get("/apiKey") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-FERN-API-KEY"] = @request_client.api_key if @request_client.api_key.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # GET request with custom api key + # + # @param request_options [RequestOptions] + # @return [String] + def get_with_api_key(request_options: nil) + response = @request_client.conn.get("/apiKey") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-FERN-API-KEY"] = request_options.api_key unless request_options&.api_key.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_with_api_key(request_options: nil) - Async.call do - response = @request_client.conn.get("/apiKey") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-FERN-API-KEY"] = @request_client.api_key if @request_client.api_key.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # GET request with custom api key + # + # @param request_options [RequestOptions] + # @return [String] + def get_with_api_key(request_options: nil) + Async do + response = @request_client.conn.get("/apiKey") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-FERN-API-KEY"] = request_options.api_key unless request_options&.api_key.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/auth-environment-variables/lib/types_export.rb b/seed/ruby-sdk/auth-environment-variables/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/auth-environment-variables/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/auth-environment-variables/seed_auth_environment_variables_client.gemspec b/seed/ruby-sdk/auth-environment-variables/seed_auth_environment_variables_client.gemspec index ad6fb0e6c39..1a74ecef95e 100644 --- a/seed/ruby-sdk/auth-environment-variables/seed_auth_environment_variables_client.gemspec +++ b/seed/ruby-sdk/auth-environment-variables/seed_auth_environment_variables_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_auth_environment_variables_client" + spec.version = SeedAuthEnvironmentVariablesClient::Gemconfig::VERSION spec.authors = SeedAuthEnvironmentVariablesClient::Gemconfig::AUTHORS spec.email = SeedAuthEnvironmentVariablesClient::Gemconfig::EMAIL spec.summary = SeedAuthEnvironmentVariablesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/basic-auth/.rubocop.yml b/seed/ruby-sdk/basic-auth/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/basic-auth/.rubocop.yml +++ b/seed/ruby-sdk/basic-auth/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/basic-auth/lib/gemconfig.rb b/seed/ruby-sdk/basic-auth/lib/gemconfig.rb index e99b2e23c46..e8c8e98a635 100644 --- a/seed/ruby-sdk/basic-auth/lib/gemconfig.rb +++ b/seed/ruby-sdk/basic-auth/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedBasicAuthClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/basic-auth/lib/requests.rb b/seed/ruby-sdk/basic-auth/lib/requests.rb index 8418e28659c..f28ee66b9fc 100644 --- a/seed/ruby-sdk/basic-auth/lib/requests.rb +++ b/seed/ruby-sdk/basic-auth/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedBasicAuthClient class RequestClient @@ -12,7 +13,7 @@ class RequestClient # @param username [String] # @param password [String] # @return [RequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, username: nil, password: nil) + def initialize(username:, password:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedBasicAuthClient", @@ -20,9 +21,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, username: nil, passwor } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -35,7 +36,7 @@ class AsyncRequestClient # @param username [String] # @param password [String] # @return [AsyncRequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, username: nil, password: nil) + def initialize(username:, password:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedBasicAuthClient", @@ -43,30 +44,28 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, username: nil, passwor } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :username, :password, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :username, :password, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param username [String] # @param password [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(username:, password:, timeout_in_seconds: nil, additional_headers: nil, - additional_query_parameters: nil, additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(username: nil, password: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @username = username # @type [String] @@ -77,6 +76,8 @@ def initialize(username:, password:, timeout_in_seconds: nil, additional_headers @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/basic-auth/lib/seed_basic_auth_client.rb b/seed/ruby-sdk/basic-auth/lib/seed_basic_auth_client.rb index 4574aa059fd..1816c94c5ee 100644 --- a/seed/ruby-sdk/basic-auth/lib/seed_basic_auth_client.rb +++ b/seed/ruby-sdk/basic-auth/lib/seed_basic_auth_client.rb @@ -1,32 +1,37 @@ # frozen_string_literal: true -require_relative "seed_basic_auth_client/errors/types/unauthorized_request_error_body" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_basic_auth_client/basic_auth/client" -require "async/http/faraday" module SeedBasicAuthClient class Client + attr_reader :basic_auth + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param username [String] # @param password [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, username: nil, password: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @basic_auth_client = BasicAuthClient.initialize(request_client: request_client) + # @return [Client] + def initialize(username:, password:, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + username: username, password: password) + @basic_auth = BasicAuthClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :basic_auth + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param username [String] # @param password [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, username: nil, password: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_basic_auth_client = AsyncBasicAuthClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(username:, password:, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + username: username, password: password) + @basic_auth = AsyncBasicAuthClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/basic-auth/lib/seed_basic_auth_client/basic_auth/client.rb b/seed/ruby-sdk/basic-auth/lib/seed_basic_auth_client/basic_auth/client.rb index 5795a4efcac..8504e0cde45 100644 --- a/seed/ruby-sdk/basic-auth/lib/seed_basic_auth_client/basic_auth/client.rb +++ b/seed/ruby-sdk/basic-auth/lib/seed_basic_auth_client/basic_auth/client.rb @@ -1,82 +1,91 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedBasicAuthClient - module BasicAuth - class BasicAuthClient - attr_reader :request_client + class BasicAuthClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [BasicAuthClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [BasicAuthClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Boolean] - def get_with_basic_auth(request_options: nil) - @request_client.conn.get("/basic-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["username"] = @request_client.username if @request_client.username.nil? - req.headers["password"] = @request_client.password if @request_client.password.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # GET request with basic auth scheme + # + # @param request_options [RequestOptions] + # @return [Boolean] + def get_with_basic_auth(request_options: nil) + response = @request_client.conn.get("/basic-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["username"] = request_options.username unless request_options&.username.nil? + req.headers["password"] = request_options.password unless request_options&.password.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Boolean] - def post_with_basic_auth(request:, request_options: nil) - @request_client.conn.post("/basic-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["username"] = @request_client.username if @request_client.username.nil? - req.headers["password"] = @request_client.password if @request_client.password.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # POST request with basic auth scheme + # + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Boolean] + def post_with_basic_auth(request:, request_options: nil) + response = @request_client.conn.post("/basic-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["username"] = request_options.username unless request_options&.username.nil? + req.headers["password"] = request_options.password unless request_options&.password.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - class AsyncBasicAuthClient - attr_reader :request_client + class AsyncBasicAuthClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncBasicAuthClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncBasicAuthClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Boolean] - def get_with_basic_auth(request_options: nil) - Async.call do - response = @request_client.conn.get("/basic-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["username"] = @request_client.username if @request_client.username.nil? - req.headers["password"] = @request_client.password if @request_client.password.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # GET request with basic auth scheme + # + # @param request_options [RequestOptions] + # @return [Boolean] + def get_with_basic_auth(request_options: nil) + Async do + response = @request_client.conn.get("/basic-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["username"] = request_options.username unless request_options&.username.nil? + req.headers["password"] = request_options.password unless request_options&.password.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Boolean] - def post_with_basic_auth(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/basic-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["username"] = @request_client.username if @request_client.username.nil? - req.headers["password"] = @request_client.password if @request_client.password.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # POST request with basic auth scheme + # + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Boolean] + def post_with_basic_auth(request:, request_options: nil) + Async do + response = @request_client.conn.post("/basic-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["username"] = request_options.username unless request_options&.username.nil? + req.headers["password"] = request_options.password unless request_options&.password.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/basic-auth/lib/types_export.rb b/seed/ruby-sdk/basic-auth/lib/types_export.rb new file mode 100644 index 00000000000..780d9ae3a84 --- /dev/null +++ b/seed/ruby-sdk/basic-auth/lib/types_export.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "seed_basic_auth_client/errors/types/unauthorized_request_error_body" diff --git a/seed/ruby-sdk/basic-auth/seed_basic_auth_client.gemspec b/seed/ruby-sdk/basic-auth/seed_basic_auth_client.gemspec index 0ad723c6ff6..1f9e11e9c99 100644 --- a/seed/ruby-sdk/basic-auth/seed_basic_auth_client.gemspec +++ b/seed/ruby-sdk/basic-auth/seed_basic_auth_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_basic_auth_client" + spec.version = SeedBasicAuthClient::Gemconfig::VERSION spec.authors = SeedBasicAuthClient::Gemconfig::AUTHORS spec.email = SeedBasicAuthClient::Gemconfig::EMAIL spec.summary = SeedBasicAuthClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/bearer-token-environment-variable/.rubocop.yml b/seed/ruby-sdk/bearer-token-environment-variable/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/bearer-token-environment-variable/.rubocop.yml +++ b/seed/ruby-sdk/bearer-token-environment-variable/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/bearer-token-environment-variable/lib/gemconfig.rb b/seed/ruby-sdk/bearer-token-environment-variable/lib/gemconfig.rb index c341ff69285..b2060c7d99c 100644 --- a/seed/ruby-sdk/bearer-token-environment-variable/lib/gemconfig.rb +++ b/seed/ruby-sdk/bearer-token-environment-variable/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedBearerTokenEnvironmentVariableClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/bearer-token-environment-variable/lib/requests.rb b/seed/ruby-sdk/bearer-token-environment-variable/lib/requests.rb index aab90f33c1f..836522d7ae1 100644 --- a/seed/ruby-sdk/bearer-token-environment-variable/lib/requests.rb +++ b/seed/ruby-sdk/bearer-token-environment-variable/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedBearerTokenEnvironmentVariableClient class RequestClient @@ -11,7 +12,7 @@ class RequestClient # @param timeout_in_seconds [Long] # @param api_key [String] # @return [RequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) + def initialize(api_key:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedBearerTokenEnvironmentVariableClient", @@ -19,9 +20,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -33,7 +34,7 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param api_key [String] # @return [AsyncRequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) + def initialize(api_key:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedBearerTokenEnvironmentVariableClient", @@ -41,29 +42,27 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :api_key, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :api_key, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param api_key [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(api_key:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(api_key: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @api_key = api_key # @type [Hash{String => Object}] @@ -72,6 +71,8 @@ def initialize(api_key:, timeout_in_seconds: nil, additional_headers: nil, addit @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/bearer-token-environment-variable/lib/seed_bearer_token_environment_variable_client.rb b/seed/ruby-sdk/bearer-token-environment-variable/lib/seed_bearer_token_environment_variable_client.rb index 11f9e740d93..85c021fbadf 100644 --- a/seed/ruby-sdk/bearer-token-environment-variable/lib/seed_bearer_token_environment_variable_client.rb +++ b/seed/ruby-sdk/bearer-token-environment-variable/lib/seed_bearer_token_environment_variable_client.rb @@ -1,29 +1,35 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_bearer_token_environment_variable_client/service/client" -require "async/http/faraday" module SeedBearerTokenEnvironmentVariableClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param api_key [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + # @return [Client] + def initialize(api_key:, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + api_key: api_key) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param api_key [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, api_key: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(api_key:, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + api_key: api_key) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/bearer-token-environment-variable/lib/seed_bearer_token_environment_variable_client/service/client.rb b/seed/ruby-sdk/bearer-token-environment-variable/lib/seed_bearer_token_environment_variable_client/service/client.rb index 009af53a29c..2fb01cb3921 100644 --- a/seed/ruby-sdk/bearer-token-environment-variable/lib/seed_bearer_token_environment_variable_client/service/client.rb +++ b/seed/ruby-sdk/bearer-token-environment-variable/lib/seed_bearer_token_environment_variable_client/service/client.rb @@ -1,51 +1,55 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedBearerTokenEnvironmentVariableClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_with_bearer_token(request_options: nil) - @request_client.conn.get("/apiKey") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.api_key if @request_client.api_key.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # GET request with custom api key + # + # @param request_options [RequestOptions] + # @return [String] + def get_with_bearer_token(request_options: nil) + response = @request_client.conn.get("/apiKey") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_with_bearer_token(request_options: nil) - Async.call do - response = @request_client.conn.get("/apiKey") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.api_key if @request_client.api_key.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # GET request with custom api key + # + # @param request_options [RequestOptions] + # @return [String] + def get_with_bearer_token(request_options: nil) + Async do + response = @request_client.conn.get("/apiKey") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/bearer-token-environment-variable/lib/types_export.rb b/seed/ruby-sdk/bearer-token-environment-variable/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/bearer-token-environment-variable/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/bearer-token-environment-variable/seed_bearer_token_environment_variable_client.gemspec b/seed/ruby-sdk/bearer-token-environment-variable/seed_bearer_token_environment_variable_client.gemspec index ac4a5d3a1c6..478c9fe18b5 100644 --- a/seed/ruby-sdk/bearer-token-environment-variable/seed_bearer_token_environment_variable_client.gemspec +++ b/seed/ruby-sdk/bearer-token-environment-variable/seed_bearer_token_environment_variable_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_bearer_token_environment_variable_client" + spec.version = SeedBearerTokenEnvironmentVariableClient::Gemconfig::VERSION spec.authors = SeedBearerTokenEnvironmentVariableClient::Gemconfig::AUTHORS spec.email = SeedBearerTokenEnvironmentVariableClient::Gemconfig::EMAIL spec.summary = SeedBearerTokenEnvironmentVariableClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/bytes/.rubocop.yml b/seed/ruby-sdk/bytes/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/bytes/.rubocop.yml +++ b/seed/ruby-sdk/bytes/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/bytes/lib/gemconfig.rb b/seed/ruby-sdk/bytes/lib/gemconfig.rb index e472d03dc9f..db2ae89f0d5 100644 --- a/seed/ruby-sdk/bytes/lib/gemconfig.rb +++ b/seed/ruby-sdk/bytes/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedBytesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/bytes/lib/requests.rb b/seed/ruby-sdk/bytes/lib/requests.rb index 7450afd41b4..42ab051eddc 100644 --- a/seed/ruby-sdk/bytes/lib/requests.rb +++ b/seed/ruby-sdk/bytes/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedBytesClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedBytesClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedBytesClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/bytes/lib/seed_bytes_client.rb b/seed/ruby-sdk/bytes/lib/seed_bytes_client.rb index 7cc8306ee18..48ed26853e2 100644 --- a/seed/ruby-sdk/bytes/lib/seed_bytes_client.rb +++ b/seed/ruby-sdk/bytes/lib/seed_bytes_client.rb @@ -1,27 +1,31 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_bytes_client/service/client" -require "async/http/faraday" module SeedBytesClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/bytes/lib/seed_bytes_client/service/client.rb b/seed/ruby-sdk/bytes/lib/seed_bytes_client/service/client.rb index 9fae05fe37d..aa59836dc72 100644 --- a/seed/ruby-sdk/bytes/lib/seed_bytes_client/service/client.rb +++ b/seed/ruby-sdk/bytes/lib/seed_bytes_client/service/client.rb @@ -1,53 +1,52 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedBytesClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [String] Base64 encoded bytes - # @param request_options [RequestOptions] - # @return [Void] - def upload(request:, request_options: nil) - @request_client.conn.post("/upload-content") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.headers["Content-Type"] = "application/octet-stream" - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [String] Base64 encoded bytes + # @param request_options [RequestOptions] + # @return [Void] + def upload(request:, request_options: nil) + @request_client.conn.post("/upload-content") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.headers["Content-Type"] = "application/octet-stream" + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [String] Base64 encoded bytes - # @param request_options [RequestOptions] - # @return [Void] - def upload(request:, request_options: nil) - Async.call do - @request_client.conn.post("/upload-content") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.headers["Content-Type"] = "application/octet-stream" - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [String] Base64 encoded bytes + # @param request_options [RequestOptions] + # @return [Void] + def upload(request:, request_options: nil) + Async do + @request_client.conn.post("/upload-content") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.headers["Content-Type"] = "application/octet-stream" + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end end diff --git a/seed/ruby-sdk/bytes/lib/types_export.rb b/seed/ruby-sdk/bytes/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/bytes/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/bytes/seed_bytes_client.gemspec b/seed/ruby-sdk/bytes/seed_bytes_client.gemspec index 9aca1dec3ff..3521f251878 100644 --- a/seed/ruby-sdk/bytes/seed_bytes_client.gemspec +++ b/seed/ruby-sdk/bytes/seed_bytes_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_bytes_client" + spec.version = SeedBytesClient::Gemconfig::VERSION spec.authors = SeedBytesClient::Gemconfig::AUTHORS spec.email = SeedBytesClient::Gemconfig::EMAIL spec.summary = SeedBytesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/circular-references/.rubocop.yml b/seed/ruby-sdk/circular-references/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/circular-references/.rubocop.yml +++ b/seed/ruby-sdk/circular-references/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/circular-references/lib/gemconfig.rb b/seed/ruby-sdk/circular-references/lib/gemconfig.rb index ca0b8ab5623..b4c1f83d5b0 100644 --- a/seed/ruby-sdk/circular-references/lib/gemconfig.rb +++ b/seed/ruby-sdk/circular-references/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/circular-references/lib/requests.rb b/seed/ruby-sdk/circular-references/lib/requests.rb index b8292bba0f6..9317fb201a2 100644 --- a/seed/ruby-sdk/circular-references/lib/requests.rb +++ b/seed/ruby-sdk/circular-references/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedApiClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedApiClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedApiClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/circular-references/lib/seed_api_client.rb b/seed/ruby-sdk/circular-references/lib/seed_api_client.rb index 25b115388b1..af0df6f0649 100644 --- a/seed/ruby-sdk/circular-references/lib/seed_api_client.rb +++ b/seed/ruby-sdk/circular-references/lib/seed_api_client.rb @@ -1,30 +1,24 @@ # frozen_string_literal: true -require_relative "seed_api_client/a/types/a" -require_relative "seed_api_client/ast/types/container_value" -require_relative "seed_api_client/ast/types/field_value" -require_relative "seed_api_client/ast/types/object_value" -require_relative "seed_api_client/types/importing_a" -require_relative "seed_api_client/types/root_type" -require "async/http/faraday" -require "faraday" +require_relative "types_export" +require_relative "requests" module SeedApiClient class Client # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end class AsyncClient # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end end diff --git a/seed/ruby-sdk/circular-references/lib/seed_api_client/ast/types/field_value.rb b/seed/ruby-sdk/circular-references/lib/seed_api_client/ast/types/field_value.rb index 3298b28a712..f926e5db520 100644 --- a/seed/ruby-sdk/circular-references/lib/seed_api_client/ast/types/field_value.rb +++ b/seed/ruby-sdk/circular-references/lib/seed_api_client/ast/types/field_value.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true require "json" -require_relative "container_value" +require_relative "primitive_value" require_relative "object_value" +require_relative "container_value" module SeedApiClient module Ast @@ -29,13 +30,13 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "primitive_value" - PRIMITIVE_VALUE.key(json_object.value) + Ast::PRIMITIVE_VALUE.key(json_object.value) || json_object.value when "object_value" Ast::ObjectValue.from_json(json_object: json_object) when "container_value" Ast::ContainerValue.from_json(json_object: json_object.value) else - PRIMITIVE_VALUE.key(json_object) + Ast::PRIMITIVE_VALUE.key(json_object) || json_object end new(member: member, discriminant: struct.type) end @@ -64,7 +65,7 @@ def to_json(*_args) def self.validate_raw(obj:) case obj.type when "primitive_value" - obj.is_a?(PRIMITIVE_VALUE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Ast::PRIMITIVE_VALUE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "object_value" Ast::ObjectValue.validate_raw(obj: obj) when "container_value" @@ -82,7 +83,7 @@ def is_a?(obj) @member.is_a?(obj) end - # @param member [Hash{String => String}] + # @param member [PRIMITIVE_VALUE] # @return [Ast::FieldValue] def self.primitive_value(member:) new(member: member, discriminant: "primitive_value") diff --git a/seed/ruby-sdk/circular-references/lib/seed_api_client/ast/types/primitive_value.rb b/seed/ruby-sdk/circular-references/lib/seed_api_client/ast/types/primitive_value.rb index 1b1affb4f0a..37de347e0a2 100644 --- a/seed/ruby-sdk/circular-references/lib/seed_api_client/ast/types/primitive_value.rb +++ b/seed/ruby-sdk/circular-references/lib/seed_api_client/ast/types/primitive_value.rb @@ -2,7 +2,7 @@ module SeedApiClient module Ast - # @type [Hash{String => String}] - PRIMITIVE_VALUE = { string: "STRING", number: "NUMBER" }.frozen + # @type [PRIMITIVE_VALUE] + PRIMITIVE_VALUE = { string: "STRING", number: "NUMBER" }.freeze end end diff --git a/seed/ruby-sdk/circular-references/lib/seed_api_client/types/importing_a.rb b/seed/ruby-sdk/circular-references/lib/seed_api_client/types/importing_a.rb index 871bf022714..8fbb1b6f12c 100644 --- a/seed/ruby-sdk/circular-references/lib/seed_api_client/types/importing_a.rb +++ b/seed/ruby-sdk/circular-references/lib/seed_api_client/types/importing_a.rb @@ -23,7 +23,8 @@ def initialize(a: nil, additional_properties: nil) # @return [ImportingA] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - a = struct.a + a = struct.a.to_h.to_json + a = A::A.from_json(json_object: a) new(a: a, additional_properties: struct) end diff --git a/seed/ruby-sdk/circular-references/lib/types_export.rb b/seed/ruby-sdk/circular-references/lib/types_export.rb new file mode 100644 index 00000000000..1d71cd54d35 --- /dev/null +++ b/seed/ruby-sdk/circular-references/lib/types_export.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require_relative "seed_api_client/types/importing_a" +require_relative "seed_api_client/types/root_type" +require_relative "seed_api_client/a/types/a" +require_relative "seed_api_client/ast/types/field_value" +require_relative "seed_api_client/ast/types/container_value" +require_relative "seed_api_client/ast/types/primitive_value" +require_relative "seed_api_client/ast/types/object_value" diff --git a/seed/ruby-sdk/circular-references/seed_api_client.gemspec b/seed/ruby-sdk/circular-references/seed_api_client.gemspec index e3108090020..f2bc0cddd0a 100644 --- a/seed/ruby-sdk/circular-references/seed_api_client.gemspec +++ b/seed/ruby-sdk/circular-references/seed_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_client" + spec.version = SeedApiClient::Gemconfig::VERSION spec.authors = SeedApiClient::Gemconfig::AUTHORS spec.email = SeedApiClient::Gemconfig::EMAIL spec.summary = SeedApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/custom-auth/.rubocop.yml b/seed/ruby-sdk/custom-auth/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/custom-auth/.rubocop.yml +++ b/seed/ruby-sdk/custom-auth/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/custom-auth/lib/gemconfig.rb b/seed/ruby-sdk/custom-auth/lib/gemconfig.rb index 11aad45bca6..52ab11a736c 100644 --- a/seed/ruby-sdk/custom-auth/lib/gemconfig.rb +++ b/seed/ruby-sdk/custom-auth/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedCustomAuthClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/custom-auth/lib/requests.rb b/seed/ruby-sdk/custom-auth/lib/requests.rb index d6f7cecb5d6..84313f00a2b 100644 --- a/seed/ruby-sdk/custom-auth/lib/requests.rb +++ b/seed/ruby-sdk/custom-auth/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedCustomAuthClient class RequestClient @@ -11,17 +12,17 @@ class RequestClient # @param timeout_in_seconds [Long] # @param custom_auth_scheme [String] # @return [RequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, custom_auth_scheme: nil) + def initialize(custom_auth_scheme:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedCustomAuthClient", - "X-API-KEY": " #{custom_auth_scheme.to_json}" + "X-API-KEY": custom_auth_scheme.to_s } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -33,37 +34,35 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param custom_auth_scheme [String] # @return [AsyncRequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, custom_auth_scheme: nil) + def initialize(custom_auth_scheme:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedCustomAuthClient", - "X-API-KEY": " #{custom_auth_scheme.to_json}" + "X-API-KEY": custom_auth_scheme.to_s } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :custom_auth_scheme, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :custom_auth_scheme, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param custom_auth_scheme [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(custom_auth_scheme:, timeout_in_seconds: nil, additional_headers: nil, - additional_query_parameters: nil, additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(custom_auth_scheme: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @custom_auth_scheme = custom_auth_scheme # @type [Hash{String => Object}] @@ -72,6 +71,8 @@ def initialize(custom_auth_scheme:, timeout_in_seconds: nil, additional_headers: @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/custom-auth/lib/seed_custom_auth_client.rb b/seed/ruby-sdk/custom-auth/lib/seed_custom_auth_client.rb index c622ae305b0..af924972d01 100644 --- a/seed/ruby-sdk/custom-auth/lib/seed_custom_auth_client.rb +++ b/seed/ruby-sdk/custom-auth/lib/seed_custom_auth_client.rb @@ -1,30 +1,35 @@ # frozen_string_literal: true -require_relative "seed_custom_auth_client/errors/types/unauthorized_request_error_body" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_custom_auth_client/custom_auth/client" -require "async/http/faraday" module SeedCustomAuthClient class Client + attr_reader :custom_auth + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param custom_auth_scheme [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, custom_auth_scheme: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @custom_auth_client = CustomAuthClient.initialize(request_client: request_client) + # @return [Client] + def initialize(custom_auth_scheme:, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + custom_auth_scheme: custom_auth_scheme) + @custom_auth = CustomAuthClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :custom_auth + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param custom_auth_scheme [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, custom_auth_scheme: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_custom_auth_client = AsyncCustomAuthClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(custom_auth_scheme:, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + custom_auth_scheme: custom_auth_scheme) + @custom_auth = AsyncCustomAuthClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/custom-auth/lib/seed_custom_auth_client/custom_auth/client.rb b/seed/ruby-sdk/custom-auth/lib/seed_custom_auth_client/custom_auth/client.rb index a628d76ecb1..3efe1b5aef6 100644 --- a/seed/ruby-sdk/custom-auth/lib/seed_custom_auth_client/custom_auth/client.rb +++ b/seed/ruby-sdk/custom-auth/lib/seed_custom_auth_client/custom_auth/client.rb @@ -1,78 +1,87 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedCustomAuthClient - module CustomAuth - class CustomAuthClient - attr_reader :request_client + class CustomAuthClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [CustomAuthClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [CustomAuthClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Boolean] - def get_with_custom_auth(request_options: nil) - @request_client.conn.get("/custom-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-KEY"] = @request_client.custom_auth_scheme if @request_client.custom_auth_scheme.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # GET request with custom auth scheme + # + # @param request_options [RequestOptions] + # @return [Boolean] + def get_with_custom_auth(request_options: nil) + response = @request_client.conn.get("/custom-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-KEY"] = request_options.custom_auth_scheme unless request_options&.custom_auth_scheme.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Boolean] - def post_with_custom_auth(request:, request_options: nil) - @request_client.conn.post("/custom-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-KEY"] = @request_client.custom_auth_scheme if @request_client.custom_auth_scheme.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # POST request with custom auth scheme + # + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Boolean] + def post_with_custom_auth(request:, request_options: nil) + response = @request_client.conn.post("/custom-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-KEY"] = request_options.custom_auth_scheme unless request_options&.custom_auth_scheme.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - class AsyncCustomAuthClient - attr_reader :request_client + class AsyncCustomAuthClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncCustomAuthClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncCustomAuthClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Boolean] - def get_with_custom_auth(request_options: nil) - Async.call do - response = @request_client.conn.get("/custom-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-KEY"] = @request_client.custom_auth_scheme if @request_client.custom_auth_scheme.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # GET request with custom auth scheme + # + # @param request_options [RequestOptions] + # @return [Boolean] + def get_with_custom_auth(request_options: nil) + Async do + response = @request_client.conn.get("/custom-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-KEY"] = request_options.custom_auth_scheme unless request_options&.custom_auth_scheme.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Boolean] - def post_with_custom_auth(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/custom-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-KEY"] = @request_client.custom_auth_scheme if @request_client.custom_auth_scheme.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # POST request with custom auth scheme + # + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Boolean] + def post_with_custom_auth(request:, request_options: nil) + Async do + response = @request_client.conn.post("/custom-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-KEY"] = request_options.custom_auth_scheme unless request_options&.custom_auth_scheme.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/custom-auth/lib/types_export.rb b/seed/ruby-sdk/custom-auth/lib/types_export.rb new file mode 100644 index 00000000000..ab7c0f4b1e8 --- /dev/null +++ b/seed/ruby-sdk/custom-auth/lib/types_export.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "seed_custom_auth_client/errors/types/unauthorized_request_error_body" diff --git a/seed/ruby-sdk/custom-auth/seed_custom_auth_client.gemspec b/seed/ruby-sdk/custom-auth/seed_custom_auth_client.gemspec index 20c23d10ee0..3c1e5a1dd8c 100644 --- a/seed/ruby-sdk/custom-auth/seed_custom_auth_client.gemspec +++ b/seed/ruby-sdk/custom-auth/seed_custom_auth_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_custom_auth_client" + spec.version = SeedCustomAuthClient::Gemconfig::VERSION spec.authors = SeedCustomAuthClient::Gemconfig::AUTHORS spec.email = SeedCustomAuthClient::Gemconfig::EMAIL spec.summary = SeedCustomAuthClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/enum-query-params/lib/gemconfig.rb b/seed/ruby-sdk/enum-query-params/lib/gemconfig.rb index ca0b8ab5623..b4c1f83d5b0 100644 --- a/seed/ruby-sdk/enum-query-params/lib/gemconfig.rb +++ b/seed/ruby-sdk/enum-query-params/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/enum-query-params/lib/requests.rb b/seed/ruby-sdk/enum-query-params/lib/requests.rb index ab43de9c1b7..a651d2328b1 100644 --- a/seed/ruby-sdk/enum-query-params/lib/requests.rb +++ b/seed/ruby-sdk/enum-query-params/lib/requests.rb @@ -2,6 +2,7 @@ require "async/http/faraday" require "faraday" +require "faraday/retry" module SeedApiClient class RequestClient @@ -52,7 +53,7 @@ class RequestOptions # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, + def initialize(timeout_in_seconds: nil, token: nil, additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil) # @type [Long] @timeout_in_seconds = timeout_in_seconds diff --git a/seed/ruby-sdk/enum-query-params/lib/seed_api_client.rb b/seed/ruby-sdk/enum-query-params/lib/seed_api_client.rb index 229370a44c7..928efc05ec8 100644 --- a/seed/ruby-sdk/enum-query-params/lib/seed_api_client.rb +++ b/seed/ruby-sdk/enum-query-params/lib/seed_api_client.rb @@ -1,29 +1,35 @@ # frozen_string_literal: true +require_relative "requests" require "faraday" +require "faraday/retry" require_relative "seed_api_client/svc/client" require "async/http/faraday" module SeedApiClient class Client + attr_reader :svc_client + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @svc_client = SvcClient.initialize(request_client: request_client) + request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, token: token) + @svc_client = Svc::SvcClient.new(request_client: request_client) end end class AsyncClient + attr_reader :async_svc_client + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_svc_client = AsyncSvcClient.initialize(request_client: request_client) + AsyncRequestClient.new(headers: headers, base_url: base_url, conn: conn) + @async_svc_client = Svc::AsyncSvcClient.new(request_client: request_client) end end end diff --git a/seed/ruby-sdk/enum-query-params/lib/seed_api_client/svc/client.rb b/seed/ruby-sdk/enum-query-params/lib/seed_api_client/svc/client.rb index 6ec5dcd7ff0..7ad95df1e96 100644 --- a/seed/ruby-sdk/enum-query-params/lib/seed_api_client/svc/client.rb +++ b/seed/ruby-sdk/enum-query-params/lib/seed_api_client/svc/client.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedApiClient @@ -8,7 +9,7 @@ class SvcClient attr_reader :request_client # @param request_client [RequestClient] - # @return [SvcClient] + # @return [Svc::SvcClient] def initialize(request_client:) # @type [RequestClient] @request_client = request_client @@ -18,12 +19,13 @@ def initialize(request_client:) # @param request_options [RequestOptions] # @return [String] def test(some_enum: nil, request_options: nil) - @request_client.conn.get("/test") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? + response = @request_client.conn.get("/test") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? req.headers = { **req.headers, **request_options&.additional_headers }.compact req.params = { **request_options&.additional_query_parameters, "some-enum": some_enum }.compact end + response.body end end @@ -31,7 +33,7 @@ class AsyncSvcClient attr_reader :request_client # @param request_client [AsyncRequestClient] - # @return [AsyncSvcClient] + # @return [Svc::AsyncSvcClient] def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client @@ -43,12 +45,12 @@ def initialize(request_client:) def test(some_enum: nil, request_options: nil) Async.call do response = @request_client.conn.get("/test") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? req.headers = { **req.headers, **request_options&.additional_headers }.compact req.params = { **request_options&.additional_query_parameters, "some-enum": some_enum }.compact end - response + response.body end end end diff --git a/seed/ruby-sdk/enum-query-params/lib/seed_api_client/svc/types/my_enum.rb b/seed/ruby-sdk/enum-query-params/lib/seed_api_client/svc/types/my_enum.rb index 1cfe23d488d..8f0803139a1 100644 --- a/seed/ruby-sdk/enum-query-params/lib/seed_api_client/svc/types/my_enum.rb +++ b/seed/ruby-sdk/enum-query-params/lib/seed_api_client/svc/types/my_enum.rb @@ -3,6 +3,6 @@ module SeedApiClient module Svc # @type [Hash{String => String}] - MY_ENUM = { one: "one", two: "two", three: "three", four: "four" }.frozen + MY_ENUM = { one: "one", two: "two", three: "three", four: "four" }.freeze end end diff --git a/seed/ruby-sdk/enum-query-params/seed_api_client.gemspec b/seed/ruby-sdk/enum-query-params/seed_api_client.gemspec index e3108090020..f2bc0cddd0a 100644 --- a/seed/ruby-sdk/enum-query-params/seed_api_client.gemspec +++ b/seed/ruby-sdk/enum-query-params/seed_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_client" + spec.version = SeedApiClient::Gemconfig::VERSION spec.authors = SeedApiClient::Gemconfig::AUTHORS spec.email = SeedApiClient::Gemconfig::EMAIL spec.summary = SeedApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/enum/.rubocop.yml b/seed/ruby-sdk/enum/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/enum/.rubocop.yml +++ b/seed/ruby-sdk/enum/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/enum/lib/gemconfig.rb b/seed/ruby-sdk/enum/lib/gemconfig.rb index 5658239e1c3..a615fe6448a 100644 --- a/seed/ruby-sdk/enum/lib/gemconfig.rb +++ b/seed/ruby-sdk/enum/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedEnumClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/enum/lib/requests.rb b/seed/ruby-sdk/enum/lib/requests.rb index 79da6c152d0..7cebeb5161b 100644 --- a/seed/ruby-sdk/enum/lib/requests.rb +++ b/seed/ruby-sdk/enum/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedEnumClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedEnumClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedEnumClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/enum/lib/seed_enum_client.rb b/seed/ruby-sdk/enum/lib/seed_enum_client.rb index 572892b2203..2841d317d52 100644 --- a/seed/ruby-sdk/enum/lib/seed_enum_client.rb +++ b/seed/ruby-sdk/enum/lib/seed_enum_client.rb @@ -1,33 +1,37 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_enum_client/inlined_request/client" require_relative "seed_enum_client/path_param/client" require_relative "seed_enum_client/query_param/client" -require "async/http/faraday" module SeedEnumClient class Client + attr_reader :inlined_request, :path_param, :query_param + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @inlined_request_client = InlinedRequestClient.initialize(request_client: request_client) - @path_param_client = PathParamClient.initialize(request_client: request_client) - @query_param_client = QueryParamClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @inlined_request = InlinedRequestClient.new(request_client: @request_client) + @path_param = PathParamClient.new(request_client: @request_client) + @query_param = QueryParamClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :inlined_request, :path_param, :query_param + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_inlined_request_client = AsyncInlinedRequestClient.initialize(request_client: request_client) - @async_path_param_client = AsyncPathParamClient.initialize(request_client: request_client) - @async_query_param_client = AsyncQueryParamClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @inlined_request = AsyncInlinedRequestClient.new(request_client: @async_request_client) + @path_param = AsyncPathParamClient.new(request_client: @async_request_client) + @query_param = AsyncQueryParamClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/enum/lib/seed_enum_client/inlined_request/client.rb b/seed/ruby-sdk/enum/lib/seed_enum_client/inlined_request/client.rb index 62a02ac4cec..4008b6e304e 100644 --- a/seed/ruby-sdk/enum/lib/seed_enum_client/inlined_request/client.rb +++ b/seed/ruby-sdk/enum/lib/seed_enum_client/inlined_request/client.rb @@ -1,51 +1,51 @@ # frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/operand" require "async" module SeedEnumClient - module InlinedRequest - class InlinedRequestClient - attr_reader :request_client + class InlinedRequestClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [InlinedRequestClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [InlinedRequestClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param value [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Void] - def send(value: nil, request_options: nil) - @request_client.conn.post("/inlined-request") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, value: value }.compact - end + # @param value [OPERAND] + # @param request_options [RequestOptions] + # @return [Void] + def send(value: nil, request_options: nil) + @request_client.conn.post("/inlined-request") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), value: value }.compact end end + end - class AsyncInlinedRequestClient - attr_reader :request_client + class AsyncInlinedRequestClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncInlinedRequestClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncInlinedRequestClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param value [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Void] - def send(value: nil, request_options: nil) - Async.call do - @request_client.conn.post("/inlined-request") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, value: value }.compact - end + # @param value [OPERAND] + # @param request_options [RequestOptions] + # @return [Void] + def send(value: nil, request_options: nil) + Async do + @request_client.conn.post("/inlined-request") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), value: value }.compact end end end diff --git a/seed/ruby-sdk/enum/lib/seed_enum_client/path_param/client.rb b/seed/ruby-sdk/enum/lib/seed_enum_client/path_param/client.rb index 7a50a5ce80c..d63f2b8fe42 100644 --- a/seed/ruby-sdk/enum/lib/seed_enum_client/path_param/client.rb +++ b/seed/ruby-sdk/enum/lib/seed_enum_client/path_param/client.rb @@ -1,49 +1,49 @@ # frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/operand" require "async" module SeedEnumClient - module PathParam - class PathParamClient - attr_reader :request_client + class PathParamClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [PathParamClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [PathParamClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param value [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Void] - def send(value:, request_options: nil) - @request_client.conn.post("/path-param/#{value}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param value [OPERAND] + # @param request_options [RequestOptions] + # @return [Void] + def send(value:, request_options: nil) + @request_client.conn.post("/path-param/#{value}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - class AsyncPathParamClient - attr_reader :request_client + class AsyncPathParamClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncPathParamClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncPathParamClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param value [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Void] - def send(value:, request_options: nil) - Async.call do - @request_client.conn.post("/path-param/#{value}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param value [OPERAND] + # @param request_options [RequestOptions] + # @return [Void] + def send(value:, request_options: nil) + Async do + @request_client.conn.post("/path-param/#{value}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/enum/lib/seed_enum_client/query_param/client.rb b/seed/ruby-sdk/enum/lib/seed_enum_client/query_param/client.rb index 325c07bf395..fb892201962 100644 --- a/seed/ruby-sdk/enum/lib/seed_enum_client/query_param/client.rb +++ b/seed/ruby-sdk/enum/lib/seed_enum_client/query_param/client.rb @@ -1,75 +1,75 @@ # frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/operand" require "async" module SeedEnumClient - module QueryParam - class QueryParamClient - attr_reader :request_client + class QueryParamClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [QueryParamClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [QueryParamClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param value [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Void] - def send(value: nil, request_options: nil) - @request_client.conn.post("/query") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "value": value }.compact - end + # @param value [OPERAND] + # @param request_options [RequestOptions] + # @return [Void] + def send(value: nil, request_options: nil) + @request_client.conn.post("/query") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "value": value }.compact end + end - # @param value [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Void] - def send_list(value: nil, request_options: nil) - @request_client.conn.post("/query-list") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "value": value }.compact - end + # @param value [OPERAND] + # @param request_options [RequestOptions] + # @return [Void] + def send_list(value: nil, request_options: nil) + @request_client.conn.post("/query-list") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "value": value }.compact end end + end - class AsyncQueryParamClient - attr_reader :request_client + class AsyncQueryParamClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncQueryParamClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncQueryParamClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param value [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Void] - def send(value: nil, request_options: nil) - Async.call do - @request_client.conn.post("/query") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "value": value }.compact - end + # @param value [OPERAND] + # @param request_options [RequestOptions] + # @return [Void] + def send(value: nil, request_options: nil) + Async do + @request_client.conn.post("/query") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "value": value }.compact end end + end - # @param value [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Void] - def send_list(value: nil, request_options: nil) - Async.call do - @request_client.conn.post("/query-list") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "value": value }.compact - end + # @param value [OPERAND] + # @param request_options [RequestOptions] + # @return [Void] + def send_list(value: nil, request_options: nil) + Async do + @request_client.conn.post("/query-list") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "value": value }.compact end end end diff --git a/seed/ruby-sdk/enum/lib/seed_enum_client/types/operand.rb b/seed/ruby-sdk/enum/lib/seed_enum_client/types/operand.rb index 5045ea714d6..f0d518b621c 100644 --- a/seed/ruby-sdk/enum/lib/seed_enum_client/types/operand.rb +++ b/seed/ruby-sdk/enum/lib/seed_enum_client/types/operand.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true module SeedEnumClient - # @type [Hash{String => String}] - OPERAND = { greater_than: ">", equal_to: "=", less_than: "less_than" }.frozen + # @type [OPERAND] + OPERAND = { greater_than: ">", equal_to: "=", less_than: "less_than" }.freeze end diff --git a/seed/ruby-sdk/enum/lib/types_export.rb b/seed/ruby-sdk/enum/lib/types_export.rb new file mode 100644 index 00000000000..f257522c215 --- /dev/null +++ b/seed/ruby-sdk/enum/lib/types_export.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "seed_enum_client/types/operand" diff --git a/seed/ruby-sdk/enum/seed_enum_client.gemspec b/seed/ruby-sdk/enum/seed_enum_client.gemspec index 3f6b5af29bf..fd30df60984 100644 --- a/seed/ruby-sdk/enum/seed_enum_client.gemspec +++ b/seed/ruby-sdk/enum/seed_enum_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_enum_client" + spec.version = SeedEnumClient::Gemconfig::VERSION spec.authors = SeedEnumClient::Gemconfig::AUTHORS spec.email = SeedEnumClient::Gemconfig::EMAIL spec.summary = SeedEnumClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/error-property/.rubocop.yml b/seed/ruby-sdk/error-property/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/error-property/.rubocop.yml +++ b/seed/ruby-sdk/error-property/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/error-property/lib/gemconfig.rb b/seed/ruby-sdk/error-property/lib/gemconfig.rb index 12c8bedeac1..aee244ffbf4 100644 --- a/seed/ruby-sdk/error-property/lib/gemconfig.rb +++ b/seed/ruby-sdk/error-property/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedErrorPropertyClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/error-property/lib/requests.rb b/seed/ruby-sdk/error-property/lib/requests.rb index 701e9cd1cb6..a88e8cb5708 100644 --- a/seed/ruby-sdk/error-property/lib/requests.rb +++ b/seed/ruby-sdk/error-property/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedErrorPropertyClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedErrorPropertyClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedErrorPropertyClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/error-property/lib/seed_error_property_client.rb b/seed/ruby-sdk/error-property/lib/seed_error_property_client.rb index 1c4407cabc4..95aa50a4b52 100644 --- a/seed/ruby-sdk/error-property/lib/seed_error_property_client.rb +++ b/seed/ruby-sdk/error-property/lib/seed_error_property_client.rb @@ -1,28 +1,31 @@ # frozen_string_literal: true -require_relative "seed_error_property_client/errors/types/property_based_error_test_body" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_error_property_client/property_based_error/client" -require "async/http/faraday" module SeedErrorPropertyClient class Client + attr_reader :property_based_error + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @property_based_error_client = PropertyBasedErrorClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @property_based_error = PropertyBasedErrorClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :property_based_error + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_property_based_error_client = AsyncPropertyBasedErrorClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @property_based_error = AsyncPropertyBasedErrorClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/error-property/lib/seed_error_property_client/property_based_error/client.rb b/seed/ruby-sdk/error-property/lib/seed_error_property_client/property_based_error/client.rb index ad1ba28f1c8..1eb73c9ddf3 100644 --- a/seed/ruby-sdk/error-property/lib/seed_error_property_client/property_based_error/client.rb +++ b/seed/ruby-sdk/error-property/lib/seed_error_property_client/property_based_error/client.rb @@ -1,49 +1,53 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedErrorPropertyClient - module PropertyBasedError - class PropertyBasedErrorClient - attr_reader :request_client + class PropertyBasedErrorClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [PropertyBasedErrorClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [PropertyBasedErrorClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def throw_error(request_options: nil) - @request_client.conn.get("/property-based-error") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # GET request that always throws an error + # + # @param request_options [RequestOptions] + # @return [String] + def throw_error(request_options: nil) + response = @request_client.conn.get("/property-based-error") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncPropertyBasedErrorClient - attr_reader :request_client + class AsyncPropertyBasedErrorClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncPropertyBasedErrorClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncPropertyBasedErrorClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def throw_error(request_options: nil) - Async.call do - response = @request_client.conn.get("/property-based-error") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # GET request that always throws an error + # + # @param request_options [RequestOptions] + # @return [String] + def throw_error(request_options: nil) + Async do + response = @request_client.conn.get("/property-based-error") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/error-property/lib/types_export.rb b/seed/ruby-sdk/error-property/lib/types_export.rb new file mode 100644 index 00000000000..ddd0c5e98d2 --- /dev/null +++ b/seed/ruby-sdk/error-property/lib/types_export.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "seed_error_property_client/errors/types/property_based_error_test_body" diff --git a/seed/ruby-sdk/error-property/seed_error_property_client.gemspec b/seed/ruby-sdk/error-property/seed_error_property_client.gemspec index 57e466df7be..c5f5c9aa25f 100644 --- a/seed/ruby-sdk/error-property/seed_error_property_client.gemspec +++ b/seed/ruby-sdk/error-property/seed_error_property_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_error_property_client" + spec.version = SeedErrorPropertyClient::Gemconfig::VERSION spec.authors = SeedErrorPropertyClient::Gemconfig::AUTHORS spec.email = SeedErrorPropertyClient::Gemconfig::EMAIL spec.summary = SeedErrorPropertyClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/examples/.rubocop.yml b/seed/ruby-sdk/examples/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/examples/.rubocop.yml +++ b/seed/ruby-sdk/examples/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/examples/lib/gemconfig.rb b/seed/ruby-sdk/examples/lib/gemconfig.rb index 3096258f1bb..da9515ea405 100644 --- a/seed/ruby-sdk/examples/lib/gemconfig.rb +++ b/seed/ruby-sdk/examples/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedExamplesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/examples/lib/requests.rb b/seed/ruby-sdk/examples/lib/requests.rb index b9cf63e555a..483457c506c 100644 --- a/seed/ruby-sdk/examples/lib/requests.rb +++ b/seed/ruby-sdk/examples/lib/requests.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -require "async/http/faraday" +require_relative "environment" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedExamplesClient class RequestClient @@ -12,7 +14,7 @@ class RequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [RequestClient] - def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, environment: nil, max_retries: nil, timeout_in_seconds: nil) @default_environment = environment @base_url = environment @headers = { @@ -22,9 +24,9 @@ def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, toke } @conn = Faraday.new(@base_url, headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -37,7 +39,7 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [AsyncRequestClient] - def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, environment: nil, max_retries: nil, timeout_in_seconds: nil) @default_environment = environment @base_url = environment @headers = { @@ -47,29 +49,27 @@ def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, toke } @conn = Faraday.new(@base_url, headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [Hash{String => Object}] @@ -78,6 +78,8 @@ def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additio @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client.rb b/seed/ruby-sdk/examples/lib/seed_examples_client.rb index 1e647fa0295..5312a78d491 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client.rb @@ -1,90 +1,70 @@ # frozen_string_literal: true -require_relative "seed_examples_client/commons/types/types/metadata" - -require_relative "seed_examples_client/commons/types/types/data" -require_relative "seed_examples_client/commons/types/types/event_info" -require_relative "seed_examples_client/commons/types/types/tag" -require_relative "seed_examples_client/file/service/types/filename" -require_relative "seed_examples_client/types/types/actor" -require_relative "seed_examples_client/types/types/actress" -require_relative "seed_examples_client/types/types/cast_member" -require_relative "seed_examples_client/types/types/directory" -require_relative "seed_examples_client/types/types/exception" -require_relative "seed_examples_client/types/types/exception_info" -require_relative "seed_examples_client/types/types/extended_movie" -require_relative "seed_examples_client/types/types/file" -require_relative "seed_examples_client/types/types/metadata" -require_relative "seed_examples_client/types/types/migration" -require_relative "seed_examples_client/types/types/moment" -require_relative "seed_examples_client/types/types/movie" -require_relative "seed_examples_client/types/types/movie_id" -require_relative "seed_examples_client/types/types/node" -require_relative "seed_examples_client/types/types/request" -require_relative "seed_examples_client/types/types/response" -require_relative "seed_examples_client/types/types/stunt_double" -require_relative "seed_examples_client/types/types/test" -require_relative "seed_examples_client/types/types/tree" -require "faraday" -require_relative "seed_examples_client/file/notification/service/client" -require_relative "seed_examples_client/file/notificationclient" -require_relative "seed_examples_client/file/service/client" -require_relative "seed_examples_client/fileclient" -require_relative "seed_examples_client/health/service/client" -require_relative "seed_examples_client/healthclient" +require_relative "environment" +require_relative "types_export" +require_relative "requests" +require_relative "seed_examples_client/file/client" +require_relative "seed_examples_client/health/client" require_relative "seed_examples_client/service/client" -require "async/http/faraday" module SeedExamplesClient class Client + attr_reader :file, :health, :service + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @client = Client.initialize(request_client: request_client) - @client = Client.initialize(request_client: request_client) - @service_client = ServiceClient.initialize(request_client: request_client) + # @return [Client] + def initialize(token:, environment: nil, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(environment: environment, max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, token: token) + @file = File::Client.new(request_client: @request_client) + @health = Health::Client.new(request_client: @request_client) + @service = ServiceClient.new(request_client: @request_client) end # @param request [String] # @param request_options [RequestOptions] # @return [String] def echo(request:, request_options: nil) - request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = request_client.token if request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact + response = @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end class AsyncClient + attr_reader :file, :health, :service + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_client = AsyncClient.initialize(client: request_client) - @async_client = AsyncClient.initialize(client: request_client) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(token:, environment: nil, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, token: token) + @file = File::AsyncClient.new(request_client: @async_request_client) + @health = Health::AsyncClient.new(request_client: @async_request_client) + @service = AsyncServiceClient.new(request_client: @async_request_client) end # @param request [String] # @param request_options [RequestOptions] # @return [String] def echo(request:, request_options: nil) - request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = request_client.token if request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact + response = @async_request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/file/client.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/file/client.rb index 361944fe93d..965aa01583c 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/file/client.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/file/client.rb @@ -1,30 +1,26 @@ # frozen_string_literal: true -require_relative "notification/service/client" -require_relative "notificationclient" +require_relative "../../requests" +require_relative "notification/client" require_relative "service/client" module SeedExamplesClient module File class Client - attr_reader :request_client - - # @param client [RequestClient] - # @return [] - def initialize(client:) - @client = Client.initialize(request_client: @request_client) - @service_client = ServiceClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [File::Client] + def initialize(request_client:) + @file = File::Notification::Client.new + @service = File::ServiceClient.new(request_client: request_client) end end class AsyncClient - attr_reader :client - - # @param client [AsyncRequestClient] - # @return [] - def initialize(client:) - @async_client = AsyncClient.initialize(client: @request_client) - @async_service_client = AsyncServiceClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [File::AsyncClient] + def initialize(request_client:) + @file = File::Notification::AsyncClient.new + @service = File::AsyncServiceClient.new(request_client: request_client) end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/file/notification/client.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/file/notification/client.rb index 1d7b20b56bd..5ea1f8c25d0 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/file/notification/client.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/file/notification/client.rb @@ -1,27 +1,24 @@ # frozen_string_literal: true +require_relative "../../../requests" require_relative "service/client" module SeedExamplesClient module File module Notification class Client - attr_reader :request_client - - # @param client [RequestClient] - # @return [] - def initialize(client:) - @service_client = ServiceClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [File::Notification::Client] + def initialize(request_client:) + @service = File::Notification::ServiceClient.new(request_client: request_client) end end class AsyncClient - attr_reader :client - - # @param client [AsyncRequestClient] - # @return [] - def initialize(client:) - @async_service_client = AsyncServiceClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [File::Notification::AsyncClient] + def initialize(request_client:) + @service = File::Notification::AsyncServiceClient.new(request_client: request_client) end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/file/notification/service/client.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/file/notification/service/client.rb index 663c60c921d..735afe23a8a 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/file/notification/service/client.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/file/notification/service/client.rb @@ -1,57 +1,56 @@ # frozen_string_literal: true +require_relative "../../../../requests" require_relative "../../../types/types/exception" require "async" module SeedExamplesClient module File module Notification - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [File::Notification::ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param notification_id [String] - # @param request_options [RequestOptions] - # @return [Types::Exception] - def get_exception(notification_id:, request_options: nil) - response = @request_client.conn.get("/file/notification/#{notification_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Types::Exception.from_json(json_object: response) + # @param notification_id [String] + # @param request_options [RequestOptions] + # @return [Types::Exception] + def get_exception(notification_id:, request_options: nil) + response = @request_client.conn.get("/file/notification/#{notification_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Types::Exception.from_json(json_object: response.body) end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [File::Notification::AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param notification_id [String] - # @param request_options [RequestOptions] - # @return [Types::Exception] - def get_exception(notification_id:, request_options: nil) - Async.call do - response = @request_client.conn.get("/file/notification/#{notification_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Types::Exception.from_json(json_object: response) + # @param notification_id [String] + # @param request_options [RequestOptions] + # @return [Types::Exception] + def get_exception(notification_id:, request_options: nil) + Async do + response = @request_client.conn.get("/file/notification/#{notification_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Types::Exception.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/file/service/client.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/file/service/client.rb index 8ff3204f8c8..e2bb905b9cf 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/file/service/client.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/file/service/client.rb @@ -1,56 +1,55 @@ # frozen_string_literal: true +require_relative "../../../requests" require_relative "../../types/types/file" require "async" module SeedExamplesClient module File - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [File::ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param filename [String] - # @param request_options [RequestOptions] - # @return [Types::File] - def get_file(filename:, request_options: nil) - response = @request_client.conn.get("/file/#{filename}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Types::File.from_json(json_object: response) + # @param filename [String] + # @param request_options [RequestOptions] + # @return [Types::File] + def get_file(filename:, request_options: nil) + response = @request_client.conn.get("/file/#{filename}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Types::File.from_json(json_object: response.body) end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [File::AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param filename [String] - # @param request_options [RequestOptions] - # @return [Types::File] - def get_file(filename:, request_options: nil) - Async.call do - response = @request_client.conn.get("/file/#{filename}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Types::File.from_json(json_object: response) + # @param filename [String] + # @param request_options [RequestOptions] + # @return [Types::File] + def get_file(filename:, request_options: nil) + Async do + response = @request_client.conn.get("/file/#{filename}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Types::File.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/health/client.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/health/client.rb index c202fe4c140..7430ebe922d 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/health/client.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/health/client.rb @@ -1,26 +1,23 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "service/client" module SeedExamplesClient module Health class Client - attr_reader :request_client - - # @param client [RequestClient] - # @return [] - def initialize(client:) - @service_client = ServiceClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [Health::Client] + def initialize(request_client:) + @service = Health::ServiceClient.new(request_client: request_client) end end class AsyncClient - attr_reader :client - - # @param client [AsyncRequestClient] - # @return [] - def initialize(client:) - @async_service_client = AsyncServiceClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [Health::AsyncClient] + def initialize(request_client:) + @service = Health::AsyncServiceClient.new(request_client: request_client) end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/health/service/client.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/health/service/client.rb index 452fd9fc04f..7afdfd3ebdc 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/health/service/client.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/health/service/client.rb @@ -1,76 +1,76 @@ # frozen_string_literal: true +require_relative "../../../requests" require "async" module SeedExamplesClient module Health - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [Health::ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param id [String] - # @param request_options [RequestOptions] - # @return [Void] - def check(id:, request_options: nil) - @request_client.conn.get("/check/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param id [String] + # @param request_options [RequestOptions] + # @return [Void] + def check(id:, request_options: nil) + @request_client.conn.get("/check/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + end - # @param request_options [RequestOptions] - # @return [Boolean] - def ping(request_options: nil) - @request_client.conn.get("/ping") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [Boolean] + def ping(request_options: nil) + response = @request_client.conn.get("/ping") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Health::AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param id [String] - # @param request_options [RequestOptions] - # @return [Void] - def check(id:, request_options: nil) - Async.call do - @request_client.conn.get("/check/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param id [String] + # @param request_options [RequestOptions] + # @return [Void] + def check(id:, request_options: nil) + Async do + @request_client.conn.get("/check/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - # @param request_options [RequestOptions] - # @return [Boolean] - def ping(request_options: nil) - Async.call do - response = @request_client.conn.get("/ping") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param request_options [RequestOptions] + # @return [Boolean] + def ping(request_options: nil) + Async do + response = @request_client.conn.get("/ping") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/service/client.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/service/client.rb index 5c23404d769..1882c0ae82a 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/service/client.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/service/client.rb @@ -1,135 +1,142 @@ # frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/types/movie_id" require_relative "../types/types/movie" - require_relative "../types/types/metadata" -require_relative "../types/types/movie_id" require "async" module SeedExamplesClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param movie_id [Types::MOVIE_ID] - # @param request_options [RequestOptions] - # @return [Types::Movie] - def get_movie(movie_id:, request_options: nil) - response = @request_client.conn.get("/movie/#{movie_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Types::Movie.from_json(json_object: response) + # @param movie_id [Types::MOVIE_ID] + # @param request_options [RequestOptions] + # @return [Types::Movie] + def get_movie(movie_id:, request_options: nil) + response = @request_client.conn.get("/movie/#{movie_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Types::Movie.from_json(json_object: response.body) + end - # @param request [Hash] Request of type Types::Movie, as a Hash - # * :id (Types::MOVIE_ID) - # * :title (String) - # * :from (String) - # * :rating (Float) - # * :type (String) - # * :tag (Commons::Types::TAG) - # * :book (String) - # @param request_options [RequestOptions] - # @return [Types::MOVIE_ID] - def create_movie(request:, request_options: nil) - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Hash] Request of type Types::Movie, as a Hash + # * :id (Types::MOVIE_ID) + # * :title (String) + # * :from (String) + # * :rating (Float) + # * :type (String) + # * :tag (Commons::Types::TAG) + # * :book (String) + # @param request_options [RequestOptions] + # @return [Types::MOVIE_ID] + def create_movie(request:, request_options: nil) + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body + end - # @param shallow [Boolean] - # @param tag [String] - # @param x_api_version [String] - # @param request_options [RequestOptions] - # @return [Types::Metadata] - def get_metadata(x_api_version:, shallow: nil, tag: nil, request_options: nil) - response = @request_client.conn.get("/metadata") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers, "X-API-Version": x_api_version }.compact - req.params = { **request_options&.additional_query_parameters, "shallow": shallow, "tag": tag }.compact - end - Types::Metadata.from_json(json_object: response) + # @param x_api_version [String] + # @param shallow [Boolean] + # @param tag [String] + # @param request_options [RequestOptions] + # @return [Types::Metadata] + def get_metadata(x_api_version:, shallow: nil, tag: nil, request_options: nil) + response = @request_client.conn.get("/metadata") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { + **req.headers, + **(request_options&.additional_headers || {}), + "X-API-Version": x_api_version + }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "shallow": shallow, "tag": tag }.compact end + Types::Metadata.from_json(json_object: response.body) end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param movie_id [Types::MOVIE_ID] - # @param request_options [RequestOptions] - # @return [Types::Movie] - def get_movie(movie_id:, request_options: nil) - Async.call do - response = @request_client.conn.get("/movie/#{movie_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Types::Movie.from_json(json_object: response) + # @param movie_id [Types::MOVIE_ID] + # @param request_options [RequestOptions] + # @return [Types::Movie] + def get_movie(movie_id:, request_options: nil) + Async do + response = @request_client.conn.get("/movie/#{movie_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Types::Movie.from_json(json_object: response.body) end + end - # @param request [Hash] Request of type Types::Movie, as a Hash - # * :id (Types::MOVIE_ID) - # * :title (String) - # * :from (String) - # * :rating (Float) - # * :type (String) - # * :tag (Commons::Types::TAG) - # * :book (String) - # @param request_options [RequestOptions] - # @return [Types::MOVIE_ID] - def create_movie(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Hash] Request of type Types::Movie, as a Hash + # * :id (Types::MOVIE_ID) + # * :title (String) + # * :from (String) + # * :rating (Float) + # * :type (String) + # * :tag (Commons::Types::TAG) + # * :book (String) + # @param request_options [RequestOptions] + # @return [Types::MOVIE_ID] + def create_movie(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param shallow [Boolean] - # @param tag [String] - # @param x_api_version [String] - # @param request_options [RequestOptions] - # @return [Types::Metadata] - def get_metadata(x_api_version:, shallow: nil, tag: nil, request_options: nil) - Async.call do - response = @request_client.conn.get("/metadata") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { - **req.headers, - **request_options&.additional_headers, - "X-API-Version": x_api_version - }.compact - req.params = { **request_options&.additional_query_parameters, "shallow": shallow, "tag": tag }.compact - end - Types::Metadata.from_json(json_object: response) + # @param x_api_version [String] + # @param shallow [Boolean] + # @param tag [String] + # @param request_options [RequestOptions] + # @return [Types::Metadata] + def get_metadata(x_api_version:, shallow: nil, tag: nil, request_options: nil) + Async do + response = @request_client.conn.get("/metadata") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { + **req.headers, + **(request_options&.additional_headers || {}), + "X-API-Version": x_api_version + }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "shallow": shallow, + "tag": tag + }.compact end + Types::Metadata.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/directory.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/directory.rb index 1c1afdfd6f4..7348965f779 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/directory.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/directory.rb @@ -31,8 +31,14 @@ def initialize(name:, files: nil, directories: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - files = struct.files - directories = struct.directories + files = struct.files.map do |v| + v = v.to_h.to_json + Types::File.from_json(json_object: v) + end + directories = struct.directories.map do |v| + v = v.to_h.to_json + Types::Directory.from_json(json_object: v) + end new(name: name, files: files, directories: directories, additional_properties: struct) end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/extended_movie.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/extended_movie.rb index 63678f77e58..9b6c917b71b 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/extended_movie.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/extended_movie.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../commons/types/types/tag" - require_relative "movie_id" +require_relative "../../commons/types/types/tag" require "json" module SeedExamplesClient diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/metadata.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/metadata.rb index b3c7d2ce490..03e9e64bc2a 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/metadata.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/metadata.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require "json" - require "set" +require "json" module SeedExamplesClient module Types diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/migration.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/migration.rb index 08f4ddd8ac7..b00b93de864 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/migration.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/migration.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "migration_status" require "json" module SeedExamplesClient @@ -8,13 +9,13 @@ class Migration attr_reader :name, :status, :additional_properties # @param name [String] - # @param status [Hash{String => String}] + # @param status [MIGRATION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Types::Migration] def initialize(name:, status:, additional_properties: nil) # @type [String] @name = name - # @type [Hash{String => String}] + # @type [MIGRATION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -27,7 +28,7 @@ def initialize(name:, status:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - status = struct.status + status = Types::MIGRATION_STATUS.key(struct.status) || struct.status new(name: name, status: status, additional_properties: struct) end @@ -35,7 +36,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "name": @name, "status": @status }.to_json + { "name": @name, "status": Types::MIGRATION_STATUS[@status] || @status }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -44,7 +45,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") - obj.status.is_a?(MIGRATION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.status.is_a?(Types::MIGRATION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/migration_status.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/migration_status.rb index e41566d81f2..8cec6b89727 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/migration_status.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/migration_status.rb @@ -2,7 +2,7 @@ module SeedExamplesClient module Types - # @type [Hash{String => String}] - MIGRATION_STATUS = { running: "RUNNING", failed: "FAILED", finished: "FINISHED" }.frozen + # @type [MIGRATION_STATUS] + MIGRATION_STATUS = { running: "RUNNING", failed: "FAILED", finished: "FINISHED" }.freeze end end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/moment.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/moment.rb index 1c3f5cebbff..62f1fd192cc 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/moment.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/moment.rb @@ -31,8 +31,8 @@ def initialize(id:, date:, datetime:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) id = struct.id - date = struct.date - datetime = struct.datetime + date = Date.parse(struct.date) + datetime = DateTime.parse(struct.datetime) new(id: id, date: date, datetime: datetime, additional_properties: struct) end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/movie.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/movie.rb index 9f96d24c94d..9e02038c3e2 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/movie.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/movie.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../commons/types/types/tag" - require_relative "movie_id" +require_relative "../../commons/types/types/tag" require "json" module SeedExamplesClient diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/node.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/node.rb index 2968af9b90a..eb03bed2ebd 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/node.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/node.rb @@ -31,8 +31,14 @@ def initialize(name:, nodes: nil, trees: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - nodes = struct.nodes - trees = struct.trees + nodes = struct.nodes.map do |v| + v = v.to_h.to_json + Types::Node.from_json(json_object: v) + end + trees = struct.trees.map do |v| + v = v.to_h.to_json + Types::Tree.from_json(json_object: v) + end new(name: name, nodes: nodes, trees: trees, additional_properties: struct) end diff --git a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/tree.rb b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/tree.rb index 3d1f0693f59..4892a76d221 100644 --- a/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/tree.rb +++ b/seed/ruby-sdk/examples/lib/seed_examples_client/types/types/tree.rb @@ -24,7 +24,10 @@ def initialize(nodes: nil, additional_properties: nil) # @return [Types::Tree] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - nodes = struct.nodes + nodes = struct.nodes.map do |v| + v = v.to_h.to_json + Types::Node.from_json(json_object: v) + end new(nodes: nodes, additional_properties: struct) end diff --git a/seed/ruby-sdk/examples/lib/types_export.rb b/seed/ruby-sdk/examples/lib/types_export.rb new file mode 100644 index 00000000000..04c75400e5b --- /dev/null +++ b/seed/ruby-sdk/examples/lib/types_export.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require_relative "seed_examples_client/commons/types/types/tag" +require_relative "seed_examples_client/commons/types/types/metadata" +require_relative "seed_examples_client/commons/types/types/event_info" +require_relative "seed_examples_client/commons/types/types/data" +require_relative "seed_examples_client/file/service/types/filename" +require_relative "seed_examples_client/types/types/movie_id" +require_relative "seed_examples_client/types/types/movie" +require_relative "seed_examples_client/types/types/cast_member" +require_relative "seed_examples_client/types/types/actor" +require_relative "seed_examples_client/types/types/actress" +require_relative "seed_examples_client/types/types/stunt_double" +require_relative "seed_examples_client/types/types/extended_movie" +require_relative "seed_examples_client/types/types/moment" +require_relative "seed_examples_client/types/types/file" +require_relative "seed_examples_client/types/types/directory" +require_relative "seed_examples_client/types/types/node" +require_relative "seed_examples_client/types/types/tree" +require_relative "seed_examples_client/types/types/metadata" +require_relative "seed_examples_client/types/types/exception" +require_relative "seed_examples_client/types/types/exception_info" +require_relative "seed_examples_client/types/types/migration_status" +require_relative "seed_examples_client/types/types/migration" +require_relative "seed_examples_client/types/types/request" +require_relative "seed_examples_client/types/types/response" +require_relative "seed_examples_client/types/types/test" diff --git a/seed/ruby-sdk/examples/seed_examples_client.gemspec b/seed/ruby-sdk/examples/seed_examples_client.gemspec index 1bc4bbc686c..ad5bcbead44 100644 --- a/seed/ruby-sdk/examples/seed_examples_client.gemspec +++ b/seed/ruby-sdk/examples/seed_examples_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_examples_client" + spec.version = SeedExamplesClient::Gemconfig::VERSION spec.authors = SeedExamplesClient::Gemconfig::AUTHORS spec.email = SeedExamplesClient::Gemconfig::EMAIL spec.summary = SeedExamplesClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/exhaustive/.rubocop.yml b/seed/ruby-sdk/exhaustive/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/exhaustive/.rubocop.yml +++ b/seed/ruby-sdk/exhaustive/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/exhaustive/lib/gemconfig.rb b/seed/ruby-sdk/exhaustive/lib/gemconfig.rb index fd926713a39..878fe59accb 100644 --- a/seed/ruby-sdk/exhaustive/lib/gemconfig.rb +++ b/seed/ruby-sdk/exhaustive/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedExhaustiveClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/exhaustive/lib/requests.rb b/seed/ruby-sdk/exhaustive/lib/requests.rb index 2535b0833f7..b153088cf28 100644 --- a/seed/ruby-sdk/exhaustive/lib/requests.rb +++ b/seed/ruby-sdk/exhaustive/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedExhaustiveClient class RequestClient @@ -11,7 +12,7 @@ class RequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [RequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedExhaustiveClient", @@ -19,9 +20,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -33,7 +34,7 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [AsyncRequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedExhaustiveClient", @@ -41,29 +42,27 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [Hash{String => Object}] @@ -72,6 +71,8 @@ def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additio @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client.rb index 7dad06028eb..fbac97722b6 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client.rb @@ -1,57 +1,47 @@ # frozen_string_literal: true -require_relative "seed_exhaustive_client/general_errors/types/bad_object_request_info" -require_relative "seed_exhaustive_client/types/object/types/nested_object_with_optional_field" -require_relative "seed_exhaustive_client/types/object/types/nested_object_with_required_field" -require_relative "seed_exhaustive_client/types/object/types/object_with_map_of_map" -require_relative "seed_exhaustive_client/types/object/types/object_with_optional_field" -require_relative "seed_exhaustive_client/types/object/types/object_with_required_field" -require_relative "seed_exhaustive_client/types/union/types/animal" -require_relative "seed_exhaustive_client/types/union/types/cat" -require_relative "seed_exhaustive_client/types/union/types/dog" -require "faraday" -require_relative "seed_exhaustive_client/endpoints/container/client" -require_relative "seed_exhaustive_client/endpoints/enum/client" -require_relative "seed_exhaustive_client/endpoints/http_methods/client" -require_relative "seed_exhaustive_client/endpoints/object/client" -require_relative "seed_exhaustive_client/endpoints/params/client" -require_relative "seed_exhaustive_client/endpoints/primitive/client" -require_relative "seed_exhaustive_client/endpoints/union/client" -require_relative "seed_exhaustive_client/endpointsclient" +require_relative "types_export" +require_relative "requests" +require_relative "seed_exhaustive_client/endpoints/client" require_relative "seed_exhaustive_client/inlined_requests/client" require_relative "seed_exhaustive_client/no_auth/client" require_relative "seed_exhaustive_client/no_req_body/client" require_relative "seed_exhaustive_client/req_with_headers/client" -require "async/http/faraday" module SeedExhaustiveClient class Client + attr_reader :endpoints, :inlined_requests, :no_auth, :no_req_body, :req_with_headers + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @client = Client.initialize(request_client: request_client) - @inlined_requests_client = InlinedRequestsClient.initialize(request_client: request_client) - @no_auth_client = NoAuthClient.initialize(request_client: request_client) - @no_req_body_client = NoReqBodyClient.initialize(request_client: request_client) - @req_with_headers_client = ReqWithHeadersClient.initialize(request_client: request_client) + # @return [Client] + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + token: token) + @endpoints = Endpoints::Client.new(request_client: @request_client) + @inlined_requests = InlinedRequestsClient.new(request_client: @request_client) + @no_auth = NoAuthClient.new(request_client: @request_client) + @no_req_body = NoReqBodyClient.new(request_client: @request_client) + @req_with_headers = ReqWithHeadersClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :endpoints, :inlined_requests, :no_auth, :no_req_body, :req_with_headers + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_client = AsyncClient.initialize(client: request_client) - @async_inlined_requests_client = AsyncInlinedRequestsClient.initialize(request_client: request_client) - @async_no_auth_client = AsyncNoAuthClient.initialize(request_client: request_client) - @async_no_req_body_client = AsyncNoReqBodyClient.initialize(request_client: request_client) - @async_req_with_headers_client = AsyncReqWithHeadersClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + token: token) + @endpoints = Endpoints::AsyncClient.new(request_client: @async_request_client) + @inlined_requests = AsyncInlinedRequestsClient.new(request_client: @async_request_client) + @no_auth = AsyncNoAuthClient.new(request_client: @async_request_client) + @no_req_body = AsyncNoReqBodyClient.new(request_client: @async_request_client) + @req_with_headers = AsyncReqWithHeadersClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/client.rb index 7306995cadb..6afe6da0f33 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/client.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "container/client" require_relative "enum/client" require_relative "http_methods/client" @@ -11,34 +12,30 @@ module SeedExhaustiveClient module Endpoints class Client - attr_reader :request_client - - # @param client [RequestClient] - # @return [] - def initialize(client:) - @container_client = ContainerClient.initialize(request_client: @request_client) - @enum_client = EnumClient.initialize(request_client: @request_client) - @http_methods_client = HttpMethodsClient.initialize(request_client: @request_client) - @object_client = ObjectClient.initialize(request_client: @request_client) - @params_client = ParamsClient.initialize(request_client: @request_client) - @primitive_client = PrimitiveClient.initialize(request_client: @request_client) - @union_client = UnionClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [Endpoints::Client] + def initialize(request_client:) + @container = Endpoints::ContainerClient.new(request_client: request_client) + @enum = Endpoints::EnumClient.new(request_client: request_client) + @http_methods = Endpoints::HttpMethodsClient.new(request_client: request_client) + @object = Endpoints::ObjectClient.new(request_client: request_client) + @params = Endpoints::ParamsClient.new(request_client: request_client) + @primitive = Endpoints::PrimitiveClient.new(request_client: request_client) + @union = Endpoints::UnionClient.new(request_client: request_client) end end class AsyncClient - attr_reader :client - - # @param client [AsyncRequestClient] - # @return [] - def initialize(client:) - @async_container_client = AsyncContainerClient.initialize(request_client: @request_client) - @async_enum_client = AsyncEnumClient.initialize(request_client: @request_client) - @async_http_methods_client = AsyncHttpMethodsClient.initialize(request_client: @request_client) - @async_object_client = AsyncObjectClient.initialize(request_client: @request_client) - @async_params_client = AsyncParamsClient.initialize(request_client: @request_client) - @async_primitive_client = AsyncPrimitiveClient.initialize(request_client: @request_client) - @async_union_client = AsyncUnionClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [Endpoints::AsyncClient] + def initialize(request_client:) + @container = Endpoints::AsyncContainerClient.new(request_client: request_client) + @enum = Endpoints::AsyncEnumClient.new(request_client: request_client) + @http_methods = Endpoints::AsyncHttpMethodsClient.new(request_client: request_client) + @object = Endpoints::AsyncObjectClient.new(request_client: request_client) + @params = Endpoints::AsyncParamsClient.new(request_client: request_client) + @primitive = Endpoints::AsyncPrimitiveClient.new(request_client: request_client) + @union = Endpoints::AsyncUnionClient.new(request_client: request_client) end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/container/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/container/client.rb index 2291319ccf9..4bcb80c945d 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/container/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/container/client.rb @@ -1,232 +1,236 @@ # frozen_string_literal: true +require_relative "../../../requests" require_relative "../../types/object/types/object_with_required_field" -require "async" require "set" +require "async" module SeedExhaustiveClient module Endpoints - module Container - class ContainerClient - attr_reader :request_client - - # @param request_client [RequestClient] - # @return [ContainerClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + class ContainerClient + attr_reader :request_client + + # @param request_client [RequestClient] + # @return [Endpoints::ContainerClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Array] - def get_and_return_list_of_primitives(request:, request_options: nil) - @request_client.conn.post("/container/list-of-primitives") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - end + # @param request [Array] + # @param request_options [RequestOptions] + # @return [Array] + def get_and_return_list_of_primitives(request:, request_options: nil) + response = @request_client.conn.post("/container/list-of-primitives") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + response.body + end - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Array] - def get_and_return_list_of_objects(request:, request_options: nil) - response = @request_client.conn.post("/container/list-of-objects") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response.map do |v| - v = v.to_h.to_json - Types::Object::ObjectWithRequiredField.from_json(json_object: v) - end + # @param request [Array] Request of type Array, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Array] + def get_and_return_list_of_objects(request:, request_options: nil) + response = @request_client.conn.post("/container/list-of-objects") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + response.body.map do |v| + v = v.to_h.to_json + Types::Object::ObjectWithRequiredField.from_json(json_object: v) end + end - # @param request [Set] - # @param request_options [RequestOptions] - # @return [Set] - def get_and_return_set_of_primitives(request:, request_options: nil) - response = @request_client.conn.post("/container/set-of-primitives") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Set.new(response) - end + # @param request [Set] + # @param request_options [RequestOptions] + # @return [Set] + def get_and_return_set_of_primitives(request:, request_options: nil) + response = @request_client.conn.post("/container/set-of-primitives") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + Set.new(response.body) + end - # @param request [Set] - # @param request_options [RequestOptions] - # @return [Set] - def get_and_return_set_of_objects(request:, request_options: nil) - response = @request_client.conn.post("/container/set-of-objects") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Set.new(response) - end + # @param request [Set] + # @param request_options [RequestOptions] + # @return [Set] + def get_and_return_set_of_objects(request:, request_options: nil) + response = @request_client.conn.post("/container/set-of-objects") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + Set.new(response.body) + end - # @param request [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Hash{String => String}] - def get_and_return_map_prim_to_prim(request:, request_options: nil) - @request_client.conn.post("/container/map-prim-to-prim") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - end + # @param request [Hash{String => String}] + # @param request_options [RequestOptions] + # @return [Hash{String => String}] + def get_and_return_map_prim_to_prim(request:, request_options: nil) + response = @request_client.conn.post("/container/map-prim-to-prim") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + response.body + end - # @param request [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Hash{String => String}] - def get_and_return_map_of_prim_to_object(request:, request_options: nil) - @request_client.conn.post("/container/map-prim-to-object") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - end + # @param request [Hash{String => String}] + # @param request_options [RequestOptions] + # @return [Hash{String => String}] + def get_and_return_map_of_prim_to_object(request:, request_options: nil) + response = @request_client.conn.post("/container/map-prim-to-object") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + response.body + end - # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash - # * :string (String) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithRequiredField] - def get_and_return_optional(request: nil, request_options: nil) - response = @request_client.conn.post("/container/opt-objects") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithRequiredField.from_json(json_object: response) - end + # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithRequiredField] + def get_and_return_optional(request: nil, request_options: nil) + response = @request_client.conn.post("/container/opt-objects") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + Types::Object::ObjectWithRequiredField.from_json(json_object: response.body) end + end - class AsyncContainerClient - attr_reader :request_client + class AsyncContainerClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncContainerClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Endpoints::AsyncContainerClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Array] - def get_and_return_list_of_primitives(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/container/list-of-primitives") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Array] + # @param request_options [RequestOptions] + # @return [Array] + def get_and_return_list_of_primitives(request:, request_options: nil) + Async do + response = @request_client.conn.post("/container/list-of-primitives") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Array] - def get_and_return_list_of_objects(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/container/list-of-objects") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response.map do |v| - v = v.to_h.to_json - Types::Object::ObjectWithRequiredField.from_json(json_object: v) - end + # @param request [Array] Request of type Array, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Array] + def get_and_return_list_of_objects(request:, request_options: nil) + Async do + response = @request_client.conn.post("/container/list-of-objects") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + response.body.map do |v| + v = v.to_h.to_json + Types::Object::ObjectWithRequiredField.from_json(json_object: v) end end + end - # @param request [Set] - # @param request_options [RequestOptions] - # @return [Set] - def get_and_return_set_of_primitives(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/container/set-of-primitives") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Set.new(response) + # @param request [Set] + # @param request_options [RequestOptions] + # @return [Set] + def get_and_return_set_of_primitives(request:, request_options: nil) + Async do + response = @request_client.conn.post("/container/set-of-primitives") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Set.new(response.body) end + end - # @param request [Set] - # @param request_options [RequestOptions] - # @return [Set] - def get_and_return_set_of_objects(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/container/set-of-objects") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Set.new(response) + # @param request [Set] + # @param request_options [RequestOptions] + # @return [Set] + def get_and_return_set_of_objects(request:, request_options: nil) + Async do + response = @request_client.conn.post("/container/set-of-objects") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Set.new(response.body) end + end - # @param request [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Hash{String => String}] - def get_and_return_map_prim_to_prim(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/container/map-prim-to-prim") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Hash{String => String}] + # @param request_options [RequestOptions] + # @return [Hash{String => String}] + def get_and_return_map_prim_to_prim(request:, request_options: nil) + Async do + response = @request_client.conn.post("/container/map-prim-to-prim") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Hash{String => String}] - def get_and_return_map_of_prim_to_object(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/container/map-prim-to-object") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Hash{String => String}] + # @param request_options [RequestOptions] + # @return [Hash{String => String}] + def get_and_return_map_of_prim_to_object(request:, request_options: nil) + Async do + response = @request_client.conn.post("/container/map-prim-to-object") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash - # * :string (String) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithRequiredField] - def get_and_return_optional(request: nil, request_options: nil) - Async.call do - response = @request_client.conn.post("/container/opt-objects") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithRequiredField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithRequiredField] + def get_and_return_optional(request: nil, request_options: nil) + Async do + response = @request_client.conn.post("/container/opt-objects") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithRequiredField.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/enum/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/enum/client.rb index 8cfa686f04d..62b7c34a45b 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/enum/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/enum/client.rb @@ -1,57 +1,57 @@ # frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/enum/types/weather_report" require "async" module SeedExhaustiveClient module Endpoints - module Enum - class EnumClient - attr_reader :request_client + class EnumClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [EnumClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [Endpoints::EnumClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Hash{String => String}] - def get_and_return_enum(request:, request_options: nil) - response = @request_client.conn.post("/enum") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - WEATHER_REPORT.key(response) + # @param request [WEATHER_REPORT] + # @param request_options [RequestOptions] + # @return [WEATHER_REPORT] + def get_and_return_enum(request:, request_options: nil) + response = @request_client.conn.post("/enum") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Enum::WEATHER_REPORT.key(response.body) || response.body end + end - class AsyncEnumClient - attr_reader :request_client + class AsyncEnumClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncEnumClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Endpoints::AsyncEnumClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Hash{String => String}] - def get_and_return_enum(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/enum") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - WEATHER_REPORT.key(response) + # @param request [WEATHER_REPORT] + # @param request_options [RequestOptions] + # @return [WEATHER_REPORT] + def get_and_return_enum(request:, request_options: nil) + Async do + response = @request_client.conn.post("/enum") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Enum::WEATHER_REPORT.key(response.body) || response.body end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/http_methods/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/http_methods/client.rb index 48036d2ab3a..9b1ce5c3c23 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/http_methods/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/http_methods/client.rb @@ -1,198 +1,198 @@ # frozen_string_literal: true -require_relative "../../types/object/types/object_with_optional_field" - +require_relative "../../../requests" require_relative "../../types/object/types/object_with_required_field" +require_relative "../../types/object/types/object_with_optional_field" require "async" module SeedExhaustiveClient module Endpoints - module HttpMethods - class HttpMethodsClient - attr_reader :request_client - - # @param request_client [RequestClient] - # @return [HttpMethodsClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + class HttpMethodsClient + attr_reader :request_client + + # @param request_client [RequestClient] + # @return [Endpoints::HttpMethodsClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param id [String] - # @param request_options [RequestOptions] - # @return [String] - def test_get(id:, request_options: nil) - @request_client.conn.get("/http-methods/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param id [String] + # @param request_options [RequestOptions] + # @return [String] + def test_get(id:, request_options: nil) + response = @request_client.conn.get("/http-methods/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body + end - # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash - # * :string (String) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def test_post(request:, request_options: nil) - response = @request_client.conn.post("/http-methods") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def test_post(request:, request_options: nil) + response = @request_client.conn.post("/http-methods") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) + end - # @param id [String] - # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash - # * :string (String) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def test_put(id:, request:, request_options: nil) - response = @request_client.conn.put("/http-methods/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param id [String] + # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def test_put(id:, request:, request_options: nil) + response = @request_client.conn.put("/http-methods/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) + end - # @param id [String] - # @param request [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def test_patch(id:, request:, request_options: nil) - response = @request_client.conn.patch("/http-methods/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param id [String] + # @param request [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def test_patch(id:, request:, request_options: nil) + response = @request_client.conn.patch("/http-methods/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) + end - # @param id [String] - # @param request_options [RequestOptions] - # @return [Boolean] - def test_delete(id:, request_options: nil) - @request_client.conn.delete("/http-methods/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param id [String] + # @param request_options [RequestOptions] + # @return [Boolean] + def test_delete(id:, request_options: nil) + response = @request_client.conn.delete("/http-methods/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncHttpMethodsClient - attr_reader :request_client + class AsyncHttpMethodsClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncHttpMethodsClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Endpoints::AsyncHttpMethodsClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param id [String] - # @param request_options [RequestOptions] - # @return [String] - def test_get(id:, request_options: nil) - Async.call do - response = @request_client.conn.get("/http-methods/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param id [String] + # @param request_options [RequestOptions] + # @return [String] + def test_get(id:, request_options: nil) + Async do + response = @request_client.conn.get("/http-methods/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash - # * :string (String) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def test_post(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/http-methods") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def test_post(request:, request_options: nil) + Async do + response = @request_client.conn.post("/http-methods") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) end + end - # @param id [String] - # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash - # * :string (String) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def test_put(id:, request:, request_options: nil) - Async.call do - response = @request_client.conn.put("/http-methods/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param id [String] + # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def test_put(id:, request:, request_options: nil) + Async do + response = @request_client.conn.put("/http-methods/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) end + end - # @param id [String] - # @param request [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def test_patch(id:, request:, request_options: nil) - Async.call do - response = @request_client.conn.patch("/http-methods/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param id [String] + # @param request [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def test_patch(id:, request:, request_options: nil) + Async do + response = @request_client.conn.patch("/http-methods/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) end + end - # @param id [String] - # @param request_options [RequestOptions] - # @return [Boolean] - def test_delete(id:, request_options: nil) - Async.call do - response = @request_client.conn.delete("/http-methods/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param id [String] + # @param request_options [RequestOptions] + # @return [Boolean] + def test_delete(id:, request_options: nil) + Async do + response = @request_client.conn.delete("/http-methods/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/object/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/object/client.rb index dc4361dc5f8..6ca5f7627e6 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/object/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/object/client.rb @@ -1,258 +1,257 @@ # frozen_string_literal: true -require_relative "../../types/object/types/nested_object_with_optional_field" -require_relative "../../types/object/types/nested_object_with_required_field" -require_relative "../../types/object/types/object_with_map_of_map" +require_relative "../../../requests" require_relative "../../types/object/types/object_with_optional_field" require_relative "../../types/object/types/object_with_required_field" +require_relative "../../types/object/types/object_with_map_of_map" +require_relative "../../types/object/types/nested_object_with_optional_field" +require_relative "../../types/object/types/nested_object_with_required_field" require "async" module SeedExhaustiveClient module Endpoints - module Object - class ObjectClient - attr_reader :request_client + class ObjectClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ObjectClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [Endpoints::ObjectClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def get_and_return_with_optional_field(request:, request_options: nil) - response = @request_client.conn.post("/object/get-and-return-with-optional-field") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def get_and_return_with_optional_field(request:, request_options: nil) + response = @request_client.conn.post("/object/get-and-return-with-optional-field") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) + end - # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash - # * :string (String) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithRequiredField] - def get_and_return_with_required_field(request:, request_options: nil) - response = @request_client.conn.post("/object/get-and-return-with-required-field") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithRequiredField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithRequiredField] + def get_and_return_with_required_field(request:, request_options: nil) + response = @request_client.conn.post("/object/get-and-return-with-required-field") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithRequiredField.from_json(json_object: response.body) + end - # @param request [Hash] Request of type Types::Object::ObjectWithMapOfMap, as a Hash - # * :map (Hash{String => String}) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithMapOfMap] - def get_and_return_with_map_of_map(request:, request_options: nil) - response = @request_client.conn.post("/object/get-and-return-with-map-of-map") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithMapOfMap.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithMapOfMap, as a Hash + # * :map (Hash{String => String}) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithMapOfMap] + def get_and_return_with_map_of_map(request:, request_options: nil) + response = @request_client.conn.post("/object/get-and-return-with-map-of-map") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithMapOfMap.from_json(json_object: response.body) + end - # @param request [Hash] Request of type Types::Object::NestedObjectWithOptionalField, as a Hash - # * :string (String) - # * :nested_object (Hash) - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::NestedObjectWithOptionalField] - def get_and_return_nested_with_optional_field(request:, request_options: nil) - response = @request_client.conn.post("/object/get-and-return-nested-with-optional-field") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::NestedObjectWithOptionalField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::NestedObjectWithOptionalField, as a Hash + # * :string (String) + # * :nested_object (Hash) + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::NestedObjectWithOptionalField] + def get_and_return_nested_with_optional_field(request:, request_options: nil) + response = @request_client.conn.post("/object/get-and-return-nested-with-optional-field") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::NestedObjectWithOptionalField.from_json(json_object: response.body) + end - # @param request [Hash] Request of type Types::Object::NestedObjectWithRequiredField, as a Hash - # * :string (String) - # * :nested_object (Hash) - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::NestedObjectWithRequiredField] - def get_and_return_nested_with_required_field(request:, request_options: nil) - response = @request_client.conn.post("/object/get-and-return-nested-with-required-field") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::NestedObjectWithRequiredField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::NestedObjectWithRequiredField, as a Hash + # * :string (String) + # * :nested_object (Hash) + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::NestedObjectWithRequiredField] + def get_and_return_nested_with_required_field(request:, request_options: nil) + response = @request_client.conn.post("/object/get-and-return-nested-with-required-field") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::NestedObjectWithRequiredField.from_json(json_object: response.body) end + end - class AsyncObjectClient - attr_reader :request_client + class AsyncObjectClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncObjectClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Endpoints::AsyncObjectClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def get_and_return_with_optional_field(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/object/get-and-return-with-optional-field") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def get_and_return_with_optional_field(request:, request_options: nil) + Async do + response = @request_client.conn.post("/object/get-and-return-with-optional-field") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) end + end - # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash - # * :string (String) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithRequiredField] - def get_and_return_with_required_field(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/object/get-and-return-with-required-field") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithRequiredField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithRequiredField, as a Hash + # * :string (String) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithRequiredField] + def get_and_return_with_required_field(request:, request_options: nil) + Async do + response = @request_client.conn.post("/object/get-and-return-with-required-field") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithRequiredField.from_json(json_object: response.body) end + end - # @param request [Hash] Request of type Types::Object::ObjectWithMapOfMap, as a Hash - # * :map (Hash{String => String}) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithMapOfMap] - def get_and_return_with_map_of_map(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/object/get-and-return-with-map-of-map") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::ObjectWithMapOfMap.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::ObjectWithMapOfMap, as a Hash + # * :map (Hash{String => String}) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithMapOfMap] + def get_and_return_with_map_of_map(request:, request_options: nil) + Async do + response = @request_client.conn.post("/object/get-and-return-with-map-of-map") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::ObjectWithMapOfMap.from_json(json_object: response.body) end + end - # @param request [Hash] Request of type Types::Object::NestedObjectWithOptionalField, as a Hash - # * :string (String) - # * :nested_object (Hash) - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::NestedObjectWithOptionalField] - def get_and_return_nested_with_optional_field(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/object/get-and-return-nested-with-optional-field") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::NestedObjectWithOptionalField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::NestedObjectWithOptionalField, as a Hash + # * :string (String) + # * :nested_object (Hash) + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::NestedObjectWithOptionalField] + def get_and_return_nested_with_optional_field(request:, request_options: nil) + Async do + response = @request_client.conn.post("/object/get-and-return-nested-with-optional-field") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::NestedObjectWithOptionalField.from_json(json_object: response.body) end + end - # @param request [Hash] Request of type Types::Object::NestedObjectWithRequiredField, as a Hash - # * :string (String) - # * :nested_object (Hash) - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::NestedObjectWithRequiredField] - def get_and_return_nested_with_required_field(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/object/get-and-return-nested-with-required-field") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Object::NestedObjectWithRequiredField.from_json(json_object: response) + # @param request [Hash] Request of type Types::Object::NestedObjectWithRequiredField, as a Hash + # * :string (String) + # * :nested_object (Hash) + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::NestedObjectWithRequiredField] + def get_and_return_nested_with_required_field(request:, request_options: nil) + Async do + response = @request_client.conn.post("/object/get-and-return-nested-with-required-field") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Object::NestedObjectWithRequiredField.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/params/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/params/client.rb index 378d9cc50d7..57205a8a4a2 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/params/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/params/client.rb @@ -1,167 +1,204 @@ # frozen_string_literal: true +require_relative "../../../requests" require "async" module SeedExhaustiveClient module Endpoints - module Params - class ParamsClient - attr_reader :request_client + class ParamsClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ParamsClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [Endpoints::ParamsClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param param [String] - # @param request_options [RequestOptions] - # @return [String] - def get_with_path(param:, request_options: nil) - @request_client.conn.get("/params/path/#{param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # GET with path param + # + # @param param [String] + # @param request_options [RequestOptions] + # @return [String] + def get_with_path(param:, request_options: nil) + response = @request_client.conn.get("/params/path/#{param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body + end - # @param query [String] - # @param number [Integer] - # @param request_options [RequestOptions] - # @return [Void] - def get_with_query(query:, number:, request_options: nil) - @request_client.conn.get("/params") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "query": query, "number": number }.compact - end + # GET with query param + # + # @param query [String] + # @param number [Integer] + # @param request_options [RequestOptions] + # @return [Void] + def get_with_query(query:, number:, request_options: nil) + @request_client.conn.get("/params") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "query": query, + "number": number + }.compact end + end - # @param query [String] - # @param numer [Integer] - # @param request_options [RequestOptions] - # @return [Void] - def get_with_allow_multiple_query(query:, numer:, request_options: nil) - @request_client.conn.get("/params") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "query": query, "numer": numer }.compact - end + # GET with multiple of same query param + # + # @param query [String] + # @param numer [Integer] + # @param request_options [RequestOptions] + # @return [Void] + def get_with_allow_multiple_query(query:, numer:, request_options: nil) + @request_client.conn.get("/params") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "query": query, + "numer": numer + }.compact end + end - # @param param [String] - # @param query [String] - # @param request_options [RequestOptions] - # @return [Void] - def get_with_path_and_query(param:, query:, request_options: nil) - @request_client.conn.get("/params/path/#{param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "query": query }.compact - end + # GET with path and query params + # + # @param param [String] + # @param query [String] + # @param request_options [RequestOptions] + # @return [Void] + def get_with_path_and_query(param:, query:, request_options: nil) + @request_client.conn.get("/params/path/#{param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "query": query }.compact end + end - # @param param [String] - # @param request [String] - # @param request_options [RequestOptions] - # @return [String] - def modify_with_path(param:, request:, request_options: nil) - @request_client.conn.put("/params/path/#{param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # PUT to update with path param + # + # @param param [String] + # @param request [String] + # @param request_options [RequestOptions] + # @return [String] + def modify_with_path(param:, request:, request_options: nil) + response = @request_client.conn.put("/params/path/#{param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - class AsyncParamsClient - attr_reader :request_client + class AsyncParamsClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncParamsClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Endpoints::AsyncParamsClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param param [String] - # @param request_options [RequestOptions] - # @return [String] - def get_with_path(param:, request_options: nil) - Async.call do - response = @request_client.conn.get("/params/path/#{param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # GET with path param + # + # @param param [String] + # @param request_options [RequestOptions] + # @return [String] + def get_with_path(param:, request_options: nil) + Async do + response = @request_client.conn.get("/params/path/#{param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - # @param query [String] - # @param number [Integer] - # @param request_options [RequestOptions] - # @return [Void] - def get_with_query(query:, number:, request_options: nil) - Async.call do - @request_client.conn.get("/params") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "query": query, "number": number }.compact - end + # GET with query param + # + # @param query [String] + # @param number [Integer] + # @param request_options [RequestOptions] + # @return [Void] + def get_with_query(query:, number:, request_options: nil) + Async do + @request_client.conn.get("/params") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "query": query, + "number": number + }.compact end end + end - # @param query [String] - # @param numer [Integer] - # @param request_options [RequestOptions] - # @return [Void] - def get_with_allow_multiple_query(query:, numer:, request_options: nil) - Async.call do - @request_client.conn.get("/params") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "query": query, "numer": numer }.compact - end + # GET with multiple of same query param + # + # @param query [String] + # @param numer [Integer] + # @param request_options [RequestOptions] + # @return [Void] + def get_with_allow_multiple_query(query:, numer:, request_options: nil) + Async do + @request_client.conn.get("/params") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "query": query, + "numer": numer + }.compact end end + end - # @param param [String] - # @param query [String] - # @param request_options [RequestOptions] - # @return [Void] - def get_with_path_and_query(param:, query:, request_options: nil) - Async.call do - @request_client.conn.get("/params/path/#{param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "query": query }.compact - end + # GET with path and query params + # + # @param param [String] + # @param query [String] + # @param request_options [RequestOptions] + # @return [Void] + def get_with_path_and_query(param:, query:, request_options: nil) + Async do + @request_client.conn.get("/params/path/#{param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "query": query }.compact end end + end - # @param param [String] - # @param request [String] - # @param request_options [RequestOptions] - # @return [String] - def modify_with_path(param:, request:, request_options: nil) - Async.call do - response = @request_client.conn.put("/params/path/#{param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # PUT to update with path param + # + # @param param [String] + # @param request [String] + # @param request_options [RequestOptions] + # @return [String] + def modify_with_path(param:, request:, request_options: nil) + Async do + response = @request_client.conn.put("/params/path/#{param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/primitive/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/primitive/client.rb index bb5326ec69d..a3d1c4df9ef 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/primitive/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/primitive/client.rb @@ -1,275 +1,281 @@ # frozen_string_literal: true -require "async" +require_relative "../../../requests" require "date" +require "async" module SeedExhaustiveClient module Endpoints - module Primitive - class PrimitiveClient - attr_reader :request_client + class PrimitiveClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [PrimitiveClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [Endpoints::PrimitiveClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [String] - def get_and_return_string(request:, request_options: nil) - @request_client.conn.post("/primitive/string") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [String] + def get_and_return_string(request:, request_options: nil) + response = @request_client.conn.post("/primitive/string") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body + end - # @param request [Integer] - # @param request_options [RequestOptions] - # @return [Integer] - def get_and_return_int(request:, request_options: nil) - @request_client.conn.post("/primitive/integer") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Integer] + # @param request_options [RequestOptions] + # @return [Integer] + def get_and_return_int(request:, request_options: nil) + response = @request_client.conn.post("/primitive/integer") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body + end - # @param request [Long] - # @param request_options [RequestOptions] - # @return [Long] - def get_and_return_long(request:, request_options: nil) - @request_client.conn.post("/primitive/long") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Long] + # @param request_options [RequestOptions] + # @return [Long] + def get_and_return_long(request:, request_options: nil) + response = @request_client.conn.post("/primitive/long") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body + end - # @param request [Float] - # @param request_options [RequestOptions] - # @return [Float] - def get_and_return_double(request:, request_options: nil) - @request_client.conn.post("/primitive/double") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Float] + # @param request_options [RequestOptions] + # @return [Float] + def get_and_return_double(request:, request_options: nil) + response = @request_client.conn.post("/primitive/double") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body + end - # @param request [Boolean] - # @param request_options [RequestOptions] - # @return [Boolean] - def get_and_return_bool(request:, request_options: nil) - @request_client.conn.post("/primitive/boolean") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Boolean] + # @param request_options [RequestOptions] + # @return [Boolean] + def get_and_return_bool(request:, request_options: nil) + response = @request_client.conn.post("/primitive/boolean") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body + end - # @param request [DateTime] - # @param request_options [RequestOptions] - # @return [DateTime] - def get_and_return_datetime(request:, request_options: nil) - response = @request_client.conn.post("/primitive/datetime") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - DateTime.parse(response) + # @param request [DateTime] + # @param request_options [RequestOptions] + # @return [DateTime] + def get_and_return_datetime(request:, request_options: nil) + response = @request_client.conn.post("/primitive/datetime") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + DateTime.parse(response.body) + end - # @param request [Date] - # @param request_options [RequestOptions] - # @return [Date] - def get_and_return_date(request:, request_options: nil) - response = @request_client.conn.post("/primitive/date") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Date.parse(response) + # @param request [Date] + # @param request_options [RequestOptions] + # @return [Date] + def get_and_return_date(request:, request_options: nil) + response = @request_client.conn.post("/primitive/date") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Date.parse(response.body) + end - # @param request [UUID] - # @param request_options [RequestOptions] - # @return [UUID] - def get_and_return_uuid(request:, request_options: nil) - @request_client.conn.post("/primitive/uuid") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [UUID] + # @param request_options [RequestOptions] + # @return [UUID] + def get_and_return_uuid(request:, request_options: nil) + response = @request_client.conn.post("/primitive/uuid") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [String] - def get_and_return_base_64(request:, request_options: nil) - @request_client.conn.post("/primitive/base64") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [String] + def get_and_return_base_64(request:, request_options: nil) + response = @request_client.conn.post("/primitive/base64") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - class AsyncPrimitiveClient - attr_reader :request_client + class AsyncPrimitiveClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncPrimitiveClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Endpoints::AsyncPrimitiveClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [String] - def get_and_return_string(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/string") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [String] + # @param request_options [RequestOptions] + # @return [String] + def get_and_return_string(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/string") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [Integer] - # @param request_options [RequestOptions] - # @return [Integer] - def get_and_return_int(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/integer") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Integer] + # @param request_options [RequestOptions] + # @return [Integer] + def get_and_return_int(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/integer") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [Long] - # @param request_options [RequestOptions] - # @return [Long] - def get_and_return_long(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/long") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Long] + # @param request_options [RequestOptions] + # @return [Long] + def get_and_return_long(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/long") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [Float] - # @param request_options [RequestOptions] - # @return [Float] - def get_and_return_double(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/double") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Float] + # @param request_options [RequestOptions] + # @return [Float] + def get_and_return_double(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/double") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [Boolean] - # @param request_options [RequestOptions] - # @return [Boolean] - def get_and_return_bool(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/boolean") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Boolean] + # @param request_options [RequestOptions] + # @return [Boolean] + def get_and_return_bool(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/boolean") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [DateTime] - # @param request_options [RequestOptions] - # @return [DateTime] - def get_and_return_datetime(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/datetime") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - DateTime.parse(response) + # @param request [DateTime] + # @param request_options [RequestOptions] + # @return [DateTime] + def get_and_return_datetime(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/datetime") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + DateTime.parse(response.body) end + end - # @param request [Date] - # @param request_options [RequestOptions] - # @return [Date] - def get_and_return_date(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/date") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Date.parse(response) + # @param request [Date] + # @param request_options [RequestOptions] + # @return [Date] + def get_and_return_date(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/date") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Date.parse(response.body) end + end - # @param request [UUID] - # @param request_options [RequestOptions] - # @return [UUID] - def get_and_return_uuid(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/uuid") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [UUID] + # @param request_options [RequestOptions] + # @return [UUID] + def get_and_return_uuid(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/uuid") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [String] - def get_and_return_base_64(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/primitive/base64") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [String] + # @param request_options [RequestOptions] + # @return [String] + def get_and_return_base_64(request:, request_options: nil) + Async do + response = @request_client.conn.post("/primitive/base64") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/union/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/union/client.rb index 5ae7350ffd9..c1f6f49d28b 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/union/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/endpoints/union/client.rb @@ -1,58 +1,57 @@ # frozen_string_literal: true +require_relative "../../../requests" require_relative "../../types/union/types/animal" require "async" module SeedExhaustiveClient module Endpoints - module Union - class UnionClient - attr_reader :request_client + class UnionClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [UnionClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [Endpoints::UnionClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Types::Union::Animal, as a Hash - # @param request_options [RequestOptions] - # @return [Types::Union::Animal] - def get_and_return_union(request:, request_options: nil) - response = @request_client.conn.post("/union") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Union::Animal.from_json(json_object: response) + # @param request [Hash] Request of type Types::Union::Animal, as a Hash + # @param request_options [RequestOptions] + # @return [Types::Union::Animal] + def get_and_return_union(request:, request_options: nil) + response = @request_client.conn.post("/union") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Union::Animal.from_json(json_object: response.body) end + end - class AsyncUnionClient - attr_reader :request_client + class AsyncUnionClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncUnionClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Endpoints::AsyncUnionClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Types::Union::Animal, as a Hash - # @param request_options [RequestOptions] - # @return [Types::Union::Animal] - def get_and_return_union(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/union") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Types::Union::Animal.from_json(json_object: response) + # @param request [Hash] Request of type Types::Union::Animal, as a Hash + # @param request_options [RequestOptions] + # @return [Types::Union::Animal] + def get_and_return_union(request:, request_options: nil) + Async do + response = @request_client.conn.post("/union") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Types::Union::Animal.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/inlined_requests/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/inlined_requests/client.rb index 7c711756781..3cf03adb815 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/inlined_requests/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/inlined_requests/client.rb @@ -1,95 +1,98 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "../types/object/types/object_with_optional_field" require "async" module SeedExhaustiveClient - module InlinedRequests - class InlinedRequestsClient - attr_reader :request_client + class InlinedRequestsClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [InlinedRequestsClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client + # @param request_client [RequestClient] + # @return [InlinedRequestsClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + + # POST with custom object in request body, response is an object + # + # @param string [String] + # @param integer [Integer] + # @param nested_object [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def post_with_object_bodyand_response(string:, integer:, nested_object:, request_options: nil) + response = @request_client.conn.post("/req-bodies/object") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + string: string, + integer: integer, + NestedObject: nested_object + }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) + end + end + + class AsyncInlinedRequestsClient + attr_reader :request_client + + # @param request_client [AsyncRequestClient] + # @return [AsyncInlinedRequestsClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param string [String] - # @param integer [Integer] - # @param nested_object [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def post_with_object_bodyand_response(string:, integer:, nested_object:, request_options: nil) + # POST with custom object in request body, response is an object + # + # @param string [String] + # @param integer [Integer] + # @param nested_object [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash + # * :string (String) + # * :integer (Integer) + # * :long (Long) + # * :double (Float) + # * :bool (Boolean) + # * :datetime (DateTime) + # * :date (Date) + # * :uuid (UUID) + # * :base_64 (String) + # * :list (Array) + # * :set (Set) + # * :map (Hash{Integer => Integer}) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def post_with_object_bodyand_response(string:, integer:, nested_object:, request_options: nil) + Async do response = @request_client.conn.post("/req-bodies/object") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.body = { - **request_options&.additional_body_parameters, + **(request_options&.additional_body_parameters || {}), string: string, integer: integer, NestedObject: nested_object }.compact end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) - end - end - - class AsyncInlinedRequestsClient - attr_reader :request_client - - # @param request_client [AsyncRequestClient] - # @return [AsyncInlinedRequestsClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - - # @param string [String] - # @param integer [Integer] - # @param nested_object [Hash] Request of type Types::Object::ObjectWithOptionalField, as a Hash - # * :string (String) - # * :integer (Integer) - # * :long (Long) - # * :double (Float) - # * :bool (Boolean) - # * :datetime (DateTime) - # * :date (Date) - # * :uuid (UUID) - # * :base_64 (String) - # * :list (Array) - # * :set (Set) - # * :map (Hash{Integer => Integer}) - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def post_with_object_bodyand_response(string:, integer:, nested_object:, request_options: nil) - Async.call do - response = @request_client.conn.post("/req-bodies/object") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - string: string, - integer: integer, - NestedObject: nested_object - }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) - end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/no_auth/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/no_auth/client.rb index c367a68a30e..fd6ab81da52 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/no_auth/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/no_auth/client.rb @@ -1,55 +1,59 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedExhaustiveClient - module NoAuth - class NoAuthClient - attr_reader :request_client + class NoAuthClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [NoAuthClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [NoAuthClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Boolean] - def post_with_no_auth(request:, request_options: nil) - @request_client.conn.post("/no-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # POST request with no auth + # + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Boolean] + def post_with_no_auth(request:, request_options: nil) + response = @request_client.conn.post("/no-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - class AsyncNoAuthClient - attr_reader :request_client + class AsyncNoAuthClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncNoAuthClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncNoAuthClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Boolean] - def post_with_no_auth(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/no-auth") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # POST request with no auth + # + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Boolean] + def post_with_no_auth(request:, request_options: nil) + Async do + response = @request_client.conn.post("/no-auth") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/no_req_body/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/no_req_body/client.rb index c4335973414..1a13af0a6e8 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/no_req_body/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/no_req_body/client.rb @@ -1,76 +1,76 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "../types/object/types/object_with_optional_field" require "async" module SeedExhaustiveClient - module NoReqBody - class NoReqBodyClient - attr_reader :request_client + class NoReqBodyClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [NoReqBodyClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [NoReqBodyClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def get_with_no_request_body(request_options: nil) - response = @request_client.conn.get("/no-req-body") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def get_with_no_request_body(request_options: nil) + response = @request_client.conn.get("/no-req-body") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) + end - # @param request_options [RequestOptions] - # @return [String] - def post_with_no_request_body(request_options: nil) - @request_client.conn.post("/no-req-body") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [String] + def post_with_no_request_body(request_options: nil) + response = @request_client.conn.post("/no-req-body") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncNoReqBodyClient - attr_reader :request_client + class AsyncNoReqBodyClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncNoReqBodyClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncNoReqBodyClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Types::Object::ObjectWithOptionalField] - def get_with_no_request_body(request_options: nil) - Async.call do - response = @request_client.conn.get("/no-req-body") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Types::Object::ObjectWithOptionalField.from_json(json_object: response) + # @param request_options [RequestOptions] + # @return [Types::Object::ObjectWithOptionalField] + def get_with_no_request_body(request_options: nil) + Async do + response = @request_client.conn.get("/no-req-body") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Types::Object::ObjectWithOptionalField.from_json(json_object: response.body) end + end - # @param request_options [RequestOptions] - # @return [String] - def post_with_no_request_body(request_options: nil) - Async.call do - response = @request_client.conn.post("/no-req-body") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param request_options [RequestOptions] + # @return [String] + def post_with_no_request_body(request_options: nil) + Async do + response = @request_client.conn.post("/no-req-body") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/req_with_headers/client.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/req_with_headers/client.rb index ef8370897ab..efca4abbe1a 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/req_with_headers/client.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/req_with_headers/client.rb @@ -1,63 +1,62 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedExhaustiveClient - module ReqWithHeaders - class ReqWithHeadersClient - attr_reader :request_client + class ReqWithHeadersClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ReqWithHeadersClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client + # @param request_client [RequestClient] + # @return [ReqWithHeadersClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + + # @param x_test_endpoint_header [String] + # @param request [String] + # @param request_options [RequestOptions] + # @return [Void] + def get_with_custom_header(x_test_endpoint_header:, request:, request_options: nil) + @request_client.conn.post("/test-headers/custom-header") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { + **req.headers, + **(request_options&.additional_headers || {}), + "X-TEST-ENDPOINT-HEADER": x_test_endpoint_header + }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + end + end + + class AsyncReqWithHeadersClient + attr_reader :request_client + + # @param request_client [AsyncRequestClient] + # @return [AsyncReqWithHeadersClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param x_test_endpoint_header [String] - # @param request [String] - # @param request_options [RequestOptions] - # @return [Void] - def get_with_custom_header(x_test_endpoint_header:, request:, request_options: nil) + # @param x_test_endpoint_header [String] + # @param request [String] + # @param request_options [RequestOptions] + # @return [Void] + def get_with_custom_header(x_test_endpoint_header:, request:, request_options: nil) + Async do @request_client.conn.post("/test-headers/custom-header") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? req.headers = { **req.headers, - **request_options&.additional_headers, + **(request_options&.additional_headers || {}), "X-TEST-ENDPOINT-HEADER": x_test_endpoint_header }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - end - end - - class AsyncReqWithHeadersClient - attr_reader :request_client - - # @param request_client [AsyncRequestClient] - # @return [AsyncReqWithHeadersClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - - # @param x_test_endpoint_header [String] - # @param request [String] - # @param request_options [RequestOptions] - # @return [Void] - def get_with_custom_header(x_test_endpoint_header:, request:, request_options: nil) - Async.call do - @request_client.conn.post("/test-headers/custom-header") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { - **req.headers, - **request_options&.additional_headers, - "X-TEST-ENDPOINT-HEADER": x_test_endpoint_header - }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/enum/types/weather_report.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/enum/types/weather_report.rb index 118fda4146a..c284452cc44 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/enum/types/weather_report.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/enum/types/weather_report.rb @@ -3,8 +3,8 @@ module SeedExhaustiveClient module Types module Enum - # @type [Hash{String => String}] - WEATHER_REPORT = { sunny: "SUNNY", cloudy: "CLOUDY", raining: "RAINING", snowing: "SNOWING" }.frozen + # @type [WEATHER_REPORT] + WEATHER_REPORT = { sunny: "SUNNY", cloudy: "CLOUDY", raining: "RAINING", snowing: "SNOWING" }.freeze end end end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_optional_field.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_optional_field.rb index 63f065955a3..ce82504ff1f 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_optional_field.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_optional_field.rb @@ -29,7 +29,8 @@ def initialize(string: nil, nested_object: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) string = struct.string - nested_object = struct.NestedObject + nested_object = struct.NestedObject.to_h.to_json + nested_object = Types::Object::ObjectWithOptionalField.from_json(json_object: nested_object) new(string: string, nested_object: nested_object, additional_properties: struct) end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_required_field.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_required_field.rb index e9d353c06d9..7fc1f77d743 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_required_field.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/nested_object_with_required_field.rb @@ -29,7 +29,8 @@ def initialize(string:, nested_object:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) string = struct.string - nested_object = struct.NestedObject + nested_object = struct.NestedObject.to_h.to_json + nested_object = Types::Object::ObjectWithOptionalField.from_json(json_object: nested_object) new(string: string, nested_object: nested_object, additional_properties: struct) end diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/object_with_optional_field.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/object_with_optional_field.rb index d84c55b56ae..0c14e36b363 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/object_with_optional_field.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/object/types/object_with_optional_field.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "date" -require "json" require "set" +require "json" module SeedExhaustiveClient module Types @@ -66,12 +66,13 @@ def self.from_json(json_object:) long = struct.long double = struct.double bool = struct.bool - datetime = struct.datetime - date = struct.date + datetime = DateTime.parse(struct.datetime) + date = Date.parse(struct.date) uuid = struct.uuid base_64 = struct.base64 list = struct.list - set = struct.set + set = struct.set.to_h.to_json + set = Set.new(set) map = struct.map new(string: string, integer: integer, long: long, double: double, bool: bool, datetime: datetime, date: date, uuid: uuid, base_64: base_64, list: list, set: set, map: map, additional_properties: struct) diff --git a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/union/types/animal.rb b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/union/types/animal.rb index 413b429d535..e765a78ae07 100644 --- a/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/union/types/animal.rb +++ b/seed/ruby-sdk/exhaustive/lib/seed_exhaustive_client/types/union/types/animal.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "cat" require_relative "dog" +require_relative "cat" module SeedExhaustiveClient module Types diff --git a/seed/ruby-sdk/exhaustive/lib/types_export.rb b/seed/ruby-sdk/exhaustive/lib/types_export.rb new file mode 100644 index 00000000000..73691c77f72 --- /dev/null +++ b/seed/ruby-sdk/exhaustive/lib/types_export.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require_relative "seed_exhaustive_client/general_errors/types/bad_object_request_info" +require_relative "seed_exhaustive_client/types/enum/types/weather_report" +require_relative "seed_exhaustive_client/types/object/types/object_with_optional_field" +require_relative "seed_exhaustive_client/types/object/types/object_with_required_field" +require_relative "seed_exhaustive_client/types/object/types/object_with_map_of_map" +require_relative "seed_exhaustive_client/types/object/types/nested_object_with_optional_field" +require_relative "seed_exhaustive_client/types/object/types/nested_object_with_required_field" +require_relative "seed_exhaustive_client/types/union/types/animal" +require_relative "seed_exhaustive_client/types/union/types/dog" +require_relative "seed_exhaustive_client/types/union/types/cat" diff --git a/seed/ruby-sdk/exhaustive/seed_exhaustive_client.gemspec b/seed/ruby-sdk/exhaustive/seed_exhaustive_client.gemspec index 2cdeea5c2ee..ad46b0330ef 100644 --- a/seed/ruby-sdk/exhaustive/seed_exhaustive_client.gemspec +++ b/seed/ruby-sdk/exhaustive/seed_exhaustive_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_exhaustive_client" + spec.version = SeedExhaustiveClient::Gemconfig::VERSION spec.authors = SeedExhaustiveClient::Gemconfig::AUTHORS spec.email = SeedExhaustiveClient::Gemconfig::EMAIL spec.summary = SeedExhaustiveClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/extends/.rubocop.yml b/seed/ruby-sdk/extends/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/extends/.rubocop.yml +++ b/seed/ruby-sdk/extends/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/extends/lib/gemconfig.rb b/seed/ruby-sdk/extends/lib/gemconfig.rb index e541320cd06..f5e3603f16b 100644 --- a/seed/ruby-sdk/extends/lib/gemconfig.rb +++ b/seed/ruby-sdk/extends/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedExtendsClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/extends/lib/requests.rb b/seed/ruby-sdk/extends/lib/requests.rb index 28238388d61..ddc26d45de8 100644 --- a/seed/ruby-sdk/extends/lib/requests.rb +++ b/seed/ruby-sdk/extends/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedExtendsClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedExtendsClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedExtendsClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/extends/lib/seed_extends_client.rb b/seed/ruby-sdk/extends/lib/seed_extends_client.rb index 62d60d7f352..3858ebda829 100644 --- a/seed/ruby-sdk/extends/lib/seed_extends_client.rb +++ b/seed/ruby-sdk/extends/lib/seed_extends_client.rb @@ -1,28 +1,24 @@ # frozen_string_literal: true -require_relative "seed_extends_client/types/docs" -require_relative "seed_extends_client/types/example_type" -require_relative "seed_extends_client/types/json" -require_relative "seed_extends_client/types/nested_type" -require "async/http/faraday" -require "faraday" +require_relative "types_export" +require_relative "requests" module SeedExtendsClient class Client # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end class AsyncClient # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end end diff --git a/seed/ruby-sdk/extends/lib/types_export.rb b/seed/ruby-sdk/extends/lib/types_export.rb new file mode 100644 index 00000000000..27ca0c060b2 --- /dev/null +++ b/seed/ruby-sdk/extends/lib/types_export.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "seed_extends_client/types/example_type" +require_relative "seed_extends_client/types/nested_type" +require_relative "seed_extends_client/types/docs" +require_relative "seed_extends_client/types/json" diff --git a/seed/ruby-sdk/extends/seed_extends_client.gemspec b/seed/ruby-sdk/extends/seed_extends_client.gemspec index 3c0d0683527..a7c4b766eaa 100644 --- a/seed/ruby-sdk/extends/seed_extends_client.gemspec +++ b/seed/ruby-sdk/extends/seed_extends_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_extends_client" + spec.version = SeedExtendsClient::Gemconfig::VERSION spec.authors = SeedExtendsClient::Gemconfig::AUTHORS spec.email = SeedExtendsClient::Gemconfig::EMAIL spec.summary = SeedExtendsClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/file-download/.rubocop.yml b/seed/ruby-sdk/file-download/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/file-download/.rubocop.yml +++ b/seed/ruby-sdk/file-download/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/file-download/lib/core/file_utilities.rb b/seed/ruby-sdk/file-download/lib/core/file_utilities.rb index a786beea06d..ca248f81ba1 100644 --- a/seed/ruby-sdk/file-download/lib/core/file_utilities.rb +++ b/seed/ruby-sdk/file-download/lib/core/file_utilities.rb @@ -9,16 +9,16 @@ class FileUtilities # @param file_like [String, IO] The file to be uploaded, or a string path to the file. # @return [Faraday::Multipart::FilePart] def self.as_faraday_multipart(file_like:) - path = if file_like.has_attribute?(path) - file_like.path - else + path = if file_like.is_a?(String) file_like + else + file_like.path end mime_type = MiniMime.lookup_by_filename(path) mime_type = if mime_type.nil? - mime_type.content_type + "application/octet-stream" else - application / octet - stream + mime_type.content_type end Faraday::Multipart::FilePart.new(file_like, mime_type) end diff --git a/seed/ruby-sdk/file-download/lib/gemconfig.rb b/seed/ruby-sdk/file-download/lib/gemconfig.rb index 311ac5cc6e3..f32dab34836 100644 --- a/seed/ruby-sdk/file-download/lib/gemconfig.rb +++ b/seed/ruby-sdk/file-download/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedFileDownloadClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/file-download/lib/requests.rb b/seed/ruby-sdk/file-download/lib/requests.rb index fcdeb945e35..18e6f4c1e11 100644 --- a/seed/ruby-sdk/file-download/lib/requests.rb +++ b/seed/ruby-sdk/file-download/lib/requests.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" require "faraday/multipart" +require "faraday/retry" +require "async/http/faraday" module SeedFileDownloadClient class RequestClient @@ -14,11 +15,11 @@ class RequestClient def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedFileDownloadClient" } @conn = Faraday.new(headers: @headers) do |faraday| + faraday.request :multipart faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.request :multipart + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -32,35 +33,35 @@ class AsyncRequestClient def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedFileDownloadClient" } @conn = Faraday.new(headers: @headers) do |faraday| + faraday.request :multipart faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http - faraday.request :multipart + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/file-download/lib/seed_file_download_client.rb b/seed/ruby-sdk/file-download/lib/seed_file_download_client.rb index e5a1806a3bc..01d311e0a06 100644 --- a/seed/ruby-sdk/file-download/lib/seed_file_download_client.rb +++ b/seed/ruby-sdk/file-download/lib/seed_file_download_client.rb @@ -1,28 +1,31 @@ # frozen_string_literal: true -require "faraday" -require "faraday/multipart" +require_relative "types_export" +require_relative "requests" require_relative "seed_file_download_client/service/client" -require "async/http/faraday" module SeedFileDownloadClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/file-download/lib/seed_file_download_client/service/client.rb b/seed/ruby-sdk/file-download/lib/seed_file_download_client/service/client.rb index 6015ff2b332..46c69d97fbb 100644 --- a/seed/ruby-sdk/file-download/lib/seed_file_download_client/service/client.rb +++ b/seed/ruby-sdk/file-download/lib/seed_file_download_client/service/client.rb @@ -1,50 +1,50 @@ # frozen_string_literal: true +require_relative "../../requests" +require_relative "../../requests" require "async" module SeedFileDownloadClient - module Service - class ServiceClient - attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end - # @yield on_data[chunk, overall_received_bytes, env] Leverage the Faraday on_data callback which will receive tuples of strings, the sum of characters received so far, and the response environment. The latter will allow access to the response status, headers and reason, as well as the request info. - # @param request_options [RequestOptions] - # @return [Void] - def download_file(&on_data, request_options: nil) - response = @request_client.conn.post("/") do | req | - unless request_options.timeout_in_seconds.nil?() + class ServiceClient + attr_reader :request_client + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + # @yield on_data[chunk, overall_received_bytes, env] Leverage the Faraday on_data callback which will receive tuples of strings, the sum of characters received so far, and the response environment. The latter will allow access to the response status, headers and reason, as well as the request info. + # @param request_options [RequestOptions] + # @return [Void] + def download_file(&on_data, request_options: nil) + response = @request_client.conn.post("/") do | req | + unless request_options&.timeout_in_seconds.nil? req.options.timeout = request_options.timeout_in_seconds end - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.options.on_data = &on_data end - end end - class AsyncServiceClient - attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - # @yield on_data[chunk, overall_received_bytes, env] Leverage the Faraday on_data callback which will receive tuples of strings, the sum of characters received so far, and the response environment. The latter will allow access to the response status, headers and reason, as well as the request info. - # @param request_options [RequestOptions] - # @return [Void] - def download_file(&on_data, request_options: nil) - Async.() do - response = @request_client.conn.post("/") do | req | - unless request_options.timeout_in_seconds.nil?() + end + class AsyncServiceClient + attr_reader :request_client + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end + # @yield on_data[chunk, overall_received_bytes, env] Leverage the Faraday on_data callback which will receive tuples of strings, the sum of characters received so far, and the response environment. The latter will allow access to the response status, headers and reason, as well as the request info. + # @param request_options [RequestOptions] + # @return [Void] + def download_file(&on_data, request_options: nil) + Async do + response = @request_client.conn.post("/") do | req | + unless request_options&.timeout_in_seconds.nil? req.options.timeout = request_options.timeout_in_seconds end - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.options.on_data = &on_data end - end end end end diff --git a/seed/ruby-sdk/file-download/lib/types_export.rb b/seed/ruby-sdk/file-download/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/file-download/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/file-download/seed_file_download_client.gemspec b/seed/ruby-sdk/file-download/seed_file_download_client.gemspec index 01ac8f1d838..0a9c814447a 100644 --- a/seed/ruby-sdk/file-download/seed_file_download_client.gemspec +++ b/seed/ruby-sdk/file-download/seed_file_download_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_file_download_client" + spec.version = SeedFileDownloadClient::Gemconfig::VERSION spec.authors = SeedFileDownloadClient::Gemconfig::AUTHORS spec.email = SeedFileDownloadClient::Gemconfig::EMAIL spec.summary = SeedFileDownloadClient::Gemconfig::SUMMARY @@ -19,7 +20,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "async-http-faraday", "~> 0.12" spec.add_dependency "faraday", "~> 2.7" + spec.add_dependency "faraday-multipart", "~> 1.0" spec.add_dependency "faraday-retry", "~> 2.2" - spec.add_dependency "farady-multipart", "~> 1.0" spec.add_dependency "mini_mime", "~> 1.1" end diff --git a/seed/ruby-sdk/file-upload/.rubocop.yml b/seed/ruby-sdk/file-upload/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/file-upload/.rubocop.yml +++ b/seed/ruby-sdk/file-upload/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/file-upload/lib/core/file_utilities.rb b/seed/ruby-sdk/file-upload/lib/core/file_utilities.rb index 9dfb9f03481..e039543620e 100644 --- a/seed/ruby-sdk/file-upload/lib/core/file_utilities.rb +++ b/seed/ruby-sdk/file-upload/lib/core/file_utilities.rb @@ -9,16 +9,16 @@ class FileUtilities # @param file_like [String, IO] The file to be uploaded, or a string path to the file. # @return [Faraday::Multipart::FilePart] def self.as_faraday_multipart(file_like:) - path = if file_like.has_attribute?(path) - file_like.path - else + path = if file_like.is_a?(String) file_like + else + file_like.path end mime_type = MiniMime.lookup_by_filename(path) mime_type = if mime_type.nil? - mime_type.content_type + "application/octet-stream" else - application / octet - stream + mime_type.content_type end Faraday::Multipart::FilePart.new(file_like, mime_type) end diff --git a/seed/ruby-sdk/file-upload/lib/gemconfig.rb b/seed/ruby-sdk/file-upload/lib/gemconfig.rb index 60dddb888cd..a796b1aa978 100644 --- a/seed/ruby-sdk/file-upload/lib/gemconfig.rb +++ b/seed/ruby-sdk/file-upload/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedFileUploadClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/file-upload/lib/requests.rb b/seed/ruby-sdk/file-upload/lib/requests.rb index b32c57f6e28..9d35a08686f 100644 --- a/seed/ruby-sdk/file-upload/lib/requests.rb +++ b/seed/ruby-sdk/file-upload/lib/requests.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" require "faraday/multipart" +require "faraday/retry" +require "async/http/faraday" module SeedFileUploadClient class RequestClient @@ -14,11 +15,11 @@ class RequestClient def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedFileUploadClient" } @conn = Faraday.new(headers: @headers) do |faraday| + faraday.request :multipart faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.request :multipart + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -32,35 +33,35 @@ class AsyncRequestClient def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedFileUploadClient" } @conn = Faraday.new(headers: @headers) do |faraday| + faraday.request :multipart faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http - faraday.request :multipart + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/file-upload/lib/seed_file_upload_client.rb b/seed/ruby-sdk/file-upload/lib/seed_file_upload_client.rb index 60402834ac1..12b6e49fa49 100644 --- a/seed/ruby-sdk/file-upload/lib/seed_file_upload_client.rb +++ b/seed/ruby-sdk/file-upload/lib/seed_file_upload_client.rb @@ -1,31 +1,31 @@ # frozen_string_literal: true -require_relative "seed_file_upload_client/service/types/maybe_list" -require_relative "seed_file_upload_client/service/types/maybe_list_or_set" -require_relative "seed_file_upload_client/service/types/my_object" -require "faraday" -require "faraday/multipart" +require_relative "types_export" +require_relative "requests" require_relative "seed_file_upload_client/service/client" -require "async/http/faraday" module SeedFileUploadClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/file-upload/lib/seed_file_upload_client/service/client.rb b/seed/ruby-sdk/file-upload/lib/seed_file_upload_client/service/client.rb index c8bb2158a80..524585afed7 100644 --- a/seed/ruby-sdk/file-upload/lib/seed_file_upload_client/service/client.rb +++ b/seed/ruby-sdk/file-upload/lib/seed_file_upload_client/service/client.rb @@ -1,50 +1,148 @@ # frozen_string_literal: true +require_relative "../../requests" require "set" require_relative "types/maybe_list" require_relative "types/maybe_list_or_set" require_relative "types/my_object" +require_relative "../../core/file_utilities" require "async" module SeedFileUploadClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + + # @param maybe_string [String] + # @param integer [Integer] + # @param file [String, IO] + # @param maybe_file [String, IO] + # @param maybe_integer [Integer] + # @param list_of_strings [Array] + # @param set_of_strings [Set] + # @param optional_list_of_strings [Array] + # @param optional_set_of_strings [Set] + # @param maybe_list [Hash] Request of type Service::MaybeList, as a Hash + # @param optional_maybe_list [Hash] Request of type Service::MaybeList, as a Hash + # @param maybe_list_or_set [Hash] Request of type Service::MaybeListOrSet, as a Hash + # @param optional_maybe_list_or_set [Hash] Request of type Service::MaybeListOrSet, as a Hash + # @param list_of_objects [Array] Request of type Array, as a Hash + # * :foo (String) + # @param request_options [RequestOptions] + # @return [Void] + def post(integer:, file:, list_of_strings:, set_of_strings:, maybe_list:, maybe_list_or_set:, list_of_objects:, + maybe_string: nil, maybe_file: nil, maybe_integer: nil, optional_list_of_strings: nil, optional_set_of_strings: nil, optional_maybe_list: nil, optional_maybe_list_or_set: nil, request_options: nil) + @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + maybeString: maybe_string, + integer: integer, + file: FileUtilities.as_faraday_multipart(file_like: file), + maybeFile: (FileUtilities.as_faraday_multipart(file_like: maybe_file) unless maybe_file.nil?), + maybeInteger: maybe_integer, + listOfStrings: list_of_strings, + setOfStrings: set_of_strings, + optionalListOfStrings: optional_list_of_strings, + optionalSetOfStrings: optional_set_of_strings, + maybeList: maybe_list, + optionalMaybeList: optional_maybe_list, + maybeListOrSet: maybe_list_or_set, + optionalMaybeListOrSet: optional_maybe_list_or_set, + listOfObjects: list_of_objects + }.compact + end + end + + # @param file [String, IO] + # @param request_options [RequestOptions] + # @return [Void] + def just_file(file:, request_options: nil) + @request_client.conn.post("/just-file") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + file: FileUtilities.as_faraday_multipart(file_like: file) + }.compact + end + end + + # @param maybe_string [String] + # @param integer [Integer] + # @param maybe_integer [Integer] + # @param list_of_strings [String] + # @param optional_list_of_strings [String] + # @param file [String, IO] + # @param request_options [RequestOptions] + # @return [Void] + def just_file_with_query_params(integer:, list_of_strings:, file:, maybe_string: nil, maybe_integer: nil, + optional_list_of_strings: nil, request_options: nil) + @request_client.conn.post("/just-file-with-query-params") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "maybeString": maybe_string, + "integer": integer, + "maybeInteger": maybe_integer, + "listOfStrings": list_of_strings, + "optionalListOfStrings": optional_list_of_strings + }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + file: FileUtilities.as_faraday_multipart(file_like: file) + }.compact end + end + end + + class AsyncServiceClient + attr_reader :request_client - # @param maybe_string [String] - # @param integer [Integer] - # @param file [String, IO] - # @param maybe_file [String, IO] - # @param maybe_integer [Integer] - # @param list_of_strings [Array] - # @param set_of_strings [Set] - # @param optional_list_of_strings [Array] - # @param optional_set_of_strings [Set] - # @param maybe_list [Hash] Request of type Service::MaybeList, as a Hash - # @param optional_maybe_list [Hash] Request of type Service::MaybeList, as a Hash - # @param maybe_list_or_set [Hash] Request of type Service::MaybeListOrSet, as a Hash - # @param optional_maybe_list_or_set [Hash] Request of type Service::MaybeListOrSet, as a Hash - # @param list_of_objects [Array] - # @param request_options [RequestOptions] - # @return [Void] - def post(integer:, file:, list_of_strings:, set_of_strings:, maybe_list:, maybe_list_or_set:, list_of_objects:, - maybe_string: nil, maybe_file: nil, maybe_integer: nil, optional_list_of_strings: nil, optional_set_of_strings: nil, optional_maybe_list: nil, optional_maybe_list_or_set: nil, request_options: nil) + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end + + # @param maybe_string [String] + # @param integer [Integer] + # @param file [String, IO] + # @param maybe_file [String, IO] + # @param maybe_integer [Integer] + # @param list_of_strings [Array] + # @param set_of_strings [Set] + # @param optional_list_of_strings [Array] + # @param optional_set_of_strings [Set] + # @param maybe_list [Hash] Request of type Service::MaybeList, as a Hash + # @param optional_maybe_list [Hash] Request of type Service::MaybeList, as a Hash + # @param maybe_list_or_set [Hash] Request of type Service::MaybeListOrSet, as a Hash + # @param optional_maybe_list_or_set [Hash] Request of type Service::MaybeListOrSet, as a Hash + # @param list_of_objects [Array] Request of type Array, as a Hash + # * :foo (String) + # @param request_options [RequestOptions] + # @return [Void] + def post(integer:, file:, list_of_strings:, set_of_strings:, maybe_list:, maybe_list_or_set:, list_of_objects:, + maybe_string: nil, maybe_file: nil, maybe_integer: nil, optional_list_of_strings: nil, optional_set_of_strings: nil, optional_maybe_list: nil, optional_maybe_list_or_set: nil, request_options: nil) + Async do @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.body = { - **request_options&.additional_body_parameters, + **(request_options&.additional_body_parameters || {}), maybeString: maybe_string, integer: integer, file: FileUtilities.as_faraday_multipart(file_like: file), - maybeFile: (FileUtilities.as_faraday_multipart(file_like: maybe_file) if maybe_file.nil?), + maybeFile: (FileUtilities.as_faraday_multipart(file_like: maybe_file) unless maybe_file.nil?), maybeInteger: maybe_integer, listOfStrings: list_of_strings, setOfStrings: set_of_strings, @@ -58,36 +156,40 @@ def post(integer:, file:, list_of_strings:, set_of_strings:, maybe_list:, maybe_ }.compact end end + end - # @param file [String, IO] - # @param request_options [RequestOptions] - # @return [Void] - def just_file(file:, request_options: nil) + # @param file [String, IO] + # @param request_options [RequestOptions] + # @return [Void] + def just_file(file:, request_options: nil) + Async do @request_client.conn.post("/just-file") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.body = { - **request_options&.additional_body_parameters, + **(request_options&.additional_body_parameters || {}), file: FileUtilities.as_faraday_multipart(file_like: file) }.compact end end + end - # @param maybe_string [String] - # @param integer [Integer] - # @param maybe_integer [Integer] - # @param list_of_strings [String] - # @param optional_list_of_strings [String] - # @param file [String, IO] - # @param request_options [RequestOptions] - # @return [Void] - def just_file_with_query_params(integer:, list_of_strings:, file:, maybe_string: nil, maybe_integer: nil, - optional_list_of_strings: nil, request_options: nil) + # @param maybe_string [String] + # @param integer [Integer] + # @param maybe_integer [Integer] + # @param list_of_strings [String] + # @param optional_list_of_strings [String] + # @param file [String, IO] + # @param request_options [RequestOptions] + # @return [Void] + def just_file_with_query_params(integer:, list_of_strings:, file:, maybe_string: nil, maybe_integer: nil, + optional_list_of_strings: nil, request_options: nil) + Async do @request_client.conn.post("/just-file-with-query-params") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.params = { - **request_options&.additional_query_parameters, + **(request_options&.additional_query_parameters || {}), "maybeString": maybe_string, "integer": integer, "maybeInteger": maybe_integer, @@ -95,111 +197,11 @@ def just_file_with_query_params(integer:, list_of_strings:, file:, maybe_string: "optionalListOfStrings": optional_list_of_strings }.compact req.body = { - **request_options&.additional_body_parameters, + **(request_options&.additional_body_parameters || {}), file: FileUtilities.as_faraday_multipart(file_like: file) }.compact end end end - - class AsyncServiceClient - attr_reader :request_client - - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - - # @param maybe_string [String] - # @param integer [Integer] - # @param file [String, IO] - # @param maybe_file [String, IO] - # @param maybe_integer [Integer] - # @param list_of_strings [Array] - # @param set_of_strings [Set] - # @param optional_list_of_strings [Array] - # @param optional_set_of_strings [Set] - # @param maybe_list [Hash] Request of type Service::MaybeList, as a Hash - # @param optional_maybe_list [Hash] Request of type Service::MaybeList, as a Hash - # @param maybe_list_or_set [Hash] Request of type Service::MaybeListOrSet, as a Hash - # @param optional_maybe_list_or_set [Hash] Request of type Service::MaybeListOrSet, as a Hash - # @param list_of_objects [Array] - # @param request_options [RequestOptions] - # @return [Void] - def post(integer:, file:, list_of_strings:, set_of_strings:, maybe_list:, maybe_list_or_set:, list_of_objects:, - maybe_string: nil, maybe_file: nil, maybe_integer: nil, optional_list_of_strings: nil, optional_set_of_strings: nil, optional_maybe_list: nil, optional_maybe_list_or_set: nil, request_options: nil) - Async.call do - @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - maybeString: maybe_string, - integer: integer, - file: FileUtilities.as_faraday_multipart(file_like: file), - maybeFile: (FileUtilities.as_faraday_multipart(file_like: maybe_file) if maybe_file.nil?), - maybeInteger: maybe_integer, - listOfStrings: list_of_strings, - setOfStrings: set_of_strings, - optionalListOfStrings: optional_list_of_strings, - optionalSetOfStrings: optional_set_of_strings, - maybeList: maybe_list, - optionalMaybeList: optional_maybe_list, - maybeListOrSet: maybe_list_or_set, - optionalMaybeListOrSet: optional_maybe_list_or_set, - listOfObjects: list_of_objects - }.compact - end - end - end - - # @param file [String, IO] - # @param request_options [RequestOptions] - # @return [Void] - def just_file(file:, request_options: nil) - Async.call do - @request_client.conn.post("/just-file") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - file: FileUtilities.as_faraday_multipart(file_like: file) - }.compact - end - end - end - - # @param maybe_string [String] - # @param integer [Integer] - # @param maybe_integer [Integer] - # @param list_of_strings [String] - # @param optional_list_of_strings [String] - # @param file [String, IO] - # @param request_options [RequestOptions] - # @return [Void] - def just_file_with_query_params(integer:, list_of_strings:, file:, maybe_string: nil, maybe_integer: nil, - optional_list_of_strings: nil, request_options: nil) - Async.call do - @request_client.conn.post("/just-file-with-query-params") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { - **request_options&.additional_query_parameters, - "maybeString": maybe_string, - "integer": integer, - "maybeInteger": maybe_integer, - "listOfStrings": list_of_strings, - "optionalListOfStrings": optional_list_of_strings - }.compact - req.body = { - **request_options&.additional_body_parameters, - file: FileUtilities.as_faraday_multipart(file_like: file) - }.compact - end - end - end - end end end diff --git a/seed/ruby-sdk/file-upload/lib/types_export.rb b/seed/ruby-sdk/file-upload/lib/types_export.rb new file mode 100644 index 00000000000..637baf999c3 --- /dev/null +++ b/seed/ruby-sdk/file-upload/lib/types_export.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require_relative "seed_file_upload_client/service/types/maybe_list" +require_relative "seed_file_upload_client/service/types/maybe_list_or_set" +require_relative "seed_file_upload_client/service/types/my_object" diff --git a/seed/ruby-sdk/file-upload/seed_file_upload_client.gemspec b/seed/ruby-sdk/file-upload/seed_file_upload_client.gemspec index c5bdf32a5ab..4f8dabb4445 100644 --- a/seed/ruby-sdk/file-upload/seed_file_upload_client.gemspec +++ b/seed/ruby-sdk/file-upload/seed_file_upload_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_file_upload_client" + spec.version = SeedFileUploadClient::Gemconfig::VERSION spec.authors = SeedFileUploadClient::Gemconfig::AUTHORS spec.email = SeedFileUploadClient::Gemconfig::EMAIL spec.summary = SeedFileUploadClient::Gemconfig::SUMMARY @@ -19,7 +20,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "async-http-faraday", "~> 0.12" spec.add_dependency "faraday", "~> 2.7" + spec.add_dependency "faraday-multipart", "~> 1.0" spec.add_dependency "faraday-retry", "~> 2.2" - spec.add_dependency "farady-multipart", "~> 1.0" spec.add_dependency "mini_mime", "~> 1.1" end diff --git a/seed/ruby-sdk/folders/.rubocop.yml b/seed/ruby-sdk/folders/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/folders/.rubocop.yml +++ b/seed/ruby-sdk/folders/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/folders/lib/gemconfig.rb b/seed/ruby-sdk/folders/lib/gemconfig.rb index ca0b8ab5623..b4c1f83d5b0 100644 --- a/seed/ruby-sdk/folders/lib/gemconfig.rb +++ b/seed/ruby-sdk/folders/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/folders/lib/requests.rb b/seed/ruby-sdk/folders/lib/requests.rb index b8292bba0f6..9317fb201a2 100644 --- a/seed/ruby-sdk/folders/lib/requests.rb +++ b/seed/ruby-sdk/folders/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedApiClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedApiClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedApiClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/folders/lib/seed_api_client.rb b/seed/ruby-sdk/folders/lib/seed_api_client.rb index 50ab6934ff4..21705e0644b 100644 --- a/seed/ruby-sdk/folders/lib/seed_api_client.rb +++ b/seed/ruby-sdk/folders/lib/seed_api_client.rb @@ -1,51 +1,52 @@ # frozen_string_literal: true - -require_relative "seed_api_client/a/d/types/types/foo" -require "faraday" -require_relative "seed_api_client/a/b/client" -require_relative "seed_api_client/a/c/client" -require_relative "seed_api_client/aclient" +require_relative "types_export" +require_relative "requests" +require_relative "seed_api_client/a/client" require_relative "seed_api_client/folder/client" -require "async/http/faraday" +require_relative "requests" +require_relative "seed_api_client/a/client" module SeedApiClient class Client + attr_reader :a, : # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. - # @param timeout_in_seconds [Long] - # @return [] + # @param timeout_in_seconds [Long] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @client = Client.initialize(request_client: request_client) - @client = Client.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @a = A::Client.new(request_client: @request_client) + @ = Folder::Client.new(request_client: @request_client) end - - # @param request_options [RequestOptions] + # @param request_options [RequestOptions] # @return [Void] def foo(request_options: nil) - request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + response = @request_client.conn.post("/") do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact +end end end - class AsyncClient + attr_reader :a, : # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. - # @param timeout_in_seconds [Long] - # @return [] + # @param timeout_in_seconds [Long] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_client = AsyncClient.initialize(client: request_client) - @async_client = AsyncClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @a = A::AsyncClient.new(request_client: @async_request_client) + @ = Folder::AsyncClient.new(request_client: @async_request_client) end - - # @param request_options [RequestOptions] + # @param request_options [RequestOptions] # @return [Void] def foo(request_options: nil) - request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - end + response = @async_request_client.conn.post("/") do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + end + end +end \ No newline at end of file diff --git a/seed/ruby-sdk/folders/lib/seed_api_client/a/b/client.rb b/seed/ruby-sdk/folders/lib/seed_api_client/a/b/client.rb index e921e1bb8f8..d1f04a7fe4e 100644 --- a/seed/ruby-sdk/folders/lib/seed_api_client/a/b/client.rb +++ b/seed/ruby-sdk/folders/lib/seed_api_client/a/b/client.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "../../../requests" require "async" module SeedApiClient @@ -9,7 +10,7 @@ class Client attr_reader :request_client # @param request_client [RequestClient] - # @return [Client] + # @return [A::B::Client] def initialize(request_client:) # @type [RequestClient] @request_client = request_client @@ -19,8 +20,8 @@ def initialize(request_client:) # @return [Void] def foo(request_options: nil) @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end @@ -29,7 +30,7 @@ class AsyncClient attr_reader :request_client # @param request_client [AsyncRequestClient] - # @return [AsyncClient] + # @return [A::B::AsyncClient] def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client @@ -38,10 +39,10 @@ def initialize(request_client:) # @param request_options [RequestOptions] # @return [Void] def foo(request_options: nil) - Async.call do + Async do @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/folders/lib/seed_api_client/a/c/client.rb b/seed/ruby-sdk/folders/lib/seed_api_client/a/c/client.rb index 295350c930d..065f491c6ac 100644 --- a/seed/ruby-sdk/folders/lib/seed_api_client/a/c/client.rb +++ b/seed/ruby-sdk/folders/lib/seed_api_client/a/c/client.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "../../../requests" require "async" module SeedApiClient @@ -9,7 +10,7 @@ class Client attr_reader :request_client # @param request_client [RequestClient] - # @return [Client] + # @return [A::C::Client] def initialize(request_client:) # @type [RequestClient] @request_client = request_client @@ -19,8 +20,8 @@ def initialize(request_client:) # @return [Void] def foo(request_options: nil) @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end @@ -29,7 +30,7 @@ class AsyncClient attr_reader :request_client # @param request_client [AsyncRequestClient] - # @return [AsyncClient] + # @return [A::C::AsyncClient] def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client @@ -38,10 +39,10 @@ def initialize(request_client:) # @param request_options [RequestOptions] # @return [Void] def foo(request_options: nil) - Async.call do + Async do @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/folders/lib/seed_api_client/a/client.rb b/seed/ruby-sdk/folders/lib/seed_api_client/a/client.rb index 18baf33584f..b277ed81de9 100644 --- a/seed/ruby-sdk/folders/lib/seed_api_client/a/client.rb +++ b/seed/ruby-sdk/folders/lib/seed_api_client/a/client.rb @@ -1,30 +1,22 @@ # frozen_string_literal: true - -require_relative "b/client" +require_relative "../../requests" require_relative "c/client" module SeedApiClient module A class Client - attr_reader :request_client - - # @param client [RequestClient] - # @return [] - def initialize(client:) - @client = Client.initialize(request_client: @request_client) - @client = Client.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [A::Client] + def initialize(request_client:) + @ = A::C::Client.new(request_client: request_client) end end - class AsyncClient - attr_reader :client - - # @param client [AsyncRequestClient] - # @return [] - def initialize(client:) - @async_client = AsyncClient.initialize(request_client: @request_client) - @async_client = AsyncClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [A::AsyncClient] + def initialize(request_client:) + @ = A::C::AsyncClient.new(request_client: request_client) end end end -end +end \ No newline at end of file diff --git a/seed/ruby-sdk/folders/lib/seed_api_client/folder/client.rb b/seed/ruby-sdk/folders/lib/seed_api_client/folder/client.rb index 80ca3e5e42d..fafa7f5bdeb 100644 --- a/seed/ruby-sdk/folders/lib/seed_api_client/folder/client.rb +++ b/seed/ruby-sdk/folders/lib/seed_api_client/folder/client.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedApiClient @@ -8,7 +9,7 @@ class Client attr_reader :request_client # @param request_client [RequestClient] - # @return [Client] + # @return [Folder::Client] def initialize(request_client:) # @type [RequestClient] @request_client = request_client @@ -18,8 +19,8 @@ def initialize(request_client:) # @return [Void] def foo(request_options: nil) @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end @@ -28,7 +29,7 @@ class AsyncClient attr_reader :request_client # @param request_client [AsyncRequestClient] - # @return [AsyncClient] + # @return [Folder::AsyncClient] def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client @@ -37,10 +38,10 @@ def initialize(request_client:) # @param request_options [RequestOptions] # @return [Void] def foo(request_options: nil) - Async.call do + Async do @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/folders/lib/seed_api_client/folder/service/client.rb b/seed/ruby-sdk/folders/lib/seed_api_client/folder/service/client.rb index b5464eb5e08..103f57cee66 100644 --- a/seed/ruby-sdk/folders/lib/seed_api_client/folder/service/client.rb +++ b/seed/ruby-sdk/folders/lib/seed_api_client/folder/service/client.rb @@ -1,72 +1,71 @@ # frozen_string_literal: true +require_relative "../../../requests" require "async" module SeedApiClient module Folder - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [Folder::ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Void] - def endpoint(request_options: nil) - @request_client.conn.get("/service") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [Void] + def endpoint(request_options: nil) + @request_client.conn.get("/service") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Void] - def unknown_request(request:, request_options: nil) - @request_client.conn.post("/service") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Void] + def unknown_request(request:, request_options: nil) + @request_client.conn.post("/service") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [Folder::AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Void] - def endpoint(request_options: nil) - Async.call do - @request_client.conn.get("/service") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [Void] + def endpoint(request_options: nil) + Async do + @request_client.conn.get("/service") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Void] - def unknown_request(request:, request_options: nil) - Async.call do - @request_client.conn.post("/service") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Void] + def unknown_request(request:, request_options: nil) + Async do + @request_client.conn.post("/service") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end end diff --git a/seed/ruby-sdk/folders/lib/types_export.rb b/seed/ruby-sdk/folders/lib/types_export.rb new file mode 100644 index 00000000000..270a740ab48 --- /dev/null +++ b/seed/ruby-sdk/folders/lib/types_export.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "seed_api_client/a/d/types/types/foo" diff --git a/seed/ruby-sdk/folders/seed_api_client.gemspec b/seed/ruby-sdk/folders/seed_api_client.gemspec index e3108090020..f2bc0cddd0a 100644 --- a/seed/ruby-sdk/folders/seed_api_client.gemspec +++ b/seed/ruby-sdk/folders/seed_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_client" + spec.version = SeedApiClient::Gemconfig::VERSION spec.authors = SeedApiClient::Gemconfig::AUTHORS spec.email = SeedApiClient::Gemconfig::EMAIL spec.summary = SeedApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/idempotency-headers/.rubocop.yml b/seed/ruby-sdk/idempotency-headers/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/idempotency-headers/.rubocop.yml +++ b/seed/ruby-sdk/idempotency-headers/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/idempotency-headers/lib/gemconfig.rb b/seed/ruby-sdk/idempotency-headers/lib/gemconfig.rb index 1fef07848b7..048480e4ec1 100644 --- a/seed/ruby-sdk/idempotency-headers/lib/gemconfig.rb +++ b/seed/ruby-sdk/idempotency-headers/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedIdempotencyHeadersClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/idempotency-headers/lib/requests.rb b/seed/ruby-sdk/idempotency-headers/lib/requests.rb index 48b48c6d716..11d07af0c54 100644 --- a/seed/ruby-sdk/idempotency-headers/lib/requests.rb +++ b/seed/ruby-sdk/idempotency-headers/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedIdempotencyHeadersClient class RequestClient @@ -11,7 +12,7 @@ class RequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [RequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedIdempotencyHeadersClient", @@ -19,9 +20,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -33,7 +34,7 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [AsyncRequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedIdempotencyHeadersClient", @@ -41,29 +42,27 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [Hash{String => Object}] @@ -72,6 +71,8 @@ def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additio @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client.rb b/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client.rb index 9b1c9bd84b9..bf2530ffb3d 100644 --- a/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client.rb +++ b/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client.rb @@ -1,29 +1,35 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_idempotency_headers_client/payment/client" -require "async/http/faraday" module SeedIdempotencyHeadersClient class Client + attr_reader :payment + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @payment_client = PaymentClient.initialize(request_client: request_client) + # @return [Client] + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + token: token) + @payment = PaymentClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :payment + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_payment_client = AsyncPaymentClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + token: token) + @payment = AsyncPaymentClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client/payment/client.rb b/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client/payment/client.rb index f70efcdae15..66d6172fc5c 100644 --- a/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client/payment/client.rb +++ b/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client/payment/client.rb @@ -1,80 +1,85 @@ # frozen_string_literal: true +require_relative "../../requests" +require_relative "types/currency" require "async" module SeedIdempotencyHeadersClient - module Payment - class PaymentClient - attr_reader :request_client + class PaymentClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [PaymentClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [PaymentClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param amount [Integer] - # @param currency [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [UUID] - def create(amount:, currency:, request_options: nil) - @request_client.conn.post("/payment") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, amount: amount, currency: currency }.compact - end + # @param amount [Integer] + # @param currency [CURRENCY] + # @param request_options [RequestOptions] + # @return [UUID] + def create(amount:, currency:, request_options: nil) + response = @request_client.conn.post("/payment") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), amount: amount, currency: currency }.compact end + response.body + end - # @param payment_id [String] - # @param request_options [RequestOptions] - # @return [Void] - def delete(payment_id:, request_options: nil) - @request_client.conn.delete("/payment/#{payment_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param payment_id [String] + # @param request_options [RequestOptions] + # @return [Void] + def delete(payment_id:, request_options: nil) + @request_client.conn.delete("/payment/#{payment_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - class AsyncPaymentClient - attr_reader :request_client + class AsyncPaymentClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncPaymentClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncPaymentClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param amount [Integer] - # @param currency [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [UUID] - def create(amount:, currency:, request_options: nil) - Async.call do - response = @request_client.conn.post("/payment") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, amount: amount, currency: currency }.compact - end - response + # @param amount [Integer] + # @param currency [CURRENCY] + # @param request_options [RequestOptions] + # @return [UUID] + def create(amount:, currency:, request_options: nil) + Async do + response = @request_client.conn.post("/payment") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + amount: amount, + currency: currency + }.compact end + response.body end + end - # @param payment_id [String] - # @param request_options [RequestOptions] - # @return [Void] - def delete(payment_id:, request_options: nil) - Async.call do - @request_client.conn.delete("/payment/#{payment_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param payment_id [String] + # @param request_options [RequestOptions] + # @return [Void] + def delete(payment_id:, request_options: nil) + Async do + @request_client.conn.delete("/payment/#{payment_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client/payment/types/currency.rb b/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client/payment/types/currency.rb index 77882b8a0a3..5941abcb538 100644 --- a/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client/payment/types/currency.rb +++ b/seed/ruby-sdk/idempotency-headers/lib/seed_idempotency_headers_client/payment/types/currency.rb @@ -2,7 +2,7 @@ module SeedIdempotencyHeadersClient module Payment - # @type [Hash{String => String}] - CURRENCY = { usd: "USD", yen: "YEN" }.frozen + # @type [CURRENCY] + CURRENCY = { usd: "USD", yen: "YEN" }.freeze end end diff --git a/seed/ruby-sdk/idempotency-headers/lib/types_export.rb b/seed/ruby-sdk/idempotency-headers/lib/types_export.rb new file mode 100644 index 00000000000..c74d9641133 --- /dev/null +++ b/seed/ruby-sdk/idempotency-headers/lib/types_export.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "seed_idempotency_headers_client/payment/types/currency" diff --git a/seed/ruby-sdk/idempotency-headers/seed_idempotency_headers_client.gemspec b/seed/ruby-sdk/idempotency-headers/seed_idempotency_headers_client.gemspec index 0b1a30d3507..5d3f8bc61ad 100644 --- a/seed/ruby-sdk/idempotency-headers/seed_idempotency_headers_client.gemspec +++ b/seed/ruby-sdk/idempotency-headers/seed_idempotency_headers_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_idempotency_headers_client" + spec.version = SeedIdempotencyHeadersClient::Gemconfig::VERSION spec.authors = SeedIdempotencyHeadersClient::Gemconfig::AUTHORS spec.email = SeedIdempotencyHeadersClient::Gemconfig::EMAIL spec.summary = SeedIdempotencyHeadersClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/imdb/.rubocop.yml b/seed/ruby-sdk/imdb/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/imdb/.rubocop.yml +++ b/seed/ruby-sdk/imdb/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/imdb/lib/gemconfig.rb b/seed/ruby-sdk/imdb/lib/gemconfig.rb index ca0b8ab5623..b4c1f83d5b0 100644 --- a/seed/ruby-sdk/imdb/lib/gemconfig.rb +++ b/seed/ruby-sdk/imdb/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/imdb/lib/requests.rb b/seed/ruby-sdk/imdb/lib/requests.rb index ab43de9c1b7..c4b3d5104f8 100644 --- a/seed/ruby-sdk/imdb/lib/requests.rb +++ b/seed/ruby-sdk/imdb/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedApiClient class RequestClient @@ -11,13 +12,13 @@ class RequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [RequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedApiClient", "Authorization": "Bearer #{token}" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -29,33 +30,31 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [AsyncRequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedApiClient", "Authorization": "Bearer #{token}" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [Hash{String => Object}] @@ -64,6 +63,8 @@ def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additio @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/imdb/lib/seed_api_client.rb b/seed/ruby-sdk/imdb/lib/seed_api_client.rb index dc4edb44302..4df1b028191 100644 --- a/seed/ruby-sdk/imdb/lib/seed_api_client.rb +++ b/seed/ruby-sdk/imdb/lib/seed_api_client.rb @@ -1,33 +1,35 @@ # frozen_string_literal: true -require_relative "seed_api_client/imdb/types/movie" - -require_relative "seed_api_client/imdb/types/create_movie_request" -require_relative "seed_api_client/imdb/types/movie_id" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_api_client/imdb/client" -require "async/http/faraday" module SeedApiClient class Client + attr_reader :imdb + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @imdb_client = ImdbClient.initialize(request_client: request_client) + # @return [Client] + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + token: token) + @imdb = ImdbClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :imdb + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_imdb_client = AsyncImdbClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + token: token) + @imdb = AsyncImdbClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/imdb/lib/seed_api_client/imdb/client.rb b/seed/ruby-sdk/imdb/lib/seed_api_client/imdb/client.rb index 1334216b91d..b2dfd0a4083 100644 --- a/seed/ruby-sdk/imdb/lib/seed_api_client/imdb/client.rb +++ b/seed/ruby-sdk/imdb/lib/seed_api_client/imdb/client.rb @@ -1,88 +1,92 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "types/create_movie_request" -require_relative "types/movie" require_relative "types/movie_id" +require_relative "types/movie" require "async" module SeedApiClient - module Imdb - class ImdbClient - attr_reader :request_client + class ImdbClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ImdbClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ImdbClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Imdb::CreateMovieRequest, as a Hash - # * :title (String) - # * :rating (Float) - # @param request_options [RequestOptions] - # @return [Imdb::MOVIE_ID] - def create_movie(request:, request_options: nil) - @request_client.conn.post("/movies/create-movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # Add a movie to the database + # + # @param request [Hash] Request of type Imdb::CreateMovieRequest, as a Hash + # * :title (String) + # * :rating (Float) + # @param request_options [RequestOptions] + # @return [Imdb::MOVIE_ID] + def create_movie(request:, request_options: nil) + response = @request_client.conn.post("/movies/create-movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body + end - # @param movie_id [Imdb::MOVIE_ID] - # @param request_options [RequestOptions] - # @return [Imdb::Movie] - def get_movie(movie_id:, request_options: nil) - response = @request_client.conn.get("/movies/#{movie_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Imdb::Movie.from_json(json_object: response) + # @param movie_id [Imdb::MOVIE_ID] + # @param request_options [RequestOptions] + # @return [Imdb::Movie] + def get_movie(movie_id:, request_options: nil) + response = @request_client.conn.get("/movies/#{movie_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Imdb::Movie.from_json(json_object: response.body) end + end - class AsyncImdbClient - attr_reader :request_client + class AsyncImdbClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncImdbClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncImdbClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Imdb::CreateMovieRequest, as a Hash - # * :title (String) - # * :rating (Float) - # @param request_options [RequestOptions] - # @return [Imdb::MOVIE_ID] - def create_movie(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/movies/create-movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # Add a movie to the database + # + # @param request [Hash] Request of type Imdb::CreateMovieRequest, as a Hash + # * :title (String) + # * :rating (Float) + # @param request_options [RequestOptions] + # @return [Imdb::MOVIE_ID] + def create_movie(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movies/create-movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - # @param movie_id [Imdb::MOVIE_ID] - # @param request_options [RequestOptions] - # @return [Imdb::Movie] - def get_movie(movie_id:, request_options: nil) - Async.call do - response = @request_client.conn.get("/movies/#{movie_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Imdb::Movie.from_json(json_object: response) + # @param movie_id [Imdb::MOVIE_ID] + # @param request_options [RequestOptions] + # @return [Imdb::Movie] + def get_movie(movie_id:, request_options: nil) + Async do + response = @request_client.conn.get("/movies/#{movie_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Imdb::Movie.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/imdb/lib/types_export.rb b/seed/ruby-sdk/imdb/lib/types_export.rb new file mode 100644 index 00000000000..4dbe7ba677c --- /dev/null +++ b/seed/ruby-sdk/imdb/lib/types_export.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require_relative "seed_api_client/imdb/types/movie_id" +require_relative "seed_api_client/imdb/types/movie" +require_relative "seed_api_client/imdb/types/create_movie_request" diff --git a/seed/ruby-sdk/imdb/seed_api_client.gemspec b/seed/ruby-sdk/imdb/seed_api_client.gemspec index e3108090020..f2bc0cddd0a 100644 --- a/seed/ruby-sdk/imdb/seed_api_client.gemspec +++ b/seed/ruby-sdk/imdb/seed_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_api_client" + spec.version = SeedApiClient::Gemconfig::VERSION spec.authors = SeedApiClient::Gemconfig::AUTHORS spec.email = SeedApiClient::Gemconfig::EMAIL spec.summary = SeedApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/literal-headers/.rubocop.yml b/seed/ruby-sdk/literal-headers/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/literal-headers/.rubocop.yml +++ b/seed/ruby-sdk/literal-headers/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/literal-headers/lib/gemconfig.rb b/seed/ruby-sdk/literal-headers/lib/gemconfig.rb index f3be0556677..30cda88a6cf 100644 --- a/seed/ruby-sdk/literal-headers/lib/gemconfig.rb +++ b/seed/ruby-sdk/literal-headers/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedLiteralHeadersClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/literal-headers/lib/requests.rb b/seed/ruby-sdk/literal-headers/lib/requests.rb index ba07331b1b9..d00ac415700 100644 --- a/seed/ruby-sdk/literal-headers/lib/requests.rb +++ b/seed/ruby-sdk/literal-headers/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedLiteralHeadersClient class RequestClient @@ -14,11 +15,13 @@ class RequestClient # @return [RequestClient] def initialize(api_header:, api_test:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedLiteralHeadersClient" } + @headers["X-API-Header"] = api_header unless api_header.nil? + @headers["X-API-Test"] = api_test unless api_test.nil? @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -33,32 +36,32 @@ class AsyncRequestClient # @return [AsyncRequestClient] def initialize(api_header:, api_test:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedLiteralHeadersClient" } + @headers["X-API-Header"] = api_header unless api_header.nil? + @headers["X-API-Test"] = api_test unless api_test.nil? @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :api_header, :api_test, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :api_header, :api_test, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param api_header [String] # @param api_test [Boolean] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(api_header:, api_test:, timeout_in_seconds: nil, additional_headers: nil, - additional_query_parameters: nil, additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(api_header: nil, api_test: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @api_header = api_header # @type [Boolean] @@ -69,6 +72,8 @@ def initialize(api_header:, api_test:, timeout_in_seconds: nil, additional_heade @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client.rb b/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client.rb index eb61a1d8038..bc47ab2c7a4 100644 --- a/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client.rb +++ b/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client.rb @@ -1,37 +1,43 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_literal_headers_client/no_headers/client" require_relative "seed_literal_headers_client/only_literal_headers/client" require_relative "seed_literal_headers_client/with_non_literal_headers/client" -require "async/http/faraday" module SeedLiteralHeadersClient class Client + attr_reader :no_headers, :only_literal_headers, :with_non_literal_headers + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param api_header [String] # @param api_test [Boolean] - # @return [] + # @return [Client] def initialize(api_header:, api_test:, max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @no_headers_client = NoHeadersClient.initialize(request_client: request_client) - @only_literal_headers_client = OnlyLiteralHeadersClient.initialize(request_client: request_client) - @with_non_literal_headers_client = WithNonLiteralHeadersClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + api_header: api_header, api_test: api_test) + @no_headers = NoHeadersClient.new(request_client: @request_client) + @only_literal_headers = OnlyLiteralHeadersClient.new(request_client: @request_client) + @with_non_literal_headers = WithNonLiteralHeadersClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :no_headers, :only_literal_headers, :with_non_literal_headers + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param api_header [String] # @param api_test [Boolean] - # @return [] + # @return [AsyncClient] def initialize(api_header:, api_test:, max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_no_headers_client = AsyncNoHeadersClient.initialize(request_client: request_client) - @async_only_literal_headers_client = AsyncOnlyLiteralHeadersClient.initialize(request_client: request_client) - @async_with_non_literal_headers_client = AsyncWithNonLiteralHeadersClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + api_header: api_header, api_test: api_test) + @no_headers = AsyncNoHeadersClient.new(request_client: @async_request_client) + @only_literal_headers = AsyncOnlyLiteralHeadersClient.new(request_client: @async_request_client) + @with_non_literal_headers = AsyncWithNonLiteralHeadersClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/no_headers/client.rb b/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/no_headers/client.rb index 546dbea8a2c..270676bfd5c 100644 --- a/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/no_headers/client.rb +++ b/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/no_headers/client.rb @@ -1,51 +1,50 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedLiteralHeadersClient - module NoHeaders - class NoHeadersClient - attr_reader :request_client + class NoHeadersClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [NoHeadersClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [NoHeadersClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Void] - def get(request_options: nil) - @request_client.conn.post("/no-headers") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-Header"] = @request_client.api_header if @request_client.api_header.nil? - req.headers["X-API-Test"] = @request_client.api_test if @request_client.api_test.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [Void] + def get(request_options: nil) + @request_client.conn.post("/no-headers") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-Header"] = request_options.api_header unless request_options&.api_header.nil? + req.headers["X-API-Test"] = request_options.api_test unless request_options&.api_test.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - class AsyncNoHeadersClient - attr_reader :request_client + class AsyncNoHeadersClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncNoHeadersClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncNoHeadersClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Void] - def get(request_options: nil) - Async.call do - @request_client.conn.post("/no-headers") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-Header"] = @request_client.api_header if @request_client.api_header.nil? - req.headers["X-API-Test"] = @request_client.api_test if @request_client.api_test.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [Void] + def get(request_options: nil) + Async do + @request_client.conn.post("/no-headers") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-Header"] = request_options.api_header unless request_options&.api_header.nil? + req.headers["X-API-Test"] = request_options.api_test unless request_options&.api_test.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/only_literal_headers/client.rb b/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/only_literal_headers/client.rb index b6781b77bc9..e6c4cf49219 100644 --- a/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/only_literal_headers/client.rb +++ b/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/only_literal_headers/client.rb @@ -1,67 +1,66 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedLiteralHeadersClient - module OnlyLiteralHeaders - class OnlyLiteralHeadersClient - attr_reader :request_client + class OnlyLiteralHeadersClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [OnlyLiteralHeadersClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client + # @param request_client [RequestClient] + # @return [OnlyLiteralHeadersClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + + # @param literal_endpoint_header [String] + # @param false_endpoint_header [Boolean] + # @param request_options [RequestOptions] + # @return [Void] + def get(literal_endpoint_header:, false_endpoint_header:, request_options: nil) + @request_client.conn.post("/only-literal-headers") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-Header"] = request_options.api_header unless request_options&.api_header.nil? + req.headers["X-API-Test"] = request_options.api_test unless request_options&.api_test.nil? + req.headers = { + **req.headers, + **(request_options&.additional_headers || {}), + "literalEndpointHeader": literal_endpoint_header, + "falseEndpointHeader": false_endpoint_header + }.compact end + end + end + + class AsyncOnlyLiteralHeadersClient + attr_reader :request_client + + # @param request_client [AsyncRequestClient] + # @return [AsyncOnlyLiteralHeadersClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param literal_endpoint_header [String] - # @param false_endpoint_header [Boolean] - # @param request_options [RequestOptions] - # @return [Void] - def get(literal_endpoint_header:, false_endpoint_header:, request_options: nil) + # @param literal_endpoint_header [String] + # @param false_endpoint_header [Boolean] + # @param request_options [RequestOptions] + # @return [Void] + def get(literal_endpoint_header:, false_endpoint_header:, request_options: nil) + Async do @request_client.conn.post("/only-literal-headers") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-Header"] = @request_client.api_header if @request_client.api_header.nil? - req.headers["X-API-Test"] = @request_client.api_test if @request_client.api_test.nil? + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-Header"] = request_options.api_header unless request_options&.api_header.nil? + req.headers["X-API-Test"] = request_options.api_test unless request_options&.api_test.nil? req.headers = { **req.headers, - **request_options&.additional_headers, + **(request_options&.additional_headers || {}), "literalEndpointHeader": literal_endpoint_header, "falseEndpointHeader": false_endpoint_header }.compact end end end - - class AsyncOnlyLiteralHeadersClient - attr_reader :request_client - - # @param request_client [AsyncRequestClient] - # @return [AsyncOnlyLiteralHeadersClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - - # @param literal_endpoint_header [String] - # @param false_endpoint_header [Boolean] - # @param request_options [RequestOptions] - # @return [Void] - def get(literal_endpoint_header:, false_endpoint_header:, request_options: nil) - Async.call do - @request_client.conn.post("/only-literal-headers") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-Header"] = @request_client.api_header if @request_client.api_header.nil? - req.headers["X-API-Test"] = @request_client.api_test if @request_client.api_test.nil? - req.headers = { - **req.headers, - **request_options&.additional_headers, - "literalEndpointHeader": literal_endpoint_header, - "falseEndpointHeader": false_endpoint_header - }.compact - end - end - end - end end end diff --git a/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/with_non_literal_headers/client.rb b/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/with_non_literal_headers/client.rb index 6f596e52bc6..31384deb02b 100644 --- a/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/with_non_literal_headers/client.rb +++ b/seed/ruby-sdk/literal-headers/lib/seed_literal_headers_client/with_non_literal_headers/client.rb @@ -1,32 +1,64 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedLiteralHeadersClient - module WithNonLiteralHeaders - class WithNonLiteralHeadersClient - attr_reader :request_client + class WithNonLiteralHeadersClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [WithNonLiteralHeadersClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client + # @param request_client [RequestClient] + # @return [WithNonLiteralHeadersClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + + # @param non_literal_endpoint_header [String] + # @param literal_endpoint_header [String] + # @param true_endpoint_header [Boolean] + # @param request_options [RequestOptions] + # @return [Void] + def get(non_literal_endpoint_header:, literal_endpoint_header:, true_endpoint_header:, request_options: nil) + @request_client.conn.post("/with-non-literal-headers") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-Header"] = request_options.api_header unless request_options&.api_header.nil? + req.headers["X-API-Test"] = request_options.api_test unless request_options&.api_test.nil? + req.headers = { + **req.headers, + **(request_options&.additional_headers || {}), + "nonLiteralEndpointHeader": non_literal_endpoint_header, + "literalEndpointHeader": literal_endpoint_header, + "trueEndpointHeader": true_endpoint_header + }.compact end + end + end + + class AsyncWithNonLiteralHeadersClient + attr_reader :request_client + + # @param request_client [AsyncRequestClient] + # @return [AsyncWithNonLiteralHeadersClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param non_literal_endpoint_header [String] - # @param literal_endpoint_header [String] - # @param true_endpoint_header [Boolean] - # @param request_options [RequestOptions] - # @return [Void] - def get(non_literal_endpoint_header:, literal_endpoint_header:, true_endpoint_header:, request_options: nil) + # @param non_literal_endpoint_header [String] + # @param literal_endpoint_header [String] + # @param true_endpoint_header [Boolean] + # @param request_options [RequestOptions] + # @return [Void] + def get(non_literal_endpoint_header:, literal_endpoint_header:, true_endpoint_header:, request_options: nil) + Async do @request_client.conn.post("/with-non-literal-headers") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-Header"] = @request_client.api_header if @request_client.api_header.nil? - req.headers["X-API-Test"] = @request_client.api_test if @request_client.api_test.nil? + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["X-API-Header"] = request_options.api_header unless request_options&.api_header.nil? + req.headers["X-API-Test"] = request_options.api_test unless request_options&.api_test.nil? req.headers = { **req.headers, - **request_options&.additional_headers, + **(request_options&.additional_headers || {}), "nonLiteralEndpointHeader": non_literal_endpoint_header, "literalEndpointHeader": literal_endpoint_header, "trueEndpointHeader": true_endpoint_header @@ -34,38 +66,5 @@ def get(non_literal_endpoint_header:, literal_endpoint_header:, true_endpoint_he end end end - - class AsyncWithNonLiteralHeadersClient - attr_reader :request_client - - # @param request_client [AsyncRequestClient] - # @return [AsyncWithNonLiteralHeadersClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - - # @param non_literal_endpoint_header [String] - # @param literal_endpoint_header [String] - # @param true_endpoint_header [Boolean] - # @param request_options [RequestOptions] - # @return [Void] - def get(non_literal_endpoint_header:, literal_endpoint_header:, true_endpoint_header:, request_options: nil) - Async.call do - @request_client.conn.post("/with-non-literal-headers") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["X-API-Header"] = @request_client.api_header if @request_client.api_header.nil? - req.headers["X-API-Test"] = @request_client.api_test if @request_client.api_test.nil? - req.headers = { - **req.headers, - **request_options&.additional_headers, - "nonLiteralEndpointHeader": non_literal_endpoint_header, - "literalEndpointHeader": literal_endpoint_header, - "trueEndpointHeader": true_endpoint_header - }.compact - end - end - end - end end end diff --git a/seed/ruby-sdk/literal-headers/lib/types_export.rb b/seed/ruby-sdk/literal-headers/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/literal-headers/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/literal-headers/seed_literal_headers_client.gemspec b/seed/ruby-sdk/literal-headers/seed_literal_headers_client.gemspec index fed87a4c05e..32eeda67391 100644 --- a/seed/ruby-sdk/literal-headers/seed_literal_headers_client.gemspec +++ b/seed/ruby-sdk/literal-headers/seed_literal_headers_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_literal_headers_client" + spec.version = SeedLiteralHeadersClient::Gemconfig::VERSION spec.authors = SeedLiteralHeadersClient::Gemconfig::AUTHORS spec.email = SeedLiteralHeadersClient::Gemconfig::EMAIL spec.summary = SeedLiteralHeadersClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/literal/.rubocop.yml b/seed/ruby-sdk/literal/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/literal/.rubocop.yml +++ b/seed/ruby-sdk/literal/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/literal/lib/gemconfig.rb b/seed/ruby-sdk/literal/lib/gemconfig.rb index 8d858b47a0b..fb36a4c1b5b 100644 --- a/seed/ruby-sdk/literal/lib/gemconfig.rb +++ b/seed/ruby-sdk/literal/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedLiteralClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/literal/lib/requests.rb b/seed/ruby-sdk/literal/lib/requests.rb index 5c26ccd43b4..e19baa03557 100644 --- a/seed/ruby-sdk/literal/lib/requests.rb +++ b/seed/ruby-sdk/literal/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedLiteralClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedLiteralClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedLiteralClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/literal/lib/seed_literal_client.rb b/seed/ruby-sdk/literal/lib/seed_literal_client.rb index d2e789df0d3..6368a161f9d 100644 --- a/seed/ruby-sdk/literal/lib/seed_literal_client.rb +++ b/seed/ruby-sdk/literal/lib/seed_literal_client.rb @@ -1,30 +1,31 @@ # frozen_string_literal: true -require_relative "seed_literal_client/literal/types/create_options_response" -require_relative "seed_literal_client/literal/types/options" -require_relative "seed_literal_client/literal/types/undiscriminated_options" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_literal_client/literal/client" -require "async/http/faraday" module SeedLiteralClient class Client + attr_reader :literal + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @literal_client = LiteralClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @literal = LiteralClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :literal + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_literal_client = AsyncLiteralClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @literal = AsyncLiteralClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/literal/lib/seed_literal_client/literal/client.rb b/seed/ruby-sdk/literal/lib/seed_literal_client/literal/client.rb index d4ba040e1f3..c1f021fe3a9 100644 --- a/seed/ruby-sdk/literal/lib/seed_literal_client/literal/client.rb +++ b/seed/ruby-sdk/literal/lib/seed_literal_client/literal/client.rb @@ -1,109 +1,108 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "types/create_options_response" require_relative "types/options" require_relative "types/undiscriminated_options" require "async" module SeedLiteralClient - module Literal - class LiteralClient - attr_reader :request_client + class LiteralClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [LiteralClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [LiteralClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param values [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Literal::CreateOptionsResponse] - def create_options(values:, request_options: nil) - response = @request_client.conn.post("/options") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, values: values }.compact - end - Literal::CreateOptionsResponse.from_json(json_object: response) + # @param values [Hash{String => String}] + # @param request_options [RequestOptions] + # @return [Literal::CreateOptionsResponse] + def create_options(values:, request_options: nil) + response = @request_client.conn.post("/options") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), values: values }.compact end + Literal::CreateOptionsResponse.from_json(json_object: response.body) + end - # @param dry_run [Boolean] - # @param request_options [RequestOptions] - # @return [Literal::Options] - def get_options(dry_run:, request_options: nil) - response = @request_client.conn.post("/options") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, dryRun: dry_run }.compact - end - Literal::Options.from_json(json_object: response) + # @param dry_run [Boolean] + # @param request_options [RequestOptions] + # @return [Literal::Options] + def get_options(dry_run:, request_options: nil) + response = @request_client.conn.post("/options") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), dryRun: dry_run }.compact end + Literal::Options.from_json(json_object: response.body) + end - # @param dry_run [Boolean] - # @param request_options [RequestOptions] - # @return [Literal::UndiscriminatedOptions] - def get_undiscriminated_options(dry_run:, request_options: nil) - response = @request_client.conn.post("/options") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, dryRun: dry_run }.compact - end - Literal::UndiscriminatedOptions.from_json(json_object: response) + # @param dry_run [Boolean] + # @param request_options [RequestOptions] + # @return [Literal::UndiscriminatedOptions] + def get_undiscriminated_options(dry_run:, request_options: nil) + response = @request_client.conn.post("/options") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), dryRun: dry_run }.compact end + Literal::UndiscriminatedOptions.from_json(json_object: response.body) end + end - class AsyncLiteralClient - attr_reader :request_client + class AsyncLiteralClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncLiteralClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncLiteralClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param values [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Literal::CreateOptionsResponse] - def create_options(values:, request_options: nil) - Async.call do - response = @request_client.conn.post("/options") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, values: values }.compact - end - Literal::CreateOptionsResponse.from_json(json_object: response) + # @param values [Hash{String => String}] + # @param request_options [RequestOptions] + # @return [Literal::CreateOptionsResponse] + def create_options(values:, request_options: nil) + Async do + response = @request_client.conn.post("/options") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), values: values }.compact end + Literal::CreateOptionsResponse.from_json(json_object: response.body) end + end - # @param dry_run [Boolean] - # @param request_options [RequestOptions] - # @return [Literal::Options] - def get_options(dry_run:, request_options: nil) - Async.call do - response = @request_client.conn.post("/options") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, dryRun: dry_run }.compact - end - Literal::Options.from_json(json_object: response) + # @param dry_run [Boolean] + # @param request_options [RequestOptions] + # @return [Literal::Options] + def get_options(dry_run:, request_options: nil) + Async do + response = @request_client.conn.post("/options") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), dryRun: dry_run }.compact end + Literal::Options.from_json(json_object: response.body) end + end - # @param dry_run [Boolean] - # @param request_options [RequestOptions] - # @return [Literal::UndiscriminatedOptions] - def get_undiscriminated_options(dry_run:, request_options: nil) - Async.call do - response = @request_client.conn.post("/options") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, dryRun: dry_run }.compact - end - Literal::UndiscriminatedOptions.from_json(json_object: response) + # @param dry_run [Boolean] + # @param request_options [RequestOptions] + # @return [Literal::UndiscriminatedOptions] + def get_undiscriminated_options(dry_run:, request_options: nil) + Async do + response = @request_client.conn.post("/options") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), dryRun: dry_run }.compact end + Literal::UndiscriminatedOptions.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/literal/lib/types_export.rb b/seed/ruby-sdk/literal/lib/types_export.rb new file mode 100644 index 00000000000..83b1e9b5dca --- /dev/null +++ b/seed/ruby-sdk/literal/lib/types_export.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require_relative "seed_literal_client/literal/types/options" +require_relative "seed_literal_client/literal/types/undiscriminated_options" +require_relative "seed_literal_client/literal/types/create_options_response" diff --git a/seed/ruby-sdk/literal/seed_literal_client.gemspec b/seed/ruby-sdk/literal/seed_literal_client.gemspec index ca43e95e5bc..cf597877a3f 100644 --- a/seed/ruby-sdk/literal/seed_literal_client.gemspec +++ b/seed/ruby-sdk/literal/seed_literal_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_literal_client" + spec.version = SeedLiteralClient::Gemconfig::VERSION spec.authors = SeedLiteralClient::Gemconfig::AUTHORS spec.email = SeedLiteralClient::Gemconfig::EMAIL spec.summary = SeedLiteralClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/multi-url-environment/.rubocop.yml b/seed/ruby-sdk/multi-url-environment/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/multi-url-environment/.rubocop.yml +++ b/seed/ruby-sdk/multi-url-environment/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/multi-url-environment/lib/environment.rb b/seed/ruby-sdk/multi-url-environment/lib/environment.rb index aef101a6d82..11bba525882 100644 --- a/seed/ruby-sdk/multi-url-environment/lib/environment.rb +++ b/seed/ruby-sdk/multi-url-environment/lib/environment.rb @@ -2,7 +2,7 @@ module SeedMultiUrlEnvironmentClient class Environment - PRODUCTION = { ec2: "https://ec2.aws.com", s3: "https://s3.aws.com" }.frozen - STAGING = { ec2: "https://staging.ec2.aws.com", s3: "https://staging.s3.aws.com" }.frozen + PRODUCTION = { ec2: "https://ec2.aws.com", s3: "https://s3.aws.com" }.freeze + STAGING = { ec2: "https://staging.ec2.aws.com", s3: "https://staging.s3.aws.com" }.freeze end end diff --git a/seed/ruby-sdk/multi-url-environment/lib/gemconfig.rb b/seed/ruby-sdk/multi-url-environment/lib/gemconfig.rb index b01e6fdbc1d..a2e658fbd42 100644 --- a/seed/ruby-sdk/multi-url-environment/lib/gemconfig.rb +++ b/seed/ruby-sdk/multi-url-environment/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedMultiUrlEnvironmentClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/multi-url-environment/lib/requests.rb b/seed/ruby-sdk/multi-url-environment/lib/requests.rb index bbe5f4b2fe5..5ce17a86bae 100644 --- a/seed/ruby-sdk/multi-url-environment/lib/requests.rb +++ b/seed/ruby-sdk/multi-url-environment/lib/requests.rb @@ -1,18 +1,20 @@ # frozen_string_literal: true -require "async/http/faraday" +require_relative "environment" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedMultiUrlEnvironmentClient class RequestClient - attr_reader :headers, :base_url, :conn + attr_reader :headers, :default_environment, :conn # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] # @return [RequestClient] - def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) @default_environment = environment @headers = { "X-Fern-Language": "Ruby", @@ -21,22 +23,22 @@ def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_i } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end class AsyncRequestClient - attr_reader :headers, :base_url, :conn + attr_reader :headers, :default_environment, :conn # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] # @return [AsyncRequestClient] - def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) @default_environment = environment @headers = { "X-Fern-Language": "Ruby", @@ -45,29 +47,27 @@ def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_i } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [Hash{String => Object}] @@ -76,6 +76,8 @@ def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additio @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client.rb b/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client.rb index b088f4a4269..d88636dd624 100644 --- a/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client.rb +++ b/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client.rb @@ -1,34 +1,41 @@ # frozen_string_literal: true -require "faraday" +require_relative "environment" +require_relative "types_export" +require_relative "requests" require_relative "seed_multi_url_environment_client/ec_2/client" require_relative "seed_multi_url_environment_client/s_3/client" -require "async/http/faraday" module SeedMultiUrlEnvironmentClient class Client + attr_reader :ec_2, :s_3 + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @ec_2_client = Ec2Client.initialize(request_client: request_client) - @s_3_client = S3Client.initialize(request_client: request_client) + # @return [Client] + def initialize(token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(environment: environment, max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, token: token) + @ec_2 = Ec2Client.new(request_client: @request_client) + @s_3 = S3Client.new(request_client: @request_client) end end class AsyncClient + attr_reader :ec_2, :s_3 + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_ec_2_client = AsyncEc2Client.initialize(request_client: request_client) - @async_s_3_client = AsyncS3Client.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, token: token) + @ec_2 = AsyncEc2Client.new(request_client: @async_request_client) + @s_3 = AsyncS3Client.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client/ec_2/client.rb b/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client/ec_2/client.rb index 90bf0f03228..0db813114f8 100644 --- a/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client/ec_2/client.rb +++ b/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client/ec_2/client.rb @@ -1,55 +1,54 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedMultiUrlEnvironmentClient - module Ec2 - class Ec2Client - attr_reader :request_client + class Ec2Client + attr_reader :request_client - # @param request_client [RequestClient] - # @return [Ec2Client] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [Ec2Client] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param size [String] - # @param request_options [RequestOptions] - # @return [Void] - def boot_instance(size:, request_options: nil) - @request_client.conn.post("/ec2/boot") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, size: size }.compact - req.url = @request_client.default_environment[ec2] - end + # @param size [String] + # @param request_options [RequestOptions] + # @return [Void] + def boot_instance(size:, request_options: nil) + @request_client.conn.post do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), size: size }.compact + req.url "#{@request_client.default_environment[:ec2]}/ec2/boot" end end + end - class AsyncEc2Client - attr_reader :request_client + class AsyncEc2Client + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncEc2Client] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncEc2Client] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param size [String] - # @param request_options [RequestOptions] - # @return [Void] - def boot_instance(size:, request_options: nil) - Async.call do - @request_client.conn.post("/ec2/boot") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, size: size }.compact - req.url = @request_client.default_environment[ec2] - end + # @param size [String] + # @param request_options [RequestOptions] + # @return [Void] + def boot_instance(size:, request_options: nil) + Async do + @request_client.conn.post do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), size: size }.compact + req.url "#{@request_client.default_environment[:ec2]}/ec2/boot" end end end diff --git a/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client/s_3/client.rb b/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client/s_3/client.rb index a2b50cf1069..9af17ce8723 100644 --- a/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client/s_3/client.rb +++ b/seed/ruby-sdk/multi-url-environment/lib/seed_multi_url_environment_client/s_3/client.rb @@ -1,57 +1,57 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedMultiUrlEnvironmentClient - module S3 - class S3Client - attr_reader :request_client + class S3Client + attr_reader :request_client - # @param request_client [RequestClient] - # @return [S3Client] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [S3Client] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param s_3_key [String] - # @param request_options [RequestOptions] - # @return [String] - def get_presigned_url(s_3_key:, request_options: nil) - @request_client.conn.post("/s3/presigned-url") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, s3Key: s_3_key }.compact - req.url = @request_client.default_environment[s3] - end + # @param s_3_key [String] + # @param request_options [RequestOptions] + # @return [String] + def get_presigned_url(s_3_key:, request_options: nil) + response = @request_client.conn.post do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), s3Key: s_3_key }.compact + req.url "#{@request_client.default_environment[:s3]}/s3/presigned-url" end + response.body end + end - class AsyncS3Client - attr_reader :request_client + class AsyncS3Client + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncS3Client] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncS3Client] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param s_3_key [String] - # @param request_options [RequestOptions] - # @return [String] - def get_presigned_url(s_3_key:, request_options: nil) - Async.call do - response = @request_client.conn.post("/s3/presigned-url") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request_options&.additional_body_parameters, s3Key: s_3_key }.compact - req.url = @request_client.default_environment[s3] - end - response + # @param s_3_key [String] + # @param request_options [RequestOptions] + # @return [String] + def get_presigned_url(s_3_key:, request_options: nil) + Async do + response = @request_client.conn.post do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), s3Key: s_3_key }.compact + req.url "#{@request_client.default_environment[:s3]}/s3/presigned-url" end + response.body end end end diff --git a/seed/ruby-sdk/multi-url-environment/lib/types_export.rb b/seed/ruby-sdk/multi-url-environment/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/multi-url-environment/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/multi-url-environment/seed_multi_url_environment_client.gemspec b/seed/ruby-sdk/multi-url-environment/seed_multi_url_environment_client.gemspec index babdccf716e..62832ccf76a 100644 --- a/seed/ruby-sdk/multi-url-environment/seed_multi_url_environment_client.gemspec +++ b/seed/ruby-sdk/multi-url-environment/seed_multi_url_environment_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_multi_url_environment_client" + spec.version = SeedMultiUrlEnvironmentClient::Gemconfig::VERSION spec.authors = SeedMultiUrlEnvironmentClient::Gemconfig::AUTHORS spec.email = SeedMultiUrlEnvironmentClient::Gemconfig::EMAIL spec.summary = SeedMultiUrlEnvironmentClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/no-environment/.rubocop.yml b/seed/ruby-sdk/no-environment/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/no-environment/.rubocop.yml +++ b/seed/ruby-sdk/no-environment/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/no-environment/lib/gemconfig.rb b/seed/ruby-sdk/no-environment/lib/gemconfig.rb index 56440982bf6..02528d851ad 100644 --- a/seed/ruby-sdk/no-environment/lib/gemconfig.rb +++ b/seed/ruby-sdk/no-environment/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedNoEnvironmentClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/no-environment/lib/requests.rb b/seed/ruby-sdk/no-environment/lib/requests.rb index 1c395c3a307..63c0b3e19bd 100644 --- a/seed/ruby-sdk/no-environment/lib/requests.rb +++ b/seed/ruby-sdk/no-environment/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedNoEnvironmentClient class RequestClient @@ -11,7 +12,7 @@ class RequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [RequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedNoEnvironmentClient", @@ -19,9 +20,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -33,7 +34,7 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [AsyncRequestClient] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedNoEnvironmentClient", @@ -41,29 +42,27 @@ def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [Hash{String => Object}] @@ -72,6 +71,8 @@ def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additio @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/no-environment/lib/seed_no_environment_client.rb b/seed/ruby-sdk/no-environment/lib/seed_no_environment_client.rb index 01c14781312..54bbd020c18 100644 --- a/seed/ruby-sdk/no-environment/lib/seed_no_environment_client.rb +++ b/seed/ruby-sdk/no-environment/lib/seed_no_environment_client.rb @@ -1,29 +1,35 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_no_environment_client/dummy/client" -require "async/http/faraday" module SeedNoEnvironmentClient class Client + attr_reader :dummy + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @dummy_client = DummyClient.initialize(request_client: request_client) + # @return [Client] + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + token: token) + @dummy = DummyClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :dummy + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_dummy_client = AsyncDummyClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(token:, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, + token: token) + @dummy = AsyncDummyClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/no-environment/lib/seed_no_environment_client/dummy/client.rb b/seed/ruby-sdk/no-environment/lib/seed_no_environment_client/dummy/client.rb index d5947e5219f..49484f43669 100644 --- a/seed/ruby-sdk/no-environment/lib/seed_no_environment_client/dummy/client.rb +++ b/seed/ruby-sdk/no-environment/lib/seed_no_environment_client/dummy/client.rb @@ -1,51 +1,51 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedNoEnvironmentClient - module Dummy - class DummyClient - attr_reader :request_client + class DummyClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [DummyClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [DummyClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_dummy(request_options: nil) - @request_client.conn.get("/dummy") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [String] + def get_dummy(request_options: nil) + response = @request_client.conn.get("/dummy") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncDummyClient - attr_reader :request_client + class AsyncDummyClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncDummyClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncDummyClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_dummy(request_options: nil) - Async.call do - response = @request_client.conn.get("/dummy") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param request_options [RequestOptions] + # @return [String] + def get_dummy(request_options: nil) + Async do + response = @request_client.conn.get("/dummy") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/no-environment/lib/types_export.rb b/seed/ruby-sdk/no-environment/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/no-environment/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/no-environment/seed_no_environment_client.gemspec b/seed/ruby-sdk/no-environment/seed_no_environment_client.gemspec index 23101701046..333ad891de1 100644 --- a/seed/ruby-sdk/no-environment/seed_no_environment_client.gemspec +++ b/seed/ruby-sdk/no-environment/seed_no_environment_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_no_environment_client" + spec.version = SeedNoEnvironmentClient::Gemconfig::VERSION spec.authors = SeedNoEnvironmentClient::Gemconfig::AUTHORS spec.email = SeedNoEnvironmentClient::Gemconfig::EMAIL spec.summary = SeedNoEnvironmentClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/object/.rubocop.yml b/seed/ruby-sdk/object/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/object/.rubocop.yml +++ b/seed/ruby-sdk/object/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/object/lib/gemconfig.rb b/seed/ruby-sdk/object/lib/gemconfig.rb index e0dbd9394da..d90831f0fcd 100644 --- a/seed/ruby-sdk/object/lib/gemconfig.rb +++ b/seed/ruby-sdk/object/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedObjectClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/object/lib/requests.rb b/seed/ruby-sdk/object/lib/requests.rb index 8138a4a5f01..6dbab4eb2a1 100644 --- a/seed/ruby-sdk/object/lib/requests.rb +++ b/seed/ruby-sdk/object/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedObjectClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedObjectClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedObjectClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/object/lib/seed_object_client.rb b/seed/ruby-sdk/object/lib/seed_object_client.rb index 1ba7fa9e244..1ffdcd2f2ff 100644 --- a/seed/ruby-sdk/object/lib/seed_object_client.rb +++ b/seed/ruby-sdk/object/lib/seed_object_client.rb @@ -1,27 +1,24 @@ # frozen_string_literal: true -require_relative "seed_object_client/types/name" - -require_relative "seed_object_client/types/type" -require "async/http/faraday" -require "faraday" +require_relative "types_export" +require_relative "requests" module SeedObjectClient class Client # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end class AsyncClient # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end end diff --git a/seed/ruby-sdk/object/lib/seed_object_client/types/type.rb b/seed/ruby-sdk/object/lib/seed_object_client/types/type.rb index aed6e318304..fac3c68f648 100644 --- a/seed/ruby-sdk/object/lib/seed_object_client/types/type.rb +++ b/seed/ruby-sdk/object/lib/seed_object_client/types/type.rb @@ -87,12 +87,13 @@ def self.from_json(json_object:) three = struct.three four = struct.four five = struct.five - six = struct.six - seven = struct.seven + six = DateTime.parse(struct.six) + seven = Date.parse(struct.seven) eight = struct.eight nine = struct.nine ten = struct.ten - eleven = struct.eleven + eleven = struct.eleven.to_h.to_json + eleven = Set.new(eleven) twelve = struct.twelve thirteen = struct.thirteen fourteen = struct.fourteen @@ -100,7 +101,8 @@ def self.from_json(json_object:) sixteen = struct.sixteen seventeen = struct.seventeen eighteen = struct.eighteen - nineteen = struct.nineteen + nineteen = struct.nineteen.to_h.to_json + nineteen = Name.from_json(json_object: nineteen) new(one: one, two: two, three: three, four: four, five: five, six: six, seven: seven, eight: eight, nine: nine, ten: ten, eleven: eleven, twelve: twelve, thirteen: thirteen, fourteen: fourteen, fifteen: fifteen, sixteen: sixteen, seventeen: seventeen, eighteen: eighteen, nineteen: nineteen, additional_properties: struct) end diff --git a/seed/ruby-sdk/object/lib/types_export.rb b/seed/ruby-sdk/object/lib/types_export.rb new file mode 100644 index 00000000000..1b3ca4b4858 --- /dev/null +++ b/seed/ruby-sdk/object/lib/types_export.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +require_relative "seed_object_client/types/type" +require_relative "seed_object_client/types/name" diff --git a/seed/ruby-sdk/object/seed_object_client.gemspec b/seed/ruby-sdk/object/seed_object_client.gemspec index a83b5af0bfa..4d452b6f3c4 100644 --- a/seed/ruby-sdk/object/seed_object_client.gemspec +++ b/seed/ruby-sdk/object/seed_object_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_object_client" + spec.version = SeedObjectClient::Gemconfig::VERSION spec.authors = SeedObjectClient::Gemconfig::AUTHORS spec.email = SeedObjectClient::Gemconfig::EMAIL spec.summary = SeedObjectClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/objects-with-imports/.rubocop.yml b/seed/ruby-sdk/objects-with-imports/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/objects-with-imports/.rubocop.yml +++ b/seed/ruby-sdk/objects-with-imports/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/objects-with-imports/lib/gemconfig.rb b/seed/ruby-sdk/objects-with-imports/lib/gemconfig.rb index de75cda39db..89ca60b7620 100644 --- a/seed/ruby-sdk/objects-with-imports/lib/gemconfig.rb +++ b/seed/ruby-sdk/objects-with-imports/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedObjectsWithImportsClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/objects-with-imports/lib/requests.rb b/seed/ruby-sdk/objects-with-imports/lib/requests.rb index 1643d271111..4a2f94bc401 100644 --- a/seed/ruby-sdk/objects-with-imports/lib/requests.rb +++ b/seed/ruby-sdk/objects-with-imports/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedObjectsWithImportsClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedObjectsWithImportsClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedObjectsWithImportsClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client.rb b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client.rb index cc1e957db4b..13056e2b5ac 100644 --- a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client.rb +++ b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client.rb @@ -1,29 +1,24 @@ # frozen_string_literal: true -require_relative "seed_objects_with_imports_client/commons/metadata/types/metadata" -require_relative "seed_objects_with_imports_client/file/directory/types/directory" -require_relative "seed_objects_with_imports_client/file/types/file" -require_relative "seed_objects_with_imports_client/types/node" -require_relative "seed_objects_with_imports_client/types/tree" -require "async/http/faraday" -require "faraday" +require_relative "types_export" +require_relative "requests" module SeedObjectsWithImportsClient class Client # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end class AsyncClient # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) end end end diff --git a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/directory/types/directory.rb b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/directory/types/directory.rb index 3cdabe96792..45ad4bc3057 100644 --- a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/directory/types/directory.rb +++ b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/directory/types/directory.rb @@ -32,8 +32,14 @@ def initialize(name:, files: nil, directories: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - files = struct.files - directories = struct.directories + files = struct.files.map do |v| + v = v.to_h.to_json + File::File.from_json(json_object: v) + end + directories = struct.directories.map do |v| + v = v.to_h.to_json + File::Directory::Directory.from_json(json_object: v) + end new(name: name, files: files, directories: directories, additional_properties: struct) end diff --git a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file.rb b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file.rb index 3bb482dd503..1b308f0021d 100644 --- a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file.rb +++ b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "file_info" require "json" module SeedObjectsWithImportsClient @@ -9,7 +10,7 @@ class File # @param name [String] # @param contents [String] - # @param info [Hash{String => String}] + # @param info [FILE_INFO] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [File::File] def initialize(name:, contents:, info:, additional_properties: nil) @@ -17,7 +18,7 @@ def initialize(name:, contents:, info:, additional_properties: nil) @name = name # @type [String] @contents = contents - # @type [Hash{String => String}] + # @type [FILE_INFO] @info = info # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -31,7 +32,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name contents = struct.contents - info = struct.info + info = File::FILE_INFO.key(struct.info) || struct.info new(name: name, contents: contents, info: info, additional_properties: struct) end @@ -39,7 +40,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "name": @name, "contents": @contents, "info": @info }.to_json + { "name": @name, "contents": @contents, "info": File::FILE_INFO[@info] || @info }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -49,7 +50,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.contents.is_a?(String) != false || raise("Passed value for field obj.contents is not the expected type, validation failed.") - obj.info.is_a?(FILE_INFO) != false || raise("Passed value for field obj.info is not the expected type, validation failed.") + obj.info.is_a?(File::FILE_INFO) != false || raise("Passed value for field obj.info is not the expected type, validation failed.") end end end diff --git a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file_info.rb b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file_info.rb index 3e96b61e14b..fea223200d3 100644 --- a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file_info.rb +++ b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/file/types/file_info.rb @@ -2,7 +2,7 @@ module SeedObjectsWithImportsClient module File - # @type [Hash{String => String}] - FILE_INFO = { regular: "REGULAR", directory: "DIRECTORY" }.frozen + # @type [FILE_INFO] + FILE_INFO = { regular: "REGULAR", directory: "DIRECTORY" }.freeze end end diff --git a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/types/node.rb b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/types/node.rb index 64c7e0aa8f1..9324c3334dc 100644 --- a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/types/node.rb +++ b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/types/node.rb @@ -31,7 +31,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) id = struct.id label = struct.label - metadata = struct.metadata + metadata = struct.metadata.to_h.to_json + metadata = Commons::Metadata::Metadata.from_json(json_object: metadata) new(id: id, label: label, metadata: metadata, additional_properties: struct) end diff --git a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/types/tree.rb b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/types/tree.rb index 507638bb91a..fe14a67df9c 100644 --- a/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/types/tree.rb +++ b/seed/ruby-sdk/objects-with-imports/lib/seed_objects_with_imports_client/types/tree.rb @@ -23,7 +23,10 @@ def initialize(nodes: nil, additional_properties: nil) # @return [Tree] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - nodes = struct.nodes + nodes = struct.nodes.map do |v| + v = v.to_h.to_json + Node.from_json(json_object: v) + end new(nodes: nodes, additional_properties: struct) end diff --git a/seed/ruby-sdk/objects-with-imports/lib/types_export.rb b/seed/ruby-sdk/objects-with-imports/lib/types_export.rb new file mode 100644 index 00000000000..b65d280cd2a --- /dev/null +++ b/seed/ruby-sdk/objects-with-imports/lib/types_export.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require_relative "seed_objects_with_imports_client/types/node" +require_relative "seed_objects_with_imports_client/types/tree" +require_relative "seed_objects_with_imports_client/commons/metadata/types/metadata" +require_relative "seed_objects_with_imports_client/file/types/file" +require_relative "seed_objects_with_imports_client/file/types/file_info" +require_relative "seed_objects_with_imports_client/file/directory/types/directory" diff --git a/seed/ruby-sdk/objects-with-imports/seed_objects_with_imports_client.gemspec b/seed/ruby-sdk/objects-with-imports/seed_objects_with_imports_client.gemspec index 8f645624054..5be8f3ef82a 100644 --- a/seed/ruby-sdk/objects-with-imports/seed_objects_with_imports_client.gemspec +++ b/seed/ruby-sdk/objects-with-imports/seed_objects_with_imports_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_objects_with_imports_client" + spec.version = SeedObjectsWithImportsClient::Gemconfig::VERSION spec.authors = SeedObjectsWithImportsClient::Gemconfig::AUTHORS spec.email = SeedObjectsWithImportsClient::Gemconfig::EMAIL spec.summary = SeedObjectsWithImportsClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/optional/.rubocop.yml b/seed/ruby-sdk/optional/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/optional/.rubocop.yml +++ b/seed/ruby-sdk/optional/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/optional/lib/gemconfig.rb b/seed/ruby-sdk/optional/lib/gemconfig.rb index de75cda39db..89ca60b7620 100644 --- a/seed/ruby-sdk/optional/lib/gemconfig.rb +++ b/seed/ruby-sdk/optional/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedObjectsWithImportsClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/optional/lib/requests.rb b/seed/ruby-sdk/optional/lib/requests.rb index 1643d271111..4a2f94bc401 100644 --- a/seed/ruby-sdk/optional/lib/requests.rb +++ b/seed/ruby-sdk/optional/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedObjectsWithImportsClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedObjectsWithImportsClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedObjectsWithImportsClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/optional/lib/seed_objects_with_imports_client.rb b/seed/ruby-sdk/optional/lib/seed_objects_with_imports_client.rb index 3629df968ae..e4e67ff99b3 100644 --- a/seed/ruby-sdk/optional/lib/seed_objects_with_imports_client.rb +++ b/seed/ruby-sdk/optional/lib/seed_objects_with_imports_client.rb @@ -1,27 +1,31 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_objects_with_imports_client/optional/client" -require "async/http/faraday" module SeedObjectsWithImportsClient class Client + attr_reader :optional + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @optional_client = OptionalClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @optional = OptionalClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :optional + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_optional_client = AsyncOptionalClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @optional = AsyncOptionalClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/optional/lib/seed_objects_with_imports_client/optional/client.rb b/seed/ruby-sdk/optional/lib/seed_objects_with_imports_client/optional/client.rb index f8b0b103c20..7dd47473147 100644 --- a/seed/ruby-sdk/optional/lib/seed_objects_with_imports_client/optional/client.rb +++ b/seed/ruby-sdk/optional/lib/seed_objects_with_imports_client/optional/client.rb @@ -1,53 +1,53 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedObjectsWithImportsClient - module Optional - class OptionalClient - attr_reader :request_client + class OptionalClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [OptionalClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [OptionalClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [String] - def send_optional_body(request: nil, request_options: nil) - @request_client.conn.post("/send-optional-body") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Hash{String => String}] + # @param request_options [RequestOptions] + # @return [String] + def send_optional_body(request: nil, request_options: nil) + response = @request_client.conn.post("/send-optional-body") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - class AsyncOptionalClient - attr_reader :request_client + class AsyncOptionalClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncOptionalClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncOptionalClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [String] - def send_optional_body(request: nil, request_options: nil) - Async.call do - response = @request_client.conn.post("/send-optional-body") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Hash{String => String}] + # @param request_options [RequestOptions] + # @return [String] + def send_optional_body(request: nil, request_options: nil) + Async do + response = @request_client.conn.post("/send-optional-body") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/optional/lib/types_export.rb b/seed/ruby-sdk/optional/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/optional/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/optional/seed_objects_with_imports_client.gemspec b/seed/ruby-sdk/optional/seed_objects_with_imports_client.gemspec index 8f645624054..5be8f3ef82a 100644 --- a/seed/ruby-sdk/optional/seed_objects_with_imports_client.gemspec +++ b/seed/ruby-sdk/optional/seed_objects_with_imports_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_objects_with_imports_client" + spec.version = SeedObjectsWithImportsClient::Gemconfig::VERSION spec.authors = SeedObjectsWithImportsClient::Gemconfig::AUTHORS spec.email = SeedObjectsWithImportsClient::Gemconfig::EMAIL spec.summary = SeedObjectsWithImportsClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/package-yml/.rubocop.yml b/seed/ruby-sdk/package-yml/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/package-yml/.rubocop.yml +++ b/seed/ruby-sdk/package-yml/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/package-yml/lib/gemconfig.rb b/seed/ruby-sdk/package-yml/lib/gemconfig.rb index b0a16bebd62..aca258854f5 100644 --- a/seed/ruby-sdk/package-yml/lib/gemconfig.rb +++ b/seed/ruby-sdk/package-yml/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedPackageYmlClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/package-yml/lib/requests.rb b/seed/ruby-sdk/package-yml/lib/requests.rb index 06365ec49aa..384630a5c5a 100644 --- a/seed/ruby-sdk/package-yml/lib/requests.rb +++ b/seed/ruby-sdk/package-yml/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedPackageYmlClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedPackageYmlClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedPackageYmlClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/package-yml/lib/seed_package_yml_client.rb b/seed/ruby-sdk/package-yml/lib/seed_package_yml_client.rb index e17c87afc21..8e1ce7ffc3a 100644 --- a/seed/ruby-sdk/package-yml/lib/seed_package_yml_client.rb +++ b/seed/ruby-sdk/package-yml/lib/seed_package_yml_client.rb @@ -1,17 +1,19 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_package_yml_client/service/client" -require "async/http/faraday" module SeedPackageYmlClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = ServiceClient.new(request_client: @request_client) end # @param id [String] @@ -19,21 +21,24 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) # @param request_options [RequestOptions] # @return [String] def echo(id:, request:, request_options: nil) - request_client.conn.post("/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact + response = @request_client.conn.post("/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = AsyncServiceClient.new(request_client: @async_request_client) end # @param id [String] @@ -41,11 +46,12 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) # @param request_options [RequestOptions] # @return [String] def echo(id:, request:, request_options: nil) - request_client.conn.post("/#{id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact + response = @async_request_client.conn.post("/#{id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/package-yml/lib/seed_package_yml_client/service/client.rb b/seed/ruby-sdk/package-yml/lib/seed_package_yml_client/service/client.rb index e7218bc4d3e..bb1fe09f5c7 100644 --- a/seed/ruby-sdk/package-yml/lib/seed_package_yml_client/service/client.rb +++ b/seed/ruby-sdk/package-yml/lib/seed_package_yml_client/service/client.rb @@ -1,51 +1,50 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedPackageYmlClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param id [String] - # @param nested_id [String] - # @param request_options [RequestOptions] - # @return [Void] - def nop(id:, nested_id:, request_options: nil) - @request_client.conn.get("/#{id}/#{nested_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param id [String] + # @param nested_id [String] + # @param request_options [RequestOptions] + # @return [Void] + def nop(id:, nested_id:, request_options: nil) + @request_client.conn.get("/#{id}/#{nested_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param id [String] - # @param nested_id [String] - # @param request_options [RequestOptions] - # @return [Void] - def nop(id:, nested_id:, request_options: nil) - Async.call do - @request_client.conn.get("/#{id}/#{nested_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param id [String] + # @param nested_id [String] + # @param request_options [RequestOptions] + # @return [Void] + def nop(id:, nested_id:, request_options: nil) + Async do + @request_client.conn.get("/#{id}/#{nested_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/package-yml/lib/types_export.rb b/seed/ruby-sdk/package-yml/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/package-yml/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/package-yml/seed_package_yml_client.gemspec b/seed/ruby-sdk/package-yml/seed_package_yml_client.gemspec index 37fcee41959..5577d5a0217 100644 --- a/seed/ruby-sdk/package-yml/seed_package_yml_client.gemspec +++ b/seed/ruby-sdk/package-yml/seed_package_yml_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_package_yml_client" + spec.version = SeedPackageYmlClient::Gemconfig::VERSION spec.authors = SeedPackageYmlClient::Gemconfig::AUTHORS spec.email = SeedPackageYmlClient::Gemconfig::EMAIL spec.summary = SeedPackageYmlClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/plain-text/.rubocop.yml b/seed/ruby-sdk/plain-text/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/plain-text/.rubocop.yml +++ b/seed/ruby-sdk/plain-text/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/plain-text/lib/gemconfig.rb b/seed/ruby-sdk/plain-text/lib/gemconfig.rb index ab188e2b775..66cad302ffe 100644 --- a/seed/ruby-sdk/plain-text/lib/gemconfig.rb +++ b/seed/ruby-sdk/plain-text/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedPlainTextClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/plain-text/lib/requests.rb b/seed/ruby-sdk/plain-text/lib/requests.rb index b23ceb61ca9..9a152d61658 100644 --- a/seed/ruby-sdk/plain-text/lib/requests.rb +++ b/seed/ruby-sdk/plain-text/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedPlainTextClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedPlainTextClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedPlainTextClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/plain-text/lib/seed_plain_text_client.rb b/seed/ruby-sdk/plain-text/lib/seed_plain_text_client.rb index a4a7247ef4e..5b8c87c494b 100644 --- a/seed/ruby-sdk/plain-text/lib/seed_plain_text_client.rb +++ b/seed/ruby-sdk/plain-text/lib/seed_plain_text_client.rb @@ -1,27 +1,31 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_plain_text_client/service/client" -require "async/http/faraday" module SeedPlainTextClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/plain-text/lib/seed_plain_text_client/service/client.rb b/seed/ruby-sdk/plain-text/lib/seed_plain_text_client/service/client.rb index ce94d215ed1..b7a99aab9b9 100644 --- a/seed/ruby-sdk/plain-text/lib/seed_plain_text_client/service/client.rb +++ b/seed/ruby-sdk/plain-text/lib/seed_plain_text_client/service/client.rb @@ -1,49 +1,49 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedPlainTextClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_text(request_options: nil) - @request_client.conn.post("/text") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [String] + def get_text(request_options: nil) + response = @request_client.conn.post("/text") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_text(request_options: nil) - Async.call do - response = @request_client.conn.post("/text") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param request_options [RequestOptions] + # @return [String] + def get_text(request_options: nil) + Async do + response = @request_client.conn.post("/text") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/plain-text/lib/types_export.rb b/seed/ruby-sdk/plain-text/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/plain-text/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/plain-text/seed_plain_text_client.gemspec b/seed/ruby-sdk/plain-text/seed_plain_text_client.gemspec index fa1147d2f58..8290ac037b7 100644 --- a/seed/ruby-sdk/plain-text/seed_plain_text_client.gemspec +++ b/seed/ruby-sdk/plain-text/seed_plain_text_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_plain_text_client" + spec.version = SeedPlainTextClient::Gemconfig::VERSION spec.authors = SeedPlainTextClient::Gemconfig::AUTHORS spec.email = SeedPlainTextClient::Gemconfig::EMAIL spec.summary = SeedPlainTextClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/reserved-keywords/.rubocop.yml b/seed/ruby-sdk/reserved-keywords/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/reserved-keywords/.rubocop.yml +++ b/seed/ruby-sdk/reserved-keywords/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/reserved-keywords/lib/gemconfig.rb b/seed/ruby-sdk/reserved-keywords/lib/gemconfig.rb index 96d9cde5b9b..5f7be76ba0b 100644 --- a/seed/ruby-sdk/reserved-keywords/lib/gemconfig.rb +++ b/seed/ruby-sdk/reserved-keywords/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedNurseryApiClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/reserved-keywords/lib/requests.rb b/seed/ruby-sdk/reserved-keywords/lib/requests.rb index a56b0011fe4..6b01823b0a5 100644 --- a/seed/ruby-sdk/reserved-keywords/lib/requests.rb +++ b/seed/ruby-sdk/reserved-keywords/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedNurseryApiClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedNurseryApiClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedNurseryApiClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client.rb b/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client.rb index d9f437e3a11..676b079b855 100644 --- a/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client.rb +++ b/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client.rb @@ -1,29 +1,31 @@ # frozen_string_literal: true -require_relative "seed_nursery_api_client/package/types/package" -require_relative "seed_nursery_api_client/package/types/record" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_nursery_api_client/package/client" -require "async/http/faraday" module SeedNurseryApiClient class Client + attr_reader :package + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @package_client = PackageClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @package = PackageClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :package + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_package_client = AsyncPackageClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @package = AsyncPackageClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client/package/client.rb b/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client/package/client.rb index cdf79b6a084..92b1a9353dc 100644 --- a/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client/package/client.rb +++ b/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client/package/client.rb @@ -1,51 +1,50 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedNurseryApiClient - module Package - class PackageClient - attr_reader :request_client + class PackageClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [PackageClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [PackageClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param for_ [String] - # @param request_options [RequestOptions] - # @return [Void] - def test(for_:, request_options: nil) - @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "for": for_ }.compact - end + # @param for_ [String] + # @param request_options [RequestOptions] + # @return [Void] + def test(for_:, request_options: nil) + @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "for": for_ }.compact end end + end - class AsyncPackageClient - attr_reader :request_client + class AsyncPackageClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncPackageClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncPackageClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param for_ [String] - # @param request_options [RequestOptions] - # @return [Void] - def test(for_:, request_options: nil) - Async.call do - @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { **request_options&.additional_query_parameters, "for": for_ }.compact - end + # @param for_ [String] + # @param request_options [RequestOptions] + # @return [Void] + def test(for_:, request_options: nil) + Async do + @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "for": for_ }.compact end end end diff --git a/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client/package/types/record.rb b/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client/package/types/record.rb index 837c12a6b97..6909c10a354 100644 --- a/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client/package/types/record.rb +++ b/seed/ruby-sdk/reserved-keywords/lib/seed_nursery_api_client/package/types/record.rb @@ -31,7 +31,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json - { "foo": @foo, "3d": @_3_d }.to_json() + { "foo": @foo, "3d": @_3_d }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. # diff --git a/seed/ruby-sdk/reserved-keywords/lib/types_export.rb b/seed/ruby-sdk/reserved-keywords/lib/types_export.rb new file mode 100644 index 00000000000..a11d4f5b1f9 --- /dev/null +++ b/seed/ruby-sdk/reserved-keywords/lib/types_export.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +require_relative "seed_nursery_api_client/package/types/package" +require_relative "seed_nursery_api_client/package/types/record" diff --git a/seed/ruby-sdk/reserved-keywords/seed_nursery_api_client.gemspec b/seed/ruby-sdk/reserved-keywords/seed_nursery_api_client.gemspec index 5026db06049..c352f7731ac 100644 --- a/seed/ruby-sdk/reserved-keywords/seed_nursery_api_client.gemspec +++ b/seed/ruby-sdk/reserved-keywords/seed_nursery_api_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_nursery_api_client" + spec.version = SeedNurseryApiClient::Gemconfig::VERSION spec.authors = SeedNurseryApiClient::Gemconfig::AUTHORS spec.email = SeedNurseryApiClient::Gemconfig::EMAIL spec.summary = SeedNurseryApiClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/response-property/.rubocop.yml b/seed/ruby-sdk/response-property/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/response-property/.rubocop.yml +++ b/seed/ruby-sdk/response-property/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/response-property/lib/gemconfig.rb b/seed/ruby-sdk/response-property/lib/gemconfig.rb index 5e8d7c4034a..3be4f14d97b 100644 --- a/seed/ruby-sdk/response-property/lib/gemconfig.rb +++ b/seed/ruby-sdk/response-property/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedResponsePropertyClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/response-property/lib/requests.rb b/seed/ruby-sdk/response-property/lib/requests.rb index 2f15989e162..c5319db716e 100644 --- a/seed/ruby-sdk/response-property/lib/requests.rb +++ b/seed/ruby-sdk/response-property/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedResponsePropertyClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedResponsePropertyClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedResponsePropertyClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/response-property/lib/seed_response_property_client.rb b/seed/ruby-sdk/response-property/lib/seed_response_property_client.rb index e7d262fe061..f207f5f988f 100644 --- a/seed/ruby-sdk/response-property/lib/seed_response_property_client.rb +++ b/seed/ruby-sdk/response-property/lib/seed_response_property_client.rb @@ -1,35 +1,31 @@ # frozen_string_literal: true -require_relative "seed_response_property_client/types/optional_string_response" - -require_relative "seed_response_property_client/service/types/movie" -require_relative "seed_response_property_client/service/types/optional_with_docs" -require_relative "seed_response_property_client/service/types/response" -require_relative "seed_response_property_client/service/types/with_docs" -require_relative "seed_response_property_client/types/string_response" -require_relative "seed_response_property_client/types/with_metadata" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_response_property_client/service/client" -require "async/http/faraday" module SeedResponsePropertyClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/response-property/lib/seed_response_property_client/service/client.rb b/seed/ruby-sdk/response-property/lib/seed_response_property_client/service/client.rb index 04a7815960a..e52fa4e3b03 100644 --- a/seed/ruby-sdk/response-property/lib/seed_response_property_client/service/client.rb +++ b/seed/ruby-sdk/response-property/lib/seed_response_property_client/service/client.rb @@ -1,229 +1,228 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "types/response" require "json" -require_relative "../types/optional_string_response" require_relative "../types/string_response" require_relative "types/optional_with_docs" +require_relative "../types/optional_string_response" require "async" module SeedResponsePropertyClient - module Service - class ServiceClient - attr_reader :request_client - - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + class ServiceClient + attr_reader :request_client + + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::Response] - def get_movie(request:, request_options: nil) - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).data.to_h.to_json - Service::Response.from_json(json_object: nested_response_json) - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::Response] + def get_movie(request:, request_options: nil) + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).data.to_h.to_json + Service::Response.from_json(json_object: nested_response_json) + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::Response] - def get_movie_docs(request:, request_options: nil) - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).docs.to_h.to_json - Service::Response.from_json(json_object: nested_response_json) - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::Response] + def get_movie_docs(request:, request_options: nil) + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).docs.to_h.to_json + Service::Response.from_json(json_object: nested_response_json) + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [StringResponse] - def get_movie_name(request:, request_options: nil) - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).data.to_h.to_json - StringResponse.from_json(json_object: nested_response_json) - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [StringResponse] + def get_movie_name(request:, request_options: nil) + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).data.to_h.to_json + StringResponse.from_json(json_object: nested_response_json) + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::Response] - def get_movie_metadata(request:, request_options: nil) - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).metadata.to_h.to_json - Service::Response.from_json(json_object: nested_response_json) - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::Response] + def get_movie_metadata(request:, request_options: nil) + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).metadata.to_h.to_json + Service::Response.from_json(json_object: nested_response_json) + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::Response] - def get_optional_movie(request:, request_options: nil) - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).data.to_h.to_json - Service::Response.from_json(json_object: nested_response_json) - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::Response] + def get_optional_movie(request:, request_options: nil) + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).data.to_h.to_json + Service::Response.from_json(json_object: nested_response_json) + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::OPTIONAL_WITH_DOCS] - def get_optional_movie_docs(request:, request_options: nil) - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).docs.to_h.to_json - Service::WithDocs.from_json(json_object: nested_response_json) - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::OPTIONAL_WITH_DOCS] + def get_optional_movie_docs(request:, request_options: nil) + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).docs.to_h.to_json + Service::WithDocs.from_json(json_object: nested_response_json) + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [OPTIONAL_STRING_RESPONSE] - def get_optional_movie_name(request:, request_options: nil) - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).data.to_h.to_json - StringResponse.from_json(json_object: nested_response_json) - end + # @param request [String] + # @param request_options [RequestOptions] + # @return [OPTIONAL_STRING_RESPONSE] + def get_optional_movie_name(request:, request_options: nil) + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).data.to_h.to_json + StringResponse.from_json(json_object: nested_response_json) end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::Response] - def get_movie(request:, request_options: nil) - Async.call do - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).data.to_h.to_json - Service::Response.from_json(json_object: nested_response_json) + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::Response] + def get_movie(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).data.to_h.to_json + Service::Response.from_json(json_object: nested_response_json) end + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::Response] - def get_movie_docs(request:, request_options: nil) - Async.call do - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).docs.to_h.to_json - Service::Response.from_json(json_object: nested_response_json) + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::Response] + def get_movie_docs(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).docs.to_h.to_json + Service::Response.from_json(json_object: nested_response_json) end + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [StringResponse] - def get_movie_name(request:, request_options: nil) - Async.call do - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).data.to_h.to_json - StringResponse.from_json(json_object: nested_response_json) + # @param request [String] + # @param request_options [RequestOptions] + # @return [StringResponse] + def get_movie_name(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).data.to_h.to_json + StringResponse.from_json(json_object: nested_response_json) end + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::Response] - def get_movie_metadata(request:, request_options: nil) - Async.call do - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).metadata.to_h.to_json - Service::Response.from_json(json_object: nested_response_json) + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::Response] + def get_movie_metadata(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).metadata.to_h.to_json + Service::Response.from_json(json_object: nested_response_json) end + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::Response] - def get_optional_movie(request:, request_options: nil) - Async.call do - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).data.to_h.to_json - Service::Response.from_json(json_object: nested_response_json) + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::Response] + def get_optional_movie(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).data.to_h.to_json + Service::Response.from_json(json_object: nested_response_json) end + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [Service::OPTIONAL_WITH_DOCS] - def get_optional_movie_docs(request:, request_options: nil) - Async.call do - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).docs.to_h.to_json - Service::WithDocs.from_json(json_object: nested_response_json) + # @param request [String] + # @param request_options [RequestOptions] + # @return [Service::OPTIONAL_WITH_DOCS] + def get_optional_movie_docs(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).docs.to_h.to_json + Service::WithDocs.from_json(json_object: nested_response_json) end + end - # @param request [String] - # @param request_options [RequestOptions] - # @return [OPTIONAL_STRING_RESPONSE] - def get_optional_movie_name(request:, request_options: nil) - Async.call do - @request_client.conn.post("/movie") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - nested_response_json JSON.parse(json_object, object_class: OpenStruct).data.to_h.to_json - StringResponse.from_json(json_object: nested_response_json) + # @param request [String] + # @param request_options [RequestOptions] + # @return [OPTIONAL_STRING_RESPONSE] + def get_optional_movie_name(request:, request_options: nil) + Async do + response = @request_client.conn.post("/movie") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + nested_response_json JSON.parse(response.body, object_class: OpenStruct).data.to_h.to_json + StringResponse.from_json(json_object: nested_response_json) end end end diff --git a/seed/ruby-sdk/response-property/lib/seed_response_property_client/service/types/response.rb b/seed/ruby-sdk/response-property/lib/seed_response_property_client/service/types/response.rb index 8bc9f1b7bac..a87f54c6b4e 100644 --- a/seed/ruby-sdk/response-property/lib/seed_response_property_client/service/types/response.rb +++ b/seed/ruby-sdk/response-property/lib/seed_response_property_client/service/types/response.rb @@ -30,7 +30,8 @@ def initialize(data:, metadata:, docs:, additional_properties: nil) # @return [Service::Response] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - data = struct.data + data = struct.data.to_h.to_json + data = Service::Movie.from_json(json_object: data) metadata = struct.metadata docs = struct.docs new(data: data, metadata: metadata, docs: docs, additional_properties: struct) diff --git a/seed/ruby-sdk/response-property/lib/types_export.rb b/seed/ruby-sdk/response-property/lib/types_export.rb new file mode 100644 index 00000000000..e3175d7e4e3 --- /dev/null +++ b/seed/ruby-sdk/response-property/lib/types_export.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require_relative "seed_response_property_client/types/string_response" +require_relative "seed_response_property_client/types/optional_string_response" +require_relative "seed_response_property_client/types/with_metadata" +require_relative "seed_response_property_client/service/types/with_docs" +require_relative "seed_response_property_client/service/types/optional_with_docs" +require_relative "seed_response_property_client/service/types/movie" +require_relative "seed_response_property_client/service/types/response" diff --git a/seed/ruby-sdk/response-property/seed_response_property_client.gemspec b/seed/ruby-sdk/response-property/seed_response_property_client.gemspec index 2921d06631d..5f925e0b44a 100644 --- a/seed/ruby-sdk/response-property/seed_response_property_client.gemspec +++ b/seed/ruby-sdk/response-property/seed_response_property_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_response_property_client" + spec.version = SeedResponsePropertyClient::Gemconfig::VERSION spec.authors = SeedResponsePropertyClient::Gemconfig::AUTHORS spec.email = SeedResponsePropertyClient::Gemconfig::EMAIL spec.summary = SeedResponsePropertyClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/single-url-environment-default/.rubocop.yml b/seed/ruby-sdk/single-url-environment-default/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/single-url-environment-default/.rubocop.yml +++ b/seed/ruby-sdk/single-url-environment-default/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/single-url-environment-default/lib/gemconfig.rb b/seed/ruby-sdk/single-url-environment-default/lib/gemconfig.rb index c57e951bfa7..584b397d5ca 100644 --- a/seed/ruby-sdk/single-url-environment-default/lib/gemconfig.rb +++ b/seed/ruby-sdk/single-url-environment-default/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedSingleUrlEnvironmentDefaultClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/single-url-environment-default/lib/requests.rb b/seed/ruby-sdk/single-url-environment-default/lib/requests.rb index 0f66fed6aa3..e7d1ec69704 100644 --- a/seed/ruby-sdk/single-url-environment-default/lib/requests.rb +++ b/seed/ruby-sdk/single-url-environment-default/lib/requests.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -require "async/http/faraday" +require_relative "environment" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedSingleUrlEnvironmentDefaultClient class RequestClient @@ -12,7 +14,7 @@ class RequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [RequestClient] - def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) @default_environment = environment @base_url = environment @headers = { @@ -22,9 +24,9 @@ def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_i } @conn = Faraday.new(@base_url, headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -37,7 +39,7 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [AsyncRequestClient] - def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) @default_environment = environment @base_url = environment @headers = { @@ -47,29 +49,27 @@ def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_i } @conn = Faraday.new(@base_url, headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [Hash{String => Object}] @@ -78,6 +78,8 @@ def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additio @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/single-url-environment-default/lib/seed_single_url_environment_default_client.rb b/seed/ruby-sdk/single-url-environment-default/lib/seed_single_url_environment_default_client.rb index 86fd21e2114..d9a0da5558a 100644 --- a/seed/ruby-sdk/single-url-environment-default/lib/seed_single_url_environment_default_client.rb +++ b/seed/ruby-sdk/single-url-environment-default/lib/seed_single_url_environment_default_client.rb @@ -1,31 +1,38 @@ # frozen_string_literal: true -require "faraday" +require_relative "environment" +require_relative "types_export" +require_relative "requests" require_relative "seed_single_url_environment_default_client/dummy/client" -require "async/http/faraday" module SeedSingleUrlEnvironmentDefaultClient class Client + attr_reader :dummy + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @dummy_client = DummyClient.initialize(request_client: request_client) + # @return [Client] + def initialize(token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(environment: environment, max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, token: token) + @dummy = DummyClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :dummy + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_dummy_client = AsyncDummyClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, token: token) + @dummy = AsyncDummyClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/single-url-environment-default/lib/seed_single_url_environment_default_client/dummy/client.rb b/seed/ruby-sdk/single-url-environment-default/lib/seed_single_url_environment_default_client/dummy/client.rb index d7a63f64154..baf197b66ae 100644 --- a/seed/ruby-sdk/single-url-environment-default/lib/seed_single_url_environment_default_client/dummy/client.rb +++ b/seed/ruby-sdk/single-url-environment-default/lib/seed_single_url_environment_default_client/dummy/client.rb @@ -1,51 +1,51 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedSingleUrlEnvironmentDefaultClient - module Dummy - class DummyClient - attr_reader :request_client + class DummyClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [DummyClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [DummyClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_dummy(request_options: nil) - @request_client.conn.get("/dummy") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [String] + def get_dummy(request_options: nil) + response = @request_client.conn.get("/dummy") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncDummyClient - attr_reader :request_client + class AsyncDummyClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncDummyClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncDummyClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_dummy(request_options: nil) - Async.call do - response = @request_client.conn.get("/dummy") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param request_options [RequestOptions] + # @return [String] + def get_dummy(request_options: nil) + Async do + response = @request_client.conn.get("/dummy") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/single-url-environment-default/lib/types_export.rb b/seed/ruby-sdk/single-url-environment-default/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/single-url-environment-default/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/single-url-environment-default/seed_single_url_environment_default_client.gemspec b/seed/ruby-sdk/single-url-environment-default/seed_single_url_environment_default_client.gemspec index 61107f5b6e0..f9e5ef2cc42 100644 --- a/seed/ruby-sdk/single-url-environment-default/seed_single_url_environment_default_client.gemspec +++ b/seed/ruby-sdk/single-url-environment-default/seed_single_url_environment_default_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_single_url_environment_default_client" + spec.version = SeedSingleUrlEnvironmentDefaultClient::Gemconfig::VERSION spec.authors = SeedSingleUrlEnvironmentDefaultClient::Gemconfig::AUTHORS spec.email = SeedSingleUrlEnvironmentDefaultClient::Gemconfig::EMAIL spec.summary = SeedSingleUrlEnvironmentDefaultClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/single-url-environment-no-default/.rubocop.yml b/seed/ruby-sdk/single-url-environment-no-default/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/single-url-environment-no-default/.rubocop.yml +++ b/seed/ruby-sdk/single-url-environment-no-default/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/single-url-environment-no-default/lib/gemconfig.rb b/seed/ruby-sdk/single-url-environment-no-default/lib/gemconfig.rb index b37b448f7cb..9cdcbf122f7 100644 --- a/seed/ruby-sdk/single-url-environment-no-default/lib/gemconfig.rb +++ b/seed/ruby-sdk/single-url-environment-no-default/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedSingleUrlEnvironmentNoDefaultClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/single-url-environment-no-default/lib/requests.rb b/seed/ruby-sdk/single-url-environment-no-default/lib/requests.rb index 30d318fc265..29e9e072dd8 100644 --- a/seed/ruby-sdk/single-url-environment-no-default/lib/requests.rb +++ b/seed/ruby-sdk/single-url-environment-no-default/lib/requests.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -require "async/http/faraday" +require_relative "environment" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedSingleUrlEnvironmentNoDefaultClient class RequestClient @@ -12,7 +14,7 @@ class RequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [RequestClient] - def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, environment: nil, max_retries: nil, timeout_in_seconds: nil) @default_environment = environment @base_url = environment @headers = { @@ -22,9 +24,9 @@ def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, toke } @conn = Faraday.new(@base_url, headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -37,7 +39,7 @@ class AsyncRequestClient # @param timeout_in_seconds [Long] # @param token [String] # @return [AsyncRequestClient] - def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, token: nil) + def initialize(token:, environment: nil, max_retries: nil, timeout_in_seconds: nil) @default_environment = environment @base_url = environment @headers = { @@ -47,29 +49,27 @@ def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, toke } @conn = Faraday.new(@base_url, headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :additional_headers, :additional_query_parameters, :additional_body_parameters, + :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [Hash{String => Object}] @@ -78,6 +78,8 @@ def initialize(token:, timeout_in_seconds: nil, additional_headers: nil, additio @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/single-url-environment-no-default/lib/seed_single_url_environment_no_default_client.rb b/seed/ruby-sdk/single-url-environment-no-default/lib/seed_single_url_environment_no_default_client.rb index 2d884c2e226..4e02df1c602 100644 --- a/seed/ruby-sdk/single-url-environment-no-default/lib/seed_single_url_environment_no_default_client.rb +++ b/seed/ruby-sdk/single-url-environment-no-default/lib/seed_single_url_environment_no_default_client.rb @@ -1,31 +1,38 @@ # frozen_string_literal: true -require "faraday" +require_relative "environment" +require_relative "types_export" +require_relative "requests" require_relative "seed_single_url_environment_no_default_client/dummy/client" -require "async/http/faraday" module SeedSingleUrlEnvironmentNoDefaultClient class Client + attr_reader :dummy + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, token: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @dummy_client = DummyClient.initialize(request_client: request_client) + # @return [Client] + def initialize(token:, environment: nil, max_retries: nil, timeout_in_seconds: nil) + @request_client = RequestClient.new(environment: environment, max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, token: token) + @dummy = DummyClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :dummy + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] # @param token [String] - # @return [] - def initialize(environment: nil, max_retries: nil, timeout_in_seconds: nil, token: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_dummy_client = AsyncDummyClient.initialize(request_client: request_client) + # @return [AsyncClient] + def initialize(token:, environment: nil, max_retries: nil, timeout_in_seconds: nil) + @async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, token: token) + @dummy = AsyncDummyClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/single-url-environment-no-default/lib/seed_single_url_environment_no_default_client/dummy/client.rb b/seed/ruby-sdk/single-url-environment-no-default/lib/seed_single_url_environment_no_default_client/dummy/client.rb index 97ed952b8e4..78bd2b5f591 100644 --- a/seed/ruby-sdk/single-url-environment-no-default/lib/seed_single_url_environment_no_default_client/dummy/client.rb +++ b/seed/ruby-sdk/single-url-environment-no-default/lib/seed_single_url_environment_no_default_client/dummy/client.rb @@ -1,51 +1,51 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedSingleUrlEnvironmentNoDefaultClient - module Dummy - class DummyClient - attr_reader :request_client + class DummyClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [DummyClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [DummyClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_dummy(request_options: nil) - @request_client.conn.get("/dummy") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [String] + def get_dummy(request_options: nil) + response = @request_client.conn.get("/dummy") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - class AsyncDummyClient - attr_reader :request_client + class AsyncDummyClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncDummyClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncDummyClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [String] - def get_dummy(request_options: nil) - Async.call do - response = @request_client.conn.get("/dummy") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param request_options [RequestOptions] + # @return [String] + def get_dummy(request_options: nil) + Async do + response = @request_client.conn.get("/dummy") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/single-url-environment-no-default/lib/types_export.rb b/seed/ruby-sdk/single-url-environment-no-default/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/single-url-environment-no-default/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/single-url-environment-no-default/seed_single_url_environment_no_default_client.gemspec b/seed/ruby-sdk/single-url-environment-no-default/seed_single_url_environment_no_default_client.gemspec index 476917d0fdc..95867483322 100644 --- a/seed/ruby-sdk/single-url-environment-no-default/seed_single_url_environment_no_default_client.gemspec +++ b/seed/ruby-sdk/single-url-environment-no-default/seed_single_url_environment_no_default_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_single_url_environment_no_default_client" + spec.version = SeedSingleUrlEnvironmentNoDefaultClient::Gemconfig::VERSION spec.authors = SeedSingleUrlEnvironmentNoDefaultClient::Gemconfig::AUTHORS spec.email = SeedSingleUrlEnvironmentNoDefaultClient::Gemconfig::EMAIL spec.summary = SeedSingleUrlEnvironmentNoDefaultClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/streaming/.rubocop.yml b/seed/ruby-sdk/streaming/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/streaming/.rubocop.yml +++ b/seed/ruby-sdk/streaming/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/streaming/lib/gemconfig.rb b/seed/ruby-sdk/streaming/lib/gemconfig.rb index c7e96f46d9e..f776f7bd6cb 100644 --- a/seed/ruby-sdk/streaming/lib/gemconfig.rb +++ b/seed/ruby-sdk/streaming/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedStreamingClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/streaming/lib/requests.rb b/seed/ruby-sdk/streaming/lib/requests.rb index cf85abb2d06..99d5e891d29 100644 --- a/seed/ruby-sdk/streaming/lib/requests.rb +++ b/seed/ruby-sdk/streaming/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedStreamingClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedStreamingClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedStreamingClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/streaming/lib/seed_streaming_client.rb b/seed/ruby-sdk/streaming/lib/seed_streaming_client.rb index 067d40073de..50495d333c4 100644 --- a/seed/ruby-sdk/streaming/lib/seed_streaming_client.rb +++ b/seed/ruby-sdk/streaming/lib/seed_streaming_client.rb @@ -1,28 +1,31 @@ # frozen_string_literal: true -require_relative "seed_streaming_client/dummy/types/stream_response" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_streaming_client/dummy/client" -require "async/http/faraday" module SeedStreamingClient class Client + attr_reader :dummy + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @dummy_client = DummyClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @dummy = DummyClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :dummy + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_dummy_client = AsyncDummyClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @dummy = AsyncDummyClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/streaming/lib/seed_streaming_client/dummy/client.rb b/seed/ruby-sdk/streaming/lib/seed_streaming_client/dummy/client.rb index ed297fd6105..4280fd40278 100644 --- a/seed/ruby-sdk/streaming/lib/seed_streaming_client/dummy/client.rb +++ b/seed/ruby-sdk/streaming/lib/seed_streaming_client/dummy/client.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true +require_relative "../../requests" + module SeedStreamingClient - module Dummy - class DummyClient - attr_reader :request_client + class DummyClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [DummyClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [DummyClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client end + end - class AsyncDummyClient - attr_reader :request_client + class AsyncDummyClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncDummyClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncDummyClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client end end end diff --git a/seed/ruby-sdk/streaming/lib/types_export.rb b/seed/ruby-sdk/streaming/lib/types_export.rb new file mode 100644 index 00000000000..6ca259a9fab --- /dev/null +++ b/seed/ruby-sdk/streaming/lib/types_export.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "seed_streaming_client/dummy/types/stream_response" diff --git a/seed/ruby-sdk/streaming/seed_streaming_client.gemspec b/seed/ruby-sdk/streaming/seed_streaming_client.gemspec index 0a10cb65432..2e631631cd4 100644 --- a/seed/ruby-sdk/streaming/seed_streaming_client.gemspec +++ b/seed/ruby-sdk/streaming/seed_streaming_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_streaming_client" + spec.version = SeedStreamingClient::Gemconfig::VERSION spec.authors = SeedStreamingClient::Gemconfig::AUTHORS spec.email = SeedStreamingClient::Gemconfig::EMAIL spec.summary = SeedStreamingClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/trace/.rubocop.yml b/seed/ruby-sdk/trace/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/trace/.rubocop.yml +++ b/seed/ruby-sdk/trace/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/trace/lib/gemconfig.rb b/seed/ruby-sdk/trace/lib/gemconfig.rb index 3f41146dd35..0e809dcecd7 100644 --- a/seed/ruby-sdk/trace/lib/gemconfig.rb +++ b/seed/ruby-sdk/trace/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedTraceClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/trace/lib/requests.rb b/seed/ruby-sdk/trace/lib/requests.rb index 3e1901656f0..5c5391b4a74 100644 --- a/seed/ruby-sdk/trace/lib/requests.rb +++ b/seed/ruby-sdk/trace/lib/requests.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -require "async/http/faraday" +require_relative "environment" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedTraceClient class RequestClient @@ -13,16 +15,17 @@ class RequestClient # @param token [String] # @param x_random_header [String] # @return [RequestClient] - def initialize(environment: Environment::PROD, max_retries: nil, timeout_in_seconds: nil, token: nil, + def initialize(token:, environment: Environment::PROD, max_retries: nil, timeout_in_seconds: nil, x_random_header: nil) @default_environment = environment @base_url = environment @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedTraceClient", "Authorization": "Bearer #{token}" } + @headers["X-Random-Header"] = x_random_header unless x_random_header.nil? @conn = Faraday.new(@base_url, headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -36,37 +39,36 @@ class AsyncRequestClient # @param token [String] # @param x_random_header [String] # @return [AsyncRequestClient] - def initialize(environment: Environment::PROD, max_retries: nil, timeout_in_seconds: nil, token: nil, + def initialize(token:, environment: Environment::PROD, max_retries: nil, timeout_in_seconds: nil, x_random_header: nil) @default_environment = environment @base_url = environment @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedTraceClient", "Authorization": "Bearer #{token}" } + @headers["X-Random-Header"] = x_random_header unless x_random_header.nil? @conn = Faraday.new(@base_url, headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :token, :x_random_header, :additional_headers, :additional_query_parameters, - :additional_body_parameters + attr_reader :token, :x_random_header, :additional_headers, :additional_query_parameters, + :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param token [String] # @param x_random_header [String] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(token:, x_random_header:, timeout_in_seconds: nil, additional_headers: nil, - additional_query_parameters: nil, additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(token: nil, x_random_header: nil, additional_headers: nil, additional_query_parameters: nil, + additional_body_parameters: nil, timeout_in_seconds: nil) # @type [String] @token = token # @type [String] @@ -77,6 +79,8 @@ def initialize(token:, x_random_header:, timeout_in_seconds: nil, additional_hea @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client.rb index 9835785f55b..1d87a3ed59a 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client.rb @@ -1,210 +1,8 @@ # frozen_string_literal: true - -require_relative "seed_trace_client/admin/types/test" -require_relative "seed_trace_client/commons/types/binary_tree_node_and_tree_value" -require_relative "seed_trace_client/commons/types/binary_tree_node_value" -require_relative "seed_trace_client/commons/types/binary_tree_value" -require_relative "seed_trace_client/commons/types/debug_key_value_pairs" -require_relative "seed_trace_client/commons/types/debug_map_value" -require_relative "seed_trace_client/commons/types/debug_variable_value" -require_relative "seed_trace_client/commons/types/doubly_linked_list_node_and_list_value" -require_relative "seed_trace_client/commons/types/doubly_linked_list_node_value" -require_relative "seed_trace_client/commons/types/doubly_linked_list_value" -require_relative "seed_trace_client/commons/types/file_info" -require_relative "seed_trace_client/commons/types/generic_value" -require_relative "seed_trace_client/commons/types/key_value_pair" -require_relative "seed_trace_client/commons/types/list_type" -require_relative "seed_trace_client/commons/types/map_type" -require_relative "seed_trace_client/commons/types/map_value" -require_relative "seed_trace_client/commons/types/node_id" -require_relative "seed_trace_client/commons/types/problem_id" -require_relative "seed_trace_client/commons/types/singly_linked_list_node_and_list_value" -require_relative "seed_trace_client/commons/types/singly_linked_list_node_value" -require_relative "seed_trace_client/commons/types/singly_linked_list_value" -require_relative "seed_trace_client/commons/types/test_case" -require_relative "seed_trace_client/commons/types/test_case_with_expected_result" -require_relative "seed_trace_client/commons/types/user_id" -require_relative "seed_trace_client/commons/types/variable_type" -require_relative "seed_trace_client/commons/types/variable_value" -require_relative "seed_trace_client/lang_server/types/lang_server_request" -require_relative "seed_trace_client/lang_server/types/lang_server_response" -require_relative "seed_trace_client/migration/types/migration" -require_relative "seed_trace_client/playlist/types/playlist" -require_relative "seed_trace_client/playlist/types/playlist_create_request" -require_relative "seed_trace_client/playlist/types/playlist_id" -require_relative "seed_trace_client/playlist/types/playlist_id_not_found_error_body" -require_relative "seed_trace_client/playlist/types/update_playlist_request" -require_relative "seed_trace_client/problem/types/create_problem_error" -require_relative "seed_trace_client/problem/types/create_problem_request" -require_relative "seed_trace_client/problem/types/create_problem_response" -require_relative "seed_trace_client/problem/types/generic_create_problem_error" -require_relative "seed_trace_client/problem/types/get_default_starter_files_response" -require_relative "seed_trace_client/problem/types/problem_description" -require_relative "seed_trace_client/problem/types/problem_description_board" -require_relative "seed_trace_client/problem/types/problem_files" -require_relative "seed_trace_client/problem/types/problem_info" -require_relative "seed_trace_client/problem/types/update_problem_response" -require_relative "seed_trace_client/problem/types/variable_type_and_name" -require_relative "seed_trace_client/submission/types/actual_result" -require_relative "seed_trace_client/submission/types/building_executor_response" -require_relative "seed_trace_client/submission/types/code_execution_update" -require_relative "seed_trace_client/submission/types/compile_error" -require_relative "seed_trace_client/submission/types/custom_test_cases_unsupported" -require_relative "seed_trace_client/submission/types/error_info" -require_relative "seed_trace_client/submission/types/errored_response" -require_relative "seed_trace_client/submission/types/exception_info" -require_relative "seed_trace_client/submission/types/exception_v_2" -require_relative "seed_trace_client/submission/types/execution_session_response" -require_relative "seed_trace_client/submission/types/execution_session_state" -require_relative "seed_trace_client/submission/types/existing_submission_executing" -require_relative "seed_trace_client/submission/types/expression_location" -require_relative "seed_trace_client/submission/types/finished_response" -require_relative "seed_trace_client/submission/types/get_execution_session_state_response" -require_relative "seed_trace_client/submission/types/get_submission_state_response" -require_relative "seed_trace_client/submission/types/get_trace_responses_page_request" -require_relative "seed_trace_client/submission/types/graded_response" -require_relative "seed_trace_client/submission/types/graded_response_v_2" -require_relative "seed_trace_client/submission/types/graded_test_case_update" -require_relative "seed_trace_client/submission/types/initialize_problem_request" -require_relative "seed_trace_client/submission/types/internal_error" -require_relative "seed_trace_client/submission/types/invalid_request_cause" -require_relative "seed_trace_client/submission/types/invalid_request_response" -require_relative "seed_trace_client/submission/types/lightweight_stackframe_information" -require_relative "seed_trace_client/submission/types/recorded_response_notification" -require_relative "seed_trace_client/submission/types/recorded_test_case_update" -require_relative "seed_trace_client/submission/types/recording_response_notification" -require_relative "seed_trace_client/submission/types/running_response" -require_relative "seed_trace_client/submission/types/runtime_error" -require_relative "seed_trace_client/submission/types/scope" -require_relative "seed_trace_client/submission/types/share_id" -require_relative "seed_trace_client/submission/types/stack_frame" -require_relative "seed_trace_client/submission/types/stack_information" -require_relative "seed_trace_client/submission/types/stderr_response" -require_relative "seed_trace_client/submission/types/stdout_response" -require_relative "seed_trace_client/submission/types/stop_request" -require_relative "seed_trace_client/submission/types/stopped_response" -require_relative "seed_trace_client/submission/types/submission_file_info" -require_relative "seed_trace_client/submission/types/submission_id" -require_relative "seed_trace_client/submission/types/submission_id_not_found" -require_relative "seed_trace_client/submission/types/submission_request" -require_relative "seed_trace_client/submission/types/submission_response" -require_relative "seed_trace_client/submission/types/submission_status_for_test_case" -require_relative "seed_trace_client/submission/types/submission_status_v_2" -require_relative "seed_trace_client/submission/types/submission_type_state" -require_relative "seed_trace_client/submission/types/submit_request_v_2" -require_relative "seed_trace_client/submission/types/terminated_response" -require_relative "seed_trace_client/submission/types/test_case_grade" -require_relative "seed_trace_client/submission/types/test_case_hidden_grade" -require_relative "seed_trace_client/submission/types/test_case_non_hidden_grade" -require_relative "seed_trace_client/submission/types/test_case_result" -require_relative "seed_trace_client/submission/types/test_case_result_with_stdout" -require_relative "seed_trace_client/submission/types/test_submission_state" -require_relative "seed_trace_client/submission/types/test_submission_status" -require_relative "seed_trace_client/submission/types/test_submission_status_v_2" -require_relative "seed_trace_client/submission/types/test_submission_update" -require_relative "seed_trace_client/submission/types/test_submission_update_info" -require_relative "seed_trace_client/submission/types/trace_response" -require_relative "seed_trace_client/submission/types/trace_response_v_2" -require_relative "seed_trace_client/submission/types/trace_responses_page" -require_relative "seed_trace_client/submission/types/trace_responses_page_v_2" -require_relative "seed_trace_client/submission/types/traced_file" -require_relative "seed_trace_client/submission/types/traced_test_case" -require_relative "seed_trace_client/submission/types/unexpected_language_error" -require_relative "seed_trace_client/submission/types/workspace_files" -require_relative "seed_trace_client/submission/types/workspace_ran_response" -require_relative "seed_trace_client/submission/types/workspace_run_details" -require_relative "seed_trace_client/submission/types/workspace_starter_files_response" -require_relative "seed_trace_client/submission/types/workspace_starter_files_response_v_2" -require_relative "seed_trace_client/submission/types/workspace_submission_state" -require_relative "seed_trace_client/submission/types/workspace_submission_status" -require_relative "seed_trace_client/submission/types/workspace_submission_status_v_2" -require_relative "seed_trace_client/submission/types/workspace_submission_update" -require_relative "seed_trace_client/submission/types/workspace_submission_update_info" -require_relative "seed_trace_client/submission/types/workspace_submit_request" -require_relative "seed_trace_client/submission/types/workspace_traced_update" -require_relative "seed_trace_client/v_2/problem/types/assert_correctness_check" -require_relative "seed_trace_client/v_2/problem/types/basic_custom_files" -require_relative "seed_trace_client/v_2/problem/types/basic_test_case_template" -require_relative "seed_trace_client/v_2/problem/types/create_problem_request_v_2" -require_relative "seed_trace_client/v_2/problem/types/custom_files" -require_relative "seed_trace_client/v_2/problem/types/deep_equality_correctness_check" -require_relative "seed_trace_client/v_2/problem/types/default_provided_file" -require_relative "seed_trace_client/v_2/problem/types/file_info_v_2" -require_relative "seed_trace_client/v_2/problem/types/files" -require_relative "seed_trace_client/v_2/problem/types/function_implementation" -require_relative "seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages" -require_relative "seed_trace_client/v_2/problem/types/function_signature" -require_relative "seed_trace_client/v_2/problem/types/generated_files" -require_relative "seed_trace_client/v_2/problem/types/get_basic_solution_file_request" -require_relative "seed_trace_client/v_2/problem/types/get_basic_solution_file_response" -require_relative "seed_trace_client/v_2/problem/types/get_function_signature_request" -require_relative "seed_trace_client/v_2/problem/types/get_function_signature_response" -require_relative "seed_trace_client/v_2/problem/types/get_generated_test_case_file_request" -require_relative "seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request" -require_relative "seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2" -require_relative "seed_trace_client/v_2/problem/types/non_void_function_definition" -require_relative "seed_trace_client/v_2/problem/types/non_void_function_signature" -require_relative "seed_trace_client/v_2/problem/types/parameter" -require_relative "seed_trace_client/v_2/problem/types/parameter_id" -require_relative "seed_trace_client/v_2/problem/types/problem_info_v_2" -require_relative "seed_trace_client/v_2/problem/types/test_case_expects" -require_relative "seed_trace_client/v_2/problem/types/test_case_function" -require_relative "seed_trace_client/v_2/problem/types/test_case_id" -require_relative "seed_trace_client/v_2/problem/types/test_case_implementation" -require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_description" -require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_description_board" -require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_reference" -require_relative "seed_trace_client/v_2/problem/types/test_case_metadata" -require_relative "seed_trace_client/v_2/problem/types/test_case_template" -require_relative "seed_trace_client/v_2/problem/types/test_case_template_id" -require_relative "seed_trace_client/v_2/problem/types/test_case_v_2" -require_relative "seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation" -require_relative "seed_trace_client/v_2/problem/types/void_function_definition" -require_relative "seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result" -require_relative "seed_trace_client/v_2/problem/types/void_function_signature" -require_relative "seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result" -require_relative "seed_trace_client/v_2/v_3/problem/types/assert_correctness_check" -require_relative "seed_trace_client/v_2/v_3/problem/types/basic_custom_files" -require_relative "seed_trace_client/v_2/v_3/problem/types/basic_test_case_template" -require_relative "seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2" -require_relative "seed_trace_client/v_2/v_3/problem/types/custom_files" -require_relative "seed_trace_client/v_2/v_3/problem/types/deep_equality_correctness_check" -require_relative "seed_trace_client/v_2/v_3/problem/types/default_provided_file" -require_relative "seed_trace_client/v_2/v_3/problem/types/file_info_v_2" -require_relative "seed_trace_client/v_2/v_3/problem/types/files" -require_relative "seed_trace_client/v_2/v_3/problem/types/function_implementation" -require_relative "seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages" -require_relative "seed_trace_client/v_2/v_3/problem/types/function_signature" -require_relative "seed_trace_client/v_2/v_3/problem/types/generated_files" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_function_signature_request" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_function_signature_response" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request" -require_relative "seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request" -require_relative "seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2" -require_relative "seed_trace_client/v_2/v_3/problem/types/non_void_function_definition" -require_relative "seed_trace_client/v_2/v_3/problem/types/non_void_function_signature" -require_relative "seed_trace_client/v_2/v_3/problem/types/parameter" -require_relative "seed_trace_client/v_2/v_3/problem/types/parameter_id" -require_relative "seed_trace_client/v_2/v_3/problem/types/problem_info_v_2" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_expects" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_function" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_id" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description_board" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_reference" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_metadata" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_template" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_template_id" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_v_2" -require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation" -require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_definition" -require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result" -require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_signature" -require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result" -require "faraday" +require_relative "environment" +require_relative "types_export" +require_relative "requests" +require_relative "seed_trace_client/v_2/client" require_relative "seed_trace_client/admin/client" require_relative "seed_trace_client/homepage/client" require_relative "seed_trace_client/migration/client" @@ -212,49 +10,47 @@ require_relative "seed_trace_client/problem/client" require_relative "seed_trace_client/submission/client" require_relative "seed_trace_client/sysprop/client" -require_relative "seed_trace_client/v_2/client" -require "async/http/faraday" +require_relative "requests" module SeedTraceClient class Client - # @param environment [Environment] + attr_reader :, :admin, :homepage, :migration, :playlist, :problem, :submission, :sysprop + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. - # @param timeout_in_seconds [Long] - # @param token [String] - # @param x_random_header [String] - # @return [] - def initialize(environment: Environment::PROD, max_retries: nil, timeout_in_seconds: nil, token: nil, - x_random_header: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @client = Client.initialize(request_client: request_client) - @admin_client = AdminClient.initialize(request_client: request_client) - @homepage_client = HomepageClient.initialize(request_client: request_client) - @migration_client = MigrationClient.initialize(request_client: request_client) - @playlist_client = PlaylistClient.initialize(request_client: request_client) - @problem_client = ProblemClient.initialize(request_client: request_client) - @submission_client = SubmissionClient.initialize(request_client: request_client) - @sysprop_client = SyspropClient.initialize(request_client: request_client) + # @param timeout_in_seconds [Long] + # @param token [String] + # @param x_random_header [String] + # @return [Client] + def initialize(environment: Environment::PROD, max_retries: nil, timeout_in_seconds: nil, token:, x_random_header: nil) + @request_client = RequestClient.new(environment: environment, max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, token: token, x_random_header: x_random_header) + @ = V2::Client.new(request_client: @request_client) + @admin = AdminClient.new(request_client: @request_client) + @homepage = HomepageClient.new(request_client: @request_client) + @migration = MigrationClient.new(request_client: @request_client) + @playlist = PlaylistClient.new(request_client: @request_client) + @problem = ProblemClient.new(request_client: @request_client) + @submission = SubmissionClient.new(request_client: @request_client) + @sysprop = SyspropClient.new(request_client: @request_client) end end - class AsyncClient - # @param environment [Environment] + attr_reader :, :admin, :homepage, :migration, :playlist, :problem, :submission, :sysprop + # @param environment [Environment] # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. - # @param timeout_in_seconds [Long] - # @param token [String] - # @param x_random_header [String] - # @return [] - def initialize(environment: Environment::PROD, max_retries: nil, timeout_in_seconds: nil, token: nil, - x_random_header: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_client = AsyncClient.initialize(request_client: request_client) - @async_admin_client = AsyncAdminClient.initialize(request_client: request_client) - @async_homepage_client = AsyncHomepageClient.initialize(request_client: request_client) - @async_migration_client = AsyncMigrationClient.initialize(request_client: request_client) - @async_playlist_client = AsyncPlaylistClient.initialize(request_client: request_client) - @async_problem_client = AsyncProblemClient.initialize(request_client: request_client) - @async_submission_client = AsyncSubmissionClient.initialize(request_client: request_client) - @async_sysprop_client = AsyncSyspropClient.initialize(request_client: request_client) + # @param timeout_in_seconds [Long] + # @param token [String] + # @param x_random_header [String] + # @return [AsyncClient] + def initialize(environment: Environment::PROD, max_retries: nil, timeout_in_seconds: nil, token:, x_random_header: nil) + @async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, token: token, x_random_header: x_random_header) + @ = V2::AsyncClient.new(request_client: @async_request_client) + @admin = AsyncAdminClient.new(request_client: @async_request_client) + @homepage = AsyncHomepageClient.new(request_client: @async_request_client) + @migration = AsyncMigrationClient.new(request_client: @async_request_client) + @playlist = AsyncPlaylistClient.new(request_client: @async_request_client) + @problem = AsyncProblemClient.new(request_client: @async_request_client) + @submission = AsyncSubmissionClient.new(request_client: @async_request_client) + @sysprop = AsyncSyspropClient.new(request_client: @async_request_client) end end -end +end \ No newline at end of file diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/admin/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/admin/client.rb index bcca9de7fc2..86b529fb58c 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/admin/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/admin/client.rb @@ -1,331 +1,446 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "../submission/types/submission_id" -require_relative "../submission/types/test_case_result_with_stdout" require_relative "../submission/types/test_submission_status" require_relative "../submission/types/test_submission_update" -require_relative "../submission/types/trace_response" -require_relative "../submission/types/trace_response_v_2" -require_relative "../submission/types/workspace_run_details" require_relative "../submission/types/workspace_submission_status" require_relative "../submission/types/workspace_submission_update" +require_relative "../submission/types/test_case_result_with_stdout" +require_relative "../submission/types/trace_response" require_relative "../v_2/problem/types/test_case_id" +require_relative "../submission/types/trace_response_v_2" +require_relative "../submission/types/workspace_run_details" require "async" module SeedTraceClient - module Admin - class AdminClient - attr_reader :request_client + class AdminClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [AdminClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [AdminClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Hash] Request of type Submission::TestSubmissionStatus, as a Hash - # @param request_options [RequestOptions] - # @return [Void] - def update_test_submission_status(submission_id:, request:, request_options: nil) - @request_client.conn.post("/admin/store-test-submission-status/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Hash] Request of type Submission::TestSubmissionStatus, as a Hash + # @param request_options [RequestOptions] + # @return [Void] + def update_test_submission_status(submission_id:, request:, request_options: nil) + @request_client.conn.post("/admin/store-test-submission-status/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Hash] Request of type Submission::TestSubmissionUpdate, as a Hash - # * :update_time (DateTime) - # * :update_info (Hash) - # @param request_options [RequestOptions] - # @return [Void] - def send_test_submission_update(submission_id:, request:, request_options: nil) - @request_client.conn.post("/admin/store-test-submission-status-v2/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Hash] Request of type Submission::TestSubmissionUpdate, as a Hash + # * :update_time (DateTime) + # * :update_info (Hash) + # @param request_options [RequestOptions] + # @return [Void] + def send_test_submission_update(submission_id:, request:, request_options: nil) + @request_client.conn.post("/admin/store-test-submission-status-v2/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Hash] Request of type Submission::WorkspaceSubmissionStatus, as a Hash - # @param request_options [RequestOptions] - # @return [Void] - def update_workspace_submission_status(submission_id:, request:, request_options: nil) - @request_client.conn.post("/admin/store-workspace-submission-status/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Hash] Request of type Submission::WorkspaceSubmissionStatus, as a Hash + # @param request_options [RequestOptions] + # @return [Void] + def update_workspace_submission_status(submission_id:, request:, request_options: nil) + @request_client.conn.post("/admin/store-workspace-submission-status/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Hash] Request of type Submission::WorkspaceSubmissionUpdate, as a Hash - # * :update_time (DateTime) - # * :update_info (Hash) - # @param request_options [RequestOptions] - # @return [Void] - def send_workspace_submission_update(submission_id:, request:, request_options: nil) - @request_client.conn.post("/admin/store-workspace-submission-status-v2/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Hash] Request of type Submission::WorkspaceSubmissionUpdate, as a Hash + # * :update_time (DateTime) + # * :update_info (Hash) + # @param request_options [RequestOptions] + # @return [Void] + def send_workspace_submission_update(submission_id:, request:, request_options: nil) + @request_client.conn.post("/admin/store-workspace-submission-status-v2/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param test_case_id [String] - # @param result [Hash] Request of type Submission::TestCaseResultWithStdout, as a Hash - # * :result (Hash) - # * :expected_result (Hash) - # * :actual_result (Hash) - # * :passed (Boolean) - # * :stdout (String) - # @param trace_responses [Array] - # @param request_options [RequestOptions] - # @return [Void] - def store_traced_test_case(submission_id:, test_case_id:, result:, trace_responses:, request_options: nil) - @request_client.conn.post("/admin/store-test-trace/submission/#{submission_id}/testCase/#{test_case_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - result: result, - traceResponses: trace_responses - }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param test_case_id [String] + # @param result [Hash] Request of type Submission::TestCaseResultWithStdout, as a Hash + # * :result (Hash) + # * :expected_result (Hash) + # * :actual_result (Hash) + # * :passed (Boolean) + # * :stdout (String) + # @param trace_responses [Array] Request of type Array, as a Hash + # * :submission_id (Submission::SUBMISSION_ID) + # * :line_number (Integer) + # * :return_value (Hash) + # * :expression_location (Hash) + # * :start (Integer) + # * :offset (Integer) + # * :stack (Hash) + # * :num_stack_frames (Integer) + # * :top_stack_frame (Hash) + # * :method_name (String) + # * :line_number (Integer) + # * :scopes (Array) + # * :stdout (String) + # @param request_options [RequestOptions] + # @return [Void] + def store_traced_test_case(submission_id:, test_case_id:, result:, trace_responses:, request_options: nil) + @request_client.conn.post("/admin/store-test-trace/submission/#{submission_id}/testCase/#{test_case_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + result: result, + traceResponses: trace_responses + }.compact end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param test_case_id [V2::Problem::TEST_CASE_ID] - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Void] - def store_traced_test_case_v_2(submission_id:, test_case_id:, request:, request_options: nil) - @request_client.conn.post("/admin/store-test-trace-v2/submission/#{submission_id}/testCase/#{test_case_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param test_case_id [V2::Problem::TEST_CASE_ID] + # @param request [Array] Request of type Array, as a Hash + # * :submission_id (Submission::SUBMISSION_ID) + # * :line_number (Integer) + # * :file (Hash) + # * :filename (String) + # * :directory (String) + # * :return_value (Hash) + # * :expression_location (Hash) + # * :start (Integer) + # * :offset (Integer) + # * :stack (Hash) + # * :num_stack_frames (Integer) + # * :top_stack_frame (Hash) + # * :method_name (String) + # * :line_number (Integer) + # * :scopes (Array) + # * :stdout (String) + # @param request_options [RequestOptions] + # @return [Void] + def store_traced_test_case_v_2(submission_id:, test_case_id:, request:, request_options: nil) + @request_client.conn.post("/admin/store-test-trace-v2/submission/#{submission_id}/testCase/#{test_case_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param workspace_run_details [Hash] Request of type Submission::WorkspaceRunDetails, as a Hash - # * :exception_v_2 (Hash) - # * :exception (Hash) - # * :exception_type (String) - # * :exception_message (String) - # * :exception_stacktrace (String) - # * :stdout (String) - # @param trace_responses [Array] - # @param request_options [RequestOptions] - # @return [Void] - def store_traced_workspace(submission_id:, workspace_run_details:, trace_responses:, request_options: nil) - @request_client.conn.post("/admin/store-workspace-trace/submission/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - workspaceRunDetails: workspace_run_details, - traceResponses: trace_responses - }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param workspace_run_details [Hash] Request of type Submission::WorkspaceRunDetails, as a Hash + # * :exception_v_2 (Hash) + # * :exception (Hash) + # * :exception_type (String) + # * :exception_message (String) + # * :exception_stacktrace (String) + # * :stdout (String) + # @param trace_responses [Array] Request of type Array, as a Hash + # * :submission_id (Submission::SUBMISSION_ID) + # * :line_number (Integer) + # * :return_value (Hash) + # * :expression_location (Hash) + # * :start (Integer) + # * :offset (Integer) + # * :stack (Hash) + # * :num_stack_frames (Integer) + # * :top_stack_frame (Hash) + # * :method_name (String) + # * :line_number (Integer) + # * :scopes (Array) + # * :stdout (String) + # @param request_options [RequestOptions] + # @return [Void] + def store_traced_workspace(submission_id:, workspace_run_details:, trace_responses:, request_options: nil) + @request_client.conn.post("/admin/store-workspace-trace/submission/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + workspaceRunDetails: workspace_run_details, + traceResponses: trace_responses + }.compact end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Void] - def store_traced_workspace_v_2(submission_id:, request:, request_options: nil) - @request_client.conn.post("/admin/store-workspace-trace-v2/submission/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Array] Request of type Array, as a Hash + # * :submission_id (Submission::SUBMISSION_ID) + # * :line_number (Integer) + # * :file (Hash) + # * :filename (String) + # * :directory (String) + # * :return_value (Hash) + # * :expression_location (Hash) + # * :start (Integer) + # * :offset (Integer) + # * :stack (Hash) + # * :num_stack_frames (Integer) + # * :top_stack_frame (Hash) + # * :method_name (String) + # * :line_number (Integer) + # * :scopes (Array) + # * :stdout (String) + # @param request_options [RequestOptions] + # @return [Void] + def store_traced_workspace_v_2(submission_id:, request:, request_options: nil) + @request_client.conn.post("/admin/store-workspace-trace-v2/submission/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - class AsyncAdminClient - attr_reader :request_client + class AsyncAdminClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncAdminClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncAdminClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Hash] Request of type Submission::TestSubmissionStatus, as a Hash - # @param request_options [RequestOptions] - # @return [Void] - def update_test_submission_status(submission_id:, request:, request_options: nil) - Async.call do - @request_client.conn.post("/admin/store-test-submission-status/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Hash] Request of type Submission::TestSubmissionStatus, as a Hash + # @param request_options [RequestOptions] + # @return [Void] + def update_test_submission_status(submission_id:, request:, request_options: nil) + Async do + @request_client.conn.post("/admin/store-test-submission-status/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Hash] Request of type Submission::TestSubmissionUpdate, as a Hash - # * :update_time (DateTime) - # * :update_info (Hash) - # @param request_options [RequestOptions] - # @return [Void] - def send_test_submission_update(submission_id:, request:, request_options: nil) - Async.call do - @request_client.conn.post("/admin/store-test-submission-status-v2/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Hash] Request of type Submission::TestSubmissionUpdate, as a Hash + # * :update_time (DateTime) + # * :update_info (Hash) + # @param request_options [RequestOptions] + # @return [Void] + def send_test_submission_update(submission_id:, request:, request_options: nil) + Async do + @request_client.conn.post("/admin/store-test-submission-status-v2/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Hash] Request of type Submission::WorkspaceSubmissionStatus, as a Hash - # @param request_options [RequestOptions] - # @return [Void] - def update_workspace_submission_status(submission_id:, request:, request_options: nil) - Async.call do - @request_client.conn.post("/admin/store-workspace-submission-status/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Hash] Request of type Submission::WorkspaceSubmissionStatus, as a Hash + # @param request_options [RequestOptions] + # @return [Void] + def update_workspace_submission_status(submission_id:, request:, request_options: nil) + Async do + @request_client.conn.post("/admin/store-workspace-submission-status/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Hash] Request of type Submission::WorkspaceSubmissionUpdate, as a Hash - # * :update_time (DateTime) - # * :update_info (Hash) - # @param request_options [RequestOptions] - # @return [Void] - def send_workspace_submission_update(submission_id:, request:, request_options: nil) - Async.call do - @request_client.conn.post("/admin/store-workspace-submission-status-v2/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Hash] Request of type Submission::WorkspaceSubmissionUpdate, as a Hash + # * :update_time (DateTime) + # * :update_info (Hash) + # @param request_options [RequestOptions] + # @return [Void] + def send_workspace_submission_update(submission_id:, request:, request_options: nil) + Async do + @request_client.conn.post("/admin/store-workspace-submission-status-v2/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param test_case_id [String] - # @param result [Hash] Request of type Submission::TestCaseResultWithStdout, as a Hash - # * :result (Hash) - # * :expected_result (Hash) - # * :actual_result (Hash) - # * :passed (Boolean) - # * :stdout (String) - # @param trace_responses [Array] - # @param request_options [RequestOptions] - # @return [Void] - def store_traced_test_case(submission_id:, test_case_id:, result:, trace_responses:, request_options: nil) - Async.call do - @request_client.conn.post("/admin/store-test-trace/submission/#{submission_id}/testCase/#{test_case_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - result: result, - traceResponses: trace_responses - }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param test_case_id [String] + # @param result [Hash] Request of type Submission::TestCaseResultWithStdout, as a Hash + # * :result (Hash) + # * :expected_result (Hash) + # * :actual_result (Hash) + # * :passed (Boolean) + # * :stdout (String) + # @param trace_responses [Array] Request of type Array, as a Hash + # * :submission_id (Submission::SUBMISSION_ID) + # * :line_number (Integer) + # * :return_value (Hash) + # * :expression_location (Hash) + # * :start (Integer) + # * :offset (Integer) + # * :stack (Hash) + # * :num_stack_frames (Integer) + # * :top_stack_frame (Hash) + # * :method_name (String) + # * :line_number (Integer) + # * :scopes (Array) + # * :stdout (String) + # @param request_options [RequestOptions] + # @return [Void] + def store_traced_test_case(submission_id:, test_case_id:, result:, trace_responses:, request_options: nil) + Async do + @request_client.conn.post("/admin/store-test-trace/submission/#{submission_id}/testCase/#{test_case_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + result: result, + traceResponses: trace_responses + }.compact end end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param test_case_id [V2::Problem::TEST_CASE_ID] - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Void] - def store_traced_test_case_v_2(submission_id:, test_case_id:, request:, request_options: nil) - Async.call do - @request_client.conn.post("/admin/store-test-trace-v2/submission/#{submission_id}/testCase/#{test_case_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param test_case_id [V2::Problem::TEST_CASE_ID] + # @param request [Array] Request of type Array, as a Hash + # * :submission_id (Submission::SUBMISSION_ID) + # * :line_number (Integer) + # * :file (Hash) + # * :filename (String) + # * :directory (String) + # * :return_value (Hash) + # * :expression_location (Hash) + # * :start (Integer) + # * :offset (Integer) + # * :stack (Hash) + # * :num_stack_frames (Integer) + # * :top_stack_frame (Hash) + # * :method_name (String) + # * :line_number (Integer) + # * :scopes (Array) + # * :stdout (String) + # @param request_options [RequestOptions] + # @return [Void] + def store_traced_test_case_v_2(submission_id:, test_case_id:, request:, request_options: nil) + Async do + @request_client.conn.post("/admin/store-test-trace-v2/submission/#{submission_id}/testCase/#{test_case_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param workspace_run_details [Hash] Request of type Submission::WorkspaceRunDetails, as a Hash - # * :exception_v_2 (Hash) - # * :exception (Hash) - # * :exception_type (String) - # * :exception_message (String) - # * :exception_stacktrace (String) - # * :stdout (String) - # @param trace_responses [Array] - # @param request_options [RequestOptions] - # @return [Void] - def store_traced_workspace(submission_id:, workspace_run_details:, trace_responses:, request_options: nil) - Async.call do - @request_client.conn.post("/admin/store-workspace-trace/submission/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - workspaceRunDetails: workspace_run_details, - traceResponses: trace_responses - }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param workspace_run_details [Hash] Request of type Submission::WorkspaceRunDetails, as a Hash + # * :exception_v_2 (Hash) + # * :exception (Hash) + # * :exception_type (String) + # * :exception_message (String) + # * :exception_stacktrace (String) + # * :stdout (String) + # @param trace_responses [Array] Request of type Array, as a Hash + # * :submission_id (Submission::SUBMISSION_ID) + # * :line_number (Integer) + # * :return_value (Hash) + # * :expression_location (Hash) + # * :start (Integer) + # * :offset (Integer) + # * :stack (Hash) + # * :num_stack_frames (Integer) + # * :top_stack_frame (Hash) + # * :method_name (String) + # * :line_number (Integer) + # * :scopes (Array) + # * :stdout (String) + # @param request_options [RequestOptions] + # @return [Void] + def store_traced_workspace(submission_id:, workspace_run_details:, trace_responses:, request_options: nil) + Async do + @request_client.conn.post("/admin/store-workspace-trace/submission/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + workspaceRunDetails: workspace_run_details, + traceResponses: trace_responses + }.compact end end + end - # @param submission_id [Submission::SUBMISSION_ID] - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Void] - def store_traced_workspace_v_2(submission_id:, request:, request_options: nil) - Async.call do - @request_client.conn.post("/admin/store-workspace-trace-v2/submission/#{submission_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param submission_id [Submission::SUBMISSION_ID] + # @param request [Array] Request of type Array, as a Hash + # * :submission_id (Submission::SUBMISSION_ID) + # * :line_number (Integer) + # * :file (Hash) + # * :filename (String) + # * :directory (String) + # * :return_value (Hash) + # * :expression_location (Hash) + # * :start (Integer) + # * :offset (Integer) + # * :stack (Hash) + # * :num_stack_frames (Integer) + # * :top_stack_frame (Hash) + # * :method_name (String) + # * :line_number (Integer) + # * :scopes (Array) + # * :stdout (String) + # @param request_options [RequestOptions] + # @return [Void] + def store_traced_workspace_v_2(submission_id:, request:, request_options: nil) + Async do + @request_client.conn.post("/admin/store-workspace-trace-v2/submission/#{submission_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/binary_tree_node_and_tree_value.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/binary_tree_node_and_tree_value.rb index 47739fba726..bd40c7c3121 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/binary_tree_node_and_tree_value.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/binary_tree_node_and_tree_value.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "binary_tree_value" - require_relative "node_id" +require_relative "binary_tree_value" require "json" module SeedTraceClient @@ -30,7 +29,8 @@ def initialize(node_id:, full_tree:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) node_id = struct.nodeId - full_tree = struct.fullTree + full_tree = struct.fullTree.to_h.to_json + full_tree = Commons::BinaryTreeValue.from_json(json_object: full_tree) new(node_id: node_id, full_tree: full_tree, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_key_value_pairs.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_key_value_pairs.rb index 90ed46516c2..a72d6290f71 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_key_value_pairs.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_key_value_pairs.rb @@ -27,8 +27,10 @@ def initialize(key:, value:, additional_properties: nil) # @return [Commons::DebugKeyValuePairs] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key = struct.key - value = struct.value + key = struct.key.to_h.to_json + key = Commons::DebugVariableValue.from_json(json_object: key) + value = struct.value.to_h.to_json + value = Commons::DebugVariableValue.from_json(json_object: value) new(key: key, value: value, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_map_value.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_map_value.rb index 5a1df63da87..403e1948bfb 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_map_value.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_map_value.rb @@ -24,7 +24,10 @@ def initialize(key_value_pairs:, additional_properties: nil) # @return [Commons::DebugMapValue] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key_value_pairs = struct.keyValuePairs + key_value_pairs = struct.keyValuePairs.map do |v| + v = v.to_h.to_json + Commons::DebugKeyValuePairs.from_json(json_object: v) + end new(key_value_pairs: key_value_pairs, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_variable_value.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_variable_value.rb index 213d0e06d09..c2fcc39f206 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_variable_value.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/debug_variable_value.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true require "json" -require_relative "binary_tree_node_and_tree_value" require_relative "debug_map_value" +require_relative "binary_tree_node_and_tree_value" +require_relative "singly_linked_list_node_and_list_value" require_relative "doubly_linked_list_node_and_list_value" require_relative "generic_value" -require_relative "singly_linked_list_node_and_list_value" module SeedTraceClient module Commons diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/doubly_linked_list_node_and_list_value.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/doubly_linked_list_node_and_list_value.rb index 319c3599a22..e714c43090e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/doubly_linked_list_node_and_list_value.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/doubly_linked_list_node_and_list_value.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "doubly_linked_list_value" - require_relative "node_id" +require_relative "doubly_linked_list_value" require "json" module SeedTraceClient @@ -30,7 +29,8 @@ def initialize(node_id:, full_list:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) node_id = struct.nodeId - full_list = struct.fullList + full_list = struct.fullList.to_h.to_json + full_list = Commons::DoublyLinkedListValue.from_json(json_object: full_list) new(node_id: node_id, full_list: full_list, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/key_value_pair.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/key_value_pair.rb index 085fa8390eb..5bf076b8399 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/key_value_pair.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/key_value_pair.rb @@ -27,8 +27,10 @@ def initialize(key:, value:, additional_properties: nil) # @return [Commons::KeyValuePair] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key = struct.key - value = struct.value + key = struct.key.to_h.to_json + key = Commons::VariableValue.from_json(json_object: key) + value = struct.value.to_h.to_json + value = Commons::VariableValue.from_json(json_object: value) new(key: key, value: value, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/language.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/language.rb index cb58775bb40..75298c6aa53 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/language.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/language.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Commons - # @type [Hash{String => String}] - LANGUAGE = { java: "JAVA", javascript: "JAVASCRIPT", python: "PYTHON" }.frozen + # @type [LANGUAGE] + LANGUAGE = { java: "JAVA", javascript: "JAVASCRIPT", python: "PYTHON" }.freeze end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/list_type.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/list_type.rb index a3d53b70226..604c73075d7 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/list_type.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/list_type.rb @@ -27,7 +27,8 @@ def initialize(value_type:, is_fixed_length: nil, additional_properties: nil) # @return [Commons::ListType] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - value_type = struct.valueType + value_type = struct.valueType.to_h.to_json + value_type = Commons::VariableType.from_json(json_object: value_type) is_fixed_length = struct.isFixedLength new(value_type: value_type, is_fixed_length: is_fixed_length, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/map_type.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/map_type.rb index 774cf0e8aa4..2703fb744b3 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/map_type.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/map_type.rb @@ -27,8 +27,10 @@ def initialize(key_type:, value_type:, additional_properties: nil) # @return [Commons::MapType] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key_type = struct.keyType - value_type = struct.valueType + key_type = struct.keyType.to_h.to_json + key_type = Commons::VariableType.from_json(json_object: key_type) + value_type = struct.valueType.to_h.to_json + value_type = Commons::VariableType.from_json(json_object: value_type) new(key_type: key_type, value_type: value_type, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/map_value.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/map_value.rb index 447e50bcc5c..7449673da55 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/map_value.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/map_value.rb @@ -24,7 +24,10 @@ def initialize(key_value_pairs:, additional_properties: nil) # @return [Commons::MapValue] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - key_value_pairs = struct.keyValuePairs + key_value_pairs = struct.keyValuePairs.map do |v| + v = v.to_h.to_json + Commons::KeyValuePair.from_json(json_object: v) + end new(key_value_pairs: key_value_pairs, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/singly_linked_list_node_and_list_value.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/singly_linked_list_node_and_list_value.rb index 78734fe2ec0..d12a56af980 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/singly_linked_list_node_and_list_value.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/singly_linked_list_node_and_list_value.rb @@ -29,7 +29,8 @@ def initialize(node_id:, full_list:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) node_id = struct.nodeId - full_list = struct.fullList + full_list = struct.fullList.to_h.to_json + full_list = Commons::SinglyLinkedListValue.from_json(json_object: full_list) new(node_id: node_id, full_list: full_list, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/test_case.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/test_case.rb index ee4841e1e0b..7296c588518 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/test_case.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/test_case.rb @@ -28,7 +28,10 @@ def initialize(id:, params:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) id = struct.id - params = struct.params + params = struct.params.map do |v| + v = v.to_h.to_json + Commons::VariableValue.from_json(json_object: v) + end new(id: id, params: params, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/test_case_with_expected_result.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/test_case_with_expected_result.rb index f932260d050..b86532449a1 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/test_case_with_expected_result.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/test_case_with_expected_result.rb @@ -28,8 +28,10 @@ def initialize(test_case:, expected_result:, additional_properties: nil) # @return [Commons::TestCaseWithExpectedResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - test_case = struct.testCase - expected_result = struct.expectedResult + test_case = struct.testCase.to_h.to_json + test_case = Commons::TestCase.from_json(json_object: test_case) + expected_result = struct.expectedResult.to_h.to_json + expected_result = Commons::VariableValue.from_json(json_object: expected_result) new(test_case: test_case, expected_result: expected_result, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/variable_value.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/variable_value.rb index 18ff971bee8..2b9047579d1 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/variable_value.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/commons/types/variable_value.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true require "json" -require_relative "binary_tree_value" -require_relative "doubly_linked_list_value" require_relative "map_value" +require_relative "binary_tree_value" require_relative "singly_linked_list_value" +require_relative "doubly_linked_list_value" module SeedTraceClient module Commons diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/homepage/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/homepage/client.rb index 8abe56bbfa8..b2c4e919cf9 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/homepage/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/homepage/client.rb @@ -1,81 +1,81 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "../commons/types/problem_id" require "async" module SeedTraceClient - module Homepage - class HomepageClient - attr_reader :request_client + class HomepageClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [HomepageClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [HomepageClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Array] - def get_homepage_problems(request_options: nil) - @request_client.conn.get("/homepage-problems") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param request_options [RequestOptions] + # @return [Array] + def get_homepage_problems(request_options: nil) + response = @request_client.conn.get("/homepage-problems") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body + end - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Void] - def set_homepage_problems(request:, request_options: nil) - @request_client.conn.post("/homepage-problems") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Array] + # @param request_options [RequestOptions] + # @return [Void] + def set_homepage_problems(request:, request_options: nil) + @request_client.conn.post("/homepage-problems") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end + end - class AsyncHomepageClient - attr_reader :request_client + class AsyncHomepageClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncHomepageClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncHomepageClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Array] - def get_homepage_problems(request_options: nil) - Async.call do - response = @request_client.conn.get("/homepage-problems") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response + # @param request_options [RequestOptions] + # @return [Array] + def get_homepage_problems(request_options: nil) + Async do + response = @request_client.conn.get("/homepage-problems") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body end + end - # @param request [Array] - # @param request_options [RequestOptions] - # @return [Void] - def set_homepage_problems(request:, request_options: nil) - Async.call do - @request_client.conn.post("/homepage-problems") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Array] + # @param request_options [RequestOptions] + # @return [Void] + def set_homepage_problems(request:, request_options: nil) + Async do + @request_client.conn.post("/homepage-problems") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/migration/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/migration/client.rb index e56d1ed8cf9..a2963329528 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/migration/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/migration/client.rb @@ -1,72 +1,71 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "types/migration" require "async" module SeedTraceClient - module Migration - class MigrationClient - attr_reader :request_client + class MigrationClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [MigrationClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client + # @param request_client [RequestClient] + # @return [MigrationClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + + # @param admin_key_header [String] + # @param request_options [RequestOptions] + # @return [Array] + def get_attempted_migrations(admin_key_header:, request_options: nil) + response = @request_client.conn.get("/migration-info/all") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { + **req.headers, + **(request_options&.additional_headers || {}), + "admin-key-header": admin_key_header + }.compact end + response.body.map do |v| + v = v.to_h.to_json + Migration::Migration.from_json(json_object: v) + end + end + end + + class AsyncMigrationClient + attr_reader :request_client + + # @param request_client [AsyncRequestClient] + # @return [AsyncMigrationClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param admin_key_header [String] - # @param request_options [RequestOptions] - # @return [Array] - def get_attempted_migrations(admin_key_header:, request_options: nil) + # @param admin_key_header [String] + # @param request_options [RequestOptions] + # @return [Array] + def get_attempted_migrations(admin_key_header:, request_options: nil) + Async do response = @request_client.conn.get("/migration-info/all") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? req.headers = { **req.headers, - **request_options&.additional_headers, + **(request_options&.additional_headers || {}), "admin-key-header": admin_key_header }.compact end - response.map do |v| + response.body.map do |v| v = v.to_h.to_json Migration::Migration.from_json(json_object: v) end end end - - class AsyncMigrationClient - attr_reader :request_client - - # @param request_client [AsyncRequestClient] - # @return [AsyncMigrationClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - - # @param admin_key_header [String] - # @param request_options [RequestOptions] - # @return [Array] - def get_attempted_migrations(admin_key_header:, request_options: nil) - Async.call do - response = @request_client.conn.get("/migration-info/all") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { - **req.headers, - **request_options&.additional_headers, - "admin-key-header": admin_key_header - }.compact - end - response.map do |v| - v = v.to_h.to_json - Migration::Migration.from_json(json_object: v) - end - end - end - end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/migration/types/migration.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/migration/types/migration.rb index c68b0fa4c1b..39d3342f99f 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/migration/types/migration.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/migration/types/migration.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "migration_status" require "json" module SeedTraceClient @@ -8,13 +9,13 @@ class Migration attr_reader :name, :status, :additional_properties # @param name [String] - # @param status [Hash{String => String}] + # @param status [MIGRATION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Migration::Migration] def initialize(name:, status:, additional_properties: nil) # @type [String] @name = name - # @type [Hash{String => String}] + # @type [MIGRATION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -27,7 +28,7 @@ def initialize(name:, status:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) name = struct.name - status = struct.status + status = Migration::MIGRATION_STATUS.key(struct.status) || struct.status new(name: name, status: status, additional_properties: struct) end @@ -35,7 +36,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "name": @name, "status": @status }.to_json + { "name": @name, "status": Migration::MIGRATION_STATUS[@status] || @status }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -44,7 +45,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") - obj.status.is_a?(MIGRATION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.status.is_a?(Migration::MIGRATION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/migration/types/migration_status.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/migration/types/migration_status.rb index c09ec788ca5..91a0ca00e81 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/migration/types/migration_status.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/migration/types/migration_status.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Migration - # @type [Hash{String => String}] - MIGRATION_STATUS = { running: "RUNNING", failed: "FAILED", finished: "FINISHED" }.frozen + # @type [MIGRATION_STATUS] + MIGRATION_STATUS = { running: "RUNNING", failed: "FAILED", finished: "FINISHED" }.freeze end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/client.rb index 9ccbf59df14..58f3ef7d99f 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/client.rb @@ -1,65 +1,194 @@ # frozen_string_literal: true +require_relative "../../requests" require "date" -require_relative "types/playlist" require_relative "types/playlist_create_request" +require_relative "types/playlist" require_relative "types/playlist_id" require_relative "types/update_playlist_request" require "async" module SeedTraceClient - module Playlist - class PlaylistClient - attr_reader :request_client + class PlaylistClient + attr_reader :request_client + + # @param request_client [RequestClient] + # @return [PlaylistClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + + # Create a new playlist + # + # @param service_param [Integer] + # @param datetime [DateTime] + # @param optional_datetime [DateTime] + # @param request [Hash] Request of type Playlist::PlaylistCreateRequest, as a Hash + # * :name (String) + # * :problems (Array) + # @param request_options [RequestOptions] + # @return [Playlist::Playlist] + def create_playlist(service_param:, datetime:, request:, optional_datetime: nil, request_options: nil) + response = @request_client.conn.post("/v2/playlist/#{service_param}/create") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "datetime": datetime, + "optionalDatetime": optional_datetime + }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + Playlist::Playlist.from_json(json_object: response.body) + end + + # Returns the user's playlists + # + # @param service_param [Integer] + # @param limit [Integer] + # @param other_field [String] i'm another field + # @param multi_line_docs [String] I'm a multiline + # description + # @param optional_multiple_field [String] + # @param multiple_field [String] + # @param request_options [RequestOptions] + # @return [Array] + def get_playlists(service_param:, other_field:, multi_line_docs:, multiple_field:, limit: nil, + optional_multiple_field: nil, request_options: nil) + response = @request_client.conn.get("/v2/playlist/#{service_param}/all") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "limit": limit, + "otherField": other_field, + "multiLineDocs": multi_line_docs, + "optionalMultipleField": optional_multiple_field, + "multipleField": multiple_field + }.compact + end + response.body.map do |v| + v = v.to_h.to_json + Playlist::Playlist.from_json(json_object: v) + end + end - # @param request_client [RequestClient] - # @return [PlaylistClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client + # Returns a playlist + # + # @param service_param [Integer] + # @param playlist_id [Playlist::PLAYLIST_ID] + # @param request_options [RequestOptions] + # @return [Playlist::Playlist] + def get_playlist(service_param:, playlist_id:, request_options: nil) + response = @request_client.conn.get("/v2/playlist/#{service_param}/#{playlist_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Playlist::Playlist.from_json(json_object: response.body) + end - # @param service_param [Integer] - # @param datetime [DateTime] - # @param optional_datetime [DateTime] - # @param request [Hash] Request of type Playlist::PlaylistCreateRequest, as a Hash - # * :name (String) - # * :problems (Array) - # @param request_options [RequestOptions] - # @return [Playlist::Playlist] - def create_playlist(service_param:, datetime:, request:, optional_datetime: nil, request_options: nil) + # Updates a playlist + # + # @param service_param [Integer] + # @param playlist_id [Playlist::PLAYLIST_ID] + # @param request [Hash] Request of type Playlist::UpdatePlaylistRequest, as a Hash + # * :name (String) + # * :problems (Array) + # @param request_options [RequestOptions] + # @return [Playlist::Playlist] + def update_playlist(service_param:, playlist_id:, request: nil, request_options: nil) + response = @request_client.conn.put("/v2/playlist/#{service_param}/#{playlist_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + Playlist::Playlist.from_json(json_object: response.body) + end + + # Deletes a playlist + # + # @param service_param [Integer] + # @param playlist_id [Playlist::PLAYLIST_ID] + # @param request_options [RequestOptions] + # @return [Void] + def delete_playlist(service_param:, playlist_id:, request_options: nil) + @request_client.conn.delete("/v2/playlist/#{service_param}/#{playlist_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + end + end + + class AsyncPlaylistClient + attr_reader :request_client + + # @param request_client [AsyncRequestClient] + # @return [AsyncPlaylistClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end + + # Create a new playlist + # + # @param service_param [Integer] + # @param datetime [DateTime] + # @param optional_datetime [DateTime] + # @param request [Hash] Request of type Playlist::PlaylistCreateRequest, as a Hash + # * :name (String) + # * :problems (Array) + # @param request_options [RequestOptions] + # @return [Playlist::Playlist] + def create_playlist(service_param:, datetime:, request:, optional_datetime: nil, request_options: nil) + Async do response = @request_client.conn.post("/v2/playlist/#{service_param}/create") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.params = { - **request_options&.additional_query_parameters, + **(request_options&.additional_query_parameters || {}), "datetime": datetime, "optionalDatetime": optional_datetime }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end - Playlist::Playlist.from_json(json_object: response) + Playlist::Playlist.from_json(json_object: response.body) end + end - # @param service_param [Integer] - # @param limit [Integer] - # @param other_field [String] i'm another field - # @param multi_line_docs [String] I'm a multiline description - # @param optional_multiple_field [String] - # @param multiple_field [String] - # @param request_options [RequestOptions] - # @return [Array] - def get_playlists(service_param:, other_field:, multi_line_docs:, multiple_field:, limit: nil, - optional_multiple_field: nil, request_options: nil) + # Returns the user's playlists + # + # @param service_param [Integer] + # @param limit [Integer] + # @param other_field [String] i'm another field + # @param multi_line_docs [String] I'm a multiline + # description + # @param optional_multiple_field [String] + # @param multiple_field [String] + # @param request_options [RequestOptions] + # @return [Array] + def get_playlists(service_param:, other_field:, multi_line_docs:, multiple_field:, limit: nil, + optional_multiple_field: nil, request_options: nil) + Async do response = @request_client.conn.get("/v2/playlist/#{service_param}/all") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.params = { - **request_options&.additional_query_parameters, + **(request_options&.additional_query_parameters || {}), "limit": limit, "otherField": other_field, "multiLineDocs": multi_line_docs, @@ -67,174 +196,66 @@ def get_playlists(service_param:, other_field:, multi_line_docs:, multiple_field "multipleField": multiple_field }.compact end - response.map do |v| + response.body.map do |v| v = v.to_h.to_json Playlist::Playlist.from_json(json_object: v) end end + end - # @param service_param [Integer] - # @param playlist_id [Playlist::PLAYLIST_ID] - # @param request_options [RequestOptions] - # @return [Playlist::Playlist] - def get_playlist(service_param:, playlist_id:, request_options: nil) + # Returns a playlist + # + # @param service_param [Integer] + # @param playlist_id [Playlist::PLAYLIST_ID] + # @param request_options [RequestOptions] + # @return [Playlist::Playlist] + def get_playlist(service_param:, playlist_id:, request_options: nil) + Async do response = @request_client.conn.get("/v2/playlist/#{service_param}/#{playlist_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end - Playlist::Playlist.from_json(json_object: response) + Playlist::Playlist.from_json(json_object: response.body) end + end - # @param service_param [Integer] - # @param playlist_id [Playlist::PLAYLIST_ID] - # @param request [Hash] Request of type Playlist::UpdatePlaylistRequest, as a Hash - # * :name (String) - # * :problems (Array) - # @param request_options [RequestOptions] - # @return [Playlist::Playlist] - def update_playlist(service_param:, playlist_id:, request: nil, request_options: nil) + # Updates a playlist + # + # @param service_param [Integer] + # @param playlist_id [Playlist::PLAYLIST_ID] + # @param request [Hash] Request of type Playlist::UpdatePlaylistRequest, as a Hash + # * :name (String) + # * :problems (Array) + # @param request_options [RequestOptions] + # @return [Playlist::Playlist] + def update_playlist(service_param:, playlist_id:, request: nil, request_options: nil) + Async do response = @request_client.conn.put("/v2/playlist/#{service_param}/#{playlist_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Playlist::Playlist.from_json(json_object: response) - end - - # @param service_param [Integer] - # @param playlist_id [Playlist::PLAYLIST_ID] - # @param request_options [RequestOptions] - # @return [Void] - def delete_playlist(service_param:, playlist_id:, request_options: nil) - @request_client.conn.delete("/v2/playlist/#{service_param}/#{playlist_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Playlist::Playlist.from_json(json_object: response.body) end end - class AsyncPlaylistClient - attr_reader :request_client - - # @param request_client [AsyncRequestClient] - # @return [AsyncPlaylistClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end - - # @param service_param [Integer] - # @param datetime [DateTime] - # @param optional_datetime [DateTime] - # @param request [Hash] Request of type Playlist::PlaylistCreateRequest, as a Hash - # * :name (String) - # * :problems (Array) - # @param request_options [RequestOptions] - # @return [Playlist::Playlist] - def create_playlist(service_param:, datetime:, request:, optional_datetime: nil, request_options: nil) - Async.call do - response = @request_client.conn.post("/v2/playlist/#{service_param}/create") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { - **request_options&.additional_query_parameters, - "datetime": datetime, - "optionalDatetime": optional_datetime - }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Playlist::Playlist.from_json(json_object: response) - end - end - - # @param service_param [Integer] - # @param limit [Integer] - # @param other_field [String] i'm another field - # @param multi_line_docs [String] I'm a multiline description - # @param optional_multiple_field [String] - # @param multiple_field [String] - # @param request_options [RequestOptions] - # @return [Array] - def get_playlists(service_param:, other_field:, multi_line_docs:, multiple_field:, limit: nil, - optional_multiple_field: nil, request_options: nil) - Async.call do - response = @request_client.conn.get("/v2/playlist/#{service_param}/all") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.params = { - **request_options&.additional_query_parameters, - "limit": limit, - "otherField": other_field, - "multiLineDocs": multi_line_docs, - "optionalMultipleField": optional_multiple_field, - "multipleField": multiple_field - }.compact - end - response.map do |v| - v = v.to_h.to_json - Playlist::Playlist.from_json(json_object: v) - end - end - end - - # @param service_param [Integer] - # @param playlist_id [Playlist::PLAYLIST_ID] - # @param request_options [RequestOptions] - # @return [Playlist::Playlist] - def get_playlist(service_param:, playlist_id:, request_options: nil) - Async.call do - response = @request_client.conn.get("/v2/playlist/#{service_param}/#{playlist_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Playlist::Playlist.from_json(json_object: response) - end - end - - # @param service_param [Integer] - # @param playlist_id [Playlist::PLAYLIST_ID] - # @param request [Hash] Request of type Playlist::UpdatePlaylistRequest, as a Hash - # * :name (String) - # * :problems (Array) - # @param request_options [RequestOptions] - # @return [Playlist::Playlist] - def update_playlist(service_param:, playlist_id:, request: nil, request_options: nil) - Async.call do - response = @request_client.conn.put("/v2/playlist/#{service_param}/#{playlist_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Playlist::Playlist.from_json(json_object: response) - end - end - - # @param service_param [Integer] - # @param playlist_id [Playlist::PLAYLIST_ID] - # @param request_options [RequestOptions] - # @return [Void] - def delete_playlist(service_param:, playlist_id:, request_options: nil) - Async.call do - @request_client.conn.delete("/v2/playlist/#{service_param}/#{playlist_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # Deletes a playlist + # + # @param service_param [Integer] + # @param playlist_id [Playlist::PLAYLIST_ID] + # @param request_options [RequestOptions] + # @return [Void] + def delete_playlist(service_param:, playlist_id:, request_options: nil) + Async do + @request_client.conn.delete("/v2/playlist/#{service_param}/#{playlist_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/types/playlist.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/types/playlist.rb index 92fb82ad914..a8e023f16f1 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/types/playlist.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/types/playlist.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "playlist_id" require_relative "../../commons/types/user_id" - require_relative "../../commons/types/problem_id" -require_relative "playlist_id" require "json" module SeedTraceClient diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/types/reserved_keyword_enum.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/types/reserved_keyword_enum.rb index 6c1edf96411..b613fa99527 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/types/reserved_keyword_enum.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/playlist/types/reserved_keyword_enum.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Playlist - # @type [Hash{String => String}] - RESERVED_KEYWORD_ENUM = { is: "is", as: "as" }.frozen + # @type [RESERVED_KEYWORD_ENUM] + RESERVED_KEYWORD_ENUM = { is: "is", as: "as" }.freeze end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/client.rb index bedfcaaceba..8cc1a71d038 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/client.rb @@ -1,199 +1,228 @@ # frozen_string_literal: true -require_relative "../commons/types/problem_id" -require_relative "../commons/types/variable_type" +require_relative "../../requests" require_relative "types/create_problem_request" require_relative "types/create_problem_response" -require_relative "types/get_default_starter_files_response" +require_relative "../commons/types/problem_id" require_relative "types/update_problem_response" require_relative "types/variable_type_and_name" +require_relative "../commons/types/variable_type" +require_relative "types/get_default_starter_files_response" require "async" module SeedTraceClient - module Problem - class ProblemClient - attr_reader :request_client + class ProblemClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ProblemClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ProblemClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Problem::CreateProblemRequest, as a Hash - # * :problem_name (String) - # * :problem_description (Hash) - # * :boards (Array) - # * :files (Hash{LANGUAGE => LANGUAGE}) - # * :input_params (Array) - # * :output_type (Hash) - # * :testcases (Array) - # * :method_name (String) - # @param request_options [RequestOptions] - # @return [Problem::CreateProblemResponse] - def create_problem(request:, request_options: nil) - response = @request_client.conn.post("/problem-crud/create") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Problem::CreateProblemResponse.from_json(json_object: response) + # Creates a problem + # + # @param request [Hash] Request of type Problem::CreateProblemRequest, as a Hash + # * :problem_name (String) + # * :problem_description (Hash) + # * :boards (Array) + # * :files (Hash{Commons::LANGUAGE => Commons::LANGUAGE}) + # * :input_params (Array) + # * :output_type (Hash) + # * :testcases (Array) + # * :method_name (String) + # @param request_options [RequestOptions] + # @return [Problem::CreateProblemResponse] + def create_problem(request:, request_options: nil) + response = @request_client.conn.post("/problem-crud/create") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Problem::CreateProblemResponse.from_json(json_object: response.body) + end - # @param problem_id [Commons::PROBLEM_ID] - # @param request [Hash] Request of type Problem::CreateProblemRequest, as a Hash - # * :problem_name (String) - # * :problem_description (Hash) - # * :boards (Array) - # * :files (Hash{LANGUAGE => LANGUAGE}) - # * :input_params (Array) - # * :output_type (Hash) - # * :testcases (Array) - # * :method_name (String) - # @param request_options [RequestOptions] - # @return [Problem::UpdateProblemResponse] - def update_problem(problem_id:, request:, request_options: nil) - response = @request_client.conn.post("/problem-crud/update/#{problem_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Problem::UpdateProblemResponse.from_json(json_object: response) + # Updates a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param request [Hash] Request of type Problem::CreateProblemRequest, as a Hash + # * :problem_name (String) + # * :problem_description (Hash) + # * :boards (Array) + # * :files (Hash{Commons::LANGUAGE => Commons::LANGUAGE}) + # * :input_params (Array) + # * :output_type (Hash) + # * :testcases (Array) + # * :method_name (String) + # @param request_options [RequestOptions] + # @return [Problem::UpdateProblemResponse] + def update_problem(problem_id:, request:, request_options: nil) + response = @request_client.conn.post("/problem-crud/update/#{problem_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Problem::UpdateProblemResponse.from_json(json_object: response.body) + end - # @param problem_id [Commons::PROBLEM_ID] - # @param request_options [RequestOptions] - # @return [Void] - def delete_problem(problem_id:, request_options: nil) - @request_client.conn.delete("/problem-crud/delete/#{problem_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # Soft deletes a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param request_options [RequestOptions] + # @return [Void] + def delete_problem(problem_id:, request_options: nil) + @request_client.conn.delete("/problem-crud/delete/#{problem_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + end - # @param input_params [Array] - # @param output_type [Hash] Request of type Commons::VariableType, as a Hash - # @param method_name [String] - # @param request_options [RequestOptions] - # @return [Problem::GetDefaultStarterFilesResponse] - def get_default_starter_files(input_params:, output_type:, method_name:, request_options: nil) - response = @request_client.conn.post("/problem-crud/default-starter-files") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - inputParams: input_params, - outputType: output_type, - methodName: method_name - }.compact - end - Problem::GetDefaultStarterFilesResponse.from_json(json_object: response) + # Returns default starter files for problem + # + # @param input_params [Array] Request of type Array, as a Hash + # * :variable_type (Hash) + # * :name (String) + # @param output_type [Hash] Request of type Commons::VariableType, as a Hash + # @param method_name [String] The name of the `method` that the student has to complete. + # The method name cannot include the following characters: + # - Greater Than `>` + # - Less Than `<`` + # - Equals `=` + # - Period `.` + # @param request_options [RequestOptions] + # @return [Problem::GetDefaultStarterFilesResponse] + def get_default_starter_files(input_params:, output_type:, method_name:, request_options: nil) + response = @request_client.conn.post("/problem-crud/default-starter-files") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + inputParams: input_params, + outputType: output_type, + methodName: method_name + }.compact end + Problem::GetDefaultStarterFilesResponse.from_json(json_object: response.body) end + end - class AsyncProblemClient - attr_reader :request_client + class AsyncProblemClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncProblemClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncProblemClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Problem::CreateProblemRequest, as a Hash - # * :problem_name (String) - # * :problem_description (Hash) - # * :boards (Array) - # * :files (Hash{LANGUAGE => LANGUAGE}) - # * :input_params (Array) - # * :output_type (Hash) - # * :testcases (Array) - # * :method_name (String) - # @param request_options [RequestOptions] - # @return [Problem::CreateProblemResponse] - def create_problem(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/problem-crud/create") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Problem::CreateProblemResponse.from_json(json_object: response) + # Creates a problem + # + # @param request [Hash] Request of type Problem::CreateProblemRequest, as a Hash + # * :problem_name (String) + # * :problem_description (Hash) + # * :boards (Array) + # * :files (Hash{Commons::LANGUAGE => Commons::LANGUAGE}) + # * :input_params (Array) + # * :output_type (Hash) + # * :testcases (Array) + # * :method_name (String) + # @param request_options [RequestOptions] + # @return [Problem::CreateProblemResponse] + def create_problem(request:, request_options: nil) + Async do + response = @request_client.conn.post("/problem-crud/create") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Problem::CreateProblemResponse.from_json(json_object: response.body) end + end - # @param problem_id [Commons::PROBLEM_ID] - # @param request [Hash] Request of type Problem::CreateProblemRequest, as a Hash - # * :problem_name (String) - # * :problem_description (Hash) - # * :boards (Array) - # * :files (Hash{LANGUAGE => LANGUAGE}) - # * :input_params (Array) - # * :output_type (Hash) - # * :testcases (Array) - # * :method_name (String) - # @param request_options [RequestOptions] - # @return [Problem::UpdateProblemResponse] - def update_problem(problem_id:, request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/problem-crud/update/#{problem_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Problem::UpdateProblemResponse.from_json(json_object: response) + # Updates a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param request [Hash] Request of type Problem::CreateProblemRequest, as a Hash + # * :problem_name (String) + # * :problem_description (Hash) + # * :boards (Array) + # * :files (Hash{Commons::LANGUAGE => Commons::LANGUAGE}) + # * :input_params (Array) + # * :output_type (Hash) + # * :testcases (Array) + # * :method_name (String) + # @param request_options [RequestOptions] + # @return [Problem::UpdateProblemResponse] + def update_problem(problem_id:, request:, request_options: nil) + Async do + response = @request_client.conn.post("/problem-crud/update/#{problem_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Problem::UpdateProblemResponse.from_json(json_object: response.body) end + end - # @param problem_id [Commons::PROBLEM_ID] - # @param request_options [RequestOptions] - # @return [Void] - def delete_problem(problem_id:, request_options: nil) - Async.call do - @request_client.conn.delete("/problem-crud/delete/#{problem_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # Soft deletes a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param request_options [RequestOptions] + # @return [Void] + def delete_problem(problem_id:, request_options: nil) + Async do + @request_client.conn.delete("/problem-crud/delete/#{problem_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - # @param input_params [Array] - # @param output_type [Hash] Request of type Commons::VariableType, as a Hash - # @param method_name [String] - # @param request_options [RequestOptions] - # @return [Problem::GetDefaultStarterFilesResponse] - def get_default_starter_files(input_params:, output_type:, method_name:, request_options: nil) - Async.call do - response = @request_client.conn.post("/problem-crud/default-starter-files") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { - **request_options&.additional_body_parameters, - inputParams: input_params, - outputType: output_type, - methodName: method_name - }.compact - end - Problem::GetDefaultStarterFilesResponse.from_json(json_object: response) + # Returns default starter files for problem + # + # @param input_params [Array] Request of type Array, as a Hash + # * :variable_type (Hash) + # * :name (String) + # @param output_type [Hash] Request of type Commons::VariableType, as a Hash + # @param method_name [String] The name of the `method` that the student has to complete. + # The method name cannot include the following characters: + # - Greater Than `>` + # - Less Than `<`` + # - Equals `=` + # - Period `.` + # @param request_options [RequestOptions] + # @return [Problem::GetDefaultStarterFilesResponse] + def get_default_starter_files(input_params:, output_type:, method_name:, request_options: nil) + Async do + response = @request_client.conn.post("/problem-crud/default-starter-files") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { + **(request_options&.additional_body_parameters || {}), + inputParams: input_params, + outputType: output_type, + methodName: method_name + }.compact end + Problem::GetDefaultStarterFilesResponse.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/create_problem_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/create_problem_request.rb index 8b0711b6950..ee206714719 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/create_problem_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/create_problem_request.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -require_relative "../../commons/types/test_case_with_expected_result" -require_relative "../../commons/types/variable_type" require_relative "problem_description" require_relative "variable_type_and_name" +require_relative "../../commons/types/variable_type" +require_relative "../../commons/types/test_case_with_expected_result" require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Problem @@ -14,7 +15,7 @@ class CreateProblemRequest # @param problem_name [String] # @param problem_description [Problem::ProblemDescription] - # @param files [Hash{LANGUAGE => LANGUAGE}] + # @param files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param input_params [Array] # @param output_type [Commons::VariableType] # @param testcases [Array] @@ -27,7 +28,7 @@ def initialize(problem_name:, problem_description:, files:, input_params:, outpu @problem_name = problem_name # @type [Problem::ProblemDescription] @problem_description = problem_description - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files = files # @type [Array] @input_params = input_params @@ -48,11 +49,22 @@ def initialize(problem_name:, problem_description:, files:, input_params:, outpu def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_name = struct.problemName - problem_description = struct.problemDescription - files = struct.files - input_params = struct.inputParams - output_type = struct.outputType - testcases = struct.testcases + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) + files = struct.files.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + input_params = struct.inputParams.map do |v| + v = v.to_h.to_json + Problem::VariableTypeAndName.from_json(json_object: v) + end + output_type = struct.outputType.to_h.to_json + output_type = Commons::VariableType.from_json(json_object: output_type) + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + Commons::TestCaseWithExpectedResult.from_json(json_object: v) + end method_name = struct.methodName new(problem_name: problem_name, problem_description: problem_description, files: files, input_params: input_params, output_type: output_type, testcases: testcases, method_name: method_name, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/create_problem_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/create_problem_response.rb index fda2aaa4f05..6641ee90ffd 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/create_problem_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/create_problem_response.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "../../commons/types/problem_id" require_relative "create_problem_error" +require_relative "../../commons/types/problem_id" module SeedTraceClient module Problem diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/get_default_starter_files_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/get_default_starter_files_response.rb index 6122bbd6a3c..15790505c9d 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/get_default_starter_files_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/get_default_starter_files_response.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Problem class GetDefaultStarterFilesResponse attr_reader :files, :additional_properties - # @param files [Hash{LANGUAGE => LANGUAGE}] + # @param files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Problem::GetDefaultStarterFilesResponse] def initialize(files:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files = files # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -23,7 +24,10 @@ def initialize(files:, additional_properties: nil) # @return [Problem::GetDefaultStarterFilesResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files = struct.files + files = struct.files.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(files: files, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_description.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_description.rb index 684d205c60d..c134078496a 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_description.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_description.rb @@ -24,7 +24,10 @@ def initialize(boards:, additional_properties: nil) # @return [Problem::ProblemDescription] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - boards = struct.boards + boards = struct.boards.map do |v| + v = v.to_h.to_json + Problem::ProblemDescriptionBoard.from_json(json_object: v) + end new(boards: boards, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_files.rb index 6ebdb21fe77..aa326f0cc2f 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_files.rb @@ -27,8 +27,12 @@ def initialize(solution_file:, read_only_files:, additional_properties: nil) # @return [Problem::ProblemFiles] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - solution_file = struct.solutionFile - read_only_files = struct.readOnlyFiles + solution_file = struct.solutionFile.to_h.to_json + solution_file = Commons::FileInfo.from_json(json_object: solution_file) + read_only_files = struct.readOnlyFiles.map do |v| + v = v.to_h.to_json + Commons::FileInfo.from_json(json_object: v) + end new(solution_file: solution_file, read_only_files: read_only_files, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_info.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_info.rb index 59f5333ad3f..f302f25baf4 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_info.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/problem_info.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true require_relative "../../commons/types/problem_id" -require_relative "../../commons/types/test_case_with_expected_result" -require_relative "../../commons/types/variable_type" require_relative "problem_description" require_relative "variable_type_and_name" +require_relative "../../commons/types/variable_type" +require_relative "../../commons/types/test_case_with_expected_result" require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Problem @@ -17,7 +18,7 @@ class ProblemInfo # @param problem_description [Problem::ProblemDescription] # @param problem_name [String] # @param problem_version [Integer] - # @param files [Hash{LANGUAGE => LANGUAGE}] + # @param files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param input_params [Array] # @param output_type [Commons::VariableType] # @param testcases [Array] @@ -35,7 +36,7 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version @problem_name = problem_name # @type [Integer] @problem_version = problem_version - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files = files # @type [Array] @input_params = input_params @@ -58,13 +59,24 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_id = struct.problemId - problem_description = struct.problemDescription + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) problem_name = struct.problemName problem_version = struct.problemVersion - files = struct.files - input_params = struct.inputParams - output_type = struct.outputType - testcases = struct.testcases + files = struct.files.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + input_params = struct.inputParams.map do |v| + v = v.to_h.to_json + Problem::VariableTypeAndName.from_json(json_object: v) + end + output_type = struct.outputType.to_h.to_json + output_type = Commons::VariableType.from_json(json_object: output_type) + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + Commons::TestCaseWithExpectedResult.from_json(json_object: v) + end method_name = struct.methodName supports_custom_test_cases = struct.supportsCustomTestCases new(problem_id: problem_id, problem_description: problem_description, problem_name: problem_name, diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/variable_type_and_name.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/variable_type_and_name.rb index feef3828cc7..a2434f333fa 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/variable_type_and_name.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/problem/types/variable_type_and_name.rb @@ -27,7 +27,8 @@ def initialize(variable_type:, name:, additional_properties: nil) # @return [Problem::VariableTypeAndName] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - variable_type = struct.variableType + variable_type = struct.variableType.to_h.to_json + variable_type = Commons::VariableType.from_json(json_object: variable_type) name = struct.name new(variable_type: variable_type, name: name, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/client.rb index 191508c59c5..2e652f2fce0 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/client.rb @@ -1,138 +1,150 @@ # frozen_string_literal: true +require_relative "../../requests" +require_relative "../commons/types/language" require_relative "types/execution_session_response" require_relative "types/get_execution_session_state_response" require "async" module SeedTraceClient - module Submission - class SubmissionClient - attr_reader :request_client + class SubmissionClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [SubmissionClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [SubmissionClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param language [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Submission::ExecutionSessionResponse] - def create_execution_session(language:, request_options: nil) - response = @request_client.conn.post("/sessions/create-session/#{language}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Submission::ExecutionSessionResponse.from_json(json_object: response) + # Returns sessionId and execution server URL for session. Spins up server. + # + # @param language [LANGUAGE] + # @param request_options [RequestOptions] + # @return [Submission::ExecutionSessionResponse] + def create_execution_session(language:, request_options: nil) + response = @request_client.conn.post("/sessions/create-session/#{language}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Submission::ExecutionSessionResponse.from_json(json_object: response.body) + end - # @param session_id [String] - # @param request_options [RequestOptions] - # @return [Submission::ExecutionSessionResponse] - def get_execution_session(session_id:, request_options: nil) - response = @request_client.conn.get("/sessions/#{session_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Submission::ExecutionSessionResponse.from_json(json_object: response) + # Returns execution server URL for session. Returns empty if session isn't registered. + # + # @param session_id [String] + # @param request_options [RequestOptions] + # @return [Submission::ExecutionSessionResponse] + def get_execution_session(session_id:, request_options: nil) + response = @request_client.conn.get("/sessions/#{session_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Submission::ExecutionSessionResponse.from_json(json_object: response.body) + end - # @param session_id [String] - # @param request_options [RequestOptions] - # @return [Void] - def stop_execution_session(session_id:, request_options: nil) - @request_client.conn.delete("/sessions/stop/#{session_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # Stops execution session. + # + # @param session_id [String] + # @param request_options [RequestOptions] + # @return [Void] + def stop_execution_session(session_id:, request_options: nil) + @request_client.conn.delete("/sessions/stop/#{session_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + end - # @param request_options [RequestOptions] - # @return [Submission::GetExecutionSessionStateResponse] - def get_execution_sessions_state(request_options: nil) - response = @request_client.conn.get("/sessions/execution-sessions-state") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Submission::GetExecutionSessionStateResponse.from_json(json_object: response) + # @param request_options [RequestOptions] + # @return [Submission::GetExecutionSessionStateResponse] + def get_execution_sessions_state(request_options: nil) + response = @request_client.conn.get("/sessions/execution-sessions-state") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Submission::GetExecutionSessionStateResponse.from_json(json_object: response.body) end + end - class AsyncSubmissionClient - attr_reader :request_client + class AsyncSubmissionClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncSubmissionClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncSubmissionClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param language [Hash{String => String}] - # @param request_options [RequestOptions] - # @return [Submission::ExecutionSessionResponse] - def create_execution_session(language:, request_options: nil) - Async.call do - response = @request_client.conn.post("/sessions/create-session/#{language}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Submission::ExecutionSessionResponse.from_json(json_object: response) + # Returns sessionId and execution server URL for session. Spins up server. + # + # @param language [LANGUAGE] + # @param request_options [RequestOptions] + # @return [Submission::ExecutionSessionResponse] + def create_execution_session(language:, request_options: nil) + Async do + response = @request_client.conn.post("/sessions/create-session/#{language}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Submission::ExecutionSessionResponse.from_json(json_object: response.body) end + end - # @param session_id [String] - # @param request_options [RequestOptions] - # @return [Submission::ExecutionSessionResponse] - def get_execution_session(session_id:, request_options: nil) - Async.call do - response = @request_client.conn.get("/sessions/#{session_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Submission::ExecutionSessionResponse.from_json(json_object: response) + # Returns execution server URL for session. Returns empty if session isn't registered. + # + # @param session_id [String] + # @param request_options [RequestOptions] + # @return [Submission::ExecutionSessionResponse] + def get_execution_session(session_id:, request_options: nil) + Async do + response = @request_client.conn.get("/sessions/#{session_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Submission::ExecutionSessionResponse.from_json(json_object: response.body) end + end - # @param session_id [String] - # @param request_options [RequestOptions] - # @return [Void] - def stop_execution_session(session_id:, request_options: nil) - Async.call do - @request_client.conn.delete("/sessions/stop/#{session_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # Stops execution session. + # + # @param session_id [String] + # @param request_options [RequestOptions] + # @return [Void] + def stop_execution_session(session_id:, request_options: nil) + Async do + @request_client.conn.delete("/sessions/stop/#{session_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - # @param request_options [RequestOptions] - # @return [Submission::GetExecutionSessionStateResponse] - def get_execution_sessions_state(request_options: nil) - Async.call do - response = @request_client.conn.get("/sessions/execution-sessions-state") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - Submission::GetExecutionSessionStateResponse.from_json(json_object: response) + # @param request_options [RequestOptions] + # @return [Submission::GetExecutionSessionStateResponse] + def get_execution_sessions_state(request_options: nil) + Async do + response = @request_client.conn.get("/sessions/execution-sessions-state") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + Submission::GetExecutionSessionStateResponse.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/building_executor_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/building_executor_response.rb index d512c01bbc1..1acff8e0732 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/building_executor_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/building_executor_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "submission_id" +require_relative "execution_session_status" require "json" module SeedTraceClient @@ -9,13 +10,13 @@ class BuildingExecutorResponse attr_reader :submission_id, :status, :additional_properties # @param submission_id [Submission::SUBMISSION_ID] - # @param status [Hash{String => String}] + # @param status [EXECUTION_SESSION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::BuildingExecutorResponse] def initialize(submission_id:, status:, additional_properties: nil) # @type [Submission::SUBMISSION_ID] @submission_id = submission_id - # @type [Hash{String => String}] + # @type [EXECUTION_SESSION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -28,7 +29,7 @@ def initialize(submission_id:, status:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - status = struct.status + status = Submission::EXECUTION_SESSION_STATUS.key(struct.status) || struct.status new(submission_id: submission_id, status: status, additional_properties: struct) end @@ -36,7 +37,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "submissionId": @submission_id, "status": @status }.to_json + { "submissionId": @submission_id, "status": Submission::EXECUTION_SESSION_STATUS[@status] || @status }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -45,7 +46,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.submission_id.is_a?(UUID) != false || raise("Passed value for field obj.submission_id is not the expected type, validation failed.") - obj.status.is_a?(EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.status.is_a?(Submission::EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/code_execution_update.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/code_execution_update.rb index d1cb54aee13..6e26b4bff49 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/code_execution_update.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/code_execution_update.rb @@ -2,16 +2,16 @@ require "json" require_relative "building_executor_response" +require_relative "running_response" require_relative "errored_response" -require_relative "finished_response" +require_relative "stopped_response" require_relative "graded_response" require_relative "graded_response_v_2" -require_relative "invalid_request_response" -require_relative "recorded_response_notification" -require_relative "recording_response_notification" -require_relative "running_response" -require_relative "stopped_response" require_relative "workspace_ran_response" +require_relative "recording_response_notification" +require_relative "recorded_response_notification" +require_relative "invalid_request_response" +require_relative "finished_response" module SeedTraceClient module Submission diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/error_info.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/error_info.rb index b99a1cfad6a..edfbdeb15b3 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/error_info.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/error_info.rb @@ -2,8 +2,8 @@ require "json" require_relative "compile_error" -require_relative "internal_error" require_relative "runtime_error" +require_relative "internal_error" module SeedTraceClient module Submission diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/errored_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/errored_response.rb index ee807ba5383..248366e10ee 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/errored_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/errored_response.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "error_info" - require_relative "submission_id" +require_relative "error_info" require "json" module SeedTraceClient @@ -30,7 +29,8 @@ def initialize(submission_id:, error_info:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - error_info = struct.errorInfo + error_info = struct.errorInfo.to_h.to_json + error_info = Submission::ErrorInfo.from_json(json_object: error_info) new(submission_id: submission_id, error_info: error_info, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_response.rb index 9d79f932c7f..3d9fa239666 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_response.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative "../../commons/types/language" +require_relative "execution_session_status" require "json" module SeedTraceClient @@ -9,8 +11,8 @@ class ExecutionSessionResponse # @param session_id [String] # @param execution_session_url [String] - # @param language [Hash{String => String}] - # @param status [Hash{String => String}] + # @param language [LANGUAGE] + # @param status [EXECUTION_SESSION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::ExecutionSessionResponse] def initialize(session_id:, language:, status:, execution_session_url: nil, additional_properties: nil) @@ -18,9 +20,9 @@ def initialize(session_id:, language:, status:, execution_session_url: nil, addi @session_id = session_id # @type [String] @execution_session_url = execution_session_url - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language - # @type [Hash{String => String}] + # @type [EXECUTION_SESSION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -34,8 +36,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) session_id = struct.sessionId execution_session_url = struct.executionSessionUrl - language = struct.language - status = struct.status + language = Commons::LANGUAGE.key(struct.language) || struct.language + status = Submission::EXECUTION_SESSION_STATUS.key(struct.status) || struct.status new(session_id: session_id, execution_session_url: execution_session_url, language: language, status: status, additional_properties: struct) end @@ -47,8 +49,8 @@ def to_json(*_args) { "sessionId": @session_id, "executionSessionUrl": @execution_session_url, - "language": @language, - "status": @status + "language": Commons::LANGUAGE[@language] || @language, + "status": Submission::EXECUTION_SESSION_STATUS[@status] || @status }.to_json end @@ -59,8 +61,8 @@ def to_json(*_args) def self.validate_raw(obj:) obj.session_id.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.") obj.execution_session_url&.is_a?(String) != false || raise("Passed value for field obj.execution_session_url is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") - obj.status.is_a?(EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.status.is_a?(Submission::EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_state.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_state.rb index 8d93a43eb06..6b58bce65f0 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_state.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_state.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative "../../commons/types/language" +require_relative "execution_session_status" require "json" module SeedTraceClient @@ -12,8 +14,8 @@ class ExecutionSessionState # @param session_id [String] The auto-generated session id. Formatted as a uuid. # @param is_warm_instance [Boolean] # @param aws_task_id [String] - # @param language [Hash{String => String}] - # @param status [Hash{String => String}] + # @param language [LANGUAGE] + # @param status [EXECUTION_SESSION_STATUS] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::ExecutionSessionState] def initialize(session_id:, is_warm_instance:, language:, status:, last_time_contacted: nil, aws_task_id: nil, @@ -26,9 +28,9 @@ def initialize(session_id:, is_warm_instance:, language:, status:, last_time_con @is_warm_instance = is_warm_instance # @type [String] @aws_task_id = aws_task_id - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language - # @type [Hash{String => String}] + # @type [EXECUTION_SESSION_STATUS] @status = status # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -44,8 +46,8 @@ def self.from_json(json_object:) session_id = struct.sessionId is_warm_instance = struct.isWarmInstance aws_task_id = struct.awsTaskId - language = struct.language - status = struct.status + language = Commons::LANGUAGE.key(struct.language) || struct.language + status = Submission::EXECUTION_SESSION_STATUS.key(struct.status) || struct.status new(last_time_contacted: last_time_contacted, session_id: session_id, is_warm_instance: is_warm_instance, aws_task_id: aws_task_id, language: language, status: status, additional_properties: struct) end @@ -59,8 +61,8 @@ def to_json(*_args) "sessionId": @session_id, "isWarmInstance": @is_warm_instance, "awsTaskId": @aws_task_id, - "language": @language, - "status": @status + "language": Commons::LANGUAGE[@language] || @language, + "status": Submission::EXECUTION_SESSION_STATUS[@status] || @status }.to_json end @@ -73,8 +75,8 @@ def self.validate_raw(obj:) obj.session_id.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.") obj.is_warm_instance.is_a?(Boolean) != false || raise("Passed value for field obj.is_warm_instance is not the expected type, validation failed.") obj.aws_task_id&.is_a?(String) != false || raise("Passed value for field obj.aws_task_id is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") - obj.status.is_a?(EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.status.is_a?(Submission::EXECUTION_SESSION_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_status.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_status.rb index 2b8411d144f..92e4e7e56ea 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_status.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/execution_session_status.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Submission - # @type [Hash{String => String}] + # @type [EXECUTION_SESSION_STATUS] EXECUTION_SESSION_STATUS = { creating_container: "CREATING_CONTAINER", provisioning_container: "PROVISIONING_CONTAINER", @@ -10,6 +10,6 @@ module Submission running_container: "RUNNING_CONTAINER", live_container: "LIVE_CONTAINER", failed_to_launch: "FAILED_TO_LAUNCH" - }.frozen + }.freeze end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/get_submission_state_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/get_submission_state_response.rb index b6edb2bb8c6..253253c3a03 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/get_submission_state_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/get_submission_state_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "date" +require_relative "../../commons/types/language" require_relative "submission_type_state" require "json" @@ -11,7 +12,7 @@ class GetSubmissionStateResponse # @param time_submitted [DateTime] # @param submission [String] - # @param language [Hash{String => String}] + # @param language [LANGUAGE] # @param submission_type_state [Submission::SubmissionTypeState] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::GetSubmissionStateResponse] @@ -20,7 +21,7 @@ def initialize(submission:, language:, submission_type_state:, time_submitted: n @time_submitted = time_submitted # @type [String] @submission = submission - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language # @type [Submission::SubmissionTypeState] @submission_type_state = submission_type_state @@ -34,10 +35,11 @@ def initialize(submission:, language:, submission_type_state:, time_submitted: n # @return [Submission::GetSubmissionStateResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - time_submitted = struct.timeSubmitted + time_submitted = DateTime.parse(struct.timeSubmitted) submission = struct.submission - language = struct.language - submission_type_state = struct.submissionTypeState + language = Commons::LANGUAGE.key(struct.language) || struct.language + submission_type_state = struct.submissionTypeState.to_h.to_json + submission_type_state = Submission::SubmissionTypeState.from_json(json_object: submission_type_state) new(time_submitted: time_submitted, submission: submission, language: language, submission_type_state: submission_type_state, additional_properties: struct) end @@ -49,7 +51,7 @@ def to_json(*_args) { "timeSubmitted": @time_submitted, "submission": @submission, - "language": @language, + "language": Commons::LANGUAGE[@language] || @language, "submissionTypeState": @submission_type_state }.to_json end @@ -61,7 +63,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.time_submitted&.is_a?(DateTime) != false || raise("Passed value for field obj.time_submitted is not the expected type, validation failed.") obj.submission.is_a?(String) != false || raise("Passed value for field obj.submission is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") Submission::SubmissionTypeState.validate_raw(obj: obj.submission_type_state) end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/graded_test_case_update.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/graded_test_case_update.rb index 08ae0de2290..2969ef56432 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/graded_test_case_update.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/graded_test_case_update.rb @@ -29,7 +29,8 @@ def initialize(test_case_id:, grade:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) test_case_id = struct.testCaseId - grade = struct.grade + grade = struct.grade.to_h.to_json + grade = Submission::TestCaseGrade.from_json(json_object: grade) new(test_case_id: test_case_id, grade: grade, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/internal_error.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/internal_error.rb index 6002d36c919..e75196b9175 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/internal_error.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/internal_error.rb @@ -24,7 +24,8 @@ def initialize(exception_info:, additional_properties: nil) # @return [Submission::InternalError] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - exception_info = struct.exceptionInfo + exception_info = struct.exceptionInfo.to_h.to_json + exception_info = Submission::ExceptionInfo.from_json(json_object: exception_info) new(exception_info: exception_info, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/invalid_request_cause.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/invalid_request_cause.rb index 28d1a22a74e..71896b6a2f5 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/invalid_request_cause.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/invalid_request_cause.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "custom_test_cases_unsupported" require_relative "submission_id_not_found" +require_relative "custom_test_cases_unsupported" require_relative "unexpected_language_error" module SeedTraceClient diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/invalid_request_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/invalid_request_response.rb index 63c29bafcf5..47d3a90a0a3 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/invalid_request_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/invalid_request_response.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "invalid_request_cause" - require_relative "submission_request" +require_relative "invalid_request_cause" require "json" module SeedTraceClient @@ -29,8 +28,10 @@ def initialize(request:, cause:, additional_properties: nil) # @return [Submission::InvalidRequestResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - request = struct.request - cause = struct.cause + request = struct.request.to_h.to_json + request = Submission::SubmissionRequest.from_json(json_object: request) + cause = struct.cause.to_h.to_json + cause = Submission::InvalidRequestCause.from_json(json_object: cause) new(request: request, cause: cause, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/recording_response_notification.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/recording_response_notification.rb index de2c5e3b58e..8719216d1c6 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/recording_response_notification.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/recording_response_notification.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "lightweight_stackframe_information" - require_relative "submission_id" +require_relative "lightweight_stackframe_information" require_relative "traced_file" require "json" @@ -44,8 +43,10 @@ def self.from_json(json_object:) submission_id = struct.submissionId test_case_id = struct.testCaseId line_number = struct.lineNumber - lightweight_stack_info = struct.lightweightStackInfo - traced_file = struct.tracedFile + lightweight_stack_info = struct.lightweightStackInfo.to_h.to_json + lightweight_stack_info = Submission::LightweightStackframeInformation.from_json(json_object: lightweight_stack_info) + traced_file = struct.tracedFile.to_h.to_json + traced_file = Submission::TracedFile.from_json(json_object: traced_file) new(submission_id: submission_id, test_case_id: test_case_id, line_number: line_number, lightweight_stack_info: lightweight_stack_info, traced_file: traced_file, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/running_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/running_response.rb index d356ffb7a3b..7b7aac1cd02 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/running_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/running_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "submission_id" +require_relative "running_submission_state" require "json" module SeedTraceClient @@ -9,13 +10,13 @@ class RunningResponse attr_reader :submission_id, :state, :additional_properties # @param submission_id [Submission::SUBMISSION_ID] - # @param state [Hash{String => String}] + # @param state [RUNNING_SUBMISSION_STATE] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::RunningResponse] def initialize(submission_id:, state:, additional_properties: nil) # @type [Submission::SUBMISSION_ID] @submission_id = submission_id - # @type [Hash{String => String}] + # @type [RUNNING_SUBMISSION_STATE] @state = state # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -28,7 +29,7 @@ def initialize(submission_id:, state:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - state = struct.state + state = Submission::RUNNING_SUBMISSION_STATE.key(struct.state) || struct.state new(submission_id: submission_id, state: state, additional_properties: struct) end @@ -36,7 +37,7 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "submissionId": @submission_id, "state": @state }.to_json + { "submissionId": @submission_id, "state": Submission::RUNNING_SUBMISSION_STATE[@state] || @state }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -45,7 +46,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.submission_id.is_a?(UUID) != false || raise("Passed value for field obj.submission_id is not the expected type, validation failed.") - obj.state.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + obj.state.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/running_submission_state.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/running_submission_state.rb index b5d99001fa1..02a9639a2c2 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/running_submission_state.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/running_submission_state.rb @@ -2,13 +2,13 @@ module SeedTraceClient module Submission - # @type [Hash{String => String}] + # @type [RUNNING_SUBMISSION_STATE] RUNNING_SUBMISSION_STATE = { queueing_submission: "QUEUEING_SUBMISSION", killing_historical_submissions: "KILLING_HISTORICAL_SUBMISSIONS", writing_submission_to_file: "WRITING_SUBMISSION_TO_FILE", compiling_submission: "COMPILING_SUBMISSION", running_submission: "RUNNING_SUBMISSION" - }.frozen + }.freeze end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/stack_frame.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/stack_frame.rb index ebbc68a9d5b..b5e16a1bf54 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/stack_frame.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/stack_frame.rb @@ -32,7 +32,10 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName line_number = struct.lineNumber - scopes = struct.scopes + scopes = struct.scopes.map do |v| + v = v.to_h.to_json + Submission::Scope.from_json(json_object: v) + end new(method_name: method_name, line_number: line_number, scopes: scopes, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/stack_information.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/stack_information.rb index 7d53af8d36b..ef86285ad47 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/stack_information.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/stack_information.rb @@ -28,7 +28,8 @@ def initialize(num_stack_frames:, top_stack_frame: nil, additional_properties: n def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) num_stack_frames = struct.numStackFrames - top_stack_frame = struct.topStackFrame + top_stack_frame = struct.topStackFrame.to_h.to_json + top_stack_frame = Submission::StackFrame.from_json(json_object: top_stack_frame) new(num_stack_frames: num_stack_frames, top_stack_frame: top_stack_frame, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_request.rb index 22bae1f0ab0..fce3f7896d2 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_request.rb @@ -2,9 +2,9 @@ require "json" require_relative "initialize_problem_request" -require_relative "stop_request" require_relative "submit_request_v_2" require_relative "workspace_submit_request" +require_relative "stop_request" module SeedTraceClient module Submission diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_response.rb index 9f586bde038..1cc4c68c922 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_response.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true require "json" -require_relative "../../commons/types/problem_id" -require_relative "code_execution_update" require_relative "exception_info" +require_relative "code_execution_update" require_relative "terminated_response" +require_relative "../../commons/types/problem_id" module SeedTraceClient module Submission diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_status_for_test_case.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_status_for_test_case.rb index 6511c7c0a03..40611c58132 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_status_for_test_case.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_status_for_test_case.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "test_case_grade" require_relative "test_case_result_with_stdout" +require_relative "test_case_grade" require_relative "traced_test_case" module SeedTraceClient diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_type_enum.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_type_enum.rb index f3bbb990916..af19d36818c 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_type_enum.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submission_type_enum.rb @@ -2,7 +2,7 @@ module SeedTraceClient module Submission - # @type [Hash{String => String}] - SUBMISSION_TYPE_ENUM = { test: "TEST" }.frozen + # @type [SUBMISSION_TYPE_ENUM] + SUBMISSION_TYPE_ENUM = { test: "TEST" }.freeze end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submit_request_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submit_request_v_2.rb index 962d8676eed..f0abf162bf6 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submit_request_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/submit_request_v_2.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true +require_relative "submission_id" +require_relative "../../commons/types/language" require_relative "submission_file_info" - require_relative "../../commons/types/problem_id" -require_relative "submission_id" require "json" module SeedTraceClient @@ -13,7 +13,7 @@ class SubmitRequestV2 :additional_properties # @param submission_id [Submission::SUBMISSION_ID] - # @param language [Hash{String => String}] + # @param language [LANGUAGE] # @param submission_files [Array] # @param problem_id [Commons::PROBLEM_ID] # @param problem_version [Integer] @@ -24,7 +24,7 @@ def initialize(submission_id:, language:, submission_files:, problem_id:, proble additional_properties: nil) # @type [Submission::SUBMISSION_ID] @submission_id = submission_id - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language # @type [Array] @submission_files = submission_files @@ -45,8 +45,11 @@ def initialize(submission_id:, language:, submission_files:, problem_id:, proble def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - language = struct.language - submission_files = struct.submissionFiles + language = Commons::LANGUAGE.key(struct.language) || struct.language + submission_files = struct.submissionFiles.map do |v| + v = v.to_h.to_json + Submission::SubmissionFileInfo.from_json(json_object: v) + end problem_id = struct.problemId problem_version = struct.problemVersion user_id = struct.userId @@ -60,7 +63,7 @@ def self.from_json(json_object:) def to_json(*_args) { "submissionId": @submission_id, - "language": @language, + "language": Commons::LANGUAGE[@language] || @language, "submissionFiles": @submission_files, "problemId": @problem_id, "problemVersion": @problem_version, @@ -74,7 +77,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.submission_id.is_a?(UUID) != false || raise("Passed value for field obj.submission_id is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") obj.submission_files.is_a?(Array) != false || raise("Passed value for field obj.submission_files is not the expected type, validation failed.") obj.problem_id.is_a?(String) != false || raise("Passed value for field obj.problem_id is not the expected type, validation failed.") obj.problem_version&.is_a?(Integer) != false || raise("Passed value for field obj.problem_version is not the expected type, validation failed.") diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_non_hidden_grade.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_non_hidden_grade.rb index e6b51384410..e4d3b015bd1 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_non_hidden_grade.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_non_hidden_grade.rb @@ -35,8 +35,10 @@ def initialize(passed:, stdout:, actual_result: nil, exception: nil, additional_ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) passed = struct.passed - actual_result = struct.actualResult - exception = struct.exception + actual_result = struct.actualResult.to_h.to_json + actual_result = Commons::VariableValue.from_json(json_object: actual_result) + exception = struct.exception.to_h.to_json + exception = Submission::ExceptionV2.from_json(json_object: exception) stdout = struct.stdout new(passed: passed, actual_result: actual_result, exception: exception, stdout: stdout, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_result.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_result.rb index be30049e998..46b838960c4 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_result.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_result.rb @@ -31,8 +31,10 @@ def initialize(expected_result:, actual_result:, passed:, additional_properties: # @return [Submission::TestCaseResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - expected_result = struct.expectedResult - actual_result = struct.actualResult + expected_result = struct.expectedResult.to_h.to_json + expected_result = Commons::VariableValue.from_json(json_object: expected_result) + actual_result = struct.actualResult.to_h.to_json + actual_result = Submission::ActualResult.from_json(json_object: actual_result) passed = struct.passed new(expected_result: expected_result, actual_result: actual_result, passed: passed, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_result_with_stdout.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_result_with_stdout.rb index 76f93c2ef7e..b5fe336d281 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_result_with_stdout.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_case_result_with_stdout.rb @@ -27,7 +27,8 @@ def initialize(result:, stdout:, additional_properties: nil) # @return [Submission::TestCaseResultWithStdout] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - result = struct.result + result = struct.result.to_h.to_json + result = Submission::TestCaseResult.from_json(json_object: result) stdout = struct.stdout new(result: result, stdout: stdout, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_state.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_state.rb index d274d84a1b8..0e2731ef1f4 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_state.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_state.rb @@ -36,9 +36,16 @@ def initialize(problem_id:, default_test_cases:, custom_test_cases:, status:, ad def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_id = struct.problemId - default_test_cases = struct.defaultTestCases - custom_test_cases = struct.customTestCases - status = struct.status + default_test_cases = struct.defaultTestCases.map do |v| + v = v.to_h.to_json + Commons::TestCase.from_json(json_object: v) + end + custom_test_cases = struct.customTestCases.map do |v| + v = v.to_h.to_json + Commons::TestCase.from_json(json_object: v) + end + status = struct.status.to_h.to_json + status = Submission::TestSubmissionStatus.from_json(json_object: status) new(problem_id: problem_id, default_test_cases: default_test_cases, custom_test_cases: custom_test_cases, status: status, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_status.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_status.rb index 5a930c95886..03101755c0b 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_status.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_status.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "running_submission_state" require_relative "error_info" module SeedTraceClient @@ -32,7 +33,7 @@ def self.from_json(json_object:) when "errored" Submission::ErrorInfo.from_json(json_object: json_object.value) when "running" - RUNNING_SUBMISSION_STATE.key(json_object.value) + Submission::RUNNING_SUBMISSION_STATE.key(json_object.value) || json_object.value when "testCaseIdToState" json_object.value else @@ -71,7 +72,7 @@ def self.validate_raw(obj:) when "errored" Submission::ErrorInfo.validate_raw(obj: obj) when "running" - obj.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "testCaseIdToState" obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") else @@ -98,7 +99,7 @@ def self.errored(member:) new(member: member, discriminant: "errored") end - # @param member [Hash{String => String}] + # @param member [RUNNING_SUBMISSION_STATE] # @return [Submission::TestSubmissionStatus] def self.running(member:) new(member: member, discriminant: "running") diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_status_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_status_v_2.rb index e6b9c96e0d0..af768ebaf85 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_status_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_status_v_2.rb @@ -1,10 +1,8 @@ # frozen_string_literal: true +require_relative "test_submission_update" require_relative "../../commons/types/problem_id" - require_relative "../../v_2/problem/types/problem_info_v_2" - -require_relative "test_submission_update" require "json" module SeedTraceClient @@ -37,10 +35,14 @@ def initialize(updates:, problem_id:, problem_version:, problem_info:, additiona # @return [Submission::TestSubmissionStatusV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - updates = struct.updates + updates = struct.updates.map do |v| + v = v.to_h.to_json + Submission::TestSubmissionUpdate.from_json(json_object: v) + end problem_id = struct.problemId problem_version = struct.problemVersion - problem_info = struct.problemInfo + problem_info = struct.problemInfo.to_h.to_json + problem_info = V2::Problem::ProblemInfoV2.from_json(json_object: problem_info) new(updates: updates, problem_id: problem_id, problem_version: problem_version, problem_info: problem_info, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_update.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_update.rb index 3b5ec1ff562..e0217670f77 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_update.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_update.rb @@ -28,8 +28,9 @@ def initialize(update_time:, update_info:, additional_properties: nil) # @return [Submission::TestSubmissionUpdate] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - update_time = struct.updateTime - update_info = struct.updateInfo + update_time = DateTime.parse(struct.updateTime) + update_info = struct.updateInfo.to_h.to_json + update_info = Submission::TestSubmissionUpdateInfo.from_json(json_object: update_info) new(update_time: update_time, update_info: update_info, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_update_info.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_update_info.rb index 8e4c44b3e65..87af634a3af 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_update_info.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/test_submission_update_info.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "running_submission_state" require_relative "error_info" require_relative "graded_test_case_update" require_relative "recorded_test_case_update" @@ -30,7 +31,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "running" - RUNNING_SUBMISSION_STATE.key(json_object.value) + Submission::RUNNING_SUBMISSION_STATE.key(json_object.value) || json_object.value when "stopped" nil when "errored" @@ -42,7 +43,7 @@ def self.from_json(json_object:) when "finished" nil else - RUNNING_SUBMISSION_STATE.key(json_object) + Submission::RUNNING_SUBMISSION_STATE.key(json_object) || json_object end new(member: member, discriminant: struct.type) end @@ -77,7 +78,7 @@ def to_json(*_args) def self.validate_raw(obj:) case obj.type when "running" - obj.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "stopped" # noop when "errored" @@ -101,7 +102,7 @@ def is_a?(obj) @member.is_a?(obj) end - # @param member [Hash{String => String}] + # @param member [RUNNING_SUBMISSION_STATE] # @return [Submission::TestSubmissionUpdateInfo] def self.running(member:) new(member: member, discriminant: "running") diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_response.rb index 20e4fc6a036..17905708161 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_response.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require_relative "expression_location" - +require_relative "submission_id" require_relative "../../commons/types/debug_variable_value" +require_relative "expression_location" require_relative "stack_information" - -require_relative "submission_id" require "json" module SeedTraceClient @@ -48,9 +46,12 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId line_number = struct.lineNumber - return_value = struct.returnValue - expression_location = struct.expressionLocation - stack = struct.stack + return_value = struct.returnValue.to_h.to_json + return_value = Commons::DebugVariableValue.from_json(json_object: return_value) + expression_location = struct.expressionLocation.to_h.to_json + expression_location = Submission::ExpressionLocation.from_json(json_object: expression_location) + stack = struct.stack.to_h.to_json + stack = Submission::StackInformation.from_json(json_object: stack) stdout = struct.stdout new(submission_id: submission_id, line_number: line_number, return_value: return_value, expression_location: expression_location, stack: stack, stdout: stdout, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_response_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_response_v_2.rb index 4d886bffd9b..e491aaf9216 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_response_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_response_v_2.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true +require_relative "submission_id" +require_relative "traced_file" require_relative "../../commons/types/debug_variable_value" require_relative "expression_location" require_relative "stack_information" -require_relative "submission_id" -require_relative "traced_file" require "json" module SeedTraceClient @@ -50,10 +50,14 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId line_number = struct.lineNumber - file = struct.file - return_value = struct.returnValue - expression_location = struct.expressionLocation - stack = struct.stack + file = struct.file.to_h.to_json + file = Submission::TracedFile.from_json(json_object: file) + return_value = struct.returnValue.to_h.to_json + return_value = Commons::DebugVariableValue.from_json(json_object: return_value) + expression_location = struct.expressionLocation.to_h.to_json + expression_location = Submission::ExpressionLocation.from_json(json_object: expression_location) + stack = struct.stack.to_h.to_json + stack = Submission::StackInformation.from_json(json_object: stack) stdout = struct.stdout new(submission_id: submission_id, line_number: line_number, file: file, return_value: return_value, expression_location: expression_location, stack: stack, stdout: stdout, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_responses_page.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_responses_page.rb index 231045d7300..65c79ab70c0 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_responses_page.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_responses_page.rb @@ -8,12 +8,14 @@ module Submission class TraceResponsesPage attr_reader :offset, :trace_responses, :additional_properties - # @param offset [Integer] If present, use this to load subseqent pages. The offset is the id of the next trace response to load. + # @param offset [Integer] If present, use this to load subseqent pages. + # The offset is the id of the next trace response to load. # @param trace_responses [Array] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::TraceResponsesPage] def initialize(trace_responses:, offset: nil, additional_properties: nil) - # @type [Integer] If present, use this to load subseqent pages. The offset is the id of the next trace response to load. + # @type [Integer] If present, use this to load subseqent pages. + # The offset is the id of the next trace response to load. @offset = offset # @type [Array] @trace_responses = trace_responses @@ -28,7 +30,10 @@ def initialize(trace_responses:, offset: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) offset = struct.offset - trace_responses = struct.traceResponses + trace_responses = struct.traceResponses.map do |v| + v = v.to_h.to_json + Submission::TraceResponse.from_json(json_object: v) + end new(offset: offset, trace_responses: trace_responses, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_responses_page_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_responses_page_v_2.rb index e79e8e8d8d7..f86b3b6669d 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_responses_page_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/trace_responses_page_v_2.rb @@ -8,12 +8,14 @@ module Submission class TraceResponsesPageV2 attr_reader :offset, :trace_responses, :additional_properties - # @param offset [Integer] If present, use this to load subseqent pages. The offset is the id of the next trace response to load. + # @param offset [Integer] If present, use this to load subseqent pages. + # The offset is the id of the next trace response to load. # @param trace_responses [Array] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::TraceResponsesPageV2] def initialize(trace_responses:, offset: nil, additional_properties: nil) - # @type [Integer] If present, use this to load subseqent pages. The offset is the id of the next trace response to load. + # @type [Integer] If present, use this to load subseqent pages. + # The offset is the id of the next trace response to load. @offset = offset # @type [Array] @trace_responses = trace_responses @@ -28,7 +30,10 @@ def initialize(trace_responses:, offset: nil, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) offset = struct.offset - trace_responses = struct.traceResponses + trace_responses = struct.traceResponses.map do |v| + v = v.to_h.to_json + Submission::TraceResponseV2.from_json(json_object: v) + end new(offset: offset, trace_responses: trace_responses, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/traced_test_case.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/traced_test_case.rb index 6645efd0f46..aa9b92cb4ed 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/traced_test_case.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/traced_test_case.rb @@ -27,7 +27,8 @@ def initialize(result:, trace_responses_size:, additional_properties: nil) # @return [Submission::TracedTestCase] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - result = struct.result + result = struct.result.to_h.to_json + result = Submission::TestCaseResultWithStdout.from_json(json_object: result) trace_responses_size = struct.traceResponsesSize new(result: result, trace_responses_size: trace_responses_size, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/unexpected_language_error.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/unexpected_language_error.rb index e1a746da62f..fd5fb524278 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/unexpected_language_error.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/unexpected_language_error.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "../../commons/types/language" require "json" module SeedTraceClient @@ -7,14 +8,14 @@ module Submission class UnexpectedLanguageError attr_reader :expected_language, :actual_language, :additional_properties - # @param expected_language [Hash{String => String}] - # @param actual_language [Hash{String => String}] + # @param expected_language [LANGUAGE] + # @param actual_language [LANGUAGE] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::UnexpectedLanguageError] def initialize(expected_language:, actual_language:, additional_properties: nil) - # @type [Hash{String => String}] + # @type [LANGUAGE] @expected_language = expected_language - # @type [Hash{String => String}] + # @type [LANGUAGE] @actual_language = actual_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -26,8 +27,8 @@ def initialize(expected_language:, actual_language:, additional_properties: nil) # @return [Submission::UnexpectedLanguageError] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - expected_language = struct.expectedLanguage - actual_language = struct.actualLanguage + expected_language = Commons::LANGUAGE.key(struct.expectedLanguage) || struct.expectedLanguage + actual_language = Commons::LANGUAGE.key(struct.actualLanguage) || struct.actualLanguage new(expected_language: expected_language, actual_language: actual_language, additional_properties: struct) end @@ -35,7 +36,10 @@ def self.from_json(json_object:) # # @return [JSON] def to_json(*_args) - { "expectedLanguage": @expected_language, "actualLanguage": @actual_language }.to_json + { + "expectedLanguage": Commons::LANGUAGE[@expected_language] || @expected_language, + "actualLanguage": Commons::LANGUAGE[@actual_language] || @actual_language + }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -43,8 +47,8 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - obj.expected_language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.expected_language is not the expected type, validation failed.") - obj.actual_language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.actual_language is not the expected type, validation failed.") + obj.expected_language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.expected_language is not the expected type, validation failed.") + obj.actual_language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.actual_language is not the expected type, validation failed.") end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_files.rb index ad225a9134f..08122be7159 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_files.rb @@ -27,8 +27,12 @@ def initialize(main_file:, read_only_files:, additional_properties: nil) # @return [Submission::WorkspaceFiles] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - main_file = struct.mainFile - read_only_files = struct.readOnlyFiles + main_file = struct.mainFile.to_h.to_json + main_file = Commons::FileInfo.from_json(json_object: main_file) + read_only_files = struct.readOnlyFiles.map do |v| + v = v.to_h.to_json + Commons::FileInfo.from_json(json_object: v) + end new(main_file: main_file, read_only_files: read_only_files, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_ran_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_ran_response.rb index 558e6cdf18e..f90a9c4e9cc 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_ran_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_ran_response.rb @@ -29,7 +29,8 @@ def initialize(submission_id:, run_details:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - run_details = struct.runDetails + run_details = struct.runDetails.to_h.to_json + run_details = Submission::WorkspaceRunDetails.from_json(json_object: run_details) new(submission_id: submission_id, run_details: run_details, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_run_details.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_run_details.rb index a0e3bdd0815..eb9cbe65256 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_run_details.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_run_details.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "exception_info" - require_relative "exception_v_2" +require_relative "exception_info" require "json" module SeedTraceClient @@ -32,8 +31,10 @@ def initialize(stdout:, exception_v_2: nil, exception: nil, additional_propertie # @return [Submission::WorkspaceRunDetails] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - exception_v_2 = struct.exceptionV2 - exception = struct.exception + exception_v_2 = struct.exceptionV2.to_h.to_json + exception_v_2 = Submission::ExceptionV2.from_json(json_object: exception_v_2) + exception = struct.exception.to_h.to_json + exception = Submission::ExceptionInfo.from_json(json_object: exception) stdout = struct.stdout new(exception_v_2: exception_v_2, exception: exception, stdout: stdout, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response.rb index 03c2bbdc4b4..714e811730e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Submission class WorkspaceStarterFilesResponse attr_reader :files, :additional_properties - # @param files [Hash{LANGUAGE => LANGUAGE}] + # @param files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::WorkspaceStarterFilesResponse] def initialize(files:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files = files # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -23,7 +24,10 @@ def initialize(files:, additional_properties: nil) # @return [Submission::WorkspaceStarterFilesResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files = struct.files + files = struct.files.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(files: files, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response_v_2.rb index 8500420e9c6..2c2f8ffda59 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_starter_files_response_v_2.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true require "json" +require_relative "../../commons/types/language" module SeedTraceClient module Submission class WorkspaceStarterFilesResponseV2 attr_reader :files_by_language, :additional_properties - # @param files_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param files_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Submission::WorkspaceStarterFilesResponseV2] def initialize(files_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @files_by_language = files_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -23,7 +24,10 @@ def initialize(files_by_language:, additional_properties: nil) # @return [Submission::WorkspaceStarterFilesResponseV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files_by_language = struct.filesByLanguage + files_by_language = struct.filesByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(files_by_language: files_by_language, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_state.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_state.rb index c53c5bb31d5..fd0ea0d6640 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_state.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_state.rb @@ -24,7 +24,8 @@ def initialize(status:, additional_properties: nil) # @return [Submission::WorkspaceSubmissionState] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - status = struct.status + status = struct.status.to_h.to_json + status = Submission::WorkspaceSubmissionStatus.from_json(json_object: status) new(status: status, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_status.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_status.rb index 6c965475ac5..727557d50ac 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_status.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_status.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "running_submission_state" require_relative "error_info" require_relative "workspace_run_details" @@ -33,7 +34,7 @@ def self.from_json(json_object:) when "errored" Submission::ErrorInfo.from_json(json_object: json_object.value) when "running" - RUNNING_SUBMISSION_STATE.key(json_object.value) + Submission::RUNNING_SUBMISSION_STATE.key(json_object.value) || json_object.value when "ran" Submission::WorkspaceRunDetails.from_json(json_object: json_object) when "traced" @@ -76,7 +77,7 @@ def self.validate_raw(obj:) when "errored" Submission::ErrorInfo.validate_raw(obj: obj) when "running" - obj.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "ran" Submission::WorkspaceRunDetails.validate_raw(obj: obj) when "traced" @@ -105,7 +106,7 @@ def self.errored(member:) new(member: member, discriminant: "errored") end - # @param member [Hash{String => String}] + # @param member [RUNNING_SUBMISSION_STATE] # @return [Submission::WorkspaceSubmissionStatus] def self.running(member:) new(member: member, discriminant: "running") diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_status_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_status_v_2.rb index 61befce906d..e8aa587cfe4 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_status_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_status_v_2.rb @@ -24,7 +24,10 @@ def initialize(updates:, additional_properties: nil) # @return [Submission::WorkspaceSubmissionStatusV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - updates = struct.updates + updates = struct.updates.map do |v| + v = v.to_h.to_json + Submission::WorkspaceSubmissionUpdate.from_json(json_object: v) + end new(updates: updates, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_update.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_update.rb index 3161122a470..d2fc6b9fb1d 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_update.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_update.rb @@ -28,8 +28,9 @@ def initialize(update_time:, update_info:, additional_properties: nil) # @return [Submission::WorkspaceSubmissionUpdate] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - update_time = struct.updateTime - update_info = struct.updateInfo + update_time = DateTime.parse(struct.updateTime) + update_info = struct.updateInfo.to_h.to_json + update_info = Submission::WorkspaceSubmissionUpdateInfo.from_json(json_object: update_info) new(update_time: update_time, update_info: update_info, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_update_info.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_update_info.rb index 90fd464857d..c48defc3ce1 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_update_info.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submission_update_info.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true require "json" -require_relative "error_info" +require_relative "running_submission_state" require_relative "workspace_run_details" require_relative "workspace_traced_update" +require_relative "error_info" module SeedTraceClient module Submission @@ -30,7 +31,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "running" - RUNNING_SUBMISSION_STATE.key(json_object.value) + Submission::RUNNING_SUBMISSION_STATE.key(json_object.value) || json_object.value when "ran" Submission::WorkspaceRunDetails.from_json(json_object: json_object) when "stopped" @@ -44,7 +45,7 @@ def self.from_json(json_object:) when "finished" nil else - RUNNING_SUBMISSION_STATE.key(json_object) + Submission::RUNNING_SUBMISSION_STATE.key(json_object) || json_object end new(member: member, discriminant: struct.type) end @@ -81,7 +82,7 @@ def to_json(*_args) def self.validate_raw(obj:) case obj.type when "running" - obj.is_a?(RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") + obj.is_a?(Submission::RUNNING_SUBMISSION_STATE) != false || raise("Passed value for field obj is not the expected type, validation failed.") when "ran" Submission::WorkspaceRunDetails.validate_raw(obj: obj) when "stopped" @@ -107,7 +108,7 @@ def is_a?(obj) @member.is_a?(obj) end - # @param member [Hash{String => String}] + # @param member [RUNNING_SUBMISSION_STATE] # @return [Submission::WorkspaceSubmissionUpdateInfo] def self.running(member:) new(member: member, discriminant: "running") diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submit_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submit_request.rb index 8150d900134..40bc5d29284 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submit_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/submission/types/workspace_submit_request.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative "submission_file_info" - require_relative "submission_id" +require_relative "../../commons/types/language" +require_relative "submission_file_info" require "json" module SeedTraceClient @@ -11,7 +11,7 @@ class WorkspaceSubmitRequest attr_reader :submission_id, :language, :submission_files, :user_id, :additional_properties # @param submission_id [Submission::SUBMISSION_ID] - # @param language [Hash{String => String}] + # @param language [LANGUAGE] # @param submission_files [Array] # @param user_id [String] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition @@ -19,7 +19,7 @@ class WorkspaceSubmitRequest def initialize(submission_id:, language:, submission_files:, user_id: nil, additional_properties: nil) # @type [Submission::SUBMISSION_ID] @submission_id = submission_id - # @type [Hash{String => String}] + # @type [LANGUAGE] @language = language # @type [Array] @submission_files = submission_files @@ -36,8 +36,11 @@ def initialize(submission_id:, language:, submission_files:, user_id: nil, addit def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) submission_id = struct.submissionId - language = struct.language - submission_files = struct.submissionFiles + language = Commons::LANGUAGE.key(struct.language) || struct.language + submission_files = struct.submissionFiles.map do |v| + v = v.to_h.to_json + Submission::SubmissionFileInfo.from_json(json_object: v) + end user_id = struct.userId new(submission_id: submission_id, language: language, submission_files: submission_files, user_id: user_id, additional_properties: struct) @@ -49,7 +52,7 @@ def self.from_json(json_object:) def to_json(*_args) { "submissionId": @submission_id, - "language": @language, + "language": Commons::LANGUAGE[@language] || @language, "submissionFiles": @submission_files, "userId": @user_id }.to_json @@ -61,7 +64,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.submission_id.is_a?(UUID) != false || raise("Passed value for field obj.submission_id is not the expected type, validation failed.") - obj.language.is_a?(LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.language.is_a?(Commons::LANGUAGE) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") obj.submission_files.is_a?(Array) != false || raise("Passed value for field obj.submission_files is not the expected type, validation failed.") obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.") end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/sysprop/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/sysprop/client.rb index d2b50374281..f9a1f544c34 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/sysprop/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/sysprop/client.rb @@ -1,87 +1,87 @@ # frozen_string_literal: true +require_relative "../../requests" +require_relative "../commons/types/language" require "async" module SeedTraceClient - module Sysprop - class SyspropClient - attr_reader :request_client + class SyspropClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [SyspropClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [SyspropClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param language [Hash{String => String}] - # @param num_warm_instances [Integer] - # @param request_options [RequestOptions] - # @return [Void] - def set_num_warm_instances(language:, num_warm_instances:, request_options: nil) - @request_client.conn.put("/sysprop/num-warm-instances/#{language}/#{num_warm_instances}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param language [LANGUAGE] + # @param num_warm_instances [Integer] + # @param request_options [RequestOptions] + # @return [Void] + def set_num_warm_instances(language:, num_warm_instances:, request_options: nil) + @request_client.conn.put("/sysprop/num-warm-instances/#{language}/#{num_warm_instances}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + end - # @param request_options [RequestOptions] - # @return [Hash{LANGUAGE => LANGUAGE}] - def get_num_warm_instances(request_options: nil) - response = @request_client.conn.get("/sysprop/num-warm-instances") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.transform_values do |_k, v| - v = v.to_h.to_json - LANGUAGE.key(v) - end + # @param request_options [RequestOptions] + # @return [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + def get_num_warm_instances(request_options: nil) + response = @request_client.conn.get("/sysprop/num-warm-instances") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + response.body.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v end end + end - class AsyncSyspropClient - attr_reader :request_client + class AsyncSyspropClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncSyspropClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncSyspropClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param language [Hash{String => String}] - # @param num_warm_instances [Integer] - # @param request_options [RequestOptions] - # @return [Void] - def set_num_warm_instances(language:, num_warm_instances:, request_options: nil) - Async.call do - @request_client.conn.put("/sysprop/num-warm-instances/#{language}/#{num_warm_instances}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param language [LANGUAGE] + # @param num_warm_instances [Integer] + # @param request_options [RequestOptions] + # @return [Void] + def set_num_warm_instances(language:, num_warm_instances:, request_options: nil) + Async do + @request_client.conn.put("/sysprop/num-warm-instances/#{language}/#{num_warm_instances}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - # @param request_options [RequestOptions] - # @return [Hash{LANGUAGE => LANGUAGE}] - def get_num_warm_instances(request_options: nil) - Async.call do - response = @request_client.conn.get("/sysprop/num-warm-instances") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.transform_values do |_k, v| - v = v.to_h.to_json - LANGUAGE.key(v) - end + # @param request_options [RequestOptions] + # @return [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + def get_num_warm_instances(request_options: nil) + Async do + response = @request_client.conn.get("/sysprop/num-warm-instances") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + response.body.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/client.rb index ae47d51fc24..e1cb0992b3e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/client.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedTraceClient @@ -8,7 +9,7 @@ class Client attr_reader :request_client # @param request_client [RequestClient] - # @return [Client] + # @return [V2::Client] def initialize(request_client:) # @type [RequestClient] @request_client = request_client @@ -18,10 +19,10 @@ def initialize(request_client:) # @return [Void] def test(request_options: nil) @request_client.conn.get("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end @@ -30,7 +31,7 @@ class AsyncClient attr_reader :request_client # @param request_client [AsyncRequestClient] - # @return [AsyncClient] + # @return [V2::AsyncClient] def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client @@ -39,12 +40,15 @@ def initialize(request_client:) # @param request_options [RequestOptions] # @return [Void] def test(request_options: nil) - Async.call do + Async do @request_client.conn.get("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/client.rb index c9b39ff741e..ffdf2a179cd 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/client.rb @@ -1,154 +1,181 @@ # frozen_string_literal: true -require_relative "../../commons/types/problem_id" +require_relative "../../../requests" require_relative "types/lightweight_problem_info_v_2" require_relative "types/problem_info_v_2" +require_relative "../../commons/types/problem_id" require "async" module SeedTraceClient module V2 - module Problem - class ProblemClient - attr_reader :request_client + class ProblemClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ProblemClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [V2::ProblemClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Array] - def get_lightweight_problems(request_options: nil) - response = @request_client.conn.get("/problems-v2/lightweight-problem-info") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.map do |v| - v = v.to_h.to_json - V2::Problem::LightweightProblemInfoV2.from_json(json_object: v) - end + # Returns lightweight versions of all problems + # + # @param request_options [RequestOptions] + # @return [Array] + def get_lightweight_problems(request_options: nil) + response = @request_client.conn.get("/problems-v2/lightweight-problem-info") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body.map do |v| + v = v.to_h.to_json + V2::Problem::LightweightProblemInfoV2.from_json(json_object: v) + end + end - # @param request_options [RequestOptions] - # @return [Array] - def get_problems(request_options: nil) - response = @request_client.conn.get("/problems-v2/problem-info") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.map do |v| - v = v.to_h.to_json - V2::Problem::ProblemInfoV2.from_json(json_object: v) - end + # Returns latest versions of all problems + # + # @param request_options [RequestOptions] + # @return [Array] + def get_problems(request_options: nil) + response = @request_client.conn.get("/problems-v2/problem-info") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body.map do |v| + v = v.to_h.to_json + V2::Problem::ProblemInfoV2.from_json(json_object: v) + end + end - # @param problem_id [Commons::PROBLEM_ID] - # @param request_options [RequestOptions] - # @return [V2::Problem::ProblemInfoV2] - def get_latest_problem(problem_id:, request_options: nil) - response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - V2::Problem::ProblemInfoV2.from_json(json_object: response) + # Returns latest version of a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param request_options [RequestOptions] + # @return [V2::Problem::ProblemInfoV2] + def get_latest_problem(problem_id:, request_options: nil) + response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + V2::Problem::ProblemInfoV2.from_json(json_object: response.body) + end - # @param problem_id [Commons::PROBLEM_ID] - # @param problem_version [Integer] - # @param request_options [RequestOptions] - # @return [V2::Problem::ProblemInfoV2] - def get_problem_version(problem_id:, problem_version:, request_options: nil) - response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}/version/#{problem_version}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - V2::Problem::ProblemInfoV2.from_json(json_object: response) + # Returns requested version of a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param problem_version [Integer] + # @param request_options [RequestOptions] + # @return [V2::Problem::ProblemInfoV2] + def get_problem_version(problem_id:, problem_version:, request_options: nil) + response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}/version/#{problem_version}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + req.headers["X-Random-Header"] = request_options.x_random_header unless request_options&.x_random_header.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + V2::Problem::ProblemInfoV2.from_json(json_object: response.body) end + end - class AsyncProblemClient - attr_reader :request_client + class AsyncProblemClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncProblemClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [V2::AsyncProblemClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Array] - def get_lightweight_problems(request_options: nil) - Async.call do - response = @request_client.conn.get("/problems-v2/lightweight-problem-info") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.map do |v| - v = v.to_h.to_json - V2::Problem::LightweightProblemInfoV2.from_json(json_object: v) + # Returns lightweight versions of all problems + # + # @param request_options [RequestOptions] + # @return [Array] + def get_lightweight_problems(request_options: nil) + Async do + response = @request_client.conn.get("/problems-v2/lightweight-problem-info") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + response.body.map do |v| + v = v.to_h.to_json + V2::Problem::LightweightProblemInfoV2.from_json(json_object: v) end end + end - # @param request_options [RequestOptions] - # @return [Array] - def get_problems(request_options: nil) - Async.call do - response = @request_client.conn.get("/problems-v2/problem-info") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.map do |v| - v = v.to_h.to_json - V2::Problem::ProblemInfoV2.from_json(json_object: v) + # Returns latest versions of all problems + # + # @param request_options [RequestOptions] + # @return [Array] + def get_problems(request_options: nil) + Async do + response = @request_client.conn.get("/problems-v2/problem-info") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + response.body.map do |v| + v = v.to_h.to_json + V2::Problem::ProblemInfoV2.from_json(json_object: v) end end + end - # @param problem_id [Commons::PROBLEM_ID] - # @param request_options [RequestOptions] - # @return [V2::Problem::ProblemInfoV2] - def get_latest_problem(problem_id:, request_options: nil) - Async.call do - response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + # Returns latest version of a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param request_options [RequestOptions] + # @return [V2::Problem::ProblemInfoV2] + def get_latest_problem(problem_id:, request_options: nil) + Async do + response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end - V2::Problem::ProblemInfoV2.from_json(json_object: response) + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + V2::Problem::ProblemInfoV2.from_json(json_object: response.body) end + end - # @param problem_id [Commons::PROBLEM_ID] - # @param problem_version [Integer] - # @param request_options [RequestOptions] - # @return [V2::Problem::ProblemInfoV2] - def get_problem_version(problem_id:, problem_version:, request_options: nil) - Async.call do - response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}/version/#{problem_version}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + # Returns requested version of a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param problem_version [Integer] + # @param request_options [RequestOptions] + # @return [V2::Problem::ProblemInfoV2] + def get_problem_version(problem_id:, problem_version:, request_options: nil) + Async do + response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}/version/#{problem_version}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end - V2::Problem::ProblemInfoV2.from_json(json_object: response) + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + V2::Problem::ProblemInfoV2.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/basic_custom_files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/basic_custom_files.rb index b12160e9d52..cf94b1b8879 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/basic_custom_files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/basic_custom_files.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative "basic_test_case_template" - require_relative "non_void_function_signature" +require_relative "basic_test_case_template" require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -13,7 +13,7 @@ class BasicCustomFiles # @param method_name [String] # @param signature [V2::Problem::NonVoidFunctionSignature] - # @param additional_files [Hash{LANGUAGE => LANGUAGE}] + # @param additional_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param basic_test_case_template [V2::Problem::BasicTestCaseTemplate] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::BasicCustomFiles] @@ -23,7 +23,7 @@ def initialize(method_name:, signature:, additional_files:, basic_test_case_temp @method_name = method_name # @type [V2::Problem::NonVoidFunctionSignature] @signature = signature - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @additional_files = additional_files # @type [V2::Problem::BasicTestCaseTemplate] @basic_test_case_template = basic_test_case_template @@ -38,9 +38,14 @@ def initialize(method_name:, signature:, additional_files:, basic_test_case_temp def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName - signature = struct.signature - additional_files = struct.additionalFiles - basic_test_case_template = struct.basicTestCaseTemplate + signature = struct.signature.to_h.to_json + signature = V2::Problem::NonVoidFunctionSignature.from_json(json_object: signature) + additional_files = struct.additionalFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + basic_test_case_template = struct.basicTestCaseTemplate.to_h.to_json + basic_test_case_template = V2::Problem::BasicTestCaseTemplate.from_json(json_object: basic_test_case_template) new(method_name: method_name, signature: signature, additional_files: additional_files, basic_test_case_template: basic_test_case_template, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/basic_test_case_template.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/basic_test_case_template.rb index d1679527841..a546d554d05 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/basic_test_case_template.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/basic_test_case_template.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "test_case_template_id" require_relative "test_case_implementation_description" - require_relative "parameter_id" -require_relative "test_case_template_id" require "json" module SeedTraceClient @@ -39,7 +38,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) template_id = struct.templateId name = struct.name - description = struct.description + description = struct.description.to_h.to_json + description = V2::Problem::TestCaseImplementationDescription.from_json(json_object: description) expected_value_parameter_id = struct.expectedValueParameterId new(template_id: template_id, name: name, description: description, expected_value_parameter_id: expected_value_parameter_id, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/create_problem_request_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/create_problem_request_v_2.rb index 5ce4796e727..ed60a903ead 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/create_problem_request_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/create_problem_request_v_2.rb @@ -4,8 +4,8 @@ require_relative "custom_files" require_relative "test_case_template" require_relative "test_case_v_2" -require "json" require "set" +require "json" module SeedTraceClient module V2 @@ -19,7 +19,7 @@ class CreateProblemRequestV2 # @param custom_files [V2::Problem::CustomFiles] # @param custom_test_case_templates [Array] # @param testcases [Array] - # @param supported_languages [Set] + # @param supported_languages [Set] # @param is_public [Boolean] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::CreateProblemRequestV2] @@ -35,7 +35,7 @@ def initialize(problem_name:, problem_description:, custom_files:, custom_test_c @custom_test_case_templates = custom_test_case_templates # @type [Array] @testcases = testcases - # @type [Set] + # @type [Set] @supported_languages = supported_languages # @type [Boolean] @is_public = is_public @@ -50,11 +50,20 @@ def initialize(problem_name:, problem_description:, custom_files:, custom_test_c def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_name = struct.problemName - problem_description = struct.problemDescription - custom_files = struct.customFiles - custom_test_case_templates = struct.customTestCaseTemplates - testcases = struct.testcases - supported_languages = struct.supportedLanguages + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) + custom_files = struct.customFiles.to_h.to_json + custom_files = V2::Problem::CustomFiles.from_json(json_object: custom_files) + custom_test_case_templates = struct.customTestCaseTemplates.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseTemplate.from_json(json_object: v) + end + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseV2.from_json(json_object: v) + end + supported_languages = struct.supportedLanguages.to_h.to_json + supported_languages = Set.new(supported_languages) is_public = struct.isPublic new(problem_name: problem_name, problem_description: problem_description, custom_files: custom_files, custom_test_case_templates: custom_test_case_templates, testcases: testcases, supported_languages: supported_languages, is_public: is_public, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/custom_files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/custom_files.rb index 22fc3bcc243..95e9ecdad63 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/custom_files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/custom_files.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" require_relative "basic_custom_files" module SeedTraceClient @@ -33,7 +34,7 @@ def self.from_json(json_object:) when "custom" json_object.value.transform_values do |_k, v| v = v.to_h.to_json - LANGUAGE.key(v) + Commons::LANGUAGE.key(v) || v end else V2::Problem::BasicCustomFiles.from_json(json_object: json_object) @@ -85,7 +86,7 @@ def self.basic(member:) new(member: member, discriminant: "basic") end - # @param member [Hash{LANGUAGE => LANGUAGE}] + # @param member [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @return [V2::Problem::CustomFiles] def self.custom(member:) new(member: member, discriminant: "custom") diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/default_provided_file.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/default_provided_file.rb index 24ca644752e..1b04dd4a9dc 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/default_provided_file.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/default_provided_file.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../commons/types/variable_type" - require_relative "file_info_v_2" +require_relative "../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -30,8 +29,12 @@ def initialize(file:, related_types:, additional_properties: nil) # @return [V2::Problem::DefaultProvidedFile] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - file = struct.file - related_types = struct.relatedTypes + file = struct.file.to_h.to_json + file = V2::Problem::FileInfoV2.from_json(json_object: file) + related_types = struct.relatedTypes.map do |v| + v = v.to_h.to_json + Commons::VariableType.from_json(json_object: v) + end new(file: file, related_types: related_types, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/files.rb index 423725f6318..28526b0c2f0 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/files.rb @@ -25,7 +25,10 @@ def initialize(files:, additional_properties: nil) # @return [V2::Problem::Files] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files = struct.files + files = struct.files.map do |v| + v = v.to_h.to_json + V2::Problem::FileInfoV2.from_json(json_object: v) + end new(files: files, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages.rb index 6bd1413d3d2..6a2b8007148 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -8,11 +9,11 @@ module Problem class FunctionImplementationForMultipleLanguages attr_reader :code_by_language, :additional_properties - # @param code_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param code_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::FunctionImplementationForMultipleLanguages] def initialize(code_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @code_by_language = code_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -24,7 +25,10 @@ def initialize(code_by_language:, additional_properties: nil) # @return [V2::Problem::FunctionImplementationForMultipleLanguages] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - code_by_language = struct.codeByLanguage + code_by_language = struct.codeByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(code_by_language: code_by_language, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/function_signature.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/function_signature.rb index cec46add7e7..2f50061e45b 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/function_signature.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/function_signature.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "non_void_function_signature" require_relative "void_function_signature" +require_relative "non_void_function_signature" require_relative "void_function_signature_that_takes_actual_result" module SeedTraceClient diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/generated_files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/generated_files.rb index 5e0b174418b..c4bd5145b7a 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/generated_files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/generated_files.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -8,17 +9,17 @@ module Problem class GeneratedFiles attr_reader :generated_test_case_files, :generated_template_files, :other, :additional_properties - # @param generated_test_case_files [Hash{LANGUAGE => LANGUAGE}] - # @param generated_template_files [Hash{LANGUAGE => LANGUAGE}] - # @param other [Hash{LANGUAGE => LANGUAGE}] + # @param generated_test_case_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + # @param generated_template_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + # @param other [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::GeneratedFiles] def initialize(generated_test_case_files:, generated_template_files:, other:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @generated_test_case_files = generated_test_case_files - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @generated_template_files = generated_template_files - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @other = other # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -30,9 +31,18 @@ def initialize(generated_test_case_files:, generated_template_files:, other:, ad # @return [V2::Problem::GeneratedFiles] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - generated_test_case_files = struct.generatedTestCaseFiles - generated_template_files = struct.generatedTemplateFiles - other = struct.other + generated_test_case_files = struct.generatedTestCaseFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + generated_template_files = struct.generatedTemplateFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + other = struct.other.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(generated_test_case_files: generated_test_case_files, generated_template_files: generated_template_files, other: other, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_request.rb index b95db88246c..117bc773b1d 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_request.rb @@ -29,7 +29,8 @@ def initialize(method_name:, signature:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName - signature = struct.signature + signature = struct.signature.to_h.to_json + signature = V2::Problem::NonVoidFunctionSignature.from_json(json_object: signature) new(method_name: method_name, signature: signature, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_response.rb index 305e0fecb0d..63c699c2e75 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_basic_solution_file_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -8,11 +9,11 @@ module Problem class GetBasicSolutionFileResponse attr_reader :solution_file_by_language, :additional_properties - # @param solution_file_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param solution_file_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::GetBasicSolutionFileResponse] def initialize(solution_file_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @solution_file_by_language = solution_file_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -24,7 +25,10 @@ def initialize(solution_file_by_language:, additional_properties: nil) # @return [V2::Problem::GetBasicSolutionFileResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - solution_file_by_language = struct.solutionFileByLanguage + solution_file_by_language = struct.solutionFileByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(solution_file_by_language: solution_file_by_language, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_request.rb index 5340b0ee43e..1bc7e57b9e4 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_request.rb @@ -25,7 +25,8 @@ def initialize(function_signature:, additional_properties: nil) # @return [V2::Problem::GetFunctionSignatureRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - function_signature = struct.functionSignature + function_signature = struct.functionSignature.to_h.to_json + function_signature = V2::Problem::FunctionSignature.from_json(json_object: function_signature) new(function_signature: function_signature, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_response.rb index 61ba6f1e705..c56d8438b0a 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_function_signature_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../commons/types/language" module SeedTraceClient module V2 @@ -8,11 +9,11 @@ module Problem class GetFunctionSignatureResponse attr_reader :function_by_language, :additional_properties - # @param function_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param function_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::Problem::GetFunctionSignatureResponse] def initialize(function_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @function_by_language = function_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -24,7 +25,10 @@ def initialize(function_by_language:, additional_properties: nil) # @return [V2::Problem::GetFunctionSignatureResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - function_by_language = struct.functionByLanguage + function_by_language = struct.functionByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(function_by_language: function_by_language, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_file_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_file_request.rb index 0f6c3ac704f..cfce4000133 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_file_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_file_request.rb @@ -29,8 +29,10 @@ def initialize(test_case:, template: nil, additional_properties: nil) # @return [V2::Problem::GetGeneratedTestCaseFileRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - template = struct.template - test_case = struct.testCase + template = struct.template.to_h.to_json + template = V2::Problem::TestCaseTemplate.from_json(json_object: template) + test_case = struct.testCase.to_h.to_json + test_case = V2::Problem::TestCaseV2.from_json(json_object: test_case) new(template: template, test_case: test_case, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request.rb index 2ecb7683285..8ba5a6ad4a3 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request.rb @@ -25,7 +25,8 @@ def initialize(template:, additional_properties: nil) # @return [V2::Problem::GetGeneratedTestCaseTemplateFileRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - template = struct.template + template = struct.template.to_h.to_json + template = V2::Problem::TestCaseTemplate.from_json(json_object: template) new(template: template, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2.rb index 8bad0d2dcd7..f0d59f057d3 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require_relative "../../../commons/types/problem_id" -require "json" require "set" +require "json" module SeedTraceClient module V2 @@ -38,7 +38,8 @@ def self.from_json(json_object:) problem_id = struct.problemId problem_name = struct.problemName problem_version = struct.problemVersion - variable_types = struct.variableTypes + variable_types = struct.variableTypes.to_h.to_json + variable_types = Set.new(variable_types) new(problem_id: problem_id, problem_name: problem_name, problem_version: problem_version, variable_types: variable_types, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_definition.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_definition.rb index f8c4e57345c..7d04109f0c1 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_definition.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_definition.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "non_void_function_signature" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -30,8 +29,10 @@ def initialize(signature:, code:, additional_properties: nil) # @return [V2::Problem::NonVoidFunctionDefinition] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - signature = struct.signature - code = struct.code + signature = struct.signature.to_h.to_json + signature = V2::Problem::NonVoidFunctionSignature.from_json(json_object: signature) + code = struct.code.to_h.to_json + code = V2::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(signature: signature, code: code, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_signature.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_signature.rb index 7f53bfa0423..96e81c06a2f 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_signature.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/non_void_function_signature.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../commons/types/variable_type" - require_relative "parameter" +require_relative "../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -30,8 +29,12 @@ def initialize(parameters:, return_type:, additional_properties: nil) # @return [V2::Problem::NonVoidFunctionSignature] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - return_type = struct.returnType + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end + return_type = struct.returnType.to_h.to_json + return_type = Commons::VariableType.from_json(json_object: return_type) new(parameters: parameters, return_type: return_type, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/parameter.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/parameter.rb index c1c30bed814..96d2a6f2783 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/parameter.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/parameter.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../commons/types/variable_type" - require_relative "parameter_id" +require_relative "../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -35,7 +34,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parameter_id = struct.parameterId name = struct.name - variable_type = struct.variableType + variable_type = struct.variableType.to_h.to_json + variable_type = Commons::VariableType.from_json(json_object: variable_type) new(parameter_id: parameter_id, name: name, variable_type: variable_type, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/problem_info_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/problem_info_v_2.rb index 81d538cb067..7990ce625b0 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/problem_info_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/problem_info_v_2.rb @@ -20,7 +20,7 @@ class ProblemInfoV2 # @param problem_description [Problem::ProblemDescription] # @param problem_name [String] # @param problem_version [Integer] - # @param supported_languages [Set] + # @param supported_languages [Set] # @param custom_files [V2::Problem::CustomFiles] # @param generated_files [V2::Problem::GeneratedFiles] # @param custom_test_case_templates [Array] @@ -38,7 +38,7 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version @problem_name = problem_name # @type [Integer] @problem_version = problem_version - # @type [Set] + # @type [Set] @supported_languages = supported_languages # @type [V2::Problem::CustomFiles] @custom_files = custom_files @@ -61,14 +61,24 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_id = struct.problemId - problem_description = struct.problemDescription + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) problem_name = struct.problemName problem_version = struct.problemVersion - supported_languages = struct.supportedLanguages - custom_files = struct.customFiles - generated_files = struct.generatedFiles - custom_test_case_templates = struct.customTestCaseTemplates - testcases = struct.testcases + supported_languages = struct.supportedLanguages.to_h.to_json + supported_languages = Set.new(supported_languages) + custom_files = struct.customFiles.to_h.to_json + custom_files = V2::Problem::CustomFiles.from_json(json_object: custom_files) + generated_files = struct.generatedFiles.to_h.to_json + generated_files = V2::Problem::GeneratedFiles.from_json(json_object: generated_files) + custom_test_case_templates = struct.customTestCaseTemplates.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseTemplate.from_json(json_object: v) + end + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseV2.from_json(json_object: v) + end is_public = struct.isPublic new(problem_id: problem_id, problem_description: problem_description, problem_name: problem_name, problem_version: problem_version, supported_languages: supported_languages, custom_files: custom_files, generated_files: generated_files, custom_test_case_templates: custom_test_case_templates, testcases: testcases, is_public: is_public, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation.rb index c452d516190..53dee0c4deb 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "test_case_function" - require_relative "test_case_implementation_description" +require_relative "test_case_function" require "json" module SeedTraceClient @@ -30,8 +29,10 @@ def initialize(description:, function:, additional_properties: nil) # @return [V2::Problem::TestCaseImplementation] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - description = struct.description - function = struct.function + description = struct.description.to_h.to_json + description = V2::Problem::TestCaseImplementationDescription.from_json(json_object: description) + function = struct.function.to_h.to_json + function = V2::Problem::TestCaseFunction.from_json(json_object: function) new(description: description, function: function, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation_description.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation_description.rb index 45f7df54ccf..e6196f66dbd 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation_description.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_implementation_description.rb @@ -25,7 +25,10 @@ def initialize(boards:, additional_properties: nil) # @return [V2::Problem::TestCaseImplementationDescription] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - boards = struct.boards + boards = struct.boards.map do |v| + v = v.to_h.to_json + V2::Problem::TestCaseImplementationDescriptionBoard.from_json(json_object: v) + end new(boards: boards, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_template.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_template.rb index c597fda32be..760bb47cb34 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_template.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_template.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "test_case_implementation" - require_relative "test_case_template_id" +require_relative "test_case_implementation" require "json" module SeedTraceClient @@ -35,7 +34,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) template_id = struct.templateId name = struct.name - implementation = struct.implementation + implementation = struct.implementation.to_h.to_json + implementation = V2::Problem::TestCaseImplementation.from_json(json_object: implementation) new(template_id: template_id, name: name, implementation: implementation, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_v_2.rb index 47d19c9cf35..4d4d332c223 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_v_2.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "test_case_metadata" require_relative "test_case_implementation_reference" - require_relative "test_case_expects" -require_relative "test_case_metadata" require "json" module SeedTraceClient @@ -37,10 +36,13 @@ def initialize(metadata:, implementation:, arguments:, expects: nil, additional_ # @return [V2::Problem::TestCaseV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - metadata = struct.metadata - implementation = struct.implementation + metadata = struct.metadata.to_h.to_json + metadata = V2::Problem::TestCaseMetadata.from_json(json_object: metadata) + implementation = struct.implementation.to_h.to_json + implementation = V2::Problem::TestCaseImplementationReference.from_json(json_object: implementation) arguments = struct.arguments - expects = struct.expects + expects = struct.expects.to_h.to_json + expects = V2::Problem::TestCaseExpects.from_json(json_object: expects) new(metadata: metadata, implementation: implementation, arguments: arguments, expects: expects, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation.rb index c63348ac4c2..8a775905a1f 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "assert_correctness_check" - require_relative "non_void_function_definition" +require_relative "assert_correctness_check" require "json" module SeedTraceClient @@ -30,8 +29,10 @@ def initialize(get_actual_result:, assert_correctness_check:, additional_propert # @return [V2::Problem::TestCaseWithActualResultImplementation] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - get_actual_result = struct.getActualResult - assert_correctness_check = struct.assertCorrectnessCheck + get_actual_result = struct.getActualResult.to_h.to_json + get_actual_result = V2::Problem::NonVoidFunctionDefinition.from_json(json_object: get_actual_result) + assert_correctness_check = struct.assertCorrectnessCheck.to_h.to_json + assert_correctness_check = V2::Problem::AssertCorrectnessCheck.from_json(json_object: assert_correctness_check) new(get_actual_result: get_actual_result, assert_correctness_check: assert_correctness_check, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition.rb index 8b098156c06..6ac0082945e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "parameter" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -30,8 +29,12 @@ def initialize(parameters:, code:, additional_properties: nil) # @return [V2::Problem::VoidFunctionDefinition] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - code = struct.code + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end + code = struct.code.to_h.to_json + code = V2::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(parameters: parameters, code: code, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result.rb index 449a4baf964..aa6c5eaa372 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "parameter" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(additional_parameters:, code:, additional_properties: nil) # @return [V2::Problem::VoidFunctionDefinitionThatTakesActualResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - additional_parameters = struct.additionalParameters - code = struct.code + additional_parameters = struct.additionalParameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end + code = struct.code.to_h.to_json + code = V2::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(additional_parameters: additional_parameters, code: code, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature.rb index 252e77ac96c..34d3a12a93d 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature.rb @@ -25,7 +25,10 @@ def initialize(parameters:, additional_properties: nil) # @return [V2::Problem::VoidFunctionSignature] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end new(parameters: parameters, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result.rb index f092b347788..b1974f7ae9a 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../commons/types/variable_type" - require_relative "parameter" +require_relative "../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -30,8 +29,12 @@ def initialize(parameters:, actual_result_type:, additional_properties: nil) # @return [V2::Problem::VoidFunctionSignatureThatTakesActualResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - actual_result_type = struct.actualResultType + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::Problem::Parameter.from_json(json_object: v) + end + actual_result_type = struct.actualResultType.to_h.to_json + actual_result_type = Commons::VariableType.from_json(json_object: actual_result_type) new(parameters: parameters, actual_result_type: actual_result_type, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/client.rb index d1bdae7eff3..c31915f6aef 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/client.rb @@ -1,27 +1,24 @@ # frozen_string_literal: true +require_relative "../../../requests" require_relative "problem/client" module SeedTraceClient module V2 module V3 class Client - attr_reader :request_client - - # @param client [RequestClient] - # @return [] - def initialize(client:) - @problem_client = ProblemClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [V2::V3::Client] + def initialize(request_client:) + @problem = V2::V3::ProblemClient.new(request_client: request_client) end end class AsyncClient - attr_reader :client - - # @param client [AsyncRequestClient] - # @return [] - def initialize(client:) - @async_problem_client = AsyncProblemClient.initialize(request_client: @request_client) + # @param request_client [RequestClient] + # @return [V2::V3::AsyncClient] + def initialize(request_client:) + @problem = V2::V3::AsyncProblemClient.new(request_client: request_client) end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/client.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/client.rb index cccdc7b0d45..7c0d1c17fcd 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/client.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/client.rb @@ -1,155 +1,194 @@ # frozen_string_literal: true -require_relative "../../../commons/types/problem_id" +require_relative "../../../../requests" require_relative "types/lightweight_problem_info_v_2" require_relative "types/problem_info_v_2" +require_relative "../../../commons/types/problem_id" require "async" module SeedTraceClient module V2 module V3 - module Problem - class ProblemClient - attr_reader :request_client + class ProblemClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ProblemClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [V2::V3::ProblemClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Array] - def get_lightweight_problems(request_options: nil) - response = @request_client.conn.get("/problems-v2/lightweight-problem-info") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.map do |v| - v = v.to_h.to_json - V2::V3::Problem::LightweightProblemInfoV2.from_json(json_object: v) + # Returns lightweight versions of all problems + # + # @param request_options [RequestOptions] + # @return [Array] + def get_lightweight_problems(request_options: nil) + response = @request_client.conn.get("/problems-v2/lightweight-problem-info") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + response.body.map do |v| + v = v.to_h.to_json + V2::V3::Problem::LightweightProblemInfoV2.from_json(json_object: v) + end + end - # @param request_options [RequestOptions] - # @return [Array] - def get_problems(request_options: nil) - response = @request_client.conn.get("/problems-v2/problem-info") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.map do |v| - v = v.to_h.to_json - V2::V3::Problem::ProblemInfoV2.from_json(json_object: v) + # Returns latest versions of all problems + # + # @param request_options [RequestOptions] + # @return [Array] + def get_problems(request_options: nil) + response = @request_client.conn.get("/problems-v2/problem-info") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + response.body.map do |v| + v = v.to_h.to_json + V2::V3::Problem::ProblemInfoV2.from_json(json_object: v) end + end - # @param problem_id [Commons::PROBLEM_ID] - # @param request_options [RequestOptions] - # @return [V2::V3::Problem::ProblemInfoV2] - def get_latest_problem(problem_id:, request_options: nil) - response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + # Returns latest version of a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param request_options [RequestOptions] + # @return [V2::V3::Problem::ProblemInfoV2] + def get_latest_problem(problem_id:, request_options: nil) + response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end - V2::V3::Problem::ProblemInfoV2.from_json(json_object: response) + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + V2::V3::Problem::ProblemInfoV2.from_json(json_object: response.body) + end - # @param problem_id [Commons::PROBLEM_ID] - # @param problem_version [Integer] - # @param request_options [RequestOptions] - # @return [V2::V3::Problem::ProblemInfoV2] - def get_problem_version(problem_id:, problem_version:, request_options: nil) - response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}/version/#{problem_version}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + # Returns requested version of a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param problem_version [Integer] + # @param request_options [RequestOptions] + # @return [V2::V3::Problem::ProblemInfoV2] + def get_problem_version(problem_id:, problem_version:, request_options: nil) + response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}/version/#{problem_version}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end - V2::V3::Problem::ProblemInfoV2.from_json(json_object: response) + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + V2::V3::Problem::ProblemInfoV2.from_json(json_object: response.body) end + end - class AsyncProblemClient - attr_reader :request_client + class AsyncProblemClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncProblemClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [V2::V3::AsyncProblemClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request_options [RequestOptions] - # @return [Array] - def get_lightweight_problems(request_options: nil) - Async.call do - response = @request_client.conn.get("/problems-v2/lightweight-problem-info") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.map do |v| - v = v.to_h.to_json - V2::V3::Problem::LightweightProblemInfoV2.from_json(json_object: v) + # Returns lightweight versions of all problems + # + # @param request_options [RequestOptions] + # @return [Array] + def get_lightweight_problems(request_options: nil) + Async do + response = @request_client.conn.get("/problems-v2/lightweight-problem-info") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + response.body.map do |v| + v = v.to_h.to_json + V2::V3::Problem::LightweightProblemInfoV2.from_json(json_object: v) end end + end - # @param request_options [RequestOptions] - # @return [Array] - def get_problems(request_options: nil) - Async.call do - response = @request_client.conn.get("/problems-v2/problem-info") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end - response.map do |v| - v = v.to_h.to_json - V2::V3::Problem::ProblemInfoV2.from_json(json_object: v) + # Returns latest versions of all problems + # + # @param request_options [RequestOptions] + # @return [Array] + def get_problems(request_options: nil) + Async do + response = @request_client.conn.get("/problems-v2/problem-info") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + response.body.map do |v| + v = v.to_h.to_json + V2::V3::Problem::ProblemInfoV2.from_json(json_object: v) end end + end - # @param problem_id [Commons::PROBLEM_ID] - # @param request_options [RequestOptions] - # @return [V2::V3::Problem::ProblemInfoV2] - def get_latest_problem(problem_id:, request_options: nil) - Async.call do - response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + # Returns latest version of a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param request_options [RequestOptions] + # @return [V2::V3::Problem::ProblemInfoV2] + def get_latest_problem(problem_id:, request_options: nil) + Async do + response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end - V2::V3::Problem::ProblemInfoV2.from_json(json_object: response) + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + V2::V3::Problem::ProblemInfoV2.from_json(json_object: response.body) end + end - # @param problem_id [Commons::PROBLEM_ID] - # @param problem_version [Integer] - # @param request_options [RequestOptions] - # @return [V2::V3::Problem::ProblemInfoV2] - def get_problem_version(problem_id:, problem_version:, request_options: nil) - Async.call do - response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}/version/#{problem_version}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers["Authorization"] = @request_client.token if @request_client.token.nil? - req.headers["X-Random-Header"] = @request_client.x_random_header if @request_client.x_random_header.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact + # Returns requested version of a problem + # + # @param problem_id [Commons::PROBLEM_ID] + # @param problem_version [Integer] + # @param request_options [RequestOptions] + # @return [V2::V3::Problem::ProblemInfoV2] + def get_problem_version(problem_id:, problem_version:, request_options: nil) + Async do + response = @request_client.conn.get("/problems-v2/problem-info/#{problem_id}/version/#{problem_version}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers["Authorization"] = request_options.token unless request_options&.token.nil? + unless request_options&.x_random_header.nil? + req.headers["X-Random-Header"] = + request_options.x_random_header end - V2::V3::Problem::ProblemInfoV2.from_json(json_object: response) + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end + V2::V3::Problem::ProblemInfoV2.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_custom_files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_custom_files.rb index b27bcfd063b..48dafd6541b 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_custom_files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_custom_files.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative "basic_test_case_template" - require_relative "non_void_function_signature" +require_relative "basic_test_case_template" require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -14,7 +14,7 @@ class BasicCustomFiles # @param method_name [String] # @param signature [V2::V3::Problem::NonVoidFunctionSignature] - # @param additional_files [Hash{LANGUAGE => LANGUAGE}] + # @param additional_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param basic_test_case_template [V2::V3::Problem::BasicTestCaseTemplate] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::BasicCustomFiles] @@ -24,7 +24,7 @@ def initialize(method_name:, signature:, additional_files:, basic_test_case_temp @method_name = method_name # @type [V2::V3::Problem::NonVoidFunctionSignature] @signature = signature - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @additional_files = additional_files # @type [V2::V3::Problem::BasicTestCaseTemplate] @basic_test_case_template = basic_test_case_template @@ -39,9 +39,14 @@ def initialize(method_name:, signature:, additional_files:, basic_test_case_temp def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName - signature = struct.signature - additional_files = struct.additionalFiles - basic_test_case_template = struct.basicTestCaseTemplate + signature = struct.signature.to_h.to_json + signature = V2::V3::Problem::NonVoidFunctionSignature.from_json(json_object: signature) + additional_files = struct.additionalFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + basic_test_case_template = struct.basicTestCaseTemplate.to_h.to_json + basic_test_case_template = V2::V3::Problem::BasicTestCaseTemplate.from_json(json_object: basic_test_case_template) new(method_name: method_name, signature: signature, additional_files: additional_files, basic_test_case_template: basic_test_case_template, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_test_case_template.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_test_case_template.rb index d80a2135b69..5c56e3a71d3 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_test_case_template.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/basic_test_case_template.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "test_case_template_id" require_relative "test_case_implementation_description" - require_relative "parameter_id" -require_relative "test_case_template_id" require "json" module SeedTraceClient @@ -40,7 +39,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) template_id = struct.templateId name = struct.name - description = struct.description + description = struct.description.to_h.to_json + description = V2::V3::Problem::TestCaseImplementationDescription.from_json(json_object: description) expected_value_parameter_id = struct.expectedValueParameterId new(template_id: template_id, name: name, description: description, expected_value_parameter_id: expected_value_parameter_id, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2.rb index 7a27afd7c82..fc141b10c99 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2.rb @@ -4,8 +4,8 @@ require_relative "custom_files" require_relative "test_case_template" require_relative "test_case_v_2" -require "json" require "set" +require "json" module SeedTraceClient module V2 @@ -20,7 +20,7 @@ class CreateProblemRequestV2 # @param custom_files [V2::V3::Problem::CustomFiles] # @param custom_test_case_templates [Array] # @param testcases [Array] - # @param supported_languages [Set] + # @param supported_languages [Set] # @param is_public [Boolean] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::CreateProblemRequestV2] @@ -36,7 +36,7 @@ def initialize(problem_name:, problem_description:, custom_files:, custom_test_c @custom_test_case_templates = custom_test_case_templates # @type [Array] @testcases = testcases - # @type [Set] + # @type [Set] @supported_languages = supported_languages # @type [Boolean] @is_public = is_public @@ -51,11 +51,20 @@ def initialize(problem_name:, problem_description:, custom_files:, custom_test_c def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_name = struct.problemName - problem_description = struct.problemDescription - custom_files = struct.customFiles - custom_test_case_templates = struct.customTestCaseTemplates - testcases = struct.testcases - supported_languages = struct.supportedLanguages + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) + custom_files = struct.customFiles.to_h.to_json + custom_files = V2::V3::Problem::CustomFiles.from_json(json_object: custom_files) + custom_test_case_templates = struct.customTestCaseTemplates.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseTemplate.from_json(json_object: v) + end + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseV2.from_json(json_object: v) + end + supported_languages = struct.supportedLanguages.to_h.to_json + supported_languages = Set.new(supported_languages) is_public = struct.isPublic new(problem_name: problem_name, problem_description: problem_description, custom_files: custom_files, custom_test_case_templates: custom_test_case_templates, testcases: testcases, supported_languages: supported_languages, is_public: is_public, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/custom_files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/custom_files.rb index 4f17c77a803..98a281ba9d3 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/custom_files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/custom_files.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" require_relative "basic_custom_files" module SeedTraceClient @@ -34,7 +35,7 @@ def self.from_json(json_object:) when "custom" json_object.value.transform_values do |_k, v| v = v.to_h.to_json - LANGUAGE.key(v) + Commons::LANGUAGE.key(v) || v end else V2::V3::Problem::BasicCustomFiles.from_json(json_object: json_object) @@ -86,7 +87,7 @@ def self.basic(member:) new(member: member, discriminant: "basic") end - # @param member [Hash{LANGUAGE => LANGUAGE}] + # @param member [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @return [V2::V3::Problem::CustomFiles] def self.custom(member:) new(member: member, discriminant: "custom") diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/default_provided_file.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/default_provided_file.rb index f16a1567aed..9afb7280ee2 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/default_provided_file.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/default_provided_file.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../../commons/types/variable_type" - require_relative "file_info_v_2" +require_relative "../../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(file:, related_types:, additional_properties: nil) # @return [V2::V3::Problem::DefaultProvidedFile] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - file = struct.file - related_types = struct.relatedTypes + file = struct.file.to_h.to_json + file = V2::V3::Problem::FileInfoV2.from_json(json_object: file) + related_types = struct.relatedTypes.map do |v| + v = v.to_h.to_json + Commons::VariableType.from_json(json_object: v) + end new(file: file, related_types: related_types, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/files.rb index b6e584cec41..0a3373ec24d 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/files.rb @@ -26,7 +26,10 @@ def initialize(files:, additional_properties: nil) # @return [V2::V3::Problem::Files] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - files = struct.files + files = struct.files.map do |v| + v = v.to_h.to_json + V2::V3::Problem::FileInfoV2.from_json(json_object: v) + end new(files: files, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb index 38ededfd429..954d1c7ec9d 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -9,11 +10,11 @@ module Problem class FunctionImplementationForMultipleLanguages attr_reader :code_by_language, :additional_properties - # @param code_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param code_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::FunctionImplementationForMultipleLanguages] def initialize(code_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @code_by_language = code_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -25,7 +26,10 @@ def initialize(code_by_language:, additional_properties: nil) # @return [V2::V3::Problem::FunctionImplementationForMultipleLanguages] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - code_by_language = struct.codeByLanguage + code_by_language = struct.codeByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(code_by_language: code_by_language, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_signature.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_signature.rb index ecf58560440..5e3d211d979 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_signature.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/function_signature.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "json" -require_relative "non_void_function_signature" require_relative "void_function_signature" +require_relative "non_void_function_signature" require_relative "void_function_signature_that_takes_actual_result" module SeedTraceClient diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/generated_files.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/generated_files.rb index b7c2cedd8a6..261f18ec439 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/generated_files.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/generated_files.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -9,17 +10,17 @@ module Problem class GeneratedFiles attr_reader :generated_test_case_files, :generated_template_files, :other, :additional_properties - # @param generated_test_case_files [Hash{LANGUAGE => LANGUAGE}] - # @param generated_template_files [Hash{LANGUAGE => LANGUAGE}] - # @param other [Hash{LANGUAGE => LANGUAGE}] + # @param generated_test_case_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + # @param generated_template_files [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] + # @param other [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::GeneratedFiles] def initialize(generated_test_case_files:, generated_template_files:, other:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @generated_test_case_files = generated_test_case_files - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @generated_template_files = generated_template_files - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @other = other # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -31,9 +32,18 @@ def initialize(generated_test_case_files:, generated_template_files:, other:, ad # @return [V2::V3::Problem::GeneratedFiles] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - generated_test_case_files = struct.generatedTestCaseFiles - generated_template_files = struct.generatedTemplateFiles - other = struct.other + generated_test_case_files = struct.generatedTestCaseFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + generated_template_files = struct.generatedTemplateFiles.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end + other = struct.other.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(generated_test_case_files: generated_test_case_files, generated_template_files: generated_template_files, other: other, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request.rb index 0fa5c6c4f6e..3a1d24854da 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request.rb @@ -30,7 +30,8 @@ def initialize(method_name:, signature:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) method_name = struct.methodName - signature = struct.signature + signature = struct.signature.to_h.to_json + signature = V2::V3::Problem::NonVoidFunctionSignature.from_json(json_object: signature) new(method_name: method_name, signature: signature, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response.rb index d50a74cc303..28b16757b4e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -9,11 +10,11 @@ module Problem class GetBasicSolutionFileResponse attr_reader :solution_file_by_language, :additional_properties - # @param solution_file_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param solution_file_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::GetBasicSolutionFileResponse] def initialize(solution_file_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @solution_file_by_language = solution_file_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -25,7 +26,10 @@ def initialize(solution_file_by_language:, additional_properties: nil) # @return [V2::V3::Problem::GetBasicSolutionFileResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - solution_file_by_language = struct.solutionFileByLanguage + solution_file_by_language = struct.solutionFileByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(solution_file_by_language: solution_file_by_language, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_request.rb index 38d3009c2ab..3f81b49e6ef 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_request.rb @@ -26,7 +26,8 @@ def initialize(function_signature:, additional_properties: nil) # @return [V2::V3::Problem::GetFunctionSignatureRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - function_signature = struct.functionSignature + function_signature = struct.functionSignature.to_h.to_json + function_signature = V2::V3::Problem::FunctionSignature.from_json(json_object: function_signature) new(function_signature: function_signature, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_response.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_response.rb index 3b5e07b3478..91dca9a1159 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_response.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_function_signature_response.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "json" +require_relative "../../../../commons/types/language" module SeedTraceClient module V2 @@ -9,11 +10,11 @@ module Problem class GetFunctionSignatureResponse attr_reader :function_by_language, :additional_properties - # @param function_by_language [Hash{LANGUAGE => LANGUAGE}] + # @param function_by_language [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [V2::V3::Problem::GetFunctionSignatureResponse] def initialize(function_by_language:, additional_properties: nil) - # @type [Hash{LANGUAGE => LANGUAGE}] + # @type [Hash{Commons::LANGUAGE => Commons::LANGUAGE}] @function_by_language = function_by_language # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -25,7 +26,10 @@ def initialize(function_by_language:, additional_properties: nil) # @return [V2::V3::Problem::GetFunctionSignatureResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - function_by_language = struct.functionByLanguage + function_by_language = struct.functionByLanguage.transform_values do |_k, v| + v = v.to_h.to_json + Commons::LANGUAGE.key(v) || v + end new(function_by_language: function_by_language, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request.rb index ec8d2cab576..bf38759990e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request.rb @@ -30,8 +30,10 @@ def initialize(test_case:, template: nil, additional_properties: nil) # @return [V2::V3::Problem::GetGeneratedTestCaseFileRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - template = struct.template - test_case = struct.testCase + template = struct.template.to_h.to_json + template = V2::V3::Problem::TestCaseTemplate.from_json(json_object: template) + test_case = struct.testCase.to_h.to_json + test_case = V2::V3::Problem::TestCaseV2.from_json(json_object: test_case) new(template: template, test_case: test_case, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request.rb index a590e0aa3a2..20d3460e126 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request.rb @@ -26,7 +26,8 @@ def initialize(template:, additional_properties: nil) # @return [V2::V3::Problem::GetGeneratedTestCaseTemplateFileRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - template = struct.template + template = struct.template.to_h.to_json + template = V2::V3::Problem::TestCaseTemplate.from_json(json_object: template) new(template: template, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb index 72b225abab4..afd08ac6c22 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require_relative "../../../../commons/types/problem_id" -require "json" require "set" +require "json" module SeedTraceClient module V2 @@ -39,7 +39,8 @@ def self.from_json(json_object:) problem_id = struct.problemId problem_name = struct.problemName problem_version = struct.problemVersion - variable_types = struct.variableTypes + variable_types = struct.variableTypes.to_h.to_json + variable_types = Set.new(variable_types) new(problem_id: problem_id, problem_name: problem_name, problem_version: problem_version, variable_types: variable_types, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_definition.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_definition.rb index fc5f7e71b83..f3db2d63caf 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_definition.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_definition.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "non_void_function_signature" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -31,8 +30,10 @@ def initialize(signature:, code:, additional_properties: nil) # @return [V2::V3::Problem::NonVoidFunctionDefinition] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - signature = struct.signature - code = struct.code + signature = struct.signature.to_h.to_json + signature = V2::V3::Problem::NonVoidFunctionSignature.from_json(json_object: signature) + code = struct.code.to_h.to_json + code = V2::V3::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(signature: signature, code: code, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_signature.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_signature.rb index e879fbbe8ac..c67c1414b49 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_signature.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/non_void_function_signature.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../../commons/types/variable_type" - require_relative "parameter" +require_relative "../../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(parameters:, return_type:, additional_properties: nil) # @return [V2::V3::Problem::NonVoidFunctionSignature] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - return_type = struct.returnType + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end + return_type = struct.returnType.to_h.to_json + return_type = Commons::VariableType.from_json(json_object: return_type) new(parameters: parameters, return_type: return_type, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/parameter.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/parameter.rb index e9fe721aad7..9d5a9607a2e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/parameter.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/parameter.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../../commons/types/variable_type" - require_relative "parameter_id" +require_relative "../../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -36,7 +35,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parameter_id = struct.parameterId name = struct.name - variable_type = struct.variableType + variable_type = struct.variableType.to_h.to_json + variable_type = Commons::VariableType.from_json(json_object: variable_type) new(parameter_id: parameter_id, name: name, variable_type: variable_type, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/problem_info_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/problem_info_v_2.rb index 644fc5a8698..e8a0a9e4a53 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/problem_info_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/problem_info_v_2.rb @@ -21,7 +21,7 @@ class ProblemInfoV2 # @param problem_description [Problem::ProblemDescription] # @param problem_name [String] # @param problem_version [Integer] - # @param supported_languages [Set] + # @param supported_languages [Set] # @param custom_files [V2::V3::Problem::CustomFiles] # @param generated_files [V2::V3::Problem::GeneratedFiles] # @param custom_test_case_templates [Array] @@ -39,7 +39,7 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version @problem_name = problem_name # @type [Integer] @problem_version = problem_version - # @type [Set] + # @type [Set] @supported_languages = supported_languages # @type [V2::V3::Problem::CustomFiles] @custom_files = custom_files @@ -62,14 +62,24 @@ def initialize(problem_id:, problem_description:, problem_name:, problem_version def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) problem_id = struct.problemId - problem_description = struct.problemDescription + problem_description = struct.problemDescription.to_h.to_json + problem_description = Problem::ProblemDescription.from_json(json_object: problem_description) problem_name = struct.problemName problem_version = struct.problemVersion - supported_languages = struct.supportedLanguages - custom_files = struct.customFiles - generated_files = struct.generatedFiles - custom_test_case_templates = struct.customTestCaseTemplates - testcases = struct.testcases + supported_languages = struct.supportedLanguages.to_h.to_json + supported_languages = Set.new(supported_languages) + custom_files = struct.customFiles.to_h.to_json + custom_files = V2::V3::Problem::CustomFiles.from_json(json_object: custom_files) + generated_files = struct.generatedFiles.to_h.to_json + generated_files = V2::V3::Problem::GeneratedFiles.from_json(json_object: generated_files) + custom_test_case_templates = struct.customTestCaseTemplates.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseTemplate.from_json(json_object: v) + end + testcases = struct.testcases.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseV2.from_json(json_object: v) + end is_public = struct.isPublic new(problem_id: problem_id, problem_description: problem_description, problem_name: problem_name, problem_version: problem_version, supported_languages: supported_languages, custom_files: custom_files, generated_files: generated_files, custom_test_case_templates: custom_test_case_templates, testcases: testcases, is_public: is_public, additional_properties: struct) diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation.rb index 32943b7d2df..1585f07224a 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "test_case_function" - require_relative "test_case_implementation_description" +require_relative "test_case_function" require "json" module SeedTraceClient @@ -31,8 +30,10 @@ def initialize(description:, function:, additional_properties: nil) # @return [V2::V3::Problem::TestCaseImplementation] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - description = struct.description - function = struct.function + description = struct.description.to_h.to_json + description = V2::V3::Problem::TestCaseImplementationDescription.from_json(json_object: description) + function = struct.function.to_h.to_json + function = V2::V3::Problem::TestCaseFunction.from_json(json_object: function) new(description: description, function: function, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description.rb index e06c055afaa..f38667971e9 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description.rb @@ -26,7 +26,10 @@ def initialize(boards:, additional_properties: nil) # @return [V2::V3::Problem::TestCaseImplementationDescription] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - boards = struct.boards + boards = struct.boards.map do |v| + v = v.to_h.to_json + V2::V3::Problem::TestCaseImplementationDescriptionBoard.from_json(json_object: v) + end new(boards: boards, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_template.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_template.rb index c6316487013..51da6190aa7 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_template.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_template.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "test_case_implementation" - require_relative "test_case_template_id" +require_relative "test_case_implementation" require "json" module SeedTraceClient @@ -36,7 +35,8 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) template_id = struct.templateId name = struct.name - implementation = struct.implementation + implementation = struct.implementation.to_h.to_json + implementation = V2::V3::Problem::TestCaseImplementation.from_json(json_object: implementation) new(template_id: template_id, name: name, implementation: implementation, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_v_2.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_v_2.rb index 72a05cec0ae..af628708248 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_v_2.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_v_2.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true +require_relative "test_case_metadata" require_relative "test_case_implementation_reference" - require_relative "test_case_expects" -require_relative "test_case_metadata" require "json" module SeedTraceClient @@ -38,10 +37,13 @@ def initialize(metadata:, implementation:, arguments:, expects: nil, additional_ # @return [V2::V3::Problem::TestCaseV2] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - metadata = struct.metadata - implementation = struct.implementation + metadata = struct.metadata.to_h.to_json + metadata = V2::V3::Problem::TestCaseMetadata.from_json(json_object: metadata) + implementation = struct.implementation.to_h.to_json + implementation = V2::V3::Problem::TestCaseImplementationReference.from_json(json_object: implementation) arguments = struct.arguments - expects = struct.expects + expects = struct.expects.to_h.to_json + expects = V2::V3::Problem::TestCaseExpects.from_json(json_object: expects) new(metadata: metadata, implementation: implementation, arguments: arguments, expects: expects, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb index d0ec5cfb68a..67d025fb24e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "assert_correctness_check" - require_relative "non_void_function_definition" +require_relative "assert_correctness_check" require "json" module SeedTraceClient @@ -31,8 +30,10 @@ def initialize(get_actual_result:, assert_correctness_check:, additional_propert # @return [V2::V3::Problem::TestCaseWithActualResultImplementation] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - get_actual_result = struct.getActualResult - assert_correctness_check = struct.assertCorrectnessCheck + get_actual_result = struct.getActualResult.to_h.to_json + get_actual_result = V2::V3::Problem::NonVoidFunctionDefinition.from_json(json_object: get_actual_result) + assert_correctness_check = struct.assertCorrectnessCheck.to_h.to_json + assert_correctness_check = V2::V3::Problem::AssertCorrectnessCheck.from_json(json_object: assert_correctness_check) new(get_actual_result: get_actual_result, assert_correctness_check: assert_correctness_check, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition.rb index 82b0021611d..7b017a4a563 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "parameter" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(parameters:, code:, additional_properties: nil) # @return [V2::V3::Problem::VoidFunctionDefinition] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - code = struct.code + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end + code = struct.code.to_h.to_json + code = V2::V3::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(parameters: parameters, code: code, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb index 40c5ebc86e6..cacc38cffee 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "function_implementation_for_multiple_languages" - require_relative "parameter" +require_relative "function_implementation_for_multiple_languages" require "json" module SeedTraceClient @@ -32,8 +31,12 @@ def initialize(additional_parameters:, code:, additional_properties: nil) # @return [V2::V3::Problem::VoidFunctionDefinitionThatTakesActualResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - additional_parameters = struct.additionalParameters - code = struct.code + additional_parameters = struct.additionalParameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end + code = struct.code.to_h.to_json + code = V2::V3::Problem::FunctionImplementationForMultipleLanguages.from_json(json_object: code) new(additional_parameters: additional_parameters, code: code, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature.rb index 2f492cfd05f..c30b073c76f 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature.rb @@ -26,7 +26,10 @@ def initialize(parameters:, additional_properties: nil) # @return [V2::V3::Problem::VoidFunctionSignature] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end new(parameters: parameters, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb index 633c9ec83f1..66730c7ef1e 100644 --- a/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb +++ b/seed/ruby-sdk/trace/lib/seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require_relative "../../../../commons/types/variable_type" - require_relative "parameter" +require_relative "../../../../commons/types/variable_type" require "json" module SeedTraceClient @@ -31,8 +30,12 @@ def initialize(parameters:, actual_result_type:, additional_properties: nil) # @return [V2::V3::Problem::VoidFunctionSignatureThatTakesActualResult] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parameters = struct.parameters - actual_result_type = struct.actualResultType + parameters = struct.parameters.map do |v| + v = v.to_h.to_json + V2::V3::Problem::Parameter.from_json(json_object: v) + end + actual_result_type = struct.actualResultType.to_h.to_json + actual_result_type = Commons::VariableType.from_json(json_object: actual_result_type) new(parameters: parameters, actual_result_type: actual_result_type, additional_properties: struct) end diff --git a/seed/ruby-sdk/trace/lib/types_export.rb b/seed/ruby-sdk/trace/lib/types_export.rb new file mode 100644 index 00000000000..429fa75cd1e --- /dev/null +++ b/seed/ruby-sdk/trace/lib/types_export.rb @@ -0,0 +1,212 @@ +# frozen_string_literal: true + +require_relative "seed_trace_client/admin/types/test" +require_relative "seed_trace_client/commons/types/user_id" +require_relative "seed_trace_client/commons/types/problem_id" +require_relative "seed_trace_client/commons/types/node_id" +require_relative "seed_trace_client/commons/types/variable_type" +require_relative "seed_trace_client/commons/types/list_type" +require_relative "seed_trace_client/commons/types/map_type" +require_relative "seed_trace_client/commons/types/variable_value" +require_relative "seed_trace_client/commons/types/debug_variable_value" +require_relative "seed_trace_client/commons/types/generic_value" +require_relative "seed_trace_client/commons/types/map_value" +require_relative "seed_trace_client/commons/types/key_value_pair" +require_relative "seed_trace_client/commons/types/binary_tree_value" +require_relative "seed_trace_client/commons/types/binary_tree_node_value" +require_relative "seed_trace_client/commons/types/binary_tree_node_and_tree_value" +require_relative "seed_trace_client/commons/types/singly_linked_list_value" +require_relative "seed_trace_client/commons/types/singly_linked_list_node_value" +require_relative "seed_trace_client/commons/types/singly_linked_list_node_and_list_value" +require_relative "seed_trace_client/commons/types/doubly_linked_list_value" +require_relative "seed_trace_client/commons/types/doubly_linked_list_node_value" +require_relative "seed_trace_client/commons/types/doubly_linked_list_node_and_list_value" +require_relative "seed_trace_client/commons/types/debug_map_value" +require_relative "seed_trace_client/commons/types/debug_key_value_pairs" +require_relative "seed_trace_client/commons/types/test_case" +require_relative "seed_trace_client/commons/types/test_case_with_expected_result" +require_relative "seed_trace_client/commons/types/file_info" +require_relative "seed_trace_client/commons/types/language" +require_relative "seed_trace_client/lang_server/types/lang_server_request" +require_relative "seed_trace_client/lang_server/types/lang_server_response" +require_relative "seed_trace_client/migration/types/migration_status" +require_relative "seed_trace_client/migration/types/migration" +require_relative "seed_trace_client/playlist/types/playlist_id" +require_relative "seed_trace_client/playlist/types/playlist" +require_relative "seed_trace_client/playlist/types/playlist_create_request" +require_relative "seed_trace_client/playlist/types/update_playlist_request" +require_relative "seed_trace_client/playlist/types/playlist_id_not_found_error_body" +require_relative "seed_trace_client/playlist/types/reserved_keyword_enum" +require_relative "seed_trace_client/problem/types/problem_info" +require_relative "seed_trace_client/problem/types/problem_description" +require_relative "seed_trace_client/problem/types/problem_description_board" +require_relative "seed_trace_client/problem/types/problem_files" +require_relative "seed_trace_client/problem/types/variable_type_and_name" +require_relative "seed_trace_client/problem/types/create_problem_request" +require_relative "seed_trace_client/problem/types/create_problem_response" +require_relative "seed_trace_client/problem/types/update_problem_response" +require_relative "seed_trace_client/problem/types/create_problem_error" +require_relative "seed_trace_client/problem/types/generic_create_problem_error" +require_relative "seed_trace_client/problem/types/get_default_starter_files_response" +require_relative "seed_trace_client/submission/types/submission_id" +require_relative "seed_trace_client/submission/types/share_id" +require_relative "seed_trace_client/submission/types/submission_request" +require_relative "seed_trace_client/submission/types/initialize_problem_request" +require_relative "seed_trace_client/submission/types/submit_request_v_2" +require_relative "seed_trace_client/submission/types/workspace_submit_request" +require_relative "seed_trace_client/submission/types/submission_file_info" +require_relative "seed_trace_client/submission/types/submission_type_enum" +require_relative "seed_trace_client/submission/types/stop_request" +require_relative "seed_trace_client/submission/types/submission_response" +require_relative "seed_trace_client/submission/types/code_execution_update" +require_relative "seed_trace_client/submission/types/building_executor_response" +require_relative "seed_trace_client/submission/types/running_response" +require_relative "seed_trace_client/submission/types/running_submission_state" +require_relative "seed_trace_client/submission/types/errored_response" +require_relative "seed_trace_client/submission/types/error_info" +require_relative "seed_trace_client/submission/types/compile_error" +require_relative "seed_trace_client/submission/types/runtime_error" +require_relative "seed_trace_client/submission/types/internal_error" +require_relative "seed_trace_client/submission/types/stopped_response" +require_relative "seed_trace_client/submission/types/workspace_ran_response" +require_relative "seed_trace_client/submission/types/workspace_run_details" +require_relative "seed_trace_client/submission/types/graded_response" +require_relative "seed_trace_client/submission/types/graded_response_v_2" +require_relative "seed_trace_client/submission/types/test_case_grade" +require_relative "seed_trace_client/submission/types/test_case_hidden_grade" +require_relative "seed_trace_client/submission/types/test_case_non_hidden_grade" +require_relative "seed_trace_client/submission/types/recorded_response_notification" +require_relative "seed_trace_client/submission/types/recording_response_notification" +require_relative "seed_trace_client/submission/types/lightweight_stackframe_information" +require_relative "seed_trace_client/submission/types/test_case_result_with_stdout" +require_relative "seed_trace_client/submission/types/test_case_result" +require_relative "seed_trace_client/submission/types/actual_result" +require_relative "seed_trace_client/submission/types/exception_v_2" +require_relative "seed_trace_client/submission/types/exception_info" +require_relative "seed_trace_client/submission/types/invalid_request_response" +require_relative "seed_trace_client/submission/types/invalid_request_cause" +require_relative "seed_trace_client/submission/types/existing_submission_executing" +require_relative "seed_trace_client/submission/types/submission_id_not_found" +require_relative "seed_trace_client/submission/types/custom_test_cases_unsupported" +require_relative "seed_trace_client/submission/types/unexpected_language_error" +require_relative "seed_trace_client/submission/types/terminated_response" +require_relative "seed_trace_client/submission/types/finished_response" +require_relative "seed_trace_client/submission/types/stdout_response" +require_relative "seed_trace_client/submission/types/stderr_response" +require_relative "seed_trace_client/submission/types/trace_response" +require_relative "seed_trace_client/submission/types/trace_response_v_2" +require_relative "seed_trace_client/submission/types/traced_file" +require_relative "seed_trace_client/submission/types/expression_location" +require_relative "seed_trace_client/submission/types/stack_information" +require_relative "seed_trace_client/submission/types/stack_frame" +require_relative "seed_trace_client/submission/types/scope" +require_relative "seed_trace_client/submission/types/execution_session_response" +require_relative "seed_trace_client/submission/types/execution_session_status" +require_relative "seed_trace_client/submission/types/submission_status_v_2" +require_relative "seed_trace_client/submission/types/test_submission_status_v_2" +require_relative "seed_trace_client/submission/types/workspace_submission_status_v_2" +require_relative "seed_trace_client/submission/types/test_submission_update" +require_relative "seed_trace_client/submission/types/test_submission_update_info" +require_relative "seed_trace_client/submission/types/workspace_submission_update" +require_relative "seed_trace_client/submission/types/workspace_submission_update_info" +require_relative "seed_trace_client/submission/types/graded_test_case_update" +require_relative "seed_trace_client/submission/types/recorded_test_case_update" +require_relative "seed_trace_client/submission/types/workspace_traced_update" +require_relative "seed_trace_client/submission/types/submission_type_state" +require_relative "seed_trace_client/submission/types/workspace_submission_state" +require_relative "seed_trace_client/submission/types/workspace_submission_status" +require_relative "seed_trace_client/submission/types/test_submission_state" +require_relative "seed_trace_client/submission/types/test_submission_status" +require_relative "seed_trace_client/submission/types/submission_status_for_test_case" +require_relative "seed_trace_client/submission/types/traced_test_case" +require_relative "seed_trace_client/submission/types/trace_responses_page" +require_relative "seed_trace_client/submission/types/trace_responses_page_v_2" +require_relative "seed_trace_client/submission/types/get_trace_responses_page_request" +require_relative "seed_trace_client/submission/types/workspace_starter_files_response" +require_relative "seed_trace_client/submission/types/workspace_starter_files_response_v_2" +require_relative "seed_trace_client/submission/types/workspace_files" +require_relative "seed_trace_client/submission/types/execution_session_state" +require_relative "seed_trace_client/submission/types/get_execution_session_state_response" +require_relative "seed_trace_client/submission/types/get_submission_state_response" +require_relative "seed_trace_client/v_2/problem/types/test_case_template_id" +require_relative "seed_trace_client/v_2/problem/types/test_case_id" +require_relative "seed_trace_client/v_2/problem/types/parameter_id" +require_relative "seed_trace_client/v_2/problem/types/problem_info_v_2" +require_relative "seed_trace_client/v_2/problem/types/lightweight_problem_info_v_2" +require_relative "seed_trace_client/v_2/problem/types/create_problem_request_v_2" +require_relative "seed_trace_client/v_2/problem/types/test_case_v_2" +require_relative "seed_trace_client/v_2/problem/types/test_case_expects" +require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_reference" +require_relative "seed_trace_client/v_2/problem/types/basic_test_case_template" +require_relative "seed_trace_client/v_2/problem/types/test_case_template" +require_relative "seed_trace_client/v_2/problem/types/test_case_implementation" +require_relative "seed_trace_client/v_2/problem/types/test_case_function" +require_relative "seed_trace_client/v_2/problem/types/test_case_with_actual_result_implementation" +require_relative "seed_trace_client/v_2/problem/types/void_function_definition" +require_relative "seed_trace_client/v_2/problem/types/parameter" +require_relative "seed_trace_client/v_2/problem/types/non_void_function_definition" +require_relative "seed_trace_client/v_2/problem/types/void_function_signature" +require_relative "seed_trace_client/v_2/problem/types/non_void_function_signature" +require_relative "seed_trace_client/v_2/problem/types/void_function_signature_that_takes_actual_result" +require_relative "seed_trace_client/v_2/problem/types/assert_correctness_check" +require_relative "seed_trace_client/v_2/problem/types/deep_equality_correctness_check" +require_relative "seed_trace_client/v_2/problem/types/void_function_definition_that_takes_actual_result" +require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_description" +require_relative "seed_trace_client/v_2/problem/types/test_case_implementation_description_board" +require_relative "seed_trace_client/v_2/problem/types/test_case_metadata" +require_relative "seed_trace_client/v_2/problem/types/function_implementation_for_multiple_languages" +require_relative "seed_trace_client/v_2/problem/types/function_implementation" +require_relative "seed_trace_client/v_2/problem/types/generated_files" +require_relative "seed_trace_client/v_2/problem/types/custom_files" +require_relative "seed_trace_client/v_2/problem/types/basic_custom_files" +require_relative "seed_trace_client/v_2/problem/types/files" +require_relative "seed_trace_client/v_2/problem/types/file_info_v_2" +require_relative "seed_trace_client/v_2/problem/types/default_provided_file" +require_relative "seed_trace_client/v_2/problem/types/function_signature" +require_relative "seed_trace_client/v_2/problem/types/get_function_signature_request" +require_relative "seed_trace_client/v_2/problem/types/get_function_signature_response" +require_relative "seed_trace_client/v_2/problem/types/get_basic_solution_file_request" +require_relative "seed_trace_client/v_2/problem/types/get_basic_solution_file_response" +require_relative "seed_trace_client/v_2/problem/types/get_generated_test_case_file_request" +require_relative "seed_trace_client/v_2/problem/types/get_generated_test_case_template_file_request" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_template_id" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_id" +require_relative "seed_trace_client/v_2/v_3/problem/types/parameter_id" +require_relative "seed_trace_client/v_2/v_3/problem/types/problem_info_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/lightweight_problem_info_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/create_problem_request_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_expects" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_reference" +require_relative "seed_trace_client/v_2/v_3/problem/types/basic_test_case_template" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_template" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_function" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_with_actual_result_implementation" +require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_definition" +require_relative "seed_trace_client/v_2/v_3/problem/types/parameter" +require_relative "seed_trace_client/v_2/v_3/problem/types/non_void_function_definition" +require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_signature" +require_relative "seed_trace_client/v_2/v_3/problem/types/non_void_function_signature" +require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result" +require_relative "seed_trace_client/v_2/v_3/problem/types/assert_correctness_check" +require_relative "seed_trace_client/v_2/v_3/problem/types/deep_equality_correctness_check" +require_relative "seed_trace_client/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_implementation_description_board" +require_relative "seed_trace_client/v_2/v_3/problem/types/test_case_metadata" +require_relative "seed_trace_client/v_2/v_3/problem/types/function_implementation_for_multiple_languages" +require_relative "seed_trace_client/v_2/v_3/problem/types/function_implementation" +require_relative "seed_trace_client/v_2/v_3/problem/types/generated_files" +require_relative "seed_trace_client/v_2/v_3/problem/types/custom_files" +require_relative "seed_trace_client/v_2/v_3/problem/types/basic_custom_files" +require_relative "seed_trace_client/v_2/v_3/problem/types/files" +require_relative "seed_trace_client/v_2/v_3/problem/types/file_info_v_2" +require_relative "seed_trace_client/v_2/v_3/problem/types/default_provided_file" +require_relative "seed_trace_client/v_2/v_3/problem/types/function_signature" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_function_signature_request" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_function_signature_response" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_request" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_basic_solution_file_response" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_file_request" +require_relative "seed_trace_client/v_2/v_3/problem/types/get_generated_test_case_template_file_request" diff --git a/seed/ruby-sdk/trace/seed_trace_client.gemspec b/seed/ruby-sdk/trace/seed_trace_client.gemspec index 98f9448cd92..e590a1d0cc2 100644 --- a/seed/ruby-sdk/trace/seed_trace_client.gemspec +++ b/seed/ruby-sdk/trace/seed_trace_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_trace_client" + spec.version = SeedTraceClient::Gemconfig::VERSION spec.authors = SeedTraceClient::Gemconfig::AUTHORS spec.email = SeedTraceClient::Gemconfig::EMAIL spec.summary = SeedTraceClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/undiscriminated-unions/.rubocop.yml b/seed/ruby-sdk/undiscriminated-unions/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/undiscriminated-unions/.rubocop.yml +++ b/seed/ruby-sdk/undiscriminated-unions/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/undiscriminated-unions/lib/gemconfig.rb b/seed/ruby-sdk/undiscriminated-unions/lib/gemconfig.rb index 6e6daafd733..3da2832afc4 100644 --- a/seed/ruby-sdk/undiscriminated-unions/lib/gemconfig.rb +++ b/seed/ruby-sdk/undiscriminated-unions/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedUndiscriminatedUnionsClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/undiscriminated-unions/lib/requests.rb b/seed/ruby-sdk/undiscriminated-unions/lib/requests.rb index 4ee419d8f82..2dea50f158a 100644 --- a/seed/ruby-sdk/undiscriminated-unions/lib/requests.rb +++ b/seed/ruby-sdk/undiscriminated-unions/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedUndiscriminatedUnionsClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedUndiscriminatedUnionsClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedUndiscriminatedUnionsClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/undiscriminated-unions/lib/seed_undiscriminated_unions_client.rb b/seed/ruby-sdk/undiscriminated-unions/lib/seed_undiscriminated_unions_client.rb index ff868a3ec40..db8bc4ef6cd 100644 --- a/seed/ruby-sdk/undiscriminated-unions/lib/seed_undiscriminated_unions_client.rb +++ b/seed/ruby-sdk/undiscriminated-unions/lib/seed_undiscriminated_unions_client.rb @@ -1,28 +1,31 @@ # frozen_string_literal: true -require_relative "seed_undiscriminated_unions_client/union/types/my_union" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_undiscriminated_unions_client/union/client" -require "async/http/faraday" module SeedUndiscriminatedUnionsClient class Client + attr_reader :union + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @union_client = UnionClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @union = UnionClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :union + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_union_client = AsyncUnionClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @union = AsyncUnionClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/undiscriminated-unions/lib/seed_undiscriminated_unions_client/union/client.rb b/seed/ruby-sdk/undiscriminated-unions/lib/seed_undiscriminated_unions_client/union/client.rb index 5702e51aa47..a64dc5c4951 100644 --- a/seed/ruby-sdk/undiscriminated-unions/lib/seed_undiscriminated_unions_client/union/client.rb +++ b/seed/ruby-sdk/undiscriminated-unions/lib/seed_undiscriminated_unions_client/union/client.rb @@ -1,55 +1,54 @@ # frozen_string_literal: true +require_relative "../../requests" require_relative "types/my_union" require "async" module SeedUndiscriminatedUnionsClient - module Union - class UnionClient - attr_reader :request_client + class UnionClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [UnionClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [UnionClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Union::MyUnion, as a Hash - # @param request_options [RequestOptions] - # @return [Union::MyUnion] - def get(request:, request_options: nil) - response = @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Union::MyUnion.from_json(json_object: response) + # @param request [Hash] Request of type Union::MyUnion, as a Hash + # @param request_options [RequestOptions] + # @return [Union::MyUnion] + def get(request:, request_options: nil) + response = @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Union::MyUnion.from_json(json_object: response.body) end + end - class AsyncUnionClient - attr_reader :request_client + class AsyncUnionClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncUnionClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncUnionClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Hash] Request of type Union::MyUnion, as a Hash - # @param request_options [RequestOptions] - # @return [Union::MyUnion] - def get(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - Union::MyUnion.from_json(json_object: response) + # @param request [Hash] Request of type Union::MyUnion, as a Hash + # @param request_options [RequestOptions] + # @return [Union::MyUnion] + def get(request:, request_options: nil) + Async do + response = @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + Union::MyUnion.from_json(json_object: response.body) end end end diff --git a/seed/ruby-sdk/undiscriminated-unions/lib/types_export.rb b/seed/ruby-sdk/undiscriminated-unions/lib/types_export.rb new file mode 100644 index 00000000000..bd157223172 --- /dev/null +++ b/seed/ruby-sdk/undiscriminated-unions/lib/types_export.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "seed_undiscriminated_unions_client/union/types/my_union" diff --git a/seed/ruby-sdk/undiscriminated-unions/seed_undiscriminated_unions_client.gemspec b/seed/ruby-sdk/undiscriminated-unions/seed_undiscriminated_unions_client.gemspec index c72daa283ff..c95c0ae5598 100644 --- a/seed/ruby-sdk/undiscriminated-unions/seed_undiscriminated_unions_client.gemspec +++ b/seed/ruby-sdk/undiscriminated-unions/seed_undiscriminated_unions_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_undiscriminated_unions_client" + spec.version = SeedUndiscriminatedUnionsClient::Gemconfig::VERSION spec.authors = SeedUndiscriminatedUnionsClient::Gemconfig::AUTHORS spec.email = SeedUndiscriminatedUnionsClient::Gemconfig::EMAIL spec.summary = SeedUndiscriminatedUnionsClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/unknown/.rubocop.yml b/seed/ruby-sdk/unknown/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/unknown/.rubocop.yml +++ b/seed/ruby-sdk/unknown/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/unknown/lib/gemconfig.rb b/seed/ruby-sdk/unknown/lib/gemconfig.rb index b8016256780..e8f5bfe739c 100644 --- a/seed/ruby-sdk/unknown/lib/gemconfig.rb +++ b/seed/ruby-sdk/unknown/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedUnknownAsAnyClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/unknown/lib/requests.rb b/seed/ruby-sdk/unknown/lib/requests.rb index 3a8e05645ee..a0ae5c25224 100644 --- a/seed/ruby-sdk/unknown/lib/requests.rb +++ b/seed/ruby-sdk/unknown/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedUnknownAsAnyClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedUnknownAsAnyClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedUnknownAsAnyClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/unknown/lib/seed_unknown_as_any_client.rb b/seed/ruby-sdk/unknown/lib/seed_unknown_as_any_client.rb index dace31c770d..51c87727b03 100644 --- a/seed/ruby-sdk/unknown/lib/seed_unknown_as_any_client.rb +++ b/seed/ruby-sdk/unknown/lib/seed_unknown_as_any_client.rb @@ -1,29 +1,31 @@ # frozen_string_literal: true -require_relative "seed_unknown_as_any_client/unknown/types/my_alias" -require_relative "seed_unknown_as_any_client/unknown/types/my_object" -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_unknown_as_any_client/unknown/client" -require "async/http/faraday" module SeedUnknownAsAnyClient class Client + attr_reader :unknown + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @unknown_client = UnknownClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @unknown = UnknownClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :unknown + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_unknown_client = AsyncUnknownClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @unknown = AsyncUnknownClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/unknown/lib/seed_unknown_as_any_client/unknown/client.rb b/seed/ruby-sdk/unknown/lib/seed_unknown_as_any_client/unknown/client.rb index d2d0feec7ee..dff4ff06c2b 100644 --- a/seed/ruby-sdk/unknown/lib/seed_unknown_as_any_client/unknown/client.rb +++ b/seed/ruby-sdk/unknown/lib/seed_unknown_as_any_client/unknown/client.rb @@ -1,53 +1,53 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedUnknownAsAnyClient - module Unknown - class UnknownClient - attr_reader :request_client + class UnknownClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [UnknownClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [UnknownClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Array] - def post(request:, request_options: nil) - @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Array] + def post(request:, request_options: nil) + response = @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end + end - class AsyncUnknownClient - attr_reader :request_client + class AsyncUnknownClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncUnknownClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncUnknownClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param request [Object] - # @param request_options [RequestOptions] - # @return [Array] - def post(request:, request_options: nil) - Async.call do - response = @request_client.conn.post("/") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - req.body = { **request, **request_options&.additional_body_parameters }.compact - end - response + # @param request [Object] + # @param request_options [RequestOptions] + # @return [Array] + def post(request:, request_options: nil) + Async do + response = @request_client.conn.post("/") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact end + response.body end end end diff --git a/seed/ruby-sdk/unknown/lib/types_export.rb b/seed/ruby-sdk/unknown/lib/types_export.rb new file mode 100644 index 00000000000..4d537ecfaa5 --- /dev/null +++ b/seed/ruby-sdk/unknown/lib/types_export.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +require_relative "seed_unknown_as_any_client/unknown/types/my_alias" +require_relative "seed_unknown_as_any_client/unknown/types/my_object" diff --git a/seed/ruby-sdk/unknown/seed_unknown_as_any_client.gemspec b/seed/ruby-sdk/unknown/seed_unknown_as_any_client.gemspec index 39ed6273fdc..b1b9bb71e7b 100644 --- a/seed/ruby-sdk/unknown/seed_unknown_as_any_client.gemspec +++ b/seed/ruby-sdk/unknown/seed_unknown_as_any_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_unknown_as_any_client" + spec.version = SeedUnknownAsAnyClient::Gemconfig::VERSION spec.authors = SeedUnknownAsAnyClient::Gemconfig::AUTHORS spec.email = SeedUnknownAsAnyClient::Gemconfig::EMAIL spec.summary = SeedUnknownAsAnyClient::Gemconfig::SUMMARY diff --git a/seed/ruby-sdk/variables/.rubocop.yml b/seed/ruby-sdk/variables/.rubocop.yml index 11b608523ad..c1d2344d6e6 100644 --- a/seed/ruby-sdk/variables/.rubocop.yml +++ b/seed/ruby-sdk/variables/.rubocop.yml @@ -4,9 +4,6 @@ AllCops: Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - -Style/RequireOrder: - Enabled: true Style/StringLiteralsInInterpolation: Enabled: true diff --git a/seed/ruby-sdk/variables/lib/gemconfig.rb b/seed/ruby-sdk/variables/lib/gemconfig.rb index 87961957426..4fcc169da55 100644 --- a/seed/ruby-sdk/variables/lib/gemconfig.rb +++ b/seed/ruby-sdk/variables/lib/gemconfig.rb @@ -2,6 +2,7 @@ module SeedVariablesClient module Gemconfig + VERSION = "" AUTHORS = [""].freeze EMAIL = "" SUMMARY = "" diff --git a/seed/ruby-sdk/variables/lib/requests.rb b/seed/ruby-sdk/variables/lib/requests.rb index 01230909430..513d94d71ac 100644 --- a/seed/ruby-sdk/variables/lib/requests.rb +++ b/seed/ruby-sdk/variables/lib/requests.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require "async/http/faraday" require "faraday" +require "faraday/retry" +require "async/http/faraday" module SeedVariablesClient class RequestClient @@ -14,9 +15,9 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedVariablesClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end @@ -31,33 +32,33 @@ def initialize(max_retries: nil, timeout_in_seconds: nil) @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "SeedVariablesClient" } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json - faraday.request :retry, { max: max_retries } faraday.response :raise_error, include_request: true - faraday.options.timeout = timeout_in_seconds - faraday.adapter = :async_http + faraday.adapter :async_http + faraday.request :retry, { max: max_retries } unless max_retries.nil? + faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end end # Additional options for request-specific configuration when calling APIs via the SDK. class RequestOptions - attr_reader :timeout_in_seconds, :additional_headers, :additional_query_parameters, :additional_body_parameters + attr_reader :additional_headers, :additional_query_parameters, :additional_body_parameters, :timeout_in_seconds - # @param timeout_in_seconds [Long] # @param additional_headers [Hash{String => Object}] # @param additional_query_parameters [Hash{String => Object}] # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] # @return [RequestOptions] - def initialize(timeout_in_seconds: nil, additional_headers: nil, additional_query_parameters: nil, - additional_body_parameters: nil) - # @type [Long] - @timeout_in_seconds = timeout_in_seconds + def initialize(additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, + timeout_in_seconds: nil) # @type [Hash{String => Object}] @additional_headers = additional_headers # @type [Hash{String => Object}] @additional_query_parameters = additional_query_parameters # @type [Hash{String => Object}] @additional_body_parameters = additional_body_parameters + # @type [Long] + @timeout_in_seconds = timeout_in_seconds end end end diff --git a/seed/ruby-sdk/variables/lib/seed_variables_client.rb b/seed/ruby-sdk/variables/lib/seed_variables_client.rb index c14a199af84..933c7d8ee9a 100644 --- a/seed/ruby-sdk/variables/lib/seed_variables_client.rb +++ b/seed/ruby-sdk/variables/lib/seed_variables_client.rb @@ -1,27 +1,31 @@ # frozen_string_literal: true -require "faraday" +require_relative "types_export" +require_relative "requests" require_relative "seed_variables_client/service/client" -require "async/http/faraday" module SeedVariablesClient class Client + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [Client] def initialize(max_retries: nil, timeout_in_seconds: nil) - request_client = RequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @service_client = ServiceClient.initialize(request_client: request_client) + @request_client = RequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = ServiceClient.new(request_client: @request_client) end end class AsyncClient + attr_reader :service + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. # @param timeout_in_seconds [Long] - # @return [] + # @return [AsyncClient] def initialize(max_retries: nil, timeout_in_seconds: nil) - AsyncRequestClient.initialize(headers: headers, base_url: base_url, conn: conn) - @async_service_client = AsyncServiceClient.initialize(request_client: request_client) + @async_request_client = AsyncRequestClient.new(max_retries: max_retries, timeout_in_seconds: timeout_in_seconds) + @service = AsyncServiceClient.new(request_client: @async_request_client) end end end diff --git a/seed/ruby-sdk/variables/lib/seed_variables_client/service/client.rb b/seed/ruby-sdk/variables/lib/seed_variables_client/service/client.rb index 8c31dfb636f..26044378694 100644 --- a/seed/ruby-sdk/variables/lib/seed_variables_client/service/client.rb +++ b/seed/ruby-sdk/variables/lib/seed_variables_client/service/client.rb @@ -1,49 +1,48 @@ # frozen_string_literal: true +require_relative "../../requests" require "async" module SeedVariablesClient - module Service - class ServiceClient - attr_reader :request_client + class ServiceClient + attr_reader :request_client - # @param request_client [RequestClient] - # @return [ServiceClient] - def initialize(request_client:) - # @type [RequestClient] - @request_client = request_client - end + # @param request_client [RequestClient] + # @return [ServiceClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end - # @param endpoint_param [String] - # @param request_options [RequestOptions] - # @return [Void] - def post(endpoint_param:, request_options: nil) - @request_client.conn.post("/#{endpoint_param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param endpoint_param [String] + # @param request_options [RequestOptions] + # @return [Void] + def post(endpoint_param:, request_options: nil) + @request_client.conn.post("/#{endpoint_param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end + end - class AsyncServiceClient - attr_reader :request_client + class AsyncServiceClient + attr_reader :request_client - # @param request_client [AsyncRequestClient] - # @return [AsyncServiceClient] - def initialize(request_client:) - # @type [AsyncRequestClient] - @request_client = request_client - end + # @param request_client [AsyncRequestClient] + # @return [AsyncServiceClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end - # @param endpoint_param [String] - # @param request_options [RequestOptions] - # @return [Void] - def post(endpoint_param:, request_options: nil) - Async.call do - @request_client.conn.post("/#{endpoint_param}") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options.timeout_in_seconds.nil? - req.headers = { **req.headers, **request_options&.additional_headers }.compact - end + # @param endpoint_param [String] + # @param request_options [RequestOptions] + # @return [Void] + def post(endpoint_param:, request_options: nil) + Async do + @request_client.conn.post("/#{endpoint_param}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact end end end diff --git a/seed/ruby-sdk/variables/lib/types_export.rb b/seed/ruby-sdk/variables/lib/types_export.rb new file mode 100644 index 00000000000..8e9b8f90fa4 --- /dev/null +++ b/seed/ruby-sdk/variables/lib/types_export.rb @@ -0,0 +1 @@ +# frozen_string_literal: true diff --git a/seed/ruby-sdk/variables/seed_variables_client.gemspec b/seed/ruby-sdk/variables/seed_variables_client.gemspec index 73bfd4faa36..be164abe73c 100644 --- a/seed/ruby-sdk/variables/seed_variables_client.gemspec +++ b/seed/ruby-sdk/variables/seed_variables_client.gemspec @@ -4,6 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "seed_variables_client" + spec.version = SeedVariablesClient::Gemconfig::VERSION spec.authors = SeedVariablesClient::Gemconfig::AUTHORS spec.email = SeedVariablesClient::Gemconfig::EMAIL spec.summary = SeedVariablesClient::Gemconfig::SUMMARY