=begin #CMS Performance API #Use these endpoints to get a time series view of your website's performance. The version of the OpenAPI document: v3 Generated by: https://openapi-generator.tech OpenAPI Generator version: 4.3.1 =end require 'date' module Hubspot module Cms module Performance class PerformanceView # The number of responses that had an http status code of 403. attr_accessor :_403 # The number of responses that had an http status code of 404. attr_accessor :_404 # The number of responses that had an http status code of 500. attr_accessor :_500 # The number of responses that had an http status code of 504. attr_accessor :_504 # The timestamp in milliseconds of the start of this interval. attr_accessor :start_timestamp # The timestamp in milliseconds of the end of this interval. attr_accessor :end_timestamp attr_accessor :start_datetime attr_accessor :end_datetime # The total number of requests received in this period. attr_accessor :total_requests # The total number of requests that were served cached responses. attr_accessor :cache_hits # The percentage of requests that were served cached responses. attr_accessor :cache_hit_rate attr_accessor :total_request_time # The average response time in milliseconds from the origin to the edge. attr_accessor :avg_origin_response_time # The average response time in milliseconds. attr_accessor :response_time_ms # The number of responses that had an http status code between 1000-1999. attr_accessor :_100_x # The number of responses that had an http status code between 200-299. attr_accessor :_20_x # The number of responses that had an http status code between 300-399. attr_accessor :_30_x # The number of responses that had an http status code between 400-499. attr_accessor :_40_x # The number of responses that had an http status code between 500-599. attr_accessor :_50_x # The 50th percentile response time. attr_accessor :_50th # The 95th percentile response time. attr_accessor :_95th # The 99th percentile response time. attr_accessor :_99th # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'_403' => :'403', :'_404' => :'404', :'_500' => :'500', :'_504' => :'504', :'start_timestamp' => :'startTimestamp', :'end_timestamp' => :'endTimestamp', :'start_datetime' => :'startDatetime', :'end_datetime' => :'endDatetime', :'total_requests' => :'totalRequests', :'cache_hits' => :'cacheHits', :'cache_hit_rate' => :'cacheHitRate', :'total_request_time' => :'totalRequestTime', :'avg_origin_response_time' => :'avgOriginResponseTime', :'response_time_ms' => :'responseTimeMs', :'_100_x' => :'100X', :'_20_x' => :'20X', :'_30_x' => :'30X', :'_40_x' => :'40X', :'_50_x' => :'50X', :'_50th' => :'50th', :'_95th' => :'95th', :'_99th' => :'99th' } end # Attribute type mapping. def self.openapi_types { :'_403' => :'Integer', :'_404' => :'Integer', :'_500' => :'Integer', :'_504' => :'Integer', :'start_timestamp' => :'Integer', :'end_timestamp' => :'Integer', :'start_datetime' => :'String', :'end_datetime' => :'String', :'total_requests' => :'Integer', :'cache_hits' => :'Integer', :'cache_hit_rate' => :'Float', :'total_request_time' => :'Integer', :'avg_origin_response_time' => :'Integer', :'response_time_ms' => :'Integer', :'_100_x' => :'Integer', :'_20_x' => :'Integer', :'_30_x' => :'Integer', :'_40_x' => :'Integer', :'_50_x' => :'Integer', :'_50th' => :'Integer', :'_95th' => :'Integer', :'_99th' => :'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 = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Cms::Performance::PerformanceView` 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| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Cms::Performance::PerformanceView`. 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?(:'_403') self._403 = attributes[:'_403'] end if attributes.key?(:'_404') self._404 = attributes[:'_404'] end if attributes.key?(:'_500') self._500 = attributes[:'_500'] end if attributes.key?(:'_504') self._504 = attributes[:'_504'] end if attributes.key?(:'start_timestamp') self.start_timestamp = attributes[:'start_timestamp'] end if attributes.key?(:'end_timestamp') self.end_timestamp = attributes[:'end_timestamp'] end if attributes.key?(:'start_datetime') self.start_datetime = attributes[:'start_datetime'] end if attributes.key?(:'end_datetime') self.end_datetime = attributes[:'end_datetime'] end if attributes.key?(:'total_requests') self.total_requests = attributes[:'total_requests'] end if attributes.key?(:'cache_hits') self.cache_hits = attributes[:'cache_hits'] end if attributes.key?(:'cache_hit_rate') self.cache_hit_rate = attributes[:'cache_hit_rate'] end if attributes.key?(:'total_request_time') self.total_request_time = attributes[:'total_request_time'] end if attributes.key?(:'avg_origin_response_time') self.avg_origin_response_time = attributes[:'avg_origin_response_time'] end if attributes.key?(:'response_time_ms') self.response_time_ms = attributes[:'response_time_ms'] end if attributes.key?(:'_100_x') self._100_x = attributes[:'_100_x'] end if attributes.key?(:'_20_x') self._20_x = attributes[:'_20_x'] end if attributes.key?(:'_30_x') self._30_x = attributes[:'_30_x'] end if attributes.key?(:'_40_x') self._40_x = attributes[:'_40_x'] end if attributes.key?(:'_50_x') self._50_x = attributes[:'_50_x'] end if attributes.key?(:'_50th') self._50th = attributes[:'_50th'] end if attributes.key?(:'_95th') self._95th = attributes[:'_95th'] end if attributes.key?(:'_99th') self._99th = attributes[:'_99th'] 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 = Array.new if @_403.nil? invalid_properties.push('invalid value for "_403", _403 cannot be nil.') end if @_404.nil? invalid_properties.push('invalid value for "_404", _404 cannot be nil.') end if @_500.nil? invalid_properties.push('invalid value for "_500", _500 cannot be nil.') end if @_504.nil? invalid_properties.push('invalid value for "_504", _504 cannot be nil.') end if @start_timestamp.nil? invalid_properties.push('invalid value for "start_timestamp", start_timestamp cannot be nil.') end if @end_timestamp.nil? invalid_properties.push('invalid value for "end_timestamp", end_timestamp cannot be nil.') end if @start_datetime.nil? invalid_properties.push('invalid value for "start_datetime", start_datetime cannot be nil.') end if @end_datetime.nil? invalid_properties.push('invalid value for "end_datetime", end_datetime cannot be nil.') end if @total_requests.nil? invalid_properties.push('invalid value for "total_requests", total_requests cannot be nil.') end if @cache_hits.nil? invalid_properties.push('invalid value for "cache_hits", cache_hits cannot be nil.') end if @cache_hit_rate.nil? invalid_properties.push('invalid value for "cache_hit_rate", cache_hit_rate cannot be nil.') end if @total_request_time.nil? invalid_properties.push('invalid value for "total_request_time", total_request_time cannot be nil.') end if @avg_origin_response_time.nil? invalid_properties.push('invalid value for "avg_origin_response_time", avg_origin_response_time cannot be nil.') end if @response_time_ms.nil? invalid_properties.push('invalid value for "response_time_ms", response_time_ms cannot be nil.') end if @_100_x.nil? invalid_properties.push('invalid value for "_100_x", _100_x cannot be nil.') end if @_20_x.nil? invalid_properties.push('invalid value for "_20_x", _20_x cannot be nil.') end if @_30_x.nil? invalid_properties.push('invalid value for "_30_x", _30_x cannot be nil.') end if @_40_x.nil? invalid_properties.push('invalid value for "_40_x", _40_x cannot be nil.') end if @_50_x.nil? invalid_properties.push('invalid value for "_50_x", _50_x cannot be nil.') end if @_50th.nil? invalid_properties.push('invalid value for "_50th", _50th cannot be nil.') end if @_95th.nil? invalid_properties.push('invalid value for "_95th", _95th cannot be nil.') end if @_99th.nil? invalid_properties.push('invalid value for "_99th", _99th 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 @_403.nil? return false if @_404.nil? return false if @_500.nil? return false if @_504.nil? return false if @start_timestamp.nil? return false if @end_timestamp.nil? return false if @start_datetime.nil? return false if @end_datetime.nil? return false if @total_requests.nil? return false if @cache_hits.nil? return false if @cache_hit_rate.nil? return false if @total_request_time.nil? return false if @avg_origin_response_time.nil? return false if @response_time_ms.nil? return false if @_100_x.nil? return false if @_20_x.nil? return false if @_30_x.nil? return false if @_40_x.nil? return false if @_50_x.nil? return false if @_50th.nil? return false if @_95th.nil? return false if @_99th.nil? true end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && _403 == o._403 && _404 == o._404 && _500 == o._500 && _504 == o._504 && start_timestamp == o.start_timestamp && end_timestamp == o.end_timestamp && start_datetime == o.start_datetime && end_datetime == o.end_datetime && total_requests == o.total_requests && cache_hits == o.cache_hits && cache_hit_rate == o.cache_hit_rate && total_request_time == o.total_request_time && avg_origin_response_time == o.avg_origin_response_time && response_time_ms == o.response_time_ms && _100_x == o._100_x && _20_x == o._20_x && _30_x == o._30_x && _40_x == o._40_x && _50_x == o._50_x && _50th == o._50th && _95th == o._95th && _99th == o._99th end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash [_403, _404, _500, _504, start_timestamp, end_timestamp, start_datetime, end_datetime, total_requests, cache_hits, cache_hit_rate, total_request_time, avg_origin_response_time, response_time_ms, _100_x, _20_x, _30_x, _40_x, _50_x, _50th, _95th, _99th].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) self.class.openapi_types.each_pair do |key, type| if 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) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional 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 :DateTime DateTime.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 Hubspot::Cms::Performance.const_get(type).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 = self.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 end end