diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..2a9dcc5 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,69 @@ +PATH + remote: . + specs: + statuscake-rb (1.0.0.pre.beta.4) + typhoeus (~> 1.0, >= 1.0.1) + +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.2) + diff-lcs (1.5.0) + ethon (0.15.0) + ffi (>= 1.15.0) + ffi (1.15.5) + json (2.6.2) + parallel (1.22.1) + parser (3.1.2.1) + ast (~> 2.4.1) + rainbow (3.1.1) + rake (13.0.6) + regexp_parser (2.5.0) + rexml (3.2.5) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.11.0) + rspec-support (3.11.0) + rubocop (1.36.0) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.1.2.1) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.20.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.21.0) + parser (>= 3.1.1.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (2.12.1) + rubocop (~> 1.31) + ruby-progressbar (1.11.0) + typhoeus (1.4.0) + ethon (>= 0.9.0) + unicode-display_width (2.2.0) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + rake (~> 13.0, >= 13.0.1) + rspec (~> 3.6, >= 3.6.0) + rubocop (~> 1.36, >= 1.36.0) + rubocop-rake (~> 0.5, >= 0.5.1) + rubocop-rspec (~> 2.12, >= 2.12.1) + statuscake-rb! + +BUNDLED WITH + 2.3.7 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..1f4d09f --- /dev/null +++ b/Rakefile @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) +task default: :spec diff --git a/lib/statuscake.rb b/lib/statuscake.rb new file mode 100644 index 0000000..fa09e0e --- /dev/null +++ b/lib/statuscake.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +# Common files +require 'statuscake/api_client' +require 'statuscake/api_error' +require 'statuscake/version' +require 'statuscake/configuration' + +# Models +require 'statuscake/models/api_error' +require 'statuscake/models/api_response' +require 'statuscake/models/api_response_data' +require 'statuscake/models/contact_group' +require 'statuscake/models/contact_group_response' +require 'statuscake/models/contact_groups' +require 'statuscake/models/links' +require 'statuscake/models/maintenance_window' +require 'statuscake/models/maintenance_window_repeat_interval' +require 'statuscake/models/maintenance_window_response' +require 'statuscake/models/maintenance_window_state' +require 'statuscake/models/maintenance_windows' +require 'statuscake/models/monitoring_location' +require 'statuscake/models/monitoring_location_status' +require 'statuscake/models/monitoring_locations' +require 'statuscake/models/pagespeed_test' +require 'statuscake/models/pagespeed_test_check_rate' +require 'statuscake/models/pagespeed_test_history' +require 'statuscake/models/pagespeed_test_history_result' +require 'statuscake/models/pagespeed_test_response' +require 'statuscake/models/pagespeed_test_stats' +require 'statuscake/models/pagespeed_test_throttling' +require 'statuscake/models/pagespeed_tests' +require 'statuscake/models/pagination' +require 'statuscake/models/ssl_test' +require 'statuscake/models/ssl_test_check_rate' +require 'statuscake/models/ssl_test_flags' +require 'statuscake/models/ssl_test_mixed_content' +require 'statuscake/models/ssl_test_response' +require 'statuscake/models/ssl_tests' +require 'statuscake/models/uptime_test' +require 'statuscake/models/uptime_test_alert' +require 'statuscake/models/uptime_test_alerts' +require 'statuscake/models/uptime_test_check_rate' +require 'statuscake/models/uptime_test_history' +require 'statuscake/models/uptime_test_history_result' +require 'statuscake/models/uptime_test_overview' +require 'statuscake/models/uptime_test_period' +require 'statuscake/models/uptime_test_periods' +require 'statuscake/models/uptime_test_processing_state' +require 'statuscake/models/uptime_test_response' +require 'statuscake/models/uptime_test_status' +require 'statuscake/models/uptime_test_type' +require 'statuscake/models/uptime_tests' + +# APIs +require 'statuscake/api/contact_groups_api' +require 'statuscake/api/locations_api' +require 'statuscake/api/maintenance_windows_api' +require 'statuscake/api/pagespeed_api' +require 'statuscake/api/ssl_api' +require 'statuscake/api/uptime_api' + +# :nodoc +module StatusCake + class << self + # Customize default settings for the SDK using block. + # StatusCake.configure do |config| + # config.username = "xxx" + # config.password = "xxx" + # end + # If no block given, return the default Configuration object. + def configure + if block_given? + yield(Configuration.default) + else + Configuration.default + end + end + end +end diff --git a/lib/statuscake/api/contact_groups_api.rb b/lib/statuscake/api/contact_groups_api.rb new file mode 100644 index 0000000..4a193b2 --- /dev/null +++ b/lib/statuscake/api/contact_groups_api.rb @@ -0,0 +1,411 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'cgi' + +module StatusCake + # :nodoc + class ContactGroupsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Create a contact group + # Creates a contact group with the given parameters. + # @param name [String] Name of the contact group + # @param [Hash] opts the optional parameters + # @option opts [Array] :email_addresses List of email addresses + # @option opts [Array] :integrations List of integration IDs + # @option opts [Array] :mobile_numbers List of international format mobile phone numbers + # @option opts [String] :ping_url URL or IP address of an endpoint to push uptime events. Currently this only supports HTTP GET endpoints + # @return [APIResponse] + def create_contact_group(name, opts = {}) + data, _status_code, _headers = create_contact_group_with_http_info(name, opts) + data + end + + # Create a contact group + # Creates a contact group with the given parameters. + # @param name [String] Name of the contact group + # @param [Hash] opts the optional parameters + # @option opts [Array] :email_addresses List of email addresses + # @option opts [Array] :integrations List of integration IDs + # @option opts [Array] :mobile_numbers List of international format mobile phone numbers + # @option opts [String] :ping_url URL or IP address of an endpoint to push uptime events. Currently this only supports HTTP GET endpoints + # @return [Array<(APIResponse, Integer, Hash)>] APIResponse data, response status code and response headers + def create_contact_group_with_http_info(name, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ContactGroupsApi.create_contact_group ...' + end + # verify the required parameter 'name' is set + if @api_client.config.client_side_validation && name.nil? + raise ArgumentError, "Missing the required parameter 'name' when calling ContactGroupsApi.create_contact_group" + end + # resource path + local_var_path = '/contact-groups' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['name'] = name + form_params['email_addresses'] = @api_client.build_collection_param(opts[:'email_addresses'], :csv) unless opts[:'email_addresses'].nil? + form_params['integrations'] = @api_client.build_collection_param(opts[:'integrations'], :csv) unless opts[:'integrations'].nil? + form_params['mobile_numbers'] = @api_client.build_collection_param(opts[:'mobile_numbers'], :csv) unless opts[:'mobile_numbers'].nil? + form_params['ping_url'] = opts[:'ping_url'] unless opts[:'ping_url'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'APIResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'ContactGroupsApi.create_contact_group', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ContactGroupsApi#create_contact_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Delete a contact group + # Deletes a contact group with the given id. + # @param group_id [String] Contact group ID + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_contact_group(group_id, opts = {}) + delete_contact_group_with_http_info(group_id, opts) + nil + end + + # Delete a contact group + # Deletes a contact group with the given id. + # @param group_id [String] Contact group ID + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_contact_group_with_http_info(group_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ContactGroupsApi.delete_contact_group ...' + end + # verify the required parameter 'group_id' is set + if @api_client.config.client_side_validation && group_id.nil? + raise ArgumentError, "Missing the required parameter 'group_id' when calling ContactGroupsApi.delete_contact_group" + end + # resource path + local_var_path = '/contact-groups/{group_id}'.sub('{' + 'group_id' + '}', CGI.escape(group_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'ContactGroupsApi.delete_contact_group', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ContactGroupsApi#delete_contact_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Retrieve a contact group + # Returns a contact group with the given id. + # @param group_id [String] Contact group ID + # @param [Hash] opts the optional parameters + # @return [ContactGroupResponse] + def get_contact_group(group_id, opts = {}) + data, _status_code, _headers = get_contact_group_with_http_info(group_id, opts) + data + end + + # Retrieve a contact group + # Returns a contact group with the given id. + # @param group_id [String] Contact group ID + # @param [Hash] opts the optional parameters + # @return [Array<(ContactGroupResponse, Integer, Hash)>] ContactGroupResponse data, response status code and response headers + def get_contact_group_with_http_info(group_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ContactGroupsApi.get_contact_group ...' + end + # verify the required parameter 'group_id' is set + if @api_client.config.client_side_validation && group_id.nil? + raise ArgumentError, "Missing the required parameter 'group_id' when calling ContactGroupsApi.get_contact_group" + end + # resource path + local_var_path = '/contact-groups/{group_id}'.sub('{' + 'group_id' + '}', CGI.escape(group_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ContactGroupResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'ContactGroupsApi.get_contact_group', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ContactGroupsApi#get_contact_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all contact groups + # Returns a list of contact groups for an account. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of contact groups to return per page (default to 25) + # @return [ContactGroups] + def list_contact_groups(opts = {}) + data, _status_code, _headers = list_contact_groups_with_http_info(opts) + data + end + + # Get all contact groups + # Returns a list of contact groups for an account. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of contact groups to return per page (default to 25) + # @return [Array<(ContactGroups, Integer, Hash)>] ContactGroups data, response status code and response headers + def list_contact_groups_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ContactGroupsApi.list_contact_groups ...' + end + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1 + raise ArgumentError, 'invalid value for "opts[:"page"]" when calling ContactGroupsApi.list_contact_groups, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling ContactGroupsApi.list_contact_groups, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling ContactGroupsApi.list_contact_groups, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/contact-groups' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'page'] = opts[:'page'] unless opts[:'page'].nil? + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ContactGroups' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'ContactGroupsApi.list_contact_groups', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ContactGroupsApi#list_contact_groups\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Update a contact group + # Updates a contact group with the given parameters. + # @param group_id [String] Contact group ID + # @param [Hash] opts the optional parameters + # @option opts [String] :name Name of the contact group + # @option opts [Array] :email_addresses List of email addresses + # @option opts [Array] :integrations List of integration IDs + # @option opts [Array] :mobile_numbers List of international format mobile phone numbers + # @option opts [String] :ping_url URL or IP address of an endpoint to push uptime events. Currently this only supports HTTP GET endpoints + # @return [nil] + def update_contact_group(group_id, opts = {}) + update_contact_group_with_http_info(group_id, opts) + nil + end + + # Update a contact group + # Updates a contact group with the given parameters. + # @param group_id [String] Contact group ID + # @param [Hash] opts the optional parameters + # @option opts [String] :name Name of the contact group + # @option opts [Array] :email_addresses List of email addresses + # @option opts [Array] :integrations List of integration IDs + # @option opts [Array] :mobile_numbers List of international format mobile phone numbers + # @option opts [String] :ping_url URL or IP address of an endpoint to push uptime events. Currently this only supports HTTP GET endpoints + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_contact_group_with_http_info(group_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ContactGroupsApi.update_contact_group ...' + end + # verify the required parameter 'group_id' is set + if @api_client.config.client_side_validation && group_id.nil? + raise ArgumentError, "Missing the required parameter 'group_id' when calling ContactGroupsApi.update_contact_group" + end + # resource path + local_var_path = '/contact-groups/{group_id}'.sub('{' + 'group_id' + '}', CGI.escape(group_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['name'] = opts[:'name'] unless opts[:'name'].nil? + form_params['email_addresses'] = @api_client.build_collection_param(opts[:'email_addresses'], :csv) unless opts[:'email_addresses'].nil? + form_params['integrations'] = @api_client.build_collection_param(opts[:'integrations'], :csv) unless opts[:'integrations'].nil? + form_params['mobile_numbers'] = @api_client.build_collection_param(opts[:'mobile_numbers'], :csv) unless opts[:'mobile_numbers'].nil? + form_params['ping_url'] = opts[:'ping_url'] unless opts[:'ping_url'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'ContactGroupsApi.update_contact_group', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ContactGroupsApi#update_contact_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + end +end diff --git a/lib/statuscake/api/locations_api.rb b/lib/statuscake/api/locations_api.rb new file mode 100644 index 0000000..81c9112 --- /dev/null +++ b/lib/statuscake/api/locations_api.rb @@ -0,0 +1,166 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'cgi' + +module StatusCake + # :nodoc + class LocationsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Get all pagespeed monitoring locations + # Returns a list of locations detailing server information for pagespeed monitoring servers. This information can be used to create further checks using the API. + # @param [Hash] opts the optional parameters + # @option opts [String] :location Alpha-2 ISO 3166-1 country code + # @return [MonitoringLocations] + def list_pagespeed_monitoring_locations(opts = {}) + data, _status_code, _headers = list_pagespeed_monitoring_locations_with_http_info(opts) + data + end + + # Get all pagespeed monitoring locations + # Returns a list of locations detailing server information for pagespeed monitoring servers. This information can be used to create further checks using the API. + # @param [Hash] opts the optional parameters + # @option opts [String] :location Alpha-2 ISO 3166-1 country code + # @return [Array<(MonitoringLocations, Integer, Hash)>] MonitoringLocations data, response status code and response headers + def list_pagespeed_monitoring_locations_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LocationsApi.list_pagespeed_monitoring_locations ...' + end + # resource path + local_var_path = '/pagespeed-locations' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'location'] = opts[:'location'] unless opts[:'location'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'MonitoringLocations' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'LocationsApi.list_pagespeed_monitoring_locations', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LocationsApi#list_pagespeed_monitoring_locations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all uptime monitoring locations + # Returns a list of locations detailing server information for uptime monitoring servers. This information can be used to create further checks using the API. + # @param [Hash] opts the optional parameters + # @option opts [String] :location Alpha-3 ISO 3166-1 country code + # @option opts [String] :region_code Server region code + # @return [MonitoringLocations] + def list_uptime_monitoring_locations(opts = {}) + data, _status_code, _headers = list_uptime_monitoring_locations_with_http_info(opts) + data + end + + # Get all uptime monitoring locations + # Returns a list of locations detailing server information for uptime monitoring servers. This information can be used to create further checks using the API. + # @param [Hash] opts the optional parameters + # @option opts [String] :location Alpha-3 ISO 3166-1 country code + # @option opts [String] :region_code Server region code + # @return [Array<(MonitoringLocations, Integer, Hash)>] MonitoringLocations data, response status code and response headers + def list_uptime_monitoring_locations_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LocationsApi.list_uptime_monitoring_locations ...' + end + # resource path + local_var_path = '/uptime-locations' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'location'] = opts[:'location'] unless opts[:'location'].nil? + query_params[:'region_code'] = opts[:'region_code'] unless opts[:'region_code'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'MonitoringLocations' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'LocationsApi.list_uptime_monitoring_locations', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LocationsApi#list_uptime_monitoring_locations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + end +end diff --git a/lib/statuscake/api/maintenance_windows_api.rb b/lib/statuscake/api/maintenance_windows_api.rb new file mode 100644 index 0000000..a096b19 --- /dev/null +++ b/lib/statuscake/api/maintenance_windows_api.rb @@ -0,0 +1,444 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'cgi' + +module StatusCake + # :nodoc + class MaintenanceWindowsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Create a maintenance window + # Creates a maintenance window with the given parameters. + # @param name [String] Name of the maintenance window + # @param end_at [Time] End of the maintenance window (RFC3339 format) + # @param start_at [Time] Start of the maintenance window (RFC3339 format) + # @param timezone [String] Standard [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) associated with this maintenance window + # @param [Hash] opts the optional parameters + # @option opts [MaintenanceWindowRepeatInterval] :repeat_interval + # @option opts [Array] :tags List of tags used to include matching uptime checks in this maintenance window. At least one of `tests` and `tags` must be present in the request + # @option opts [Array] :tests List of uptime check IDs explicitly included in this maintenance window. At least one of `tests` and `tags` must be present in the request + # @return [APIResponse] + def create_maintenance_window(name, end_at, start_at, timezone, opts = {}) + data, _status_code, _headers = create_maintenance_window_with_http_info(name, end_at, start_at, timezone, opts) + data + end + + # Create a maintenance window + # Creates a maintenance window with the given parameters. + # @param name [String] Name of the maintenance window + # @param end_at [Time] End of the maintenance window (RFC3339 format) + # @param start_at [Time] Start of the maintenance window (RFC3339 format) + # @param timezone [String] Standard [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) associated with this maintenance window + # @param [Hash] opts the optional parameters + # @option opts [MaintenanceWindowRepeatInterval] :repeat_interval + # @option opts [Array] :tags List of tags used to include matching uptime checks in this maintenance window. At least one of `tests` and `tags` must be present in the request + # @option opts [Array] :tests List of uptime check IDs explicitly included in this maintenance window. At least one of `tests` and `tags` must be present in the request + # @return [Array<(APIResponse, Integer, Hash)>] APIResponse data, response status code and response headers + def create_maintenance_window_with_http_info(name, end_at, start_at, timezone, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MaintenanceWindowsApi.create_maintenance_window ...' + end + # verify the required parameter 'name' is set + if @api_client.config.client_side_validation && name.nil? + raise ArgumentError, "Missing the required parameter 'name' when calling MaintenanceWindowsApi.create_maintenance_window" + end + # verify the required parameter 'end_at' is set + if @api_client.config.client_side_validation && end_at.nil? + raise ArgumentError, "Missing the required parameter 'end_at' when calling MaintenanceWindowsApi.create_maintenance_window" + end + # verify the required parameter 'start_at' is set + if @api_client.config.client_side_validation && start_at.nil? + raise ArgumentError, "Missing the required parameter 'start_at' when calling MaintenanceWindowsApi.create_maintenance_window" + end + # verify the required parameter 'timezone' is set + if @api_client.config.client_side_validation && timezone.nil? + raise ArgumentError, "Missing the required parameter 'timezone' when calling MaintenanceWindowsApi.create_maintenance_window" + end + # resource path + local_var_path = '/maintenance-windows' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['name'] = name + form_params['end_at'] = end_at + form_params['start_at'] = start_at + form_params['timezone'] = timezone + form_params['repeat_interval'] = opts[:'repeat_interval'] unless opts[:'repeat_interval'].nil? + form_params['tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) unless opts[:'tags'].nil? + form_params['tests'] = @api_client.build_collection_param(opts[:'tests'], :csv) unless opts[:'tests'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'APIResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'MaintenanceWindowsApi.create_maintenance_window', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MaintenanceWindowsApi#create_maintenance_window\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Delete a maintenance window + # Deletes a maintenance window with the given id. + # @param window_id [String] Maintenance window ID + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_maintenance_window(window_id, opts = {}) + delete_maintenance_window_with_http_info(window_id, opts) + nil + end + + # Delete a maintenance window + # Deletes a maintenance window with the given id. + # @param window_id [String] Maintenance window ID + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_maintenance_window_with_http_info(window_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MaintenanceWindowsApi.delete_maintenance_window ...' + end + # verify the required parameter 'window_id' is set + if @api_client.config.client_side_validation && window_id.nil? + raise ArgumentError, "Missing the required parameter 'window_id' when calling MaintenanceWindowsApi.delete_maintenance_window" + end + # resource path + local_var_path = '/maintenance-windows/{window_id}'.sub('{' + 'window_id' + '}', CGI.escape(window_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'MaintenanceWindowsApi.delete_maintenance_window', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MaintenanceWindowsApi#delete_maintenance_window\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Retrieve a maintenance window + # Returns a maintenance window with the given id. + # @param window_id [String] Maintenance window ID + # @param [Hash] opts the optional parameters + # @return [MaintenanceWindowResponse] + def get_maintenance_window(window_id, opts = {}) + data, _status_code, _headers = get_maintenance_window_with_http_info(window_id, opts) + data + end + + # Retrieve a maintenance window + # Returns a maintenance window with the given id. + # @param window_id [String] Maintenance window ID + # @param [Hash] opts the optional parameters + # @return [Array<(MaintenanceWindowResponse, Integer, Hash)>] MaintenanceWindowResponse data, response status code and response headers + def get_maintenance_window_with_http_info(window_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MaintenanceWindowsApi.get_maintenance_window ...' + end + # verify the required parameter 'window_id' is set + if @api_client.config.client_side_validation && window_id.nil? + raise ArgumentError, "Missing the required parameter 'window_id' when calling MaintenanceWindowsApi.get_maintenance_window" + end + # resource path + local_var_path = '/maintenance-windows/{window_id}'.sub('{' + 'window_id' + '}', CGI.escape(window_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'MaintenanceWindowResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'MaintenanceWindowsApi.get_maintenance_window', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MaintenanceWindowsApi#get_maintenance_window\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all maintenance windows + # Returns a list of maintenance windows for an account. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of maintenance windows to return per page (default to 25) + # @option opts [String] :state Maintenance window state + # @return [MaintenanceWindows] + def list_maintenance_windows(opts = {}) + data, _status_code, _headers = list_maintenance_windows_with_http_info(opts) + data + end + + # Get all maintenance windows + # Returns a list of maintenance windows for an account. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of maintenance windows to return per page (default to 25) + # @option opts [String] :state Maintenance window state + # @return [Array<(MaintenanceWindows, Integer, Hash)>] MaintenanceWindows data, response status code and response headers + def list_maintenance_windows_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MaintenanceWindowsApi.list_maintenance_windows ...' + end + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1 + raise ArgumentError, 'invalid value for "opts[:"page"]" when calling MaintenanceWindowsApi.list_maintenance_windows, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling MaintenanceWindowsApi.list_maintenance_windows, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling MaintenanceWindowsApi.list_maintenance_windows, must be greater than or equal to 1.' + end + + # rubocop:disable Style/WordArray + allowable_values = ["active", "paused", "pending"] + # rubocop:enable Style/WordArray + if @api_client.config.client_side_validation && opts[:'state'] && !allowable_values.include?(opts[:'state']) + raise ArgumentError, "invalid value for \"state\", must be one of #{allowable_values}" + end + # resource path + local_var_path = '/maintenance-windows' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'page'] = opts[:'page'] unless opts[:'page'].nil? + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + query_params[:'state'] = opts[:'state'] unless opts[:'state'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'MaintenanceWindows' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'MaintenanceWindowsApi.list_maintenance_windows', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MaintenanceWindowsApi#list_maintenance_windows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Update a maintenance window + # Updates a maintenance window with the given parameters. + # @param window_id [String] Maintenance window ID + # @param [Hash] opts the optional parameters + # @option opts [String] :name Name of the maintenance window + # @option opts [Time] :end_at End of the maintenance window (RFC3339 format) + # @option opts [MaintenanceWindowRepeatInterval] :repeat_interval + # @option opts [Time] :start_at Start of the maintenance window (RFC3339 format) + # @option opts [Array] :tags List of tags used to include matching uptime checks in this maintenance window + # @option opts [Array] :tests List of uptime check IDs explicitly included in this maintenance window + # @option opts [String] :timezone Standard [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) associated with this maintenance window + # @return [nil] + def update_maintenance_window(window_id, opts = {}) + update_maintenance_window_with_http_info(window_id, opts) + nil + end + + # Update a maintenance window + # Updates a maintenance window with the given parameters. + # @param window_id [String] Maintenance window ID + # @param [Hash] opts the optional parameters + # @option opts [String] :name Name of the maintenance window + # @option opts [Time] :end_at End of the maintenance window (RFC3339 format) + # @option opts [MaintenanceWindowRepeatInterval] :repeat_interval + # @option opts [Time] :start_at Start of the maintenance window (RFC3339 format) + # @option opts [Array] :tags List of tags used to include matching uptime checks in this maintenance window + # @option opts [Array] :tests List of uptime check IDs explicitly included in this maintenance window + # @option opts [String] :timezone Standard [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) associated with this maintenance window + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_maintenance_window_with_http_info(window_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MaintenanceWindowsApi.update_maintenance_window ...' + end + # verify the required parameter 'window_id' is set + if @api_client.config.client_side_validation && window_id.nil? + raise ArgumentError, "Missing the required parameter 'window_id' when calling MaintenanceWindowsApi.update_maintenance_window" + end + # resource path + local_var_path = '/maintenance-windows/{window_id}'.sub('{' + 'window_id' + '}', CGI.escape(window_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['name'] = opts[:'name'] unless opts[:'name'].nil? + form_params['end_at'] = opts[:'end_at'] unless opts[:'end_at'].nil? + form_params['repeat_interval'] = opts[:'repeat_interval'] unless opts[:'repeat_interval'].nil? + form_params['start_at'] = opts[:'start_at'] unless opts[:'start_at'].nil? + form_params['tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) unless opts[:'tags'].nil? + form_params['tests'] = @api_client.build_collection_param(opts[:'tests'], :csv) unless opts[:'tests'].nil? + form_params['timezone'] = opts[:'timezone'] unless opts[:'timezone'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'MaintenanceWindowsApi.update_maintenance_window', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MaintenanceWindowsApi#update_maintenance_window\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + end +end diff --git a/lib/statuscake/api/pagespeed_api.rb b/lib/statuscake/api/pagespeed_api.rb new file mode 100644 index 0000000..57bb6eb --- /dev/null +++ b/lib/statuscake/api/pagespeed_api.rb @@ -0,0 +1,550 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'cgi' + +module StatusCake + # :nodoc + class PagespeedApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Create a pagespeed check + # Creates a pagespeed check with the given parameters. + # @param name [String] Name of the check + # @param website_url [String] URL, FQDN, or IP address of the website under test + # @param check_rate [PagespeedTestCheckRate] + # @param region [PagespeedTestRegion] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :alert_bigger An alert will be sent if the size of the page is larger than this value (kb). A value of 0 prevents alerts being sent. (default to 0) + # @option opts [Integer] :alert_slower An alert will be sent if the load time of the page exceeds this value (ms). A value of 0 prevents alerts being sent (default to 0) + # @option opts [Integer] :alert_smaller An alert will be sent if the size of the page is smaller than this value (kb). A value of 0 prevents alerts being sent (default to 0) + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [Boolean] :paused Whether the check should be run (default to false) + # @return [APIResponse] + def create_pagespeed_test(name, website_url, check_rate, region, opts = {}) + data, _status_code, _headers = create_pagespeed_test_with_http_info(name, website_url, check_rate, region, opts) + data + end + + # Create a pagespeed check + # Creates a pagespeed check with the given parameters. + # @param name [String] Name of the check + # @param website_url [String] URL, FQDN, or IP address of the website under test + # @param check_rate [PagespeedTestCheckRate] + # @param region [PagespeedTestRegion] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :alert_bigger An alert will be sent if the size of the page is larger than this value (kb). A value of 0 prevents alerts being sent. (default to 0) + # @option opts [Integer] :alert_slower An alert will be sent if the load time of the page exceeds this value (ms). A value of 0 prevents alerts being sent (default to 0) + # @option opts [Integer] :alert_smaller An alert will be sent if the size of the page is smaller than this value (kb). A value of 0 prevents alerts being sent (default to 0) + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [Boolean] :paused Whether the check should be run (default to false) + # @return [Array<(APIResponse, Integer, Hash)>] APIResponse data, response status code and response headers + def create_pagespeed_test_with_http_info(name, website_url, check_rate, region, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PagespeedApi.create_pagespeed_test ...' + end + # verify the required parameter 'name' is set + if @api_client.config.client_side_validation && name.nil? + raise ArgumentError, "Missing the required parameter 'name' when calling PagespeedApi.create_pagespeed_test" + end + # verify the required parameter 'website_url' is set + if @api_client.config.client_side_validation && website_url.nil? + raise ArgumentError, "Missing the required parameter 'website_url' when calling PagespeedApi.create_pagespeed_test" + end + # verify the required parameter 'check_rate' is set + if @api_client.config.client_side_validation && check_rate.nil? + raise ArgumentError, "Missing the required parameter 'check_rate' when calling PagespeedApi.create_pagespeed_test" + end + # verify the required parameter 'region' is set + if @api_client.config.client_side_validation && region.nil? + raise ArgumentError, "Missing the required parameter 'region' when calling PagespeedApi.create_pagespeed_test" + end + if @api_client.config.client_side_validation && !opts[:'alert_bigger'].nil? && opts[:'alert_bigger'] < 0 + raise ArgumentError, 'invalid value for "opts[:"alert_bigger"]" when calling PagespeedApi.create_pagespeed_test, must be greater than or equal to 0.' + end + + if @api_client.config.client_side_validation && !opts[:'alert_slower'].nil? && opts[:'alert_slower'] < 0 + raise ArgumentError, 'invalid value for "opts[:"alert_slower"]" when calling PagespeedApi.create_pagespeed_test, must be greater than or equal to 0.' + end + + if @api_client.config.client_side_validation && !opts[:'alert_smaller'].nil? && opts[:'alert_smaller'] < 0 + raise ArgumentError, 'invalid value for "opts[:"alert_smaller"]" when calling PagespeedApi.create_pagespeed_test, must be greater than or equal to 0.' + end + + # resource path + local_var_path = '/pagespeed' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['name'] = name + form_params['website_url'] = website_url + form_params['check_rate'] = check_rate + form_params['region'] = region + form_params['alert_bigger'] = opts[:'alert_bigger'] unless opts[:'alert_bigger'].nil? + form_params['alert_slower'] = opts[:'alert_slower'] unless opts[:'alert_slower'].nil? + form_params['alert_smaller'] = opts[:'alert_smaller'] unless opts[:'alert_smaller'].nil? + form_params['contact_groups'] = @api_client.build_collection_param(opts[:'contact_groups'], :csv) unless opts[:'contact_groups'].nil? + form_params['paused'] = opts[:'paused'] unless opts[:'paused'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'APIResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'PagespeedApi.create_pagespeed_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PagespeedApi#create_pagespeed_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Delete a pagespeed check + # Deletes a pagespeed check with the given id. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_pagespeed_test(test_id, opts = {}) + delete_pagespeed_test_with_http_info(test_id, opts) + nil + end + + # Delete a pagespeed check + # Deletes a pagespeed check with the given id. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_pagespeed_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PagespeedApi.delete_pagespeed_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling PagespeedApi.delete_pagespeed_test" + end + # resource path + local_var_path = '/pagespeed/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'PagespeedApi.delete_pagespeed_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PagespeedApi#delete_pagespeed_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Retrieve a pagespeed check + # Returns a pagespeed check with the given id. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @return [PagespeedTestResponse] + def get_pagespeed_test(test_id, opts = {}) + data, _status_code, _headers = get_pagespeed_test_with_http_info(test_id, opts) + data + end + + # Retrieve a pagespeed check + # Returns a pagespeed check with the given id. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @return [Array<(PagespeedTestResponse, Integer, Hash)>] PagespeedTestResponse data, response status code and response headers + def get_pagespeed_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PagespeedApi.get_pagespeed_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling PagespeedApi.get_pagespeed_test" + end + # resource path + local_var_path = '/pagespeed/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PagespeedTestResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'PagespeedApi.get_pagespeed_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PagespeedApi#get_pagespeed_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all pagespeed check history + # Returns a list of pagespeed check history results for a given id, detailing the runs performed on the StatusCake testing infrastruture. The returned results are a paginated series. Alongside the response data is a `links` object referencing the current response document, `self`, and the next page in the series, `next`. Aggregated data over the specified duration is returned in the root level `metadata` field. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit The number of results to return from the series (default to 25) + # @option opts [Integer] :before Only results created before this UNIX timestamp will be returned + # @return [PagespeedTestHistory] + def list_pagespeed_test_history(test_id, opts = {}) + data, _status_code, _headers = list_pagespeed_test_history_with_http_info(test_id, opts) + data + end + + # Get all pagespeed check history + # Returns a list of pagespeed check history results for a given id, detailing the runs performed on the StatusCake testing infrastruture. The returned results are a paginated series. Alongside the response data is a `links` object referencing the current response document, `self`, and the next page in the series, `next`. Aggregated data over the specified duration is returned in the root level `metadata` field. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit The number of results to return from the series (default to 25) + # @option opts [Integer] :before Only results created before this UNIX timestamp will be returned + # @return [Array<(PagespeedTestHistory, Integer, Hash)>] PagespeedTestHistory data, response status code and response headers + def list_pagespeed_test_history_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PagespeedApi.list_pagespeed_test_history ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling PagespeedApi.list_pagespeed_test_history" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling PagespeedApi.list_pagespeed_test_history, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling PagespeedApi.list_pagespeed_test_history, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'before'].nil? && opts[:'before'] < 0 + raise ArgumentError, 'invalid value for "opts[:"before"]" when calling PagespeedApi.list_pagespeed_test_history, must be greater than or equal to 0.' + end + + # resource path + local_var_path = '/pagespeed/{test_id}/history'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + query_params[:'before'] = opts[:'before'] unless opts[:'before'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PagespeedTestHistory' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'PagespeedApi.list_pagespeed_test_history', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PagespeedApi#list_pagespeed_test_history\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all pagespeed checks + # Returns a list of pagespeed checks for an account. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of pagespeed checks to return per page (default to 25) + # @return [PagespeedTests] + def list_pagespeed_tests(opts = {}) + data, _status_code, _headers = list_pagespeed_tests_with_http_info(opts) + data + end + + # Get all pagespeed checks + # Returns a list of pagespeed checks for an account. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of pagespeed checks to return per page (default to 25) + # @return [Array<(PagespeedTests, Integer, Hash)>] PagespeedTests data, response status code and response headers + def list_pagespeed_tests_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PagespeedApi.list_pagespeed_tests ...' + end + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1 + raise ArgumentError, 'invalid value for "opts[:"page"]" when calling PagespeedApi.list_pagespeed_tests, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling PagespeedApi.list_pagespeed_tests, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling PagespeedApi.list_pagespeed_tests, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/pagespeed' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'page'] = opts[:'page'] unless opts[:'page'].nil? + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PagespeedTests' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'PagespeedApi.list_pagespeed_tests', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PagespeedApi#list_pagespeed_tests\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Update a pagespeed check + # Updates a pagespeed check with the given parameters. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @option opts [String] :name Name of the check + # @option opts [PagespeedTestCheckRate] :check_rate + # @option opts [Integer] :alert_bigger An alert will be sent if the size of the page is larger than this value (kb). A value of 0 prevents alerts being sent. + # @option opts [Integer] :alert_slower An alert will be sent if the load time of the page exceeds this value (ms). A value of 0 prevents alerts being sent + # @option opts [Integer] :alert_smaller An alert will be sent if the size of the page is smaller than this value (kb). A value of 0 prevents alerts being sent + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [Boolean] :paused Whether the check should be run + # @option opts [PagespeedTestRegion] :region + # @return [nil] + def update_pagespeed_test(test_id, opts = {}) + update_pagespeed_test_with_http_info(test_id, opts) + nil + end + + # Update a pagespeed check + # Updates a pagespeed check with the given parameters. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @option opts [String] :name Name of the check + # @option opts [PagespeedTestCheckRate] :check_rate + # @option opts [Integer] :alert_bigger An alert will be sent if the size of the page is larger than this value (kb). A value of 0 prevents alerts being sent. + # @option opts [Integer] :alert_slower An alert will be sent if the load time of the page exceeds this value (ms). A value of 0 prevents alerts being sent + # @option opts [Integer] :alert_smaller An alert will be sent if the size of the page is smaller than this value (kb). A value of 0 prevents alerts being sent + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [Boolean] :paused Whether the check should be run + # @option opts [PagespeedTestRegion] :region + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_pagespeed_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PagespeedApi.update_pagespeed_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling PagespeedApi.update_pagespeed_test" + end + if @api_client.config.client_side_validation && !opts[:'alert_bigger'].nil? && opts[:'alert_bigger'] < 0 + raise ArgumentError, 'invalid value for "opts[:"alert_bigger"]" when calling PagespeedApi.update_pagespeed_test, must be greater than or equal to 0.' + end + + if @api_client.config.client_side_validation && !opts[:'alert_slower'].nil? && opts[:'alert_slower'] < 0 + raise ArgumentError, 'invalid value for "opts[:"alert_slower"]" when calling PagespeedApi.update_pagespeed_test, must be greater than or equal to 0.' + end + + if @api_client.config.client_side_validation && !opts[:'alert_smaller'].nil? && opts[:'alert_smaller'] < 0 + raise ArgumentError, 'invalid value for "opts[:"alert_smaller"]" when calling PagespeedApi.update_pagespeed_test, must be greater than or equal to 0.' + end + + # resource path + local_var_path = '/pagespeed/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['name'] = opts[:'name'] unless opts[:'name'].nil? + form_params['check_rate'] = opts[:'check_rate'] unless opts[:'check_rate'].nil? + form_params['alert_bigger'] = opts[:'alert_bigger'] unless opts[:'alert_bigger'].nil? + form_params['alert_slower'] = opts[:'alert_slower'] unless opts[:'alert_slower'].nil? + form_params['alert_smaller'] = opts[:'alert_smaller'] unless opts[:'alert_smaller'].nil? + form_params['contact_groups'] = @api_client.build_collection_param(opts[:'contact_groups'], :csv) unless opts[:'contact_groups'].nil? + form_params['paused'] = opts[:'paused'] unless opts[:'paused'].nil? + form_params['region'] = opts[:'region'] unless opts[:'region'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'PagespeedApi.update_pagespeed_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PagespeedApi#update_pagespeed_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + end +end diff --git a/lib/statuscake/api/ssl_api.rb b/lib/statuscake/api/ssl_api.rb new file mode 100644 index 0000000..d498b98 --- /dev/null +++ b/lib/statuscake/api/ssl_api.rb @@ -0,0 +1,458 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'cgi' + +module StatusCake + # :nodoc + class SslApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Create an SSL check + # Creates an SSL check with the given parameters. + # @param website_url [String] URL of the server under test. Must begin with https:// + # @param check_rate [SSLTestCheckRate] + # @param alert_at [Array] List representing when alerts should be sent (days). Must be exactly 3 numerical values + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :alert_broken Whether to enable alerts when SSL certificate issues are found (default to false) + # @option opts [Boolean] :alert_expiry Whether to enable alerts when the SSL certificate is to expire (default to false) + # @option opts [Boolean] :alert_mixed Whether to enable alerts when mixed content is found (default to false) + # @option opts [Boolean] :alert_reminder Whether to enable alert reminders (default to false) + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [Boolean] :follow_redirects Whether to follow redirects when testing. Disabled by default (default to false) + # @option opts [String] :hostname Hostname of the server under test + # @option opts [Boolean] :paused Whether the check should be run (default to false) + # @option opts [String] :user_agent Custom user agent string set when testing + # @return [APIResponse] + def create_ssl_test(website_url, check_rate, alert_at, opts = {}) + data, _status_code, _headers = create_ssl_test_with_http_info(website_url, check_rate, alert_at, opts) + data + end + + # Create an SSL check + # Creates an SSL check with the given parameters. + # @param website_url [String] URL of the server under test. Must begin with https:// + # @param check_rate [SSLTestCheckRate] + # @param alert_at [Array] List representing when alerts should be sent (days). Must be exactly 3 numerical values + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :alert_broken Whether to enable alerts when SSL certificate issues are found (default to false) + # @option opts [Boolean] :alert_expiry Whether to enable alerts when the SSL certificate is to expire (default to false) + # @option opts [Boolean] :alert_mixed Whether to enable alerts when mixed content is found (default to false) + # @option opts [Boolean] :alert_reminder Whether to enable alert reminders (default to false) + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [Boolean] :follow_redirects Whether to follow redirects when testing. Disabled by default (default to false) + # @option opts [String] :hostname Hostname of the server under test + # @option opts [Boolean] :paused Whether the check should be run (default to false) + # @option opts [String] :user_agent Custom user agent string set when testing + # @return [Array<(APIResponse, Integer, Hash)>] APIResponse data, response status code and response headers + def create_ssl_test_with_http_info(website_url, check_rate, alert_at, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SslApi.create_ssl_test ...' + end + # verify the required parameter 'website_url' is set + if @api_client.config.client_side_validation && website_url.nil? + raise ArgumentError, "Missing the required parameter 'website_url' when calling SslApi.create_ssl_test" + end + # verify the required parameter 'check_rate' is set + if @api_client.config.client_side_validation && check_rate.nil? + raise ArgumentError, "Missing the required parameter 'check_rate' when calling SslApi.create_ssl_test" + end + # verify the required parameter 'alert_at' is set + if @api_client.config.client_side_validation && alert_at.nil? + raise ArgumentError, "Missing the required parameter 'alert_at' when calling SslApi.create_ssl_test" + end + # resource path + local_var_path = '/ssl' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['website_url'] = website_url + form_params['check_rate'] = check_rate + form_params['alert_at'] = @api_client.build_collection_param(alert_at, :csv) + form_params['alert_broken'] = opts[:'alert_broken'] unless opts[:'alert_broken'].nil? + form_params['alert_expiry'] = opts[:'alert_expiry'] unless opts[:'alert_expiry'].nil? + form_params['alert_mixed'] = opts[:'alert_mixed'] unless opts[:'alert_mixed'].nil? + form_params['alert_reminder'] = opts[:'alert_reminder'] unless opts[:'alert_reminder'].nil? + form_params['contact_groups'] = @api_client.build_collection_param(opts[:'contact_groups'], :csv) unless opts[:'contact_groups'].nil? + form_params['follow_redirects'] = opts[:'follow_redirects'] unless opts[:'follow_redirects'].nil? + form_params['hostname'] = opts[:'hostname'] unless opts[:'hostname'].nil? + form_params['paused'] = opts[:'paused'] unless opts[:'paused'].nil? + form_params['user_agent'] = opts[:'user_agent'] unless opts[:'user_agent'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'APIResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'SslApi.create_ssl_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SslApi#create_ssl_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Delete an SSL check + # Deletes an SSL check with the given id. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_ssl_test(test_id, opts = {}) + delete_ssl_test_with_http_info(test_id, opts) + nil + end + + # Delete an SSL check + # Deletes an SSL check with the given id. + # @param test_id [String] Pagespeed check ID + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_ssl_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SslApi.delete_ssl_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling SslApi.delete_ssl_test" + end + # resource path + local_var_path = '/ssl/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'SslApi.delete_ssl_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SslApi#delete_ssl_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Retrieve an SSL check + # Returns an SSL check with the given id. + # @param test_id [String] SSL check ID + # @param [Hash] opts the optional parameters + # @return [SSLTestResponse] + def get_ssl_test(test_id, opts = {}) + data, _status_code, _headers = get_ssl_test_with_http_info(test_id, opts) + data + end + + # Retrieve an SSL check + # Returns an SSL check with the given id. + # @param test_id [String] SSL check ID + # @param [Hash] opts the optional parameters + # @return [Array<(SSLTestResponse, Integer, Hash)>] SSLTestResponse data, response status code and response headers + def get_ssl_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SslApi.get_ssl_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling SslApi.get_ssl_test" + end + # resource path + local_var_path = '/ssl/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'SSLTestResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'SslApi.get_ssl_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SslApi#get_ssl_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all SSL checks + # Returns a list of SSL checks for an account. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of SSL checks to return per page (default to 25) + # @return [SSLTests] + def list_ssl_tests(opts = {}) + data, _status_code, _headers = list_ssl_tests_with_http_info(opts) + data + end + + # Get all SSL checks + # Returns a list of SSL checks for an account. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of SSL checks to return per page (default to 25) + # @return [Array<(SSLTests, Integer, Hash)>] SSLTests data, response status code and response headers + def list_ssl_tests_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SslApi.list_ssl_tests ...' + end + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1 + raise ArgumentError, 'invalid value for "opts[:"page"]" when calling SslApi.list_ssl_tests, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling SslApi.list_ssl_tests, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling SslApi.list_ssl_tests, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/ssl' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'page'] = opts[:'page'] unless opts[:'page'].nil? + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'SSLTests' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'SslApi.list_ssl_tests', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SslApi#list_ssl_tests\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Update an SSL check + # Updates an SSL check with the given parameters. + # @param test_id [String] SSL check ID + # @param [Hash] opts the optional parameters + # @option opts [SSLTestCheckRate] :check_rate + # @option opts [Array] :alert_at List representing when alerts should be sent (days). Must be exactly 3 numerical values + # @option opts [Boolean] :alert_broken Whether to enable alerts when SSL certificate issues are found + # @option opts [Boolean] :alert_expiry Whether to enable alerts when the SSL certificate is to expire + # @option opts [Boolean] :alert_mixed Whether to enable alerts when mixed content is found + # @option opts [Boolean] :alert_reminder Whether to enable alert reminders + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [Boolean] :follow_redirects Whether to follow redirects when testing. Disabled by default + # @option opts [String] :hostname Hostname of the server under test + # @option opts [Boolean] :paused Whether the check should be run + # @option opts [String] :user_agent Custom user agent string set when testing + # @return [nil] + def update_ssl_test(test_id, opts = {}) + update_ssl_test_with_http_info(test_id, opts) + nil + end + + # Update an SSL check + # Updates an SSL check with the given parameters. + # @param test_id [String] SSL check ID + # @param [Hash] opts the optional parameters + # @option opts [SSLTestCheckRate] :check_rate + # @option opts [Array] :alert_at List representing when alerts should be sent (days). Must be exactly 3 numerical values + # @option opts [Boolean] :alert_broken Whether to enable alerts when SSL certificate issues are found + # @option opts [Boolean] :alert_expiry Whether to enable alerts when the SSL certificate is to expire + # @option opts [Boolean] :alert_mixed Whether to enable alerts when mixed content is found + # @option opts [Boolean] :alert_reminder Whether to enable alert reminders + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [Boolean] :follow_redirects Whether to follow redirects when testing. Disabled by default + # @option opts [String] :hostname Hostname of the server under test + # @option opts [Boolean] :paused Whether the check should be run + # @option opts [String] :user_agent Custom user agent string set when testing + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_ssl_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SslApi.update_ssl_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling SslApi.update_ssl_test" + end + # resource path + local_var_path = '/ssl/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['check_rate'] = opts[:'check_rate'] unless opts[:'check_rate'].nil? + form_params['alert_at'] = @api_client.build_collection_param(opts[:'alert_at'], :csv) unless opts[:'alert_at'].nil? + form_params['alert_broken'] = opts[:'alert_broken'] unless opts[:'alert_broken'].nil? + form_params['alert_expiry'] = opts[:'alert_expiry'] unless opts[:'alert_expiry'].nil? + form_params['alert_mixed'] = opts[:'alert_mixed'] unless opts[:'alert_mixed'].nil? + form_params['alert_reminder'] = opts[:'alert_reminder'] unless opts[:'alert_reminder'].nil? + form_params['contact_groups'] = @api_client.build_collection_param(opts[:'contact_groups'], :csv) unless opts[:'contact_groups'].nil? + form_params['follow_redirects'] = opts[:'follow_redirects'] unless opts[:'follow_redirects'].nil? + form_params['hostname'] = opts[:'hostname'] unless opts[:'hostname'].nil? + form_params['paused'] = opts[:'paused'] unless opts[:'paused'].nil? + form_params['user_agent'] = opts[:'user_agent'] unless opts[:'user_agent'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'SslApi.update_ssl_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SslApi#update_ssl_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + end +end diff --git a/lib/statuscake/api/uptime_api.rb b/lib/statuscake/api/uptime_api.rb new file mode 100644 index 0000000..57b00e5 --- /dev/null +++ b/lib/statuscake/api/uptime_api.rb @@ -0,0 +1,881 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'cgi' + +module StatusCake + # :nodoc + class UptimeApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Create an uptime check + # Creates an uptime check with the given parameters. + # @param name [String] Name of the check + # @param test_type [UptimeTestType] + # @param website_url [String] URL or IP address of the server under test + # @param check_rate [UptimeTestCheckRate] + # @param [Hash] opts the optional parameters + # @option opts [String] :basic_username Basic authentication username + # @option opts [String] :basic_password Basic authentication password + # @option opts [Integer] :confirmation Number of confirmation servers to confirm downtime before an alert is triggered (default to 2) + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [String] :custom_header JSON object. Represents headers to be sent when making requests + # @option opts [Boolean] :do_not_find Whether to consider the check as down if the content is present within the response (default to false) + # @option opts [Array] :dns_ips List of IP addresses to compare against returned DNS records + # @option opts [String] :dns_server FQDN or IP address of the nameserver to query + # @option opts [Boolean] :enable_ssl_alert Whether to send an alert if the SSL certificate is soon to expire (default to false) + # @option opts [String] :final_endpoint Specify where the redirect chain should end + # @option opts [String] :find_string String to look for within the response. Considered down if not found + # @option opts [Boolean] :follow_redirects Whether to follow redirects when testing. Disabled by default (default to false) + # @option opts [String] :host Name of the hosting provider + # @option opts [Boolean] :include_header Include header content in string match search (default to false) + # @option opts [Boolean] :paused Whether the check should be run (default to false) + # @option opts [Integer] :port Destination port for TCP checks + # @option opts [String] :_post_body JSON object. Payload submitted with the request. Setting this updates the check to use the HTTP POST verb + # @option opts [String] :post_raw Raw HTTP POST string to send to the server + # @option opts [Array] :regions List of regions on which to run checks. The values required for this parameter can be retrieved from the `GET /v1/uptime-locations` endpoint. + # @option opts [String] :status_codes_csv Comma separated list of status codes that trigger an alert + # @option opts [Array] :tags List of tags + # @option opts [Integer] :timeout The number of seconds to wait to receive the first byte (default to 15) + # @option opts [Integer] :trigger_rate The number of minutes to wait before sending an alert (default to 0) + # @option opts [Boolean] :use_jar Whether to enable cookie storage (default to false) + # @option opts [String] :user_agent Custom user agent string set when testing + # @return [APIResponse] + def create_uptime_test(name, test_type, website_url, check_rate, opts = {}) + data, _status_code, _headers = create_uptime_test_with_http_info(name, test_type, website_url, check_rate, opts) + data + end + + # Create an uptime check + # Creates an uptime check with the given parameters. + # @param name [String] Name of the check + # @param test_type [UptimeTestType] + # @param website_url [String] URL or IP address of the server under test + # @param check_rate [UptimeTestCheckRate] + # @param [Hash] opts the optional parameters + # @option opts [String] :basic_username Basic authentication username + # @option opts [String] :basic_password Basic authentication password + # @option opts [Integer] :confirmation Number of confirmation servers to confirm downtime before an alert is triggered (default to 2) + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [String] :custom_header JSON object. Represents headers to be sent when making requests + # @option opts [Boolean] :do_not_find Whether to consider the check as down if the content is present within the response (default to false) + # @option opts [Array] :dns_ips List of IP addresses to compare against returned DNS records + # @option opts [String] :dns_server FQDN or IP address of the nameserver to query + # @option opts [Boolean] :enable_ssl_alert Whether to send an alert if the SSL certificate is soon to expire (default to false) + # @option opts [String] :final_endpoint Specify where the redirect chain should end + # @option opts [String] :find_string String to look for within the response. Considered down if not found + # @option opts [Boolean] :follow_redirects Whether to follow redirects when testing. Disabled by default (default to false) + # @option opts [String] :host Name of the hosting provider + # @option opts [Boolean] :include_header Include header content in string match search (default to false) + # @option opts [Boolean] :paused Whether the check should be run (default to false) + # @option opts [Integer] :port Destination port for TCP checks + # @option opts [String] :_post_body JSON object. Payload submitted with the request. Setting this updates the check to use the HTTP POST verb + # @option opts [String] :post_raw Raw HTTP POST string to send to the server + # @option opts [Array] :regions List of regions on which to run checks. The values required for this parameter can be retrieved from the `GET /v1/uptime-locations` endpoint. + # @option opts [String] :status_codes_csv Comma separated list of status codes that trigger an alert + # @option opts [Array] :tags List of tags + # @option opts [Integer] :timeout The number of seconds to wait to receive the first byte (default to 15) + # @option opts [Integer] :trigger_rate The number of minutes to wait before sending an alert (default to 0) + # @option opts [Boolean] :use_jar Whether to enable cookie storage (default to false) + # @option opts [String] :user_agent Custom user agent string set when testing + # @return [Array<(APIResponse, Integer, Hash)>] APIResponse data, response status code and response headers + def create_uptime_test_with_http_info(name, test_type, website_url, check_rate, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UptimeApi.create_uptime_test ...' + end + # verify the required parameter 'name' is set + if @api_client.config.client_side_validation && name.nil? + raise ArgumentError, "Missing the required parameter 'name' when calling UptimeApi.create_uptime_test" + end + # verify the required parameter 'test_type' is set + if @api_client.config.client_side_validation && test_type.nil? + raise ArgumentError, "Missing the required parameter 'test_type' when calling UptimeApi.create_uptime_test" + end + # verify the required parameter 'website_url' is set + if @api_client.config.client_side_validation && website_url.nil? + raise ArgumentError, "Missing the required parameter 'website_url' when calling UptimeApi.create_uptime_test" + end + # verify the required parameter 'check_rate' is set + if @api_client.config.client_side_validation && check_rate.nil? + raise ArgumentError, "Missing the required parameter 'check_rate' when calling UptimeApi.create_uptime_test" + end + if @api_client.config.client_side_validation && !opts[:'confirmation'].nil? && opts[:'confirmation'] > 3 + raise ArgumentError, 'invalid value for "opts[:"confirmation"]" when calling UptimeApi.create_uptime_test, must be smaller than or equal to 3.' + end + + if @api_client.config.client_side_validation && !opts[:'confirmation'].nil? && opts[:'confirmation'] < 0 + raise ArgumentError, 'invalid value for "opts[:"confirmation"]" when calling UptimeApi.create_uptime_test, must be greater than or equal to 0.' + end + + if @api_client.config.client_side_validation && !opts[:'port'].nil? && opts[:'port'] < 0 + raise ArgumentError, 'invalid value for "opts[:"port"]" when calling UptimeApi.create_uptime_test, must be greater than or equal to 0.' + end + + if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] > 75 + raise ArgumentError, 'invalid value for "opts[:"timeout"]" when calling UptimeApi.create_uptime_test, must be smaller than or equal to 75.' + end + + if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] < 5 + raise ArgumentError, 'invalid value for "opts[:"timeout"]" when calling UptimeApi.create_uptime_test, must be greater than or equal to 5.' + end + + if @api_client.config.client_side_validation && !opts[:'trigger_rate'].nil? && opts[:'trigger_rate'] > 60 + raise ArgumentError, 'invalid value for "opts[:"trigger_rate"]" when calling UptimeApi.create_uptime_test, must be smaller than or equal to 60.' + end + + if @api_client.config.client_side_validation && !opts[:'trigger_rate'].nil? && opts[:'trigger_rate'] < 0 + raise ArgumentError, 'invalid value for "opts[:"trigger_rate"]" when calling UptimeApi.create_uptime_test, must be greater than or equal to 0.' + end + + # resource path + local_var_path = '/uptime' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['name'] = name + form_params['test_type'] = test_type + form_params['website_url'] = website_url + form_params['check_rate'] = check_rate + form_params['basic_username'] = opts[:'basic_username'] unless opts[:'basic_username'].nil? + form_params['basic_password'] = opts[:'basic_password'] unless opts[:'basic_password'].nil? + form_params['confirmation'] = opts[:'confirmation'] unless opts[:'confirmation'].nil? + form_params['contact_groups'] = @api_client.build_collection_param(opts[:'contact_groups'], :csv) unless opts[:'contact_groups'].nil? + form_params['custom_header'] = opts[:'custom_header'] unless opts[:'custom_header'].nil? + form_params['do_not_find'] = opts[:'do_not_find'] unless opts[:'do_not_find'].nil? + form_params['dns_ips'] = @api_client.build_collection_param(opts[:'dns_ips'], :csv) unless opts[:'dns_ips'].nil? + form_params['dns_server'] = opts[:'dns_server'] unless opts[:'dns_server'].nil? + form_params['enable_ssl_alert'] = opts[:'enable_ssl_alert'] unless opts[:'enable_ssl_alert'].nil? + form_params['final_endpoint'] = opts[:'final_endpoint'] unless opts[:'final_endpoint'].nil? + form_params['find_string'] = opts[:'find_string'] unless opts[:'find_string'].nil? + form_params['follow_redirects'] = opts[:'follow_redirects'] unless opts[:'follow_redirects'].nil? + form_params['host'] = opts[:'host'] unless opts[:'host'].nil? + form_params['include_header'] = opts[:'include_header'] unless opts[:'include_header'].nil? + form_params['paused'] = opts[:'paused'] unless opts[:'paused'].nil? + form_params['port'] = opts[:'port'] unless opts[:'port'].nil? + form_params['post_body'] = opts[:'_post_body'] unless opts[:'_post_body'].nil? + form_params['post_raw'] = opts[:'post_raw'] unless opts[:'post_raw'].nil? + form_params['regions'] = @api_client.build_collection_param(opts[:'regions'], :csv) unless opts[:'regions'].nil? + form_params['status_codes_csv'] = opts[:'status_codes_csv'] unless opts[:'status_codes_csv'].nil? + form_params['tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) unless opts[:'tags'].nil? + form_params['timeout'] = opts[:'timeout'] unless opts[:'timeout'].nil? + form_params['trigger_rate'] = opts[:'trigger_rate'] unless opts[:'trigger_rate'].nil? + form_params['use_jar'] = opts[:'use_jar'] unless opts[:'use_jar'].nil? + form_params['user_agent'] = opts[:'user_agent'] unless opts[:'user_agent'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'APIResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'UptimeApi.create_uptime_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UptimeApi#create_uptime_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Delete an uptime check + # Deletes an uptime check with the given id. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_uptime_test(test_id, opts = {}) + delete_uptime_test_with_http_info(test_id, opts) + nil + end + + # Delete an uptime check + # Deletes an uptime check with the given id. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_uptime_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UptimeApi.delete_uptime_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling UptimeApi.delete_uptime_test" + end + # resource path + local_var_path = '/uptime/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'UptimeApi.delete_uptime_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UptimeApi#delete_uptime_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Retrieve an uptime check + # Returns an uptime check with the given id. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @return [UptimeTestResponse] + def get_uptime_test(test_id, opts = {}) + data, _status_code, _headers = get_uptime_test_with_http_info(test_id, opts) + data + end + + # Retrieve an uptime check + # Returns an uptime check with the given id. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @return [Array<(UptimeTestResponse, Integer, Hash)>] UptimeTestResponse data, response status code and response headers + def get_uptime_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UptimeApi.get_uptime_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling UptimeApi.get_uptime_test" + end + # resource path + local_var_path = '/uptime/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'UptimeTestResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'UptimeApi.get_uptime_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UptimeApi#get_uptime_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all uptime check alerts + # Returns a list of uptime check alerts for a given id. The returned results are a paginated series. Alongside the response data is a `links` object referencing the current response document, `self`, and the next page in the series, `next`. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit The number of uptime alerts to return per page (default to 25) + # @option opts [Integer] :before Only alerts triggered before this UNIX timestamp will be returned + # @return [UptimeTestAlerts] + def list_uptime_test_alerts(test_id, opts = {}) + data, _status_code, _headers = list_uptime_test_alerts_with_http_info(test_id, opts) + data + end + + # Get all uptime check alerts + # Returns a list of uptime check alerts for a given id. The returned results are a paginated series. Alongside the response data is a `links` object referencing the current response document, `self`, and the next page in the series, `next`. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit The number of uptime alerts to return per page (default to 25) + # @option opts [Integer] :before Only alerts triggered before this UNIX timestamp will be returned + # @return [Array<(UptimeTestAlerts, Integer, Hash)>] UptimeTestAlerts data, response status code and response headers + def list_uptime_test_alerts_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UptimeApi.list_uptime_test_alerts ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling UptimeApi.list_uptime_test_alerts" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling UptimeApi.list_uptime_test_alerts, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling UptimeApi.list_uptime_test_alerts, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'before'].nil? && opts[:'before'] < 0 + raise ArgumentError, 'invalid value for "opts[:"before"]" when calling UptimeApi.list_uptime_test_alerts, must be greater than or equal to 0.' + end + + # resource path + local_var_path = '/uptime/{test_id}/alerts'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + query_params[:'before'] = opts[:'before'] unless opts[:'before'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'UptimeTestAlerts' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'UptimeApi.list_uptime_test_alerts', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UptimeApi#list_uptime_test_alerts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all uptime check history + # Returns a list of uptime check history results for a given id, detailing the runs performed on the StatusCake testing infrastruture. The returned results are a paginated series. Alongside the response data is a `links` object referencing the current response document, `self`, and the next page in the series, `next`. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit The number of results to return per page (default to 25) + # @option opts [Integer] :before Only results created before this UNIX timestamp will be returned + # @return [UptimeTestHistory] + def list_uptime_test_history(test_id, opts = {}) + data, _status_code, _headers = list_uptime_test_history_with_http_info(test_id, opts) + data + end + + # Get all uptime check history + # Returns a list of uptime check history results for a given id, detailing the runs performed on the StatusCake testing infrastruture. The returned results are a paginated series. Alongside the response data is a `links` object referencing the current response document, `self`, and the next page in the series, `next`. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit The number of results to return per page (default to 25) + # @option opts [Integer] :before Only results created before this UNIX timestamp will be returned + # @return [Array<(UptimeTestHistory, Integer, Hash)>] UptimeTestHistory data, response status code and response headers + def list_uptime_test_history_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UptimeApi.list_uptime_test_history ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling UptimeApi.list_uptime_test_history" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling UptimeApi.list_uptime_test_history, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling UptimeApi.list_uptime_test_history, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'before'].nil? && opts[:'before'] < 0 + raise ArgumentError, 'invalid value for "opts[:"before"]" when calling UptimeApi.list_uptime_test_history, must be greater than or equal to 0.' + end + + # resource path + local_var_path = '/uptime/{test_id}/history'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + query_params[:'before'] = opts[:'before'] unless opts[:'before'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'UptimeTestHistory' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'UptimeApi.list_uptime_test_history', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UptimeApi#list_uptime_test_history\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all uptime check periods + # Returns a list of uptime check periods for a given id, detailing the creation time of the period, when it ended and the duration. The returned results are a paginated series. Alongside the response data is a `links` object referencing the current response document, `self`, and the next page in the series, `next`. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit The number of uptime check periods to return per page (default to 25) + # @option opts [Integer] :before Only check periods created before this UNIX timestamp will be returned + # @return [UptimeTestPeriods] + def list_uptime_test_periods(test_id, opts = {}) + data, _status_code, _headers = list_uptime_test_periods_with_http_info(test_id, opts) + data + end + + # Get all uptime check periods + # Returns a list of uptime check periods for a given id, detailing the creation time of the period, when it ended and the duration. The returned results are a paginated series. Alongside the response data is a `links` object referencing the current response document, `self`, and the next page in the series, `next`. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit The number of uptime check periods to return per page (default to 25) + # @option opts [Integer] :before Only check periods created before this UNIX timestamp will be returned + # @return [Array<(UptimeTestPeriods, Integer, Hash)>] UptimeTestPeriods data, response status code and response headers + def list_uptime_test_periods_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UptimeApi.list_uptime_test_periods ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling UptimeApi.list_uptime_test_periods" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling UptimeApi.list_uptime_test_periods, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling UptimeApi.list_uptime_test_periods, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'before'].nil? && opts[:'before'] < 0 + raise ArgumentError, 'invalid value for "opts[:"before"]" when calling UptimeApi.list_uptime_test_periods, must be greater than or equal to 0.' + end + + # resource path + local_var_path = '/uptime/{test_id}/periods'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + query_params[:'before'] = opts[:'before'] unless opts[:'before'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'UptimeTestPeriods' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'UptimeApi.list_uptime_test_periods', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UptimeApi#list_uptime_test_periods\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Get all uptime checks + # Returns a list of uptime checks for an account. + # @param [Hash] opts the optional parameters + # @option opts [String] :status Uptime check status + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of uptime checks to return per page (default to 25) + # @option opts [String] :tags Comma separated list of tags assocaited with a check + # @option opts [Boolean] :matchany Include uptime checks in response that match any specified tag or all tags (default to false) + # @option opts [Boolean] :nouptime Do not calculate uptime percentages for results (default to false) + # @return [UptimeTests] + def list_uptime_tests(opts = {}) + data, _status_code, _headers = list_uptime_tests_with_http_info(opts) + data + end + + # Get all uptime checks + # Returns a list of uptime checks for an account. + # @param [Hash] opts the optional parameters + # @option opts [String] :status Uptime check status + # @option opts [Integer] :page Page of results (default to 1) + # @option opts [Integer] :limit The number of uptime checks to return per page (default to 25) + # @option opts [String] :tags Comma separated list of tags assocaited with a check + # @option opts [Boolean] :matchany Include uptime checks in response that match any specified tag or all tags (default to false) + # @option opts [Boolean] :nouptime Do not calculate uptime percentages for results (default to false) + # @return [Array<(UptimeTests, Integer, Hash)>] UptimeTests data, response status code and response headers + def list_uptime_tests_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UptimeApi.list_uptime_tests ...' + end + # rubocop:disable Style/WordArray + allowable_values = ["down", "up"] + # rubocop:enable Style/WordArray + if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status']) + raise ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}" + end + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1 + raise ArgumentError, 'invalid value for "opts[:"page"]" when calling UptimeApi.list_uptime_tests, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling UptimeApi.list_uptime_tests, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + raise ArgumentError, 'invalid value for "opts[:"limit"]" when calling UptimeApi.list_uptime_tests, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/uptime' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'status'] = opts[:'status'] unless opts[:'status'].nil? + query_params[:'page'] = opts[:'page'] unless opts[:'page'].nil? + query_params[:'limit'] = opts[:'limit'] unless opts[:'limit'].nil? + query_params[:'tags'] = opts[:'tags'] unless opts[:'tags'].nil? + query_params[:'matchany'] = opts[:'matchany'] unless opts[:'matchany'].nil? + query_params[:'nouptime'] = opts[:'nouptime'] unless opts[:'nouptime'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'UptimeTests' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'UptimeApi.list_uptime_tests', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UptimeApi#list_uptime_tests\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + + # Update an uptime check + # Updates an uptime check with the given parameters. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @option opts [String] :name Name of the check + # @option opts [UptimeTestCheckRate] :check_rate + # @option opts [String] :basic_username Basic authentication username + # @option opts [String] :basic_password Basic authentication password + # @option opts [Integer] :confirmation Number of confirmation servers to confirm downtime before an alert is triggered + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [String] :custom_header JSON object. Represents headers to be sent when making requests + # @option opts [Boolean] :do_not_find Whether to consider the check as down if the content is present within the response + # @option opts [Array] :dns_ips List of IP addresses to compare against returned DNS records + # @option opts [String] :dns_server FQDN or IP address of the nameserver to query + # @option opts [Boolean] :enable_ssl_alert Whether to send an alert if the SSL certificate is soon to expire + # @option opts [String] :final_endpoint Specify where the redirect chain should end + # @option opts [String] :find_string String to look for within the response. Considered down if not found + # @option opts [Boolean] :follow_redirects Whether to follow redirects when testing. Disabled by default + # @option opts [String] :host Name of the hosting provider + # @option opts [Boolean] :include_header Include header content in string match search + # @option opts [Boolean] :paused Whether the check should be run + # @option opts [Integer] :port Destination port for TCP checks + # @option opts [String] :_post_body JSON object. Payload submitted with the request. Setting this updates the check to use the HTTP POST verb + # @option opts [String] :post_raw Raw HTTP POST string to send to the server + # @option opts [Array] :regions List of regions on which to run checks. The values required for this parameter can be retrieved from the `GET /v1/uptime-locations` endpoint. + # @option opts [String] :status_codes_csv Comma separated list of status codes that trigger an alert + # @option opts [Array] :tags List of tags + # @option opts [Integer] :timeout The number of seconds to wait to receive the first byte + # @option opts [Integer] :trigger_rate The number of minutes to wait before sending an alert + # @option opts [Boolean] :use_jar Whether to enable cookie storage + # @option opts [String] :user_agent Custom user agent string set when testing + # @return [nil] + def update_uptime_test(test_id, opts = {}) + update_uptime_test_with_http_info(test_id, opts) + nil + end + + # Update an uptime check + # Updates an uptime check with the given parameters. + # @param test_id [String] Uptime check ID + # @param [Hash] opts the optional parameters + # @option opts [String] :name Name of the check + # @option opts [UptimeTestCheckRate] :check_rate + # @option opts [String] :basic_username Basic authentication username + # @option opts [String] :basic_password Basic authentication password + # @option opts [Integer] :confirmation Number of confirmation servers to confirm downtime before an alert is triggered + # @option opts [Array] :contact_groups List of contact group IDs + # @option opts [String] :custom_header JSON object. Represents headers to be sent when making requests + # @option opts [Boolean] :do_not_find Whether to consider the check as down if the content is present within the response + # @option opts [Array] :dns_ips List of IP addresses to compare against returned DNS records + # @option opts [String] :dns_server FQDN or IP address of the nameserver to query + # @option opts [Boolean] :enable_ssl_alert Whether to send an alert if the SSL certificate is soon to expire + # @option opts [String] :final_endpoint Specify where the redirect chain should end + # @option opts [String] :find_string String to look for within the response. Considered down if not found + # @option opts [Boolean] :follow_redirects Whether to follow redirects when testing. Disabled by default + # @option opts [String] :host Name of the hosting provider + # @option opts [Boolean] :include_header Include header content in string match search + # @option opts [Boolean] :paused Whether the check should be run + # @option opts [Integer] :port Destination port for TCP checks + # @option opts [String] :_post_body JSON object. Payload submitted with the request. Setting this updates the check to use the HTTP POST verb + # @option opts [String] :post_raw Raw HTTP POST string to send to the server + # @option opts [Array] :regions List of regions on which to run checks. The values required for this parameter can be retrieved from the `GET /v1/uptime-locations` endpoint. + # @option opts [String] :status_codes_csv Comma separated list of status codes that trigger an alert + # @option opts [Array] :tags List of tags + # @option opts [Integer] :timeout The number of seconds to wait to receive the first byte + # @option opts [Integer] :trigger_rate The number of minutes to wait before sending an alert + # @option opts [Boolean] :use_jar Whether to enable cookie storage + # @option opts [String] :user_agent Custom user agent string set when testing + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_uptime_test_with_http_info(test_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UptimeApi.update_uptime_test ...' + end + # verify the required parameter 'test_id' is set + if @api_client.config.client_side_validation && test_id.nil? + raise ArgumentError, "Missing the required parameter 'test_id' when calling UptimeApi.update_uptime_test" + end + if @api_client.config.client_side_validation && !opts[:'confirmation'].nil? && opts[:'confirmation'] > 3 + raise ArgumentError, 'invalid value for "opts[:"confirmation"]" when calling UptimeApi.update_uptime_test, must be smaller than or equal to 3.' + end + + if @api_client.config.client_side_validation && !opts[:'confirmation'].nil? && opts[:'confirmation'] < 0 + raise ArgumentError, 'invalid value for "opts[:"confirmation"]" when calling UptimeApi.update_uptime_test, must be greater than or equal to 0.' + end + + if @api_client.config.client_side_validation && !opts[:'port'].nil? && opts[:'port'] < 0 + raise ArgumentError, 'invalid value for "opts[:"port"]" when calling UptimeApi.update_uptime_test, must be greater than or equal to 0.' + end + + if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] > 75 + raise ArgumentError, 'invalid value for "opts[:"timeout"]" when calling UptimeApi.update_uptime_test, must be smaller than or equal to 75.' + end + + if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] < 5 + raise ArgumentError, 'invalid value for "opts[:"timeout"]" when calling UptimeApi.update_uptime_test, must be greater than or equal to 5.' + end + + if @api_client.config.client_side_validation && !opts[:'trigger_rate'].nil? && opts[:'trigger_rate'] > 60 + raise ArgumentError, 'invalid value for "opts[:"trigger_rate"]" when calling UptimeApi.update_uptime_test, must be smaller than or equal to 60.' + end + + if @api_client.config.client_side_validation && !opts[:'trigger_rate'].nil? && opts[:'trigger_rate'] < 0 + raise ArgumentError, 'invalid value for "opts[:"trigger_rate"]" when calling UptimeApi.update_uptime_test, must be greater than or equal to 0.' + end + + # resource path + local_var_path = '/uptime/{test_id}'.sub('{' + 'test_id' + '}', CGI.escape(test_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + unless content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['name'] = opts[:'name'] unless opts[:'name'].nil? + form_params['check_rate'] = opts[:'check_rate'] unless opts[:'check_rate'].nil? + form_params['basic_username'] = opts[:'basic_username'] unless opts[:'basic_username'].nil? + form_params['basic_password'] = opts[:'basic_password'] unless opts[:'basic_password'].nil? + form_params['confirmation'] = opts[:'confirmation'] unless opts[:'confirmation'].nil? + form_params['contact_groups'] = @api_client.build_collection_param(opts[:'contact_groups'], :csv) unless opts[:'contact_groups'].nil? + form_params['custom_header'] = opts[:'custom_header'] unless opts[:'custom_header'].nil? + form_params['do_not_find'] = opts[:'do_not_find'] unless opts[:'do_not_find'].nil? + form_params['dns_ips'] = @api_client.build_collection_param(opts[:'dns_ips'], :csv) unless opts[:'dns_ips'].nil? + form_params['dns_server'] = opts[:'dns_server'] unless opts[:'dns_server'].nil? + form_params['enable_ssl_alert'] = opts[:'enable_ssl_alert'] unless opts[:'enable_ssl_alert'].nil? + form_params['final_endpoint'] = opts[:'final_endpoint'] unless opts[:'final_endpoint'].nil? + form_params['find_string'] = opts[:'find_string'] unless opts[:'find_string'].nil? + form_params['follow_redirects'] = opts[:'follow_redirects'] unless opts[:'follow_redirects'].nil? + form_params['host'] = opts[:'host'] unless opts[:'host'].nil? + form_params['include_header'] = opts[:'include_header'] unless opts[:'include_header'].nil? + form_params['paused'] = opts[:'paused'] unless opts[:'paused'].nil? + form_params['port'] = opts[:'port'] unless opts[:'port'].nil? + form_params['post_body'] = opts[:'_post_body'] unless opts[:'_post_body'].nil? + form_params['post_raw'] = opts[:'post_raw'] unless opts[:'post_raw'].nil? + form_params['regions'] = @api_client.build_collection_param(opts[:'regions'], :csv) unless opts[:'regions'].nil? + form_params['status_codes_csv'] = opts[:'status_codes_csv'] unless opts[:'status_codes_csv'].nil? + form_params['tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) unless opts[:'tags'].nil? + form_params['timeout'] = opts[:'timeout'] unless opts[:'timeout'].nil? + form_params['trigger_rate'] = opts[:'trigger_rate'] unless opts[:'trigger_rate'].nil? + form_params['use_jar'] = opts[:'use_jar'] unless opts[:'use_jar'].nil? + form_params['user_agent'] = opts[:'user_agent'] unless opts[:'user_agent'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :'UptimeApi.update_uptime_test', + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UptimeApi#update_uptime_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + + [data, status_code, headers] + end + end +end diff --git a/lib/statuscake/api_client.rb b/lib/statuscake/api_client.rb new file mode 100644 index 0000000..1ff1502 --- /dev/null +++ b/lib/statuscake/api_client.rb @@ -0,0 +1,407 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'json' +require 'logger' +require 'tempfile' +require 'time' +require 'typhoeus' + +module StatusCake + # :nodoc + class ApiClient + # The Configuration object holding settings to be used in the API client. + attr_accessor :config + + # Defines the headers to be used in HTTP requests of all API calls by default. + # + # @return [Hash] + attr_accessor :default_headers + + # Initializes the ApiClient + # @option config [Configuration] Configuration for initializing the object, default to Configuration.default + def initialize(config = Configuration.default) + @config = config + @user_agent = "statuscake/rb" + @default_headers = { + 'Content-Type' => 'application/json', + 'User-Agent' => @user_agent, + } + end + + def self.default + @default ||= ApiClient.new + end + + # Call an API with given options. + # + # @return [Array<(Object, Integer, Hash)>] an array of 3 elements: + # the data deserialized from response body (could be nil), response status code and response headers. + def call_api(http_method, path, opts = {}) + request = build_request(http_method, path, opts) + response = request.run + + if @config.debugging + @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" + end + + unless response.success? + if response.timed_out? + raise StandardError, ApiError.new('Connection timed out') + elsif response.code == 0 + # Errors from libcurl will be made visible here + raise StandardError, ApiError.new(:code => 0, + :message => response.return_message) + else + raise StandardError, ApiError.new(:code => response.code, + :response_headers => response.headers, + :response_body => response.body) + end + end + + data = if opts[:return_type] + deserialize(response, opts[:return_type]) + end + + [data, response.code, response.headers] + end + + # Builds the HTTP request + # + # @param [String] http_method HTTP method/verb (e.g. POST) + # @param [String] path URL path (e.g. /account/new) + # @option opts [Hash] :header_params Header parameters + # @option opts [Hash] :query_params Query parameters + # @option opts [Hash] :form_params Query parameters + # @option opts [Object] :body HTTP body (JSON/XML) + # @return [Typhoeus::Request] A Typhoeus Request + def build_request(http_method, path, opts = {}) + url = build_request_url(path, opts) + http_method = http_method.to_sym.downcase + + header_params = @default_headers.merge(opts[:header_params] || {}) + query_params = opts[:query_params] || {} + form_params = opts[:form_params] || {} + follow_location = opts[:follow_location] || true + + update_params_for_auth! header_params, query_params, opts[:auth_names] + + # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false) + verify_ssl_host = @config.verify_ssl_host ? 2 : 0 + + req_opts = { + :method => http_method, + :headers => header_params, + :params => query_params, + :params_encoding => @config.params_encoding, + :timeout => @config.timeout, + :ssl_verifypeer => @config.verify_ssl, + :ssl_verifyhost => verify_ssl_host, + :sslcert => @config.cert_file, + :sslkey => @config.key_file, + :verbose => @config.debugging, + :followlocation => follow_location, + } + + # set custom cert, if provided + req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert + + if %i[post patch put delete].include?(http_method) + req_body = build_request_body(header_params, form_params, opts[:body]) + req_opts.update :body => req_body + if @config.debugging + @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" + end + end + + request = Typhoeus::Request.new(url, req_opts) + download_file(request) if opts[:return_type] == 'File' + request + end + + # Builds the HTTP request body + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [Object] body HTTP body (JSON/XML) + # @return [String] HTTP body data in the form of string + def build_request_body(header_params, form_params, body) + # http form + if header_params['Content-Type'] == 'application/x-www-form-urlencoded' || + header_params['Content-Type'] == 'multipart/form-data' + data = {} + form_params.each do |key, value| + data[key] = case value + when ::File, ::Array, nil + # let typhoeus handle File, Array and nil parameters + value + else + value.to_s + end + end + elsif body + data = body.is_a?(String) ? body : body.to_json + else + data = nil + end + data + end + + # Save response body into a file in (the defined) temporary folder, using the filename + # from the "Content-Disposition" header if provided, otherwise a random filename. + # The response body is written to the file in chunks in order to handle files which + # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby + # process can use. + # + # @see Configuration#temp_folder_path + def download_file(request) + tempfile = nil + encoding = nil + request.on_headers do |response| + content_disposition = response.headers['Content-Disposition'] + if content_disposition && content_disposition =~ /filename=/i + filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] + prefix = sanitize_filename(filename) + else + prefix = 'download-' + end + prefix += '-' unless prefix.end_with?('-') + encoding = response.body.encoding + tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) + @tempfile = tempfile + end + request.on_body do |chunk| + chunk.force_encoding(encoding) + tempfile.write(chunk) + end + request.on_complete do |_| + if tempfile + tempfile.close + @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder " \ + "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \ + "will be deleted automatically with GC. It's also recommended to delete the temp file " \ + "explicitly with `tempfile.delete`" + end + end + end + + # Check if the given MIME is a JSON MIME. + # JSON MIME examples: + # application/json + # application/json; charset=UTF8 + # APPLICATION/JSON + # */* + # @param [String] mime MIME + # @return [Boolean] True if the MIME is application/json + def json_mime?(mime) + (mime == '*/*') || !(mime =~ %r{Application/.*json(?!p)(;.*)?}i).nil? + end + + # Deserialize the response to the given return type. + # + # @param [Response] response HTTP response + # @param [String] return_type some examples: "User", "Array", "Hash" + def deserialize(response, return_type) + body = response.body + + # handle file downloading - return the File instance processed in request callbacks + # note that response body is empty when the file is written in chunks in request on_body callback + return @tempfile if return_type == 'File' + + return nil if body.nil? || body.empty? + + # return response body directly for String return type + return body if return_type == 'String' + + # ensuring a default content type + content_type = response.headers['Content-Type'] || 'application/json' + + raise ArgumentError, "Content-Type is not supported: #{content_type}" unless json_mime?(content_type) + + begin + data = JSON.parse("[#{body}]", :symbolize_names => true)[0] + rescue JSON::ParserError => e + if %w[String Date Time].include?(return_type) + data = body + else + raise e + end + end + + convert_to_type data, return_type + end + + # Convert data to the given return type. + # @param [Object] data Data to be converted + # @param [String] return_type Return type + # @return [Mixed] Data in a particular type + def convert_to_type(data, return_type) + return nil if data.nil? + case return_type + when 'String' + data.to_s + when 'Integer' + data.to_i + when 'Float' + data.to_f + when 'Boolean' + data == true + when 'Time' + # parse date time (expecting ISO 8601 format) + Time.parse data + when 'Date' + # parse date time (expecting ISO 8601 format) + Date.parse data + when 'Object' + # generic object (usually a Hash), return directly + data + when /\AArray<(.+)>\z/ + # e.g. Array + sub_type = Regexp.last_match(1) + data.map { |item| convert_to_type(item, sub_type) } + when /\AHash\z/ + # e.g. Hash + sub_type = Regexp.last_match(1) + {}.tap do |hash| + data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } + end + else + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(return_type) + klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) + end + end + + # Sanitize filename by removing path. + # e.g. ../../sun.gif becomes sun.gif + # + # @param [String] filename the filename to be sanitized + # @return [String] the sanitized filename + def sanitize_filename(filename) + filename.gsub(%r{.*[/\\]}, '') + end + + def build_request_url(path, opts = {}) + # Add leading and trailing slashes to path + path = "/#{path}".gsub(%r{/+}, '/') + @config.base_url(opts[:operation]) + path + end + + # Update header and query params based on authentication settings. + # + # @param [Hash] header_params Header parameters + # @param [Hash] query_params Query parameters + # @param [String] auth_names Authentication scheme name + def update_params_for_auth!(header_params, query_params, auth_names) + Array(auth_names).each do |auth_name| + auth_setting = @config.auth_settings[auth_name] + next unless auth_setting + case auth_setting[:in] + when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] + when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] + else raise ArgumentError, 'Authentication token must be in `query` or `header`' + end + end + end + + # Sets user agent in HTTP header + # + # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0) + def user_agent=(user_agent) + @user_agent = user_agent + @default_headers['User-Agent'] = @user_agent + end + + # Return Accept header based on an array of accepts provided. + # @param [Array] accepts array for Accept + # @return [String] the Accept header (e.g. application/json) + def select_header_accept(accepts) + return nil if accepts.nil? || accepts.empty? + # use JSON when present, otherwise use all of the provided + json_accept = accepts.find { |s| json_mime?(s) } + json_accept || accepts.join(',') + end + + # Return Content-Type header based on an array of content types provided. + # @param [Array] content_types array for Content-Type + # @return [String] the Content-Type header (e.g. application/json) + def select_header_content_type(content_types) + # return nil by default + return if content_types.nil? || content_types.empty? + # use JSON when present, otherwise use the first one + json_content_type = content_types.find { |s| json_mime?(s) } + json_content_type || content_types.first + end + + # Convert object (array, hash, object, etc) to JSON string. + # @param [Object] model object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_http_body(model) + return model if model.nil? || model.is_a?(String) + local_body = if model.is_a?(Array) + model.map { |m| object_to_hash(m) } + else + object_to_hash(model) + end + local_body.to_json + end + + # Convert object(non-array) to hash. + # @param [Object] obj object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_hash(obj) + if obj.respond_to?(:to_hash) + obj.to_hash + else + obj + end + end + + # Build parameter value according to the given collection format. + # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi + def build_collection_param(param, collection_format) + case collection_format + when :csv + param.join(',') + when :ssv + param.join(' ') + when :tsv + param.join("\t") + when :pipes + param.join('|') + when :multi + # return the array directly as typhoeus will handle it as expected + param + else + raise ArgumentError, "unknown collection format: #{collection_format.inspect}" + end + end + end +end diff --git a/lib/statuscake/api_error.rb b/lib/statuscake/api_error.rb new file mode 100644 index 0000000..935a06b --- /dev/null +++ b/lib/statuscake/api_error.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +module StatusCake + # :nodoc + class ApiError < StandardError + attr_reader :code, :response_headers, :response_body + + # Usage examples: + # ApiError.new + # ApiError.new("message") + # ApiError.new(:code => 500, :response_headers => {}, :response_body => "") + # ApiError.new(:code => 404, :message => "Not Found") + def initialize(arg = nil) + if arg.is_a? Hash + if arg.key?(:message) || arg.key?('message') + super(arg[:message] || arg['message']) + else + super arg + end + + arg.each do |k, v| + instance_variable_set "@#{k}", v + end + else + super arg + end + end + + # Override to_s to display a friendly error message + def to_s + message + end + + def message + msg = if @message.nil? + "Error message: the server returns an error" + else + @message + end + + msg += "\nHTTP status code: #{code}" if code + msg += "\nResponse headers: #{response_headers}" if response_headers + msg += "\nResponse body: #{response_body}" if response_body + + msg + end + end +end diff --git a/lib/statuscake/configuration.rb b/lib/statuscake/configuration.rb new file mode 100644 index 0000000..30bb71c --- /dev/null +++ b/lib/statuscake/configuration.rb @@ -0,0 +1,296 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +module StatusCake + # :nodoc + class Configuration + # Defines url scheme + attr_accessor :scheme + + # Defines url host + attr_accessor :host + + # Defines url base path + attr_accessor :base_path + + # Define server configuration index + attr_accessor :server_index + + # Define server operation configuration index + attr_accessor :server_operation_index + + # Default server variables + attr_accessor :server_variables + + # Default server operation variables + attr_accessor :server_operation_variables + + # Defines API keys used with API Key authentications. + # + # @return [Hash] key: parameter name, value: parameter value (API key) + # + # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string) + # config.api_key['api_key'] = 'xxx' + attr_accessor :api_key + + # Defines API key prefixes used with API Key authentications. + # + # @return [Hash] key: parameter name, value: API key prefix + # + # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers) + # config.api_key_prefix['api_key'] = 'Token' + attr_accessor :api_key_prefix + + # Defines the username used with HTTP basic authentication. + # + # @return [String] + attr_accessor :username + + # Defines the password used with HTTP basic authentication. + # + # @return [String] + attr_accessor :password + + # Defines the access token (Bearer) used with OAuth2. + attr_accessor :access_token + + # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response + # details will be logged with `logger.debug` (see the `logger` attribute). + # Default to false. + # + # @return [true, false] + attr_accessor :debugging + + # Defines the logger used for debugging. + # Default to `Rails.logger` (when in Rails) or logging to STDOUT. + # + # @return [#debug] + attr_accessor :logger + + # Defines the temporary folder to store downloaded files + # (for API endpoints that have file response). + # Default to use `Tempfile`. + # + # @return [String] + attr_accessor :temp_folder_path + + # The time limit for HTTP request in seconds. + # Default to 0 (never times out). + attr_accessor :timeout + + # Set this to false to skip client side validation in the operation. + # Default to true. + # @return [true, false] + attr_accessor :client_side_validation + + ### TLS/SSL setting + # Set this to false to skip verifying SSL certificate when calling API from https server. + # Default to true. + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + # @return [true, false] + attr_accessor :verify_ssl + + ### TLS/SSL setting + # Set this to false to skip verifying SSL host name + # Default to true. + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + # @return [true, false] + attr_accessor :verify_ssl_host + + ### TLS/SSL setting + # Set this to customize the certificate file to verify the peer. + # + # @return [String] the path to the certificate file + # + # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code: + # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145 + attr_accessor :ssl_ca_cert + + ### TLS/SSL setting + # Client certificate file (for client certificate) + attr_accessor :cert_file + + ### TLS/SSL setting + # Client private key file (for client certificate) + attr_accessor :key_file + + # Set this to customize parameters encoding of array parameter with multi collectionFormat. + # Default to nil. + # + # @see The params_encoding option of Ethon. Related source code: + # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96 + attr_accessor :params_encoding + + attr_accessor :inject_format + + attr_accessor :force_ending_format + + def initialize + @scheme = 'https' + @host = 'api.statuscake.com' + @base_path = '/v1' + @server_index = 0 + @server_operation_index = {} + @server_variables = {} + @server_operation_variables = {} + @api_key = {} + @api_key_prefix = {} + @client_side_validation = true + @verify_ssl = true + @verify_ssl_host = true + @cert_file = nil + @key_file = nil + @timeout = 0 + @params_encoding = nil + @debugging = false + @inject_format = false + @force_ending_format = false + @logger = defined?(Rails) ? Rails.logger : Logger.new($stdout) + + yield(self) if block_given? + end + + # The default Configuration object. + def self.default + @default ||= Configuration.new + end + + def configure + yield(self) if block_given? + end + + def scheme=(scheme) + # remove :// from scheme + @scheme = scheme.sub(%r{://}, '') + end + + def host=(host) + # remove http(s):// and anything after a slash + @host = host.sub(%r{https?://}, '').split('/').first + end + + def base_path=(base_path) + # Add leading and trailing slashes to base_path + @base_path = "/#{base_path}".gsub(%r{/+}, '/') + @base_path = '' if @base_path == '/' + end + + # Returns base URL for specified operation based on server settings + def base_url(operation = nil) + index = server_operation_index.fetch(operation, server_index) + return "#{scheme}://#{[host, base_path].join('/').gsub(%r{/+}, '/')}".sub(%r{/+\z}, '') if index.nil? + + server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation]) + end + + # Gets API key (with prefix if set). + # @param [String] param_name the parameter name of API key auth + def api_key_with_prefix(param_name, param_alias = nil) + key = @api_key[param_name] + key = @api_key.fetch(param_alias, key) unless param_alias.nil? + if @api_key_prefix[param_name] + "#{@api_key_prefix[param_name]} #{key}" + else + key + end + end + + # Gets Basic Auth token string + def basic_auth_token + 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n") + end + + # Returns Auth Settings hash for api client. + def auth_settings + { + 'api_key' => + { + type: 'api_key', + in: 'header', + key: 'Authorization', + value: api_key_with_prefix('api_key'), + }, + } + end + + # Returns an array of Server setting + def server_settings + [ + { + url: "https://api.statuscake.com/v1", + description: "No description provided", + }, + ] + end + + def operation_server_settings + { + } + end + + # Returns URL based on server settings + # + # @param index array index of the server settings + # @param variables hash of variable and the corresponding value + def server_url(index, variables = {}, servers = nil) + servers = server_settings if servers.nil? + + # check array index out of bound + if index.negative? || index >= servers.size + raise ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}" + end + + server = servers[index] + url = server[:url] + + return url unless server.key? :variables + + # go through variable and assign a value + server[:variables].each do |name, _| + if variables.key?(name) + if !server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]) + url.gsub! "{" + name.to_s + "}", variables[name] + else + raise ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}." + end + else + # use default value + url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value] + end + end + + url + end + + end +end diff --git a/lib/statuscake/models/api_error.rb b/lib/statuscake/models/api_error.rb new file mode 100644 index 0000000..7dab210 --- /dev/null +++ b/lib/statuscake/models/api_error.rb @@ -0,0 +1,249 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class APIError + # Additional message + attr_accessor :message + + # List of error messages + attr_accessor :errors + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'message' => :'message', + :'errors' => :'errors', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'message' => :'String', + :'errors' => :'Hash>', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::APIError` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::APIError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + + if attributes.key?(:'errors') + if (value = attributes[:'errors']).is_a?(Hash) + self.errors = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + message == other.message && + errors == other.errors + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [message, errors].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/api_response.rb b/lib/statuscake/models/api_response.rb new file mode 100644 index 0000000..cfbdaae --- /dev/null +++ b/lib/statuscake/models/api_response.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class APIResponse + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'APIResponseData', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::APIResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::APIResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/api_response_data.rb b/lib/statuscake/models/api_response_data.rb new file mode 100644 index 0000000..fada290 --- /dev/null +++ b/lib/statuscake/models/api_response_data.rb @@ -0,0 +1,243 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + # Response body + class APIResponseData + # ID of newly created resource. + attr_accessor :new_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'new_id' => :'new_id', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'new_id' => :'String', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::APIResponseData` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::APIResponseData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'new_id') + self.new_id = attributes[:'new_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @new_id.nil? + invalid_properties.push('invalid value for "new_id", new_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @new_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + new_id == other.new_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [new_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/contact_group.rb b/lib/statuscake/models/contact_group.rb new file mode 100644 index 0000000..269fcb6 --- /dev/null +++ b/lib/statuscake/models/contact_group.rb @@ -0,0 +1,318 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class ContactGroup + # Contact group ID + attr_accessor :id + + # Name of the contact group + attr_accessor :name + + # List of email addresses + attr_accessor :email_addresses + + # List of configured integration IDs + attr_accessor :integrations + + # List of international format mobile phone numbers + attr_accessor :mobile_numbers + + # URL or IP address of an endpoint to push uptime events. Currently this only supports HTTP GET endpoints + attr_accessor :ping_url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'email_addresses' => :'email_addresses', + :'integrations' => :'integrations', + :'mobile_numbers' => :'mobile_numbers', + :'ping_url' => :'ping_url', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'email_addresses' => :'Array', + :'integrations' => :'Array', + :'mobile_numbers' => :'Array', + :'ping_url' => :'String', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::ContactGroup` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::ContactGroup`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'email_addresses') + if (value = attributes[:'email_addresses']).is_a?(Array) + self.email_addresses = value + end + end + + if attributes.key?(:'integrations') + if (value = attributes[:'integrations']).is_a?(Array) + self.integrations = value + end + end + + if attributes.key?(:'mobile_numbers') + if (value = attributes[:'mobile_numbers']).is_a?(Array) + self.mobile_numbers = value + end + end + + if attributes.key?(:'ping_url') + self.ping_url = attributes[:'ping_url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @email_addresses.nil? + invalid_properties.push('invalid value for "email_addresses", email_addresses cannot be nil.') + end + + if @integrations.nil? + invalid_properties.push('invalid value for "integrations", integrations cannot be nil.') + end + + if @mobile_numbers.nil? + invalid_properties.push('invalid value for "mobile_numbers", mobile_numbers cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @id.nil? + return false if @name.nil? + return false if @email_addresses.nil? + return false if @integrations.nil? + return false if @mobile_numbers.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + id == other.id && + name == other.name && + email_addresses == other.email_addresses && + integrations == other.integrations && + mobile_numbers == other.mobile_numbers && + ping_url == other.ping_url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, email_addresses, integrations, mobile_numbers, ping_url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/contact_group_response.rb b/lib/statuscake/models/contact_group_response.rb new file mode 100644 index 0000000..b203e52 --- /dev/null +++ b/lib/statuscake/models/contact_group_response.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class ContactGroupResponse + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'ContactGroup', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::ContactGroupResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::ContactGroupResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/contact_groups.rb b/lib/statuscake/models/contact_groups.rb new file mode 100644 index 0000000..5115d80 --- /dev/null +++ b/lib/statuscake/models/contact_groups.rb @@ -0,0 +1,258 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class ContactGroups + # List of contact groups + attr_accessor :data + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'metadata' => :'Pagination', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::ContactGroups` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::ContactGroups`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/links.rb b/lib/statuscake/models/links.rb new file mode 100644 index 0000000..2859806 --- /dev/null +++ b/lib/statuscake/models/links.rb @@ -0,0 +1,242 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class Links + # The URL that created the current response document + attr_accessor :_self + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'_self' => :'self', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'_self' => :'String', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::Links` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::Links`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'_self') + self._self = attributes[:'_self'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @_self.nil? + invalid_properties.push('invalid value for "_self", _self cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @_self.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + _self == other._self + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [_self].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/maintenance_window.rb b/lib/statuscake/models/maintenance_window.rb new file mode 100644 index 0000000..df16bed --- /dev/null +++ b/lib/statuscake/models/maintenance_window.rb @@ -0,0 +1,364 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class MaintenanceWindow + # Maintenance window ID + attr_accessor :id + + # Name of the maintenance window + attr_accessor :name + + # End of the maintenance window (RFC3339 format) + attr_accessor :end_at + + attr_accessor :repeat_interval + + # Start of the maintenance window (RFC3339 format) + attr_accessor :start_at + + attr_accessor :state + + # List of tags used to include matching uptime checks in this maintenance window + attr_accessor :tags + + # List of uptime check IDs explicitly included in this maintenance window + attr_accessor :tests + + # Standard [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) associated with this maintenance window + attr_accessor :timezone + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'end_at' => :'end_at', + :'repeat_interval' => :'repeat_interval', + :'start_at' => :'start_at', + :'state' => :'state', + :'tags' => :'tags', + :'tests' => :'tests', + :'timezone' => :'timezone', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'end_at' => :'Time', + :'repeat_interval' => :'MaintenanceWindowRepeatInterval', + :'start_at' => :'Time', + :'state' => :'MaintenanceWindowState', + :'tags' => :'Array', + :'tests' => :'Array', + :'timezone' => :'String', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::MaintenanceWindow` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::MaintenanceWindow`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'end_at') + self.end_at = attributes[:'end_at'] + end + + if attributes.key?(:'repeat_interval') + self.repeat_interval = attributes[:'repeat_interval'] + end + + if attributes.key?(:'start_at') + self.start_at = attributes[:'start_at'] + end + + if attributes.key?(:'state') + self.state = attributes[:'state'] + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes.key?(:'tests') + if (value = attributes[:'tests']).is_a?(Array) + self.tests = value + end + end + + if attributes.key?(:'timezone') + self.timezone = attributes[:'timezone'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @end_at.nil? + invalid_properties.push('invalid value for "end_at", end_at cannot be nil.') + end + + if @repeat_interval.nil? + invalid_properties.push('invalid value for "repeat_interval", repeat_interval cannot be nil.') + end + + if @start_at.nil? + invalid_properties.push('invalid value for "start_at", start_at cannot be nil.') + end + + if @state.nil? + invalid_properties.push('invalid value for "state", state cannot be nil.') + end + + if @tags.nil? + invalid_properties.push('invalid value for "tags", tags cannot be nil.') + end + + if @tests.nil? + invalid_properties.push('invalid value for "tests", tests cannot be nil.') + end + + if @timezone.nil? + invalid_properties.push('invalid value for "timezone", timezone cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @id.nil? + return false if @name.nil? + return false if @end_at.nil? + return false if @repeat_interval.nil? + return false if @start_at.nil? + return false if @state.nil? + return false if @tags.nil? + return false if @tests.nil? + return false if @timezone.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + id == other.id && + name == other.name && + end_at == other.end_at && + repeat_interval == other.repeat_interval && + start_at == other.start_at && + state == other.state && + tags == other.tags && + tests == other.tests && + timezone == other.timezone + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, end_at, repeat_interval, start_at, state, tags, tests, timezone].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/maintenance_window_repeat_interval.rb b/lib/statuscake/models/maintenance_window_repeat_interval.rb new file mode 100644 index 0000000..970a43b --- /dev/null +++ b/lib/statuscake/models/maintenance_window_repeat_interval.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class MaintenanceWindowRepeatInterval + Never = "never" + Daily = "1d" + Weekly = "1w" + Biweekly = "2w" + Monthly = "1m" + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = MaintenanceWindowRepeatInterval.constants.select { |c| MaintenanceWindowRepeatInterval.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #MaintenanceWindowRepeatInterval" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/maintenance_window_response.rb b/lib/statuscake/models/maintenance_window_response.rb new file mode 100644 index 0000000..b441628 --- /dev/null +++ b/lib/statuscake/models/maintenance_window_response.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class MaintenanceWindowResponse + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'MaintenanceWindow', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::MaintenanceWindowResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::MaintenanceWindowResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/maintenance_window_state.rb b/lib/statuscake/models/maintenance_window_state.rb new file mode 100644 index 0000000..56fd21e --- /dev/null +++ b/lib/statuscake/models/maintenance_window_state.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class MaintenanceWindowState + Active = "active" + Paused = "paused" + Pending = "pending" + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = MaintenanceWindowState.constants.select { |c| MaintenanceWindowState.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #MaintenanceWindowState" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/maintenance_windows.rb b/lib/statuscake/models/maintenance_windows.rb new file mode 100644 index 0000000..5cc2f76 --- /dev/null +++ b/lib/statuscake/models/maintenance_windows.rb @@ -0,0 +1,258 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class MaintenanceWindows + # List of maintenance windows + attr_accessor :data + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'metadata' => :'Pagination', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::MaintenanceWindows` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::MaintenanceWindows`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/monitoring_location.rb b/lib/statuscake/models/monitoring_location.rb new file mode 100644 index 0000000..5832f1e --- /dev/null +++ b/lib/statuscake/models/monitoring_location.rb @@ -0,0 +1,306 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class MonitoringLocation + # Server description + attr_accessor :description + + # Server IPv4 address + attr_accessor :ipv4 + + # Server IPv6 address + attr_accessor :ipv6 + + # Server region + attr_accessor :region + + # Server region code + attr_accessor :region_code + + attr_accessor :status + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'description' => :'description', + :'ipv4' => :'ipv4', + :'ipv6' => :'ipv6', + :'region' => :'region', + :'region_code' => :'region_code', + :'status' => :'status', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'description' => :'String', + :'ipv4' => :'String', + :'ipv6' => :'String', + :'region' => :'String', + :'region_code' => :'String', + :'status' => :'MonitoringLocationStatus', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::MonitoringLocation` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::MonitoringLocation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'ipv4') + self.ipv4 = attributes[:'ipv4'] + end + + if attributes.key?(:'ipv6') + self.ipv6 = attributes[:'ipv6'] + end + + if attributes.key?(:'region') + self.region = attributes[:'region'] + end + + if attributes.key?(:'region_code') + self.region_code = attributes[:'region_code'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + if @region.nil? + invalid_properties.push('invalid value for "region", region cannot be nil.') + end + + if @region_code.nil? + invalid_properties.push('invalid value for "region_code", region_code cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @description.nil? + return false if @region.nil? + return false if @region_code.nil? + return false if @status.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + description == other.description && + ipv4 == other.ipv4 && + ipv6 == other.ipv6 && + region == other.region && + region_code == other.region_code && + status == other.status + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [description, ipv4, ipv6, region, region_code, status].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/monitoring_location_status.rb b/lib/statuscake/models/monitoring_location_status.rb new file mode 100644 index 0000000..77e0a7f --- /dev/null +++ b/lib/statuscake/models/monitoring_location_status.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class MonitoringLocationStatus + Down = "down" + Up = "up" + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = MonitoringLocationStatus.constants.select { |c| MonitoringLocationStatus.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #MonitoringLocationStatus" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/monitoring_locations.rb b/lib/statuscake/models/monitoring_locations.rb new file mode 100644 index 0000000..13c5982 --- /dev/null +++ b/lib/statuscake/models/monitoring_locations.rb @@ -0,0 +1,244 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class MonitoringLocations + # List of monitoring locations + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::MonitoringLocations` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::MonitoringLocations`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/pagespeed_test.rb b/lib/statuscake/models/pagespeed_test.rb new file mode 100644 index 0000000..b146ff9 --- /dev/null +++ b/lib/statuscake/models/pagespeed_test.rb @@ -0,0 +1,444 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTest + # Pagespeed check ID + attr_accessor :id + + # Name of the check + attr_accessor :name + + # URL, FQDN, or IP address of the website under test + attr_accessor :website_url + + attr_accessor :check_rate + + # An alert will be sent if the size of the page is larger than this value (kb). A value of 0 prevents alerts being sent. + attr_accessor :alert_bigger + + # An alert will be sent if the load time of the page exceeds this value (ms). A value of 0 prevents alerts being sent + attr_accessor :alert_slower + + # An alert will be sent if the size of the page is smaller than this value (kb). A value of 0 prevents alerts being sent + attr_accessor :alert_smaller + + # List of contact group IDs + attr_accessor :contact_groups + + attr_accessor :latest_stats + + # Assigned monitoring location on which checks will be run + attr_accessor :location + + # Whether the check should be run + attr_accessor :paused + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'website_url' => :'website_url', + :'check_rate' => :'check_rate', + :'alert_bigger' => :'alert_bigger', + :'alert_slower' => :'alert_slower', + :'alert_smaller' => :'alert_smaller', + :'contact_groups' => :'contact_groups', + :'latest_stats' => :'latest_stats', + :'location' => :'location', + :'paused' => :'paused', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'website_url' => :'String', + :'check_rate' => :'PagespeedTestCheckRate', + :'alert_bigger' => :'Integer', + :'alert_slower' => :'Integer', + :'alert_smaller' => :'Integer', + :'contact_groups' => :'Array', + :'latest_stats' => :'PagespeedTestStats', + :'location' => :'String', + :'paused' => :'Boolean', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::PagespeedTest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::PagespeedTest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'website_url') + self.website_url = attributes[:'website_url'] + end + + if attributes.key?(:'check_rate') + self.check_rate = attributes[:'check_rate'] + end + + if attributes.key?(:'alert_bigger') + self.alert_bigger = attributes[:'alert_bigger'] + end + + if attributes.key?(:'alert_slower') + self.alert_slower = attributes[:'alert_slower'] + end + + if attributes.key?(:'alert_smaller') + self.alert_smaller = attributes[:'alert_smaller'] + end + + if attributes.key?(:'contact_groups') + if (value = attributes[:'contact_groups']).is_a?(Array) + self.contact_groups = value + end + end + + if attributes.key?(:'latest_stats') + self.latest_stats = attributes[:'latest_stats'] + end + + if attributes.key?(:'location') + self.location = attributes[:'location'] + end + + if attributes.key?(:'paused') + self.paused = attributes[:'paused'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @website_url.nil? + invalid_properties.push('invalid value for "website_url", website_url cannot be nil.') + end + + if @check_rate.nil? + invalid_properties.push('invalid value for "check_rate", check_rate cannot be nil.') + end + + if @alert_bigger.nil? + invalid_properties.push('invalid value for "alert_bigger", alert_bigger cannot be nil.') + end + + if @alert_bigger < 0 + invalid_properties.push('invalid value for "alert_bigger", must be greater than or equal to 0.') + end + + if @alert_slower.nil? + invalid_properties.push('invalid value for "alert_slower", alert_slower cannot be nil.') + end + + if @alert_slower < 0 + invalid_properties.push('invalid value for "alert_slower", must be greater than or equal to 0.') + end + + if @alert_smaller.nil? + invalid_properties.push('invalid value for "alert_smaller", alert_smaller cannot be nil.') + end + + if @alert_smaller < 0 + invalid_properties.push('invalid value for "alert_smaller", must be greater than or equal to 0.') + end + + if @contact_groups.nil? + invalid_properties.push('invalid value for "contact_groups", contact_groups cannot be nil.') + end + + if @location.nil? + invalid_properties.push('invalid value for "location", location cannot be nil.') + end + + if @paused.nil? + invalid_properties.push('invalid value for "paused", paused cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @id.nil? + return false if @name.nil? + return false if @website_url.nil? + return false if @check_rate.nil? + return false if @alert_bigger.nil? + return false if @alert_bigger < 0 + return false if @alert_slower.nil? + return false if @alert_slower < 0 + return false if @alert_smaller.nil? + return false if @alert_smaller < 0 + return false if @contact_groups.nil? + return false if @location.nil? + return false if @paused.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] alert_bigger Value to be assigned + def alert_bigger=(alert_bigger) + if alert_bigger.nil? + raise ArgumentError, 'alert_bigger cannot be nil' + end + + if alert_bigger < 0 + raise ArgumentError, 'invalid value for "alert_bigger", must be greater than or equal to 0.' + end + + @alert_bigger = alert_bigger + end + + # Custom attribute writer method with validation + # @param [Object] alert_slower Value to be assigned + def alert_slower=(alert_slower) + if alert_slower.nil? + raise ArgumentError, 'alert_slower cannot be nil' + end + + if alert_slower < 0 + raise ArgumentError, 'invalid value for "alert_slower", must be greater than or equal to 0.' + end + + @alert_slower = alert_slower + end + + # Custom attribute writer method with validation + # @param [Object] alert_smaller Value to be assigned + def alert_smaller=(alert_smaller) + if alert_smaller.nil? + raise ArgumentError, 'alert_smaller cannot be nil' + end + + if alert_smaller < 0 + raise ArgumentError, 'invalid value for "alert_smaller", must be greater than or equal to 0.' + end + + @alert_smaller = alert_smaller + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + id == other.id && + name == other.name && + website_url == other.website_url && + check_rate == other.check_rate && + alert_bigger == other.alert_bigger && + alert_slower == other.alert_slower && + alert_smaller == other.alert_smaller && + contact_groups == other.contact_groups && + latest_stats == other.latest_stats && + location == other.location && + paused == other.paused + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, website_url, check_rate, alert_bigger, alert_slower, alert_smaller, contact_groups, latest_stats, location, paused].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/pagespeed_test_check_rate.rb b/lib/statuscake/models/pagespeed_test_check_rate.rb new file mode 100644 index 0000000..f5e48f6 --- /dev/null +++ b/lib/statuscake/models/pagespeed_test_check_rate.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTestCheckRate + OneMinute = 60 + FiveMinutes = 300 + TenMinutes = 600 + FifteenMinutes = 900 + ThirtyMinutes = 1800 + OneHour = 3600 + OneDay = 86400 + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = PagespeedTestCheckRate.constants.select { |c| PagespeedTestCheckRate.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #PagespeedTestCheckRate" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/pagespeed_test_history.rb b/lib/statuscake/models/pagespeed_test_history.rb new file mode 100644 index 0000000..e966363 --- /dev/null +++ b/lib/statuscake/models/pagespeed_test_history.rb @@ -0,0 +1,269 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTestHistory + # List of pagespeed check history results + attr_accessor :data + + attr_accessor :links + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'links' => :'links', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'links' => :'Links', + :'metadata' => :'Hash', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::PagespeedTestHistory` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::PagespeedTestHistory`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'links') + self.links = attributes[:'links'] + end + + if attributes.key?(:'metadata') + if (value = attributes[:'metadata']).is_a?(Hash) + self.metadata = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @links.nil? + invalid_properties.push('invalid value for "links", links cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @links.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + links == other.links && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, links, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/pagespeed_test_history_result.rb b/lib/statuscake/models/pagespeed_test_history_result.rb new file mode 100644 index 0000000..39b00ae --- /dev/null +++ b/lib/statuscake/models/pagespeed_test_history_result.rb @@ -0,0 +1,373 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTestHistoryResult + # Creation time of the result (RFC3339 format) + attr_accessor :created_at + + # Recorded filesize (kb) + attr_accessor :filesize + + # Location of the saved HAR file + attr_accessor :har_location + + # Recorded loadtime (ms) + attr_accessor :loadtime + + # Recorded request count + attr_accessor :requests + + attr_accessor :throttling + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'created_at' => :'created_at', + :'filesize' => :'filesize', + :'har_location' => :'har_location', + :'loadtime' => :'loadtime', + :'requests' => :'requests', + :'throttling' => :'throttling', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'created_at' => :'Time', + :'filesize' => :'Float', + :'har_location' => :'String', + :'loadtime' => :'Integer', + :'requests' => :'Integer', + :'throttling' => :'PagespeedTestThrottling', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::PagespeedTestHistoryResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::PagespeedTestHistoryResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'filesize') + self.filesize = attributes[:'filesize'] + end + + if attributes.key?(:'har_location') + self.har_location = attributes[:'har_location'] + end + + if attributes.key?(:'loadtime') + self.loadtime = attributes[:'loadtime'] + end + + if attributes.key?(:'requests') + self.requests = attributes[:'requests'] + end + + if attributes.key?(:'throttling') + self.throttling = attributes[:'throttling'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @filesize.nil? + invalid_properties.push('invalid value for "filesize", filesize cannot be nil.') + end + + if @filesize < 0 + invalid_properties.push('invalid value for "filesize", must be greater than or equal to 0.') + end + + if @har_location.nil? + invalid_properties.push('invalid value for "har_location", har_location cannot be nil.') + end + + if @loadtime.nil? + invalid_properties.push('invalid value for "loadtime", loadtime cannot be nil.') + end + + if @loadtime < 0 + invalid_properties.push('invalid value for "loadtime", must be greater than or equal to 0.') + end + + if @requests.nil? + invalid_properties.push('invalid value for "requests", requests cannot be nil.') + end + + if @requests < 0 + invalid_properties.push('invalid value for "requests", must be greater than or equal to 0.') + end + + if @throttling.nil? + invalid_properties.push('invalid value for "throttling", throttling cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @created_at.nil? + return false if @filesize.nil? + return false if @filesize < 0 + return false if @har_location.nil? + return false if @loadtime.nil? + return false if @loadtime < 0 + return false if @requests.nil? + return false if @requests < 0 + return false if @throttling.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] filesize Value to be assigned + def filesize=(filesize) + if filesize.nil? + raise ArgumentError, 'filesize cannot be nil' + end + + if filesize < 0 + raise ArgumentError, 'invalid value for "filesize", must be greater than or equal to 0.' + end + + @filesize = filesize + end + + # Custom attribute writer method with validation + # @param [Object] loadtime Value to be assigned + def loadtime=(loadtime) + if loadtime.nil? + raise ArgumentError, 'loadtime cannot be nil' + end + + if loadtime < 0 + raise ArgumentError, 'invalid value for "loadtime", must be greater than or equal to 0.' + end + + @loadtime = loadtime + end + + # Custom attribute writer method with validation + # @param [Object] requests Value to be assigned + def requests=(requests) + if requests.nil? + raise ArgumentError, 'requests cannot be nil' + end + + if requests < 0 + raise ArgumentError, 'invalid value for "requests", must be greater than or equal to 0.' + end + + @requests = requests + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + created_at == other.created_at && + filesize == other.filesize && + har_location == other.har_location && + loadtime == other.loadtime && + requests == other.requests && + throttling == other.throttling + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [created_at, filesize, har_location, loadtime, requests, throttling].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/pagespeed_test_region.rb b/lib/statuscake/models/pagespeed_test_region.rb new file mode 100644 index 0000000..a8f65f5 --- /dev/null +++ b/lib/statuscake/models/pagespeed_test_region.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0-beta.3 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTestRegion + Australia = "AU" + Canada = "CA" + Germany = "DE" + France = "FR" + India = "IN" + Japan = "JP" + Netherlands = "NL" + Singapore = "SG" + UnitedKingdom = "UK" + AmericaEast = "US" + AmericaWest = "USW" + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = PagespeedTestRegion.constants.select { |c| PagespeedTestRegion.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #PagespeedTestRegion" if values.empty? + value + end + end +end diff --git a/lib/statuscake/models/pagespeed_test_response.rb b/lib/statuscake/models/pagespeed_test_response.rb new file mode 100644 index 0000000..dbb2865 --- /dev/null +++ b/lib/statuscake/models/pagespeed_test_response.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTestResponse + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'PagespeedTest', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::PagespeedTestResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::PagespeedTestResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/pagespeed_test_stats.rb b/lib/statuscake/models/pagespeed_test_stats.rb new file mode 100644 index 0000000..421d0b7 --- /dev/null +++ b/lib/statuscake/models/pagespeed_test_stats.rb @@ -0,0 +1,354 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTestStats + # Latest recorded filesize (kb) + attr_accessor :filesize + + # Whether the latest check has an issue + attr_accessor :has_issue + + # Latest recorded loadtime (ms) + attr_accessor :loadtime + + # Latest recorded request count + attr_accessor :requests + + # Latest recorded issue + attr_accessor :latest_issue + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'filesize' => :'filesize', + :'has_issue' => :'has_issue', + :'loadtime' => :'loadtime', + :'requests' => :'requests', + :'latest_issue' => :'latest_issue', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'filesize' => :'Float', + :'has_issue' => :'Boolean', + :'loadtime' => :'Integer', + :'requests' => :'Integer', + :'latest_issue' => :'String', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::PagespeedTestStats` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::PagespeedTestStats`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'filesize') + self.filesize = attributes[:'filesize'] + end + + if attributes.key?(:'has_issue') + self.has_issue = attributes[:'has_issue'] + end + + if attributes.key?(:'loadtime') + self.loadtime = attributes[:'loadtime'] + end + + if attributes.key?(:'requests') + self.requests = attributes[:'requests'] + end + + if attributes.key?(:'latest_issue') + self.latest_issue = attributes[:'latest_issue'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @filesize.nil? + invalid_properties.push('invalid value for "filesize", filesize cannot be nil.') + end + + if @filesize < 0 + invalid_properties.push('invalid value for "filesize", must be greater than or equal to 0.') + end + + if @has_issue.nil? + invalid_properties.push('invalid value for "has_issue", has_issue cannot be nil.') + end + + if @loadtime.nil? + invalid_properties.push('invalid value for "loadtime", loadtime cannot be nil.') + end + + if @loadtime < 0 + invalid_properties.push('invalid value for "loadtime", must be greater than or equal to 0.') + end + + if @requests.nil? + invalid_properties.push('invalid value for "requests", requests cannot be nil.') + end + + if @requests < 0 + invalid_properties.push('invalid value for "requests", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @filesize.nil? + return false if @filesize < 0 + return false if @has_issue.nil? + return false if @loadtime.nil? + return false if @loadtime < 0 + return false if @requests.nil? + return false if @requests < 0 + true + end + + # Custom attribute writer method with validation + # @param [Object] filesize Value to be assigned + def filesize=(filesize) + if filesize.nil? + raise ArgumentError, 'filesize cannot be nil' + end + + if filesize < 0 + raise ArgumentError, 'invalid value for "filesize", must be greater than or equal to 0.' + end + + @filesize = filesize + end + + # Custom attribute writer method with validation + # @param [Object] loadtime Value to be assigned + def loadtime=(loadtime) + if loadtime.nil? + raise ArgumentError, 'loadtime cannot be nil' + end + + if loadtime < 0 + raise ArgumentError, 'invalid value for "loadtime", must be greater than or equal to 0.' + end + + @loadtime = loadtime + end + + # Custom attribute writer method with validation + # @param [Object] requests Value to be assigned + def requests=(requests) + if requests.nil? + raise ArgumentError, 'requests cannot be nil' + end + + if requests < 0 + raise ArgumentError, 'invalid value for "requests", must be greater than or equal to 0.' + end + + @requests = requests + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + filesize == other.filesize && + has_issue == other.has_issue && + loadtime == other.loadtime && + requests == other.requests && + latest_issue == other.latest_issue + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [filesize, has_issue, loadtime, requests, latest_issue].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/pagespeed_test_throttling.rb b/lib/statuscake/models/pagespeed_test_throttling.rb new file mode 100644 index 0000000..116ae4b --- /dev/null +++ b/lib/statuscake/models/pagespeed_test_throttling.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTestThrottling + None = "NONE" + Fast3G = "3G_FAST" + Slow3G = "3G_SLOW" + _4G = "4G" + EDGE = "EDGE" + GPRS = "GPRS" + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = PagespeedTestThrottling.constants.select { |c| PagespeedTestThrottling.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #PagespeedTestThrottling" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/pagespeed_tests.rb b/lib/statuscake/models/pagespeed_tests.rb new file mode 100644 index 0000000..363d5f2 --- /dev/null +++ b/lib/statuscake/models/pagespeed_tests.rb @@ -0,0 +1,258 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class PagespeedTests + # List of pagespeed checks + attr_accessor :data + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'metadata' => :'Pagination', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::PagespeedTests` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::PagespeedTests`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/pagination.rb b/lib/statuscake/models/pagination.rb new file mode 100644 index 0000000..459826c --- /dev/null +++ b/lib/statuscake/models/pagination.rb @@ -0,0 +1,363 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class Pagination + # The current page of results + attr_accessor :page + + # The number of results per page + attr_accessor :per_page + + # The total number of pages + attr_accessor :page_count + + # The total number of results + attr_accessor :total_count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'page' => :'page', + :'per_page' => :'per_page', + :'page_count' => :'page_count', + :'total_count' => :'total_count', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'page' => :'Integer', + :'per_page' => :'Integer', + :'page_count' => :'Integer', + :'total_count' => :'Integer', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::Pagination` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::Pagination`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'page') + self.page = attributes[:'page'] + end + + if attributes.key?(:'per_page') + self.per_page = attributes[:'per_page'] + end + + if attributes.key?(:'page_count') + self.page_count = attributes[:'page_count'] + end + + if attributes.key?(:'total_count') + self.total_count = attributes[:'total_count'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @page.nil? + invalid_properties.push('invalid value for "page", page cannot be nil.') + end + + if @page < 1 + invalid_properties.push('invalid value for "page", must be greater than or equal to 1.') + end + + if @per_page.nil? + invalid_properties.push('invalid value for "per_page", per_page cannot be nil.') + end + + if @per_page < 1 + invalid_properties.push('invalid value for "per_page", must be greater than or equal to 1.') + end + + if @page_count.nil? + invalid_properties.push('invalid value for "page_count", page_count cannot be nil.') + end + + if @page_count < 1 + invalid_properties.push('invalid value for "page_count", must be greater than or equal to 1.') + end + + if @total_count.nil? + invalid_properties.push('invalid value for "total_count", total_count cannot be nil.') + end + + if @total_count < 1 + invalid_properties.push('invalid value for "total_count", must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @page.nil? + return false if @page < 1 + return false if @per_page.nil? + return false if @per_page < 1 + return false if @page_count.nil? + return false if @page_count < 1 + return false if @total_count.nil? + return false if @total_count < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] page Value to be assigned + def page=(page) + if page.nil? + raise ArgumentError, 'page cannot be nil' + end + + if page < 1 + raise ArgumentError, 'invalid value for "page", must be greater than or equal to 1.' + end + + @page = page + end + + # Custom attribute writer method with validation + # @param [Object] per_page Value to be assigned + def per_page=(per_page) + if per_page.nil? + raise ArgumentError, 'per_page cannot be nil' + end + + if per_page < 1 + raise ArgumentError, 'invalid value for "per_page", must be greater than or equal to 1.' + end + + @per_page = per_page + end + + # Custom attribute writer method with validation + # @param [Object] page_count Value to be assigned + def page_count=(page_count) + if page_count.nil? + raise ArgumentError, 'page_count cannot be nil' + end + + if page_count < 1 + raise ArgumentError, 'invalid value for "page_count", must be greater than or equal to 1.' + end + + @page_count = page_count + end + + # Custom attribute writer method with validation + # @param [Object] total_count Value to be assigned + def total_count=(total_count) + if total_count.nil? + raise ArgumentError, 'total_count cannot be nil' + end + + if total_count < 1 + raise ArgumentError, 'invalid value for "total_count", must be greater than or equal to 1.' + end + + @total_count = total_count + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + page == other.page && + per_page == other.per_page && + page_count == other.page_count && + total_count == other.total_count + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [page, per_page, page_count, total_count].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/ssl_test.rb b/lib/statuscake/models/ssl_test.rb new file mode 100644 index 0000000..ca02d46 --- /dev/null +++ b/lib/statuscake/models/ssl_test.rb @@ -0,0 +1,594 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class SSLTest + # SSL check ID + attr_accessor :id + + # URL of the server under test + attr_accessor :website_url + + attr_accessor :check_rate + + # List representing when alerts should be sent (days). + attr_accessor :alert_at + + # Whether to enable alerts when SSL certificate issues are found + attr_accessor :alert_broken + + # Whether to enable alerts when the SSL certificate is to expire + attr_accessor :alert_expiry + + # Whether to enable alerts when mixed content is found + attr_accessor :alert_mixed + + # Whether to enable alert reminders + attr_accessor :alert_reminder + + # SSL certificate score (%) + attr_accessor :certificate_score + + # SSL certificate status + attr_accessor :certificate_status + + # SSL/TLS cipher suite belonging to the SSL certificate + attr_accessor :cipher + + # SSL certificate cipher strength (%) + attr_accessor :cipher_score + + # List of contact group IDs + attr_accessor :contact_groups + + # Issuer of the SSL certificate + attr_accessor :issuer_common_name + + attr_accessor :flags + + # Whether to follow redirects when testing. Disabled by default + attr_accessor :follow_redirects + + # Hostname of the server under test + attr_accessor :hostname + + # The last reminder to have been sent (days) + attr_accessor :last_reminder + + # List of mixed content resources + attr_accessor :mixed_content + + # Whether the check should be run + attr_accessor :paused + + # When the SSL certificate was last updated (RFC3339 format) + attr_accessor :updated_at + + # Custom user agent string set when testing + attr_accessor :user_agent + + # SSL certificate validity start (RFC3339 format) + attr_accessor :valid_from + + # SSL certificate validity end (RFC3339 format) + attr_accessor :valid_until + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'website_url' => :'website_url', + :'check_rate' => :'check_rate', + :'alert_at' => :'alert_at', + :'alert_broken' => :'alert_broken', + :'alert_expiry' => :'alert_expiry', + :'alert_mixed' => :'alert_mixed', + :'alert_reminder' => :'alert_reminder', + :'certificate_score' => :'certificate_score', + :'certificate_status' => :'certificate_status', + :'cipher' => :'cipher', + :'cipher_score' => :'cipher_score', + :'contact_groups' => :'contact_groups', + :'issuer_common_name' => :'issuer_common_name', + :'flags' => :'flags', + :'follow_redirects' => :'follow_redirects', + :'hostname' => :'hostname', + :'last_reminder' => :'last_reminder', + :'mixed_content' => :'mixed_content', + :'paused' => :'paused', + :'updated_at' => :'updated_at', + :'user_agent' => :'user_agent', + :'valid_from' => :'valid_from', + :'valid_until' => :'valid_until', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'website_url' => :'String', + :'check_rate' => :'SSLTestCheckRate', + :'alert_at' => :'Array', + :'alert_broken' => :'Boolean', + :'alert_expiry' => :'Boolean', + :'alert_mixed' => :'Boolean', + :'alert_reminder' => :'Boolean', + :'certificate_score' => :'Integer', + :'certificate_status' => :'String', + :'cipher' => :'String', + :'cipher_score' => :'Integer', + :'contact_groups' => :'Array', + :'issuer_common_name' => :'String', + :'flags' => :'SSLTestFlags', + :'follow_redirects' => :'Boolean', + :'hostname' => :'String', + :'last_reminder' => :'Integer', + :'mixed_content' => :'Array', + :'paused' => :'Boolean', + :'updated_at' => :'Time', + :'user_agent' => :'String', + :'valid_from' => :'Time', + :'valid_until' => :'Time', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::SSLTest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::SSLTest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'website_url') + self.website_url = attributes[:'website_url'] + end + + if attributes.key?(:'check_rate') + self.check_rate = attributes[:'check_rate'] + end + + if attributes.key?(:'alert_at') + if (value = attributes[:'alert_at']).is_a?(Array) + self.alert_at = value + end + end + + if attributes.key?(:'alert_broken') + self.alert_broken = attributes[:'alert_broken'] + end + + if attributes.key?(:'alert_expiry') + self.alert_expiry = attributes[:'alert_expiry'] + end + + if attributes.key?(:'alert_mixed') + self.alert_mixed = attributes[:'alert_mixed'] + end + + if attributes.key?(:'alert_reminder') + self.alert_reminder = attributes[:'alert_reminder'] + end + + if attributes.key?(:'certificate_score') + self.certificate_score = attributes[:'certificate_score'] + end + + if attributes.key?(:'certificate_status') + self.certificate_status = attributes[:'certificate_status'] + end + + if attributes.key?(:'cipher') + self.cipher = attributes[:'cipher'] + end + + if attributes.key?(:'cipher_score') + self.cipher_score = attributes[:'cipher_score'] + end + + if attributes.key?(:'contact_groups') + if (value = attributes[:'contact_groups']).is_a?(Array) + self.contact_groups = value + end + end + + if attributes.key?(:'issuer_common_name') + self.issuer_common_name = attributes[:'issuer_common_name'] + end + + if attributes.key?(:'flags') + self.flags = attributes[:'flags'] + end + + if attributes.key?(:'follow_redirects') + self.follow_redirects = attributes[:'follow_redirects'] + end + + if attributes.key?(:'hostname') + self.hostname = attributes[:'hostname'] + end + + if attributes.key?(:'last_reminder') + self.last_reminder = attributes[:'last_reminder'] + end + + if attributes.key?(:'mixed_content') + if (value = attributes[:'mixed_content']).is_a?(Array) + self.mixed_content = value + end + end + + if attributes.key?(:'paused') + self.paused = attributes[:'paused'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'user_agent') + self.user_agent = attributes[:'user_agent'] + end + + if attributes.key?(:'valid_from') + self.valid_from = attributes[:'valid_from'] + end + + if attributes.key?(:'valid_until') + self.valid_until = attributes[:'valid_until'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @website_url.nil? + invalid_properties.push('invalid value for "website_url", website_url cannot be nil.') + end + + if @check_rate.nil? + invalid_properties.push('invalid value for "check_rate", check_rate cannot be nil.') + end + + if @alert_at.nil? + invalid_properties.push('invalid value for "alert_at", alert_at cannot be nil.') + end + + if @alert_broken.nil? + invalid_properties.push('invalid value for "alert_broken", alert_broken cannot be nil.') + end + + if @alert_expiry.nil? + invalid_properties.push('invalid value for "alert_expiry", alert_expiry cannot be nil.') + end + + if @alert_mixed.nil? + invalid_properties.push('invalid value for "alert_mixed", alert_mixed cannot be nil.') + end + + if @alert_reminder.nil? + invalid_properties.push('invalid value for "alert_reminder", alert_reminder cannot be nil.') + end + + if !@certificate_score.nil? && @certificate_score > 100 + invalid_properties.push('invalid value for "certificate_score", must be smaller than or equal to 100.') + end + + if !@certificate_score.nil? && @certificate_score < 0 + invalid_properties.push('invalid value for "certificate_score", must be greater than or equal to 0.') + end + + if !@cipher_score.nil? && @cipher_score > 100 + invalid_properties.push('invalid value for "cipher_score", must be smaller than or equal to 100.') + end + + if !@cipher_score.nil? && @cipher_score < 0 + invalid_properties.push('invalid value for "cipher_score", must be greater than or equal to 0.') + end + + if @contact_groups.nil? + invalid_properties.push('invalid value for "contact_groups", contact_groups cannot be nil.') + end + + if @follow_redirects.nil? + invalid_properties.push('invalid value for "follow_redirects", follow_redirects cannot be nil.') + end + + if !@last_reminder.nil? && @last_reminder < 0 + invalid_properties.push('invalid value for "last_reminder", must be greater than or equal to 0.') + end + + if @mixed_content.nil? + invalid_properties.push('invalid value for "mixed_content", mixed_content cannot be nil.') + end + + if @paused.nil? + invalid_properties.push('invalid value for "paused", paused cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @id.nil? + return false if @website_url.nil? + return false if @check_rate.nil? + return false if @alert_at.nil? + return false if @alert_broken.nil? + return false if @alert_expiry.nil? + return false if @alert_mixed.nil? + return false if @alert_reminder.nil? + return false if !@certificate_score.nil? && @certificate_score > 100 + return false if !@certificate_score.nil? && @certificate_score < 0 + return false if !@cipher_score.nil? && @cipher_score > 100 + return false if !@cipher_score.nil? && @cipher_score < 0 + return false if @contact_groups.nil? + return false if @follow_redirects.nil? + return false if !@last_reminder.nil? && @last_reminder < 0 + return false if @mixed_content.nil? + return false if @paused.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] certificate_score Value to be assigned + def certificate_score=(certificate_score) + if !certificate_score.nil? && certificate_score > 100 + raise ArgumentError, 'invalid value for "certificate_score", must be smaller than or equal to 100.' + end + + if !certificate_score.nil? && certificate_score < 0 + raise ArgumentError, 'invalid value for "certificate_score", must be greater than or equal to 0.' + end + + @certificate_score = certificate_score + end + + # Custom attribute writer method with validation + # @param [Object] cipher_score Value to be assigned + def cipher_score=(cipher_score) + if !cipher_score.nil? && cipher_score > 100 + raise ArgumentError, 'invalid value for "cipher_score", must be smaller than or equal to 100.' + end + + if !cipher_score.nil? && cipher_score < 0 + raise ArgumentError, 'invalid value for "cipher_score", must be greater than or equal to 0.' + end + + @cipher_score = cipher_score + end + + # Custom attribute writer method with validation + # @param [Object] last_reminder Value to be assigned + def last_reminder=(last_reminder) + if !last_reminder.nil? && last_reminder < 0 + raise ArgumentError, 'invalid value for "last_reminder", must be greater than or equal to 0.' + end + + @last_reminder = last_reminder + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + id == other.id && + website_url == other.website_url && + check_rate == other.check_rate && + alert_at == other.alert_at && + alert_broken == other.alert_broken && + alert_expiry == other.alert_expiry && + alert_mixed == other.alert_mixed && + alert_reminder == other.alert_reminder && + certificate_score == other.certificate_score && + certificate_status == other.certificate_status && + cipher == other.cipher && + cipher_score == other.cipher_score && + contact_groups == other.contact_groups && + issuer_common_name == other.issuer_common_name && + flags == other.flags && + follow_redirects == other.follow_redirects && + hostname == other.hostname && + last_reminder == other.last_reminder && + mixed_content == other.mixed_content && + paused == other.paused && + updated_at == other.updated_at && + user_agent == other.user_agent && + valid_from == other.valid_from && + valid_until == other.valid_until + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, website_url, check_rate, alert_at, alert_broken, alert_expiry, alert_mixed, alert_reminder, certificate_score, certificate_status, cipher, cipher_score, contact_groups, issuer_common_name, flags, follow_redirects, hostname, last_reminder, mixed_content, paused, updated_at, user_agent, valid_from, valid_until].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/ssl_test_check_rate.rb b/lib/statuscake/models/ssl_test_check_rate.rb new file mode 100644 index 0000000..8435fed --- /dev/null +++ b/lib/statuscake/models/ssl_test_check_rate.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class SSLTestCheckRate + FiveMinutes = 300 + TenMinutes = 600 + ThirtyMinutes = 1800 + OneHour = 3600 + OneDay = 86400 + OneWeek = 2073600 + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = SSLTestCheckRate.constants.select { |c| SSLTestCheckRate.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #SSLTestCheckRate" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/ssl_test_flags.rb b/lib/statuscake/models/ssl_test_flags.rb new file mode 100644 index 0000000..1651863 --- /dev/null +++ b/lib/statuscake/models/ssl_test_flags.rb @@ -0,0 +1,347 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class SSLTestFlags + # Wherher follow redirects has been enabled for the SSL check + attr_accessor :follow_redirects + + # Whether the requested page has mixed content + attr_accessor :has_mixed + + # Whether the SSL certificate has Perfect Forward Security enabled + attr_accessor :has_pfs + + # Whether the SSL certificate has errors + attr_accessor :is_broken + + # Whether the SSL certificate has expired + attr_accessor :is_expired + + # Whether the SSL certificate has Extended Validation (EV) + attr_accessor :is_extended + + # Whether the SSL certificate is missing + attr_accessor :is_missing + + # Whether the SSL certificate has been revoked by the certificate authority + attr_accessor :is_revoked + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'follow_redirects' => :'follow_redirects', + :'has_mixed' => :'has_mixed', + :'has_pfs' => :'has_pfs', + :'is_broken' => :'is_broken', + :'is_expired' => :'is_expired', + :'is_extended' => :'is_extended', + :'is_missing' => :'is_missing', + :'is_revoked' => :'is_revoked', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'follow_redirects' => :'Boolean', + :'has_mixed' => :'Boolean', + :'has_pfs' => :'Boolean', + :'is_broken' => :'Boolean', + :'is_expired' => :'Boolean', + :'is_extended' => :'Boolean', + :'is_missing' => :'Boolean', + :'is_revoked' => :'Boolean', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::SSLTestFlags` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::SSLTestFlags`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'follow_redirects') + self.follow_redirects = attributes[:'follow_redirects'] + end + + if attributes.key?(:'has_mixed') + self.has_mixed = attributes[:'has_mixed'] + end + + if attributes.key?(:'has_pfs') + self.has_pfs = attributes[:'has_pfs'] + end + + if attributes.key?(:'is_broken') + self.is_broken = attributes[:'is_broken'] + end + + if attributes.key?(:'is_expired') + self.is_expired = attributes[:'is_expired'] + end + + if attributes.key?(:'is_extended') + self.is_extended = attributes[:'is_extended'] + end + + if attributes.key?(:'is_missing') + self.is_missing = attributes[:'is_missing'] + end + + if attributes.key?(:'is_revoked') + self.is_revoked = attributes[:'is_revoked'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @follow_redirects.nil? + invalid_properties.push('invalid value for "follow_redirects", follow_redirects cannot be nil.') + end + + if @has_mixed.nil? + invalid_properties.push('invalid value for "has_mixed", has_mixed cannot be nil.') + end + + if @has_pfs.nil? + invalid_properties.push('invalid value for "has_pfs", has_pfs cannot be nil.') + end + + if @is_broken.nil? + invalid_properties.push('invalid value for "is_broken", is_broken cannot be nil.') + end + + if @is_expired.nil? + invalid_properties.push('invalid value for "is_expired", is_expired cannot be nil.') + end + + if @is_extended.nil? + invalid_properties.push('invalid value for "is_extended", is_extended cannot be nil.') + end + + if @is_missing.nil? + invalid_properties.push('invalid value for "is_missing", is_missing cannot be nil.') + end + + if @is_revoked.nil? + invalid_properties.push('invalid value for "is_revoked", is_revoked cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @follow_redirects.nil? + return false if @has_mixed.nil? + return false if @has_pfs.nil? + return false if @is_broken.nil? + return false if @is_expired.nil? + return false if @is_extended.nil? + return false if @is_missing.nil? + return false if @is_revoked.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + follow_redirects == other.follow_redirects && + has_mixed == other.has_mixed && + has_pfs == other.has_pfs && + is_broken == other.is_broken && + is_expired == other.is_expired && + is_extended == other.is_extended && + is_missing == other.is_missing && + is_revoked == other.is_revoked + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [follow_redirects, has_mixed, has_pfs, is_broken, is_expired, is_extended, is_missing, is_revoked].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/ssl_test_mixed_content.rb b/lib/statuscake/models/ssl_test_mixed_content.rb new file mode 100644 index 0000000..7c70131 --- /dev/null +++ b/lib/statuscake/models/ssl_test_mixed_content.rb @@ -0,0 +1,257 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class SSLTestMixedContent + # Full path to the content resource + attr_accessor :src + + # Type of the content + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'src' => :'src', + :'type' => :'type', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'src' => :'String', + :'type' => :'String', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::SSLTestMixedContent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::SSLTestMixedContent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'src') + self.src = attributes[:'src'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @src.nil? + invalid_properties.push('invalid value for "src", src cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @src.nil? + return false if @type.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + src == other.src && + type == other.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [src, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/ssl_test_response.rb b/lib/statuscake/models/ssl_test_response.rb new file mode 100644 index 0000000..58ea031 --- /dev/null +++ b/lib/statuscake/models/ssl_test_response.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class SSLTestResponse + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'SSLTest', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::SSLTestResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::SSLTestResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/ssl_tests.rb b/lib/statuscake/models/ssl_tests.rb new file mode 100644 index 0000000..403157f --- /dev/null +++ b/lib/statuscake/models/ssl_tests.rb @@ -0,0 +1,258 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class SSLTests + # List of SSL checks + attr_accessor :data + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'metadata' => :'Pagination', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::SSLTests` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::SSLTests`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test.rb b/lib/statuscake/models/uptime_test.rb new file mode 100644 index 0000000..f36f05e --- /dev/null +++ b/lib/statuscake/models/uptime_test.rb @@ -0,0 +1,811 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTest + # Uptime check ID + attr_accessor :id + + # Name of the check + attr_accessor :name + + attr_accessor :test_type + + # URL, FQDN, or IP address of the server under test + attr_accessor :website_url + + attr_accessor :check_rate + + # Number of confirmation servers to confirm downtime before an alert is triggered + attr_accessor :confirmation + + # List of contact group IDs + attr_accessor :contact_groups + + # JSON object. Represents headers to be sent when making requests + attr_accessor :custom_header + + # List of IP addresses to compare against returned DNS records + attr_accessor :dns_ips + + # FQDN or IP address of the nameserver to query + attr_accessor :dns_server + + # Whether to consider the check as down if the content is present within the response + attr_accessor :do_not_find + + # Whether to send an alert if the SSL certificate is soon to expire + attr_accessor :enable_ssl_alert + + # Specify where the redirect chain should end + attr_accessor :final_endpoint + + # String to look for within the response. Considered down if not found + attr_accessor :find_string + + # Whether to follow redirects when testing. Disabled by default + attr_accessor :follow_redirects + + # Include header content in string match search + attr_accessor :include_header + + # Name of the hosting provider + attr_accessor :host + + # When the check was last run (RFC3339 format) + attr_accessor :last_tested_at + + # The server location the check will run next + attr_accessor :next_location + + # Whether the check should be run + attr_accessor :paused + + # Destination port for TCP checks + attr_accessor :port + + # JSON object. Payload submitted with the request. Setting this updates the check to use the HTTP POST verb + attr_accessor :_post_body + + # Raw HTTP POST string to send to the server + attr_accessor :post_raw + + # Whether the check is currently being processed + attr_accessor :processing + + # The server location the check is currently being run + attr_accessor :processing_on + + attr_accessor :processing_state + + # List of assigned monitoring locations on which to run checks + attr_accessor :servers + + attr_accessor :status + + # List of status codes that trigger an alert + attr_accessor :status_codes + + # List of tags + attr_accessor :tags + + # The number of seconds to wait to receive the first byte + attr_accessor :timeout + + # The number of minutes to wait before sending an alert + attr_accessor :trigger_rate + + # Uptime percentage for a check + attr_accessor :uptime + + # Whether to enable cookie storage + attr_accessor :use_jar + + # Custom user agent string set when testing + attr_accessor :user_agent + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'test_type' => :'test_type', + :'website_url' => :'website_url', + :'check_rate' => :'check_rate', + :'confirmation' => :'confirmation', + :'contact_groups' => :'contact_groups', + :'custom_header' => :'custom_header', + :'dns_ips' => :'dns_ips', + :'dns_server' => :'dns_server', + :'do_not_find' => :'do_not_find', + :'enable_ssl_alert' => :'enable_ssl_alert', + :'final_endpoint' => :'final_endpoint', + :'find_string' => :'find_string', + :'follow_redirects' => :'follow_redirects', + :'include_header' => :'include_header', + :'host' => :'host', + :'last_tested_at' => :'last_tested_at', + :'next_location' => :'next_location', + :'paused' => :'paused', + :'port' => :'port', + :'_post_body' => :'post_body', + :'post_raw' => :'post_raw', + :'processing' => :'processing', + :'processing_on' => :'processing_on', + :'processing_state' => :'processing_state', + :'servers' => :'servers', + :'status' => :'status', + :'status_codes' => :'status_codes', + :'tags' => :'tags', + :'timeout' => :'timeout', + :'trigger_rate' => :'trigger_rate', + :'uptime' => :'uptime', + :'use_jar' => :'use_jar', + :'user_agent' => :'user_agent', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'test_type' => :'UptimeTestType', + :'website_url' => :'String', + :'check_rate' => :'UptimeTestCheckRate', + :'confirmation' => :'Integer', + :'contact_groups' => :'Array', + :'custom_header' => :'String', + :'dns_ips' => :'Array', + :'dns_server' => :'String', + :'do_not_find' => :'Boolean', + :'enable_ssl_alert' => :'Boolean', + :'final_endpoint' => :'String', + :'find_string' => :'String', + :'follow_redirects' => :'Boolean', + :'include_header' => :'Boolean', + :'host' => :'String', + :'last_tested_at' => :'Time', + :'next_location' => :'String', + :'paused' => :'Boolean', + :'port' => :'Integer', + :'_post_body' => :'String', + :'post_raw' => :'String', + :'processing' => :'Boolean', + :'processing_on' => :'String', + :'processing_state' => :'UptimeTestProcessingState', + :'servers' => :'Array', + :'status' => :'UptimeTestStatus', + :'status_codes' => :'Array', + :'tags' => :'Array', + :'timeout' => :'Integer', + :'trigger_rate' => :'Integer', + :'uptime' => :'Float', + :'use_jar' => :'Boolean', + :'user_agent' => :'String', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'test_type') + self.test_type = attributes[:'test_type'] + end + + if attributes.key?(:'website_url') + self.website_url = attributes[:'website_url'] + end + + if attributes.key?(:'check_rate') + self.check_rate = attributes[:'check_rate'] + end + + if attributes.key?(:'confirmation') + self.confirmation = attributes[:'confirmation'] + end + + if attributes.key?(:'contact_groups') + if (value = attributes[:'contact_groups']).is_a?(Array) + self.contact_groups = value + end + end + + if attributes.key?(:'custom_header') + self.custom_header = attributes[:'custom_header'] + end + + if attributes.key?(:'dns_ips') + if (value = attributes[:'dns_ips']).is_a?(Array) + self.dns_ips = value + end + end + + if attributes.key?(:'dns_server') + self.dns_server = attributes[:'dns_server'] + end + + if attributes.key?(:'do_not_find') + self.do_not_find = attributes[:'do_not_find'] + end + + if attributes.key?(:'enable_ssl_alert') + self.enable_ssl_alert = attributes[:'enable_ssl_alert'] + end + + if attributes.key?(:'final_endpoint') + self.final_endpoint = attributes[:'final_endpoint'] + end + + if attributes.key?(:'find_string') + self.find_string = attributes[:'find_string'] + end + + if attributes.key?(:'follow_redirects') + self.follow_redirects = attributes[:'follow_redirects'] + end + + if attributes.key?(:'include_header') + self.include_header = attributes[:'include_header'] + end + + if attributes.key?(:'host') + self.host = attributes[:'host'] + end + + if attributes.key?(:'last_tested_at') + self.last_tested_at = attributes[:'last_tested_at'] + end + + if attributes.key?(:'next_location') + self.next_location = attributes[:'next_location'] + end + + if attributes.key?(:'paused') + self.paused = attributes[:'paused'] + end + + if attributes.key?(:'port') + self.port = attributes[:'port'] + end + + if attributes.key?(:'_post_body') + self._post_body = attributes[:'_post_body'] + end + + if attributes.key?(:'post_raw') + self.post_raw = attributes[:'post_raw'] + end + + if attributes.key?(:'processing') + self.processing = attributes[:'processing'] + end + + if attributes.key?(:'processing_on') + self.processing_on = attributes[:'processing_on'] + end + + if attributes.key?(:'processing_state') + self.processing_state = attributes[:'processing_state'] + end + + if attributes.key?(:'servers') + if (value = attributes[:'servers']).is_a?(Array) + self.servers = value + end + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'status_codes') + if (value = attributes[:'status_codes']).is_a?(Array) + self.status_codes = value + end + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes.key?(:'timeout') + self.timeout = attributes[:'timeout'] + end + + if attributes.key?(:'trigger_rate') + self.trigger_rate = attributes[:'trigger_rate'] + end + + if attributes.key?(:'uptime') + self.uptime = attributes[:'uptime'] + end + + if attributes.key?(:'use_jar') + self.use_jar = attributes[:'use_jar'] + end + + if attributes.key?(:'user_agent') + self.user_agent = attributes[:'user_agent'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @test_type.nil? + invalid_properties.push('invalid value for "test_type", test_type cannot be nil.') + end + + if @website_url.nil? + invalid_properties.push('invalid value for "website_url", website_url cannot be nil.') + end + + if @check_rate.nil? + invalid_properties.push('invalid value for "check_rate", check_rate cannot be nil.') + end + + if @confirmation.nil? + invalid_properties.push('invalid value for "confirmation", confirmation cannot be nil.') + end + + if @confirmation > 3 + invalid_properties.push('invalid value for "confirmation", must be smaller than or equal to 3.') + end + + if @confirmation < 0 + invalid_properties.push('invalid value for "confirmation", must be greater than or equal to 0.') + end + + if @contact_groups.nil? + invalid_properties.push('invalid value for "contact_groups", contact_groups cannot be nil.') + end + + if @dns_ips.nil? + invalid_properties.push('invalid value for "dns_ips", dns_ips cannot be nil.') + end + + if @do_not_find.nil? + invalid_properties.push('invalid value for "do_not_find", do_not_find cannot be nil.') + end + + if @enable_ssl_alert.nil? + invalid_properties.push('invalid value for "enable_ssl_alert", enable_ssl_alert cannot be nil.') + end + + if @follow_redirects.nil? + invalid_properties.push('invalid value for "follow_redirects", follow_redirects cannot be nil.') + end + + if @include_header.nil? + invalid_properties.push('invalid value for "include_header", include_header cannot be nil.') + end + + if @paused.nil? + invalid_properties.push('invalid value for "paused", paused cannot be nil.') + end + + if !@port.nil? && @port < 0 + invalid_properties.push('invalid value for "port", must be greater than or equal to 0.') + end + + if @processing.nil? + invalid_properties.push('invalid value for "processing", processing cannot be nil.') + end + + if @servers.nil? + invalid_properties.push('invalid value for "servers", servers cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @status_codes.nil? + invalid_properties.push('invalid value for "status_codes", status_codes cannot be nil.') + end + + if @tags.nil? + invalid_properties.push('invalid value for "tags", tags cannot be nil.') + end + + if @timeout.nil? + invalid_properties.push('invalid value for "timeout", timeout cannot be nil.') + end + + if @timeout > 75 + invalid_properties.push('invalid value for "timeout", must be smaller than or equal to 75.') + end + + if @timeout < 5 + invalid_properties.push('invalid value for "timeout", must be greater than or equal to 5.') + end + + if @trigger_rate.nil? + invalid_properties.push('invalid value for "trigger_rate", trigger_rate cannot be nil.') + end + + if @trigger_rate > 60 + invalid_properties.push('invalid value for "trigger_rate", must be smaller than or equal to 60.') + end + + if @trigger_rate < 0 + invalid_properties.push('invalid value for "trigger_rate", must be greater than or equal to 0.') + end + + if @uptime.nil? + invalid_properties.push('invalid value for "uptime", uptime cannot be nil.') + end + + if @uptime < 0 + invalid_properties.push('invalid value for "uptime", must be greater than or equal to 0.') + end + + if @use_jar.nil? + invalid_properties.push('invalid value for "use_jar", use_jar cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @id.nil? + return false if @name.nil? + return false if @test_type.nil? + return false if @website_url.nil? + return false if @check_rate.nil? + return false if @confirmation.nil? + return false if @confirmation > 3 + return false if @confirmation < 0 + return false if @contact_groups.nil? + return false if @dns_ips.nil? + return false if @do_not_find.nil? + return false if @enable_ssl_alert.nil? + return false if @follow_redirects.nil? + return false if @include_header.nil? + return false if @paused.nil? + return false if !@port.nil? && @port < 0 + return false if @processing.nil? + return false if @servers.nil? + return false if @status.nil? + return false if @status_codes.nil? + return false if @tags.nil? + return false if @timeout.nil? + return false if @timeout > 75 + return false if @timeout < 5 + return false if @trigger_rate.nil? + return false if @trigger_rate > 60 + return false if @trigger_rate < 0 + return false if @uptime.nil? + return false if @uptime < 0 + return false if @use_jar.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] confirmation Value to be assigned + def confirmation=(confirmation) + if confirmation.nil? + raise ArgumentError, 'confirmation cannot be nil' + end + + if confirmation > 3 + raise ArgumentError, 'invalid value for "confirmation", must be smaller than or equal to 3.' + end + + if confirmation < 0 + raise ArgumentError, 'invalid value for "confirmation", must be greater than or equal to 0.' + end + + @confirmation = confirmation + end + + # Custom attribute writer method with validation + # @param [Object] port Value to be assigned + def port=(port) + if !port.nil? && port < 0 + raise ArgumentError, 'invalid value for "port", must be greater than or equal to 0.' + end + + @port = port + end + + # Custom attribute writer method with validation + # @param [Object] timeout Value to be assigned + def timeout=(timeout) + if timeout.nil? + raise ArgumentError, 'timeout cannot be nil' + end + + if timeout > 75 + raise ArgumentError, 'invalid value for "timeout", must be smaller than or equal to 75.' + end + + if timeout < 5 + raise ArgumentError, 'invalid value for "timeout", must be greater than or equal to 5.' + end + + @timeout = timeout + end + + # Custom attribute writer method with validation + # @param [Object] trigger_rate Value to be assigned + def trigger_rate=(trigger_rate) + if trigger_rate.nil? + raise ArgumentError, 'trigger_rate cannot be nil' + end + + if trigger_rate > 60 + raise ArgumentError, 'invalid value for "trigger_rate", must be smaller than or equal to 60.' + end + + if trigger_rate < 0 + raise ArgumentError, 'invalid value for "trigger_rate", must be greater than or equal to 0.' + end + + @trigger_rate = trigger_rate + end + + # Custom attribute writer method with validation + # @param [Object] uptime Value to be assigned + def uptime=(uptime) + if uptime.nil? + raise ArgumentError, 'uptime cannot be nil' + end + + if uptime < 0 + raise ArgumentError, 'invalid value for "uptime", must be greater than or equal to 0.' + end + + @uptime = uptime + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + id == other.id && + name == other.name && + test_type == other.test_type && + website_url == other.website_url && + check_rate == other.check_rate && + confirmation == other.confirmation && + contact_groups == other.contact_groups && + custom_header == other.custom_header && + dns_ips == other.dns_ips && + dns_server == other.dns_server && + do_not_find == other.do_not_find && + enable_ssl_alert == other.enable_ssl_alert && + final_endpoint == other.final_endpoint && + find_string == other.find_string && + follow_redirects == other.follow_redirects && + include_header == other.include_header && + host == other.host && + last_tested_at == other.last_tested_at && + next_location == other.next_location && + paused == other.paused && + port == other.port && + _post_body == other._post_body && + post_raw == other.post_raw && + processing == other.processing && + processing_on == other.processing_on && + processing_state == other.processing_state && + servers == other.servers && + status == other.status && + status_codes == other.status_codes && + tags == other.tags && + timeout == other.timeout && + trigger_rate == other.trigger_rate && + uptime == other.uptime && + use_jar == other.use_jar && + user_agent == other.user_agent + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, test_type, website_url, check_rate, confirmation, contact_groups, custom_header, dns_ips, dns_server, do_not_find, enable_ssl_alert, final_endpoint, find_string, follow_redirects, include_header, host, last_tested_at, next_location, paused, port, _post_body, post_raw, processing, processing_on, processing_state, servers, status, status_codes, tags, timeout, trigger_rate, uptime, use_jar, user_agent].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_alert.rb b/lib/statuscake/models/uptime_test_alert.rb new file mode 100644 index 0000000..7b54b97 --- /dev/null +++ b/lib/statuscake/models/uptime_test_alert.rb @@ -0,0 +1,300 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestAlert + # Uptime check ID + attr_accessor :id + + attr_accessor :status + + # Uptime check status code + attr_accessor :status_code + + # When the alert was triggered (RFC3339 format) + attr_accessor :triggered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'status' => :'status', + :'status_code' => :'status_code', + :'triggered_at' => :'triggered_at', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'status' => :'UptimeTestStatus', + :'status_code' => :'Integer', + :'triggered_at' => :'Time', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestAlert` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestAlert`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'status_code') + self.status_code = attributes[:'status_code'] + end + + if attributes.key?(:'triggered_at') + self.triggered_at = attributes[:'triggered_at'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @status_code.nil? + invalid_properties.push('invalid value for "status_code", status_code cannot be nil.') + end + + if @status_code < 0 + invalid_properties.push('invalid value for "status_code", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @id.nil? + return false if @status.nil? + return false if @status_code.nil? + return false if @status_code < 0 + true + end + + # Custom attribute writer method with validation + # @param [Object] status_code Value to be assigned + def status_code=(status_code) + if status_code.nil? + raise ArgumentError, 'status_code cannot be nil' + end + + if status_code < 0 + raise ArgumentError, 'invalid value for "status_code", must be greater than or equal to 0.' + end + + @status_code = status_code + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + id == other.id && + status == other.status && + status_code == other.status_code && + triggered_at == other.triggered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, status, status_code, triggered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_alerts.rb b/lib/statuscake/models/uptime_test_alerts.rb new file mode 100644 index 0000000..03b5d10 --- /dev/null +++ b/lib/statuscake/models/uptime_test_alerts.rb @@ -0,0 +1,269 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestAlerts + # List of uptime check alerts + attr_accessor :data + + attr_accessor :links + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'links' => :'links', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'links' => :'Links', + :'metadata' => :'Hash', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestAlerts` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestAlerts`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'links') + self.links = attributes[:'links'] + end + + if attributes.key?(:'metadata') + if (value = attributes[:'metadata']).is_a?(Hash) + self.metadata = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @links.nil? + invalid_properties.push('invalid value for "links", links cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @links.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + links == other.links && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, links, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_check_rate.rb b/lib/statuscake/models/uptime_test_check_rate.rb new file mode 100644 index 0000000..72c8838 --- /dev/null +++ b/lib/statuscake/models/uptime_test_check_rate.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestCheckRate + Constant = 0 + ThirtySeconds = 30 + OneMinute = 60 + FiveMinutes = 300 + FifteenMinutes = 900 + ThirtyMinutes = 1800 + OneHour = 3600 + OneDay = 86400 + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = UptimeTestCheckRate.constants.select { |c| UptimeTestCheckRate.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #UptimeTestCheckRate" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/uptime_test_history.rb b/lib/statuscake/models/uptime_test_history.rb new file mode 100644 index 0000000..cc2ccf7 --- /dev/null +++ b/lib/statuscake/models/uptime_test_history.rb @@ -0,0 +1,269 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestHistory + # List of uptime check history results + attr_accessor :data + + attr_accessor :links + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'links' => :'links', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'links' => :'Links', + :'metadata' => :'Hash', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestHistory` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestHistory`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'links') + self.links = attributes[:'links'] + end + + if attributes.key?(:'metadata') + if (value = attributes[:'metadata']).is_a?(Hash) + self.metadata = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @links.nil? + invalid_properties.push('invalid value for "links", links cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @links.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + links == other.links && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, links, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_history_result.rb b/lib/statuscake/models/uptime_test_history_result.rb new file mode 100644 index 0000000..9d5d9a4 --- /dev/null +++ b/lib/statuscake/models/uptime_test_history_result.rb @@ -0,0 +1,302 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestHistoryResult + # Creation time of the result (RFC3339 format) + attr_accessor :created_at + + # The server location the check ran + attr_accessor :location + + # Recorded loadtime (ms) + attr_accessor :performance + + # Uptime check status code + attr_accessor :status_code + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'created_at' => :'created_at', + :'location' => :'location', + :'performance' => :'performance', + :'status_code' => :'status_code', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'created_at' => :'Time', + :'location' => :'String', + :'performance' => :'Integer', + :'status_code' => :'Integer', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestHistoryResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestHistoryResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'location') + self.location = attributes[:'location'] + end + + if attributes.key?(:'performance') + self.performance = attributes[:'performance'] + end + + if attributes.key?(:'status_code') + self.status_code = attributes[:'status_code'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if !@performance.nil? && @performance < 0 + invalid_properties.push('invalid value for "performance", must be greater than or equal to 0.') + end + + if !@status_code.nil? && @status_code < 0 + invalid_properties.push('invalid value for "status_code", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @created_at.nil? + return false if !@performance.nil? && @performance < 0 + return false if !@status_code.nil? && @status_code < 0 + true + end + + # Custom attribute writer method with validation + # @param [Object] performance Value to be assigned + def performance=(performance) + if !performance.nil? && performance < 0 + raise ArgumentError, 'invalid value for "performance", must be greater than or equal to 0.' + end + + @performance = performance + end + + # Custom attribute writer method with validation + # @param [Object] status_code Value to be assigned + def status_code=(status_code) + if !status_code.nil? && status_code < 0 + raise ArgumentError, 'invalid value for "status_code", must be greater than or equal to 0.' + end + + @status_code = status_code + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + created_at == other.created_at && + location == other.location && + performance == other.performance && + status_code == other.status_code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [created_at, location, performance, status_code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_overview.rb b/lib/statuscake/models/uptime_test_overview.rb new file mode 100644 index 0000000..68ae726 --- /dev/null +++ b/lib/statuscake/models/uptime_test_overview.rb @@ -0,0 +1,388 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestOverview + # Uptime check ID + attr_accessor :id + + # Name of the check + attr_accessor :name + + # URL or IP address of the server under test + attr_accessor :website_url + + attr_accessor :test_type + + attr_accessor :check_rate + + # List of contact group IDs + attr_accessor :contact_groups + + # Whether the check should be run + attr_accessor :paused + + attr_accessor :status + + # List of tags + attr_accessor :tags + + # Uptime percentage for a check + attr_accessor :uptime + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'website_url' => :'website_url', + :'test_type' => :'test_type', + :'check_rate' => :'check_rate', + :'contact_groups' => :'contact_groups', + :'paused' => :'paused', + :'status' => :'status', + :'tags' => :'tags', + :'uptime' => :'uptime', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'website_url' => :'String', + :'test_type' => :'UptimeTestType', + :'check_rate' => :'UptimeTestCheckRate', + :'contact_groups' => :'Array', + :'paused' => :'Boolean', + :'status' => :'UptimeTestStatus', + :'tags' => :'Array', + :'uptime' => :'Float', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestOverview` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestOverview`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'website_url') + self.website_url = attributes[:'website_url'] + end + + if attributes.key?(:'test_type') + self.test_type = attributes[:'test_type'] + end + + if attributes.key?(:'check_rate') + self.check_rate = attributes[:'check_rate'] + end + + if attributes.key?(:'contact_groups') + if (value = attributes[:'contact_groups']).is_a?(Array) + self.contact_groups = value + end + end + + if attributes.key?(:'paused') + self.paused = attributes[:'paused'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes.key?(:'uptime') + self.uptime = attributes[:'uptime'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @website_url.nil? + invalid_properties.push('invalid value for "website_url", website_url cannot be nil.') + end + + if @test_type.nil? + invalid_properties.push('invalid value for "test_type", test_type cannot be nil.') + end + + if @check_rate.nil? + invalid_properties.push('invalid value for "check_rate", check_rate cannot be nil.') + end + + if @contact_groups.nil? + invalid_properties.push('invalid value for "contact_groups", contact_groups cannot be nil.') + end + + if @paused.nil? + invalid_properties.push('invalid value for "paused", paused cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @tags.nil? + invalid_properties.push('invalid value for "tags", tags cannot be nil.') + end + + if !@uptime.nil? && @uptime < 0 + invalid_properties.push('invalid value for "uptime", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @id.nil? + return false if @name.nil? + return false if @website_url.nil? + return false if @test_type.nil? + return false if @check_rate.nil? + return false if @contact_groups.nil? + return false if @paused.nil? + return false if @status.nil? + return false if @tags.nil? + return false if !@uptime.nil? && @uptime < 0 + true + end + + # Custom attribute writer method with validation + # @param [Object] uptime Value to be assigned + def uptime=(uptime) + if !uptime.nil? && uptime < 0 + raise ArgumentError, 'invalid value for "uptime", must be greater than or equal to 0.' + end + + @uptime = uptime + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + id == other.id && + name == other.name && + website_url == other.website_url && + test_type == other.test_type && + check_rate == other.check_rate && + contact_groups == other.contact_groups && + paused == other.paused && + status == other.status && + tags == other.tags && + uptime == other.uptime + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, website_url, test_type, check_rate, contact_groups, paused, status, tags, uptime].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_period.rb b/lib/statuscake/models/uptime_test_period.rb new file mode 100644 index 0000000..6fde7a7 --- /dev/null +++ b/lib/statuscake/models/uptime_test_period.rb @@ -0,0 +1,291 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestPeriod + # When the status period was created (RFC3339 format) + attr_accessor :created_at + + # Status period duration (ms) + attr_accessor :duration + + # When the status period ended (RFC3339 format) + attr_accessor :ended_at + + attr_accessor :status + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'created_at' => :'created_at', + :'duration' => :'duration', + :'ended_at' => :'ended_at', + :'status' => :'status', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'created_at' => :'Time', + :'duration' => :'Integer', + :'ended_at' => :'Time', + :'status' => :'UptimeTestStatus', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestPeriod` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestPeriod`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'ended_at') + self.ended_at = attributes[:'ended_at'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if !@duration.nil? && @duration < 0 + invalid_properties.push('invalid value for "duration", must be greater than or equal to 0.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @created_at.nil? + return false if !@duration.nil? && @duration < 0 + return false if @status.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] duration Value to be assigned + def duration=(duration) + if !duration.nil? && duration < 0 + raise ArgumentError, 'invalid value for "duration", must be greater than or equal to 0.' + end + + @duration = duration + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + created_at == other.created_at && + duration == other.duration && + ended_at == other.ended_at && + status == other.status + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [created_at, duration, ended_at, status].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_periods.rb b/lib/statuscake/models/uptime_test_periods.rb new file mode 100644 index 0000000..327b4ba --- /dev/null +++ b/lib/statuscake/models/uptime_test_periods.rb @@ -0,0 +1,269 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestPeriods + # List of uptime check periods + attr_accessor :data + + attr_accessor :links + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'links' => :'links', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'links' => :'Links', + :'metadata' => :'Hash', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestPeriods` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestPeriods`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'links') + self.links = attributes[:'links'] + end + + if attributes.key?(:'metadata') + if (value = attributes[:'metadata']).is_a?(Hash) + self.metadata = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @links.nil? + invalid_properties.push('invalid value for "links", links cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @links.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + links == other.links && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, links, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_processing_state.rb b/lib/statuscake/models/uptime_test_processing_state.rb new file mode 100644 index 0000000..d8c7eae --- /dev/null +++ b/lib/statuscake/models/uptime_test_processing_state.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestProcessingState + Complete = "complete" + Pretest = "pretest" + Retest = "retest" + UpRetest = "up_retest" + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = UptimeTestProcessingState.constants.select { |c| UptimeTestProcessingState.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #UptimeTestProcessingState" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/uptime_test_response.rb b/lib/statuscake/models/uptime_test_response.rb new file mode 100644 index 0000000..e700dde --- /dev/null +++ b/lib/statuscake/models/uptime_test_response.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestResponse + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'UptimeTest', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/models/uptime_test_status.rb b/lib/statuscake/models/uptime_test_status.rb new file mode 100644 index 0000000..aca8d83 --- /dev/null +++ b/lib/statuscake/models/uptime_test_status.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestStatus + Down = "down" + Up = "up" + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = UptimeTestStatus.constants.select { |c| UptimeTestStatus.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #UptimeTestStatus" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/uptime_test_type.rb b/lib/statuscake/models/uptime_test_type.rb new file mode 100644 index 0000000..e82875e --- /dev/null +++ b/lib/statuscake/models/uptime_test_type.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTestType + DNS = "DNS" + HEAD = "HEAD" + HTTP = "HTTP" + PING = "PING" + SMTP = "SMTP" + SSH = "SSH" + TCP = "TCP" + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + values = UptimeTestType.constants.select { |c| UptimeTestType.const_get(c) == value } + raise "Invalid ENUM value #{value} for class #UptimeTestType" if values.empty? + value + end + end + +end diff --git a/lib/statuscake/models/uptime_tests.rb b/lib/statuscake/models/uptime_tests.rb new file mode 100644 index 0000000..fe1fbe2 --- /dev/null +++ b/lib/statuscake/models/uptime_tests.rb @@ -0,0 +1,258 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +require 'date' +require 'time' + +module StatusCake + # :nodoc + class UptimeTests + # List of uptime checks + attr_accessor :data + + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'metadata' => :'metadata', + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'metadata' => :'Pagination', + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTests` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTests`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = [] + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @data.nil? + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + self.class == other.class && + data == other.data && + metadata == other.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = StatusCake.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/statuscake/version.rb b/lib/statuscake/version.rb new file mode 100644 index 0000000..fc573b8 --- /dev/null +++ b/lib/statuscake/version.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +# StatusCake API +# +# Copyright (c) 2022 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# API version: 1.0.0 +# Contact: support@statuscake.com +# +# Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +module StatusCake + VERSION = '1.0.0-beta.4' +end diff --git a/statuscake.gemspec b/statuscake.gemspec index cda5cff..2dec29b 100644 --- a/statuscake.gemspec +++ b/statuscake.gemspec @@ -43,6 +43,14 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.4' s.metadata = { 'rubygems_mfa_required' => 'true' } + s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' + + s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1' + s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' + s.add_development_dependency 'rubocop', '~> 1.36', '>= 1.36.0' + s.add_development_dependency 'rubocop-rake', '~> 0.5', '>= 0.5.1' + s.add_development_dependency 'rubocop-rspec', '~> 2.12', '>= 2.12.1' + s.files = Dir.glob('{bin,lib}/**/*').uniq.sort.reject(&:empty?) s.executables = [] s.require_paths = ['lib']