Skip to content

add custom extent prop for geomap widget #2448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-26 17:56:17.204143",
"spec_repo_commit": "76086f13"
"regenerated": "2025-06-26 21:05:34.194849",
"spec_repo_commit": "3211ca1b"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-26 17:56:17.219918",
"spec_repo_commit": "76086f13"
"regenerated": "2025-06-26 21:05:34.211477",
"spec_repo_commit": "3211ca1b"
}
}
}
21 changes: 18 additions & 3 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3439,13 +3439,28 @@ components:
example:
focus: WORLD
properties:
custom_extent:
description: A custom extent of the map defined by an array of four numbers
in the order `[minLongitude, minLatitude, maxLongitude, maxLatitude]`.
Mutually exclusive with `focus`.
example:
- -30
- -40
- 40
- 30
items:
description: The longitudinal or latitudinal coordinates of the bounding
box.
format: double
type: number
maxItems: 4
minItems: 4
type: array
focus:
description: The 2-letter ISO code of a country to focus the map on. Or
`WORLD`.
`WORLD`. Mutually exclusive with `custom_extent`.
example: WORLD
type: string
required:
- focus
type: object
GeomapWidgetRequest:
description: An updated geomap widget.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ module DatadogAPIClient::V1
class GeomapWidgetDefinitionView
include BaseGenericModel

# The 2-letter ISO code of a country to focus the map on. Or `WORLD`.
attr_reader :focus
# A custom extent of the map defined by an array of four numbers in the order `[minLongitude, minLatitude, maxLongitude, maxLatitude]`. Mutually exclusive with `focus`.
attr_reader :custom_extent

# The 2-letter ISO code of a country to focus the map on. Or `WORLD`. Mutually exclusive with `custom_extent`.
attr_accessor :focus

attr_accessor :additional_properties

# Attribute mapping from ruby-style variable name to JSON key.
# @!visibility private
def self.attribute_map
{
:'custom_extent' => :'custom_extent',
:'focus' => :'focus'
}
end
Expand All @@ -38,6 +42,7 @@ def self.attribute_map
# @!visibility private
def self.openapi_types
{
:'custom_extent' => :'Array<Float>',
:'focus' => :'String'
}
end
Expand All @@ -60,6 +65,12 @@ def initialize(attributes = {})
end
}

if attributes.key?(:'custom_extent')
if (value = attributes[:'custom_extent']).is_a?(Array)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Consider using Array() to ensure the type is that of an array (...read more)

The rule "Use Array() to ensure your variable is an array" is important for ensuring your code behaves as expected, regardless of the type of data it receives. It is common in Ruby to need to iterate through an array of items. However, if the variable is not an array, this can lead to unexpected behavior or errors.

The Array() method in Ruby is a Kernel method that converts its argument to an Array. If the argument is already an Array, it returns the argument. If the argument is nil, it returns an empty Array. This can be used to ensure that a variable is an array before trying to iterate over it, preventing potential errors or unexpected behavior.

By using Array(foos), you can ensure that foos is an array before you try to iterate over it with each. This prevents the need to check if foos is an array with foos.is_a?(Array) and makes your code cleaner and easier to understand.

View in Datadog  Leave us feedback  Documentation

self.custom_extent = value
end
end

if attributes.key?(:'focus')
self.focus = attributes[:'focus']
end
Expand All @@ -69,18 +80,22 @@ def initialize(attributes = {})
# @return true if the model is valid
# @!visibility private
def valid?
return false if @focus.nil?
return false if !@custom_extent.nil? && @custom_extent.length > 4
return false if !@custom_extent.nil? && @custom_extent.length < 4
true
end

# Custom attribute writer method with validation
# @param focus [Object] Object to be assigned
# @param custom_extent [Object] Object to be assigned
# @!visibility private
def focus=(focus)
if focus.nil?
fail ArgumentError, 'invalid value for "focus", focus cannot be nil.'
def custom_extent=(custom_extent)
if !custom_extent.nil? && custom_extent.length > 4
fail ArgumentError, 'invalid value for "custom_extent", number of items must be less than or equal to 4.'
end
if !custom_extent.nil? && custom_extent.length < 4
fail ArgumentError, 'invalid value for "custom_extent", number of items must be greater than or equal to 4.'
end
@focus = focus
@custom_extent = custom_extent
end

# Returns the object in the form of hash, with additionalProperties support.
Expand Down Expand Up @@ -109,6 +124,7 @@ def to_hash
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
custom_extent == o.custom_extent &&
focus == o.focus &&
additional_properties == o.additional_properties
end
Expand All @@ -117,7 +133,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[focus, additional_properties].hash
[custom_extent, focus, additional_properties].hash
end
end
end
Loading