Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetStringOrIntResourceData ¶ added in v0.7.3
func SetStringOrIntResourceData(d *schema.ResourceData, key string, value *StringOrInt) error
SetStringOrIntResourceData sets a Terraform resource field from a StringOrInt. Used in sourceCopyAttrs to handle fields that can be string or int.
Parameters:
- d: The Terraform resource data
- key: The field name (e.g., "team_id")
- value: The StringOrInt value from the API
Example:
SetStringOrIntResourceData(d, "team_id", in.TeamId)
Types ¶
type ClientConfig ¶ added in v0.9.0
type StringOrInt ¶ added in v0.7.3
type StringOrInt string
StringOrInt handles JSON fields that can be either a string or an integer. It unmarshals both "t1234" (string) and 123456 (number) into a string value, and marshals back to the appropriate JSON type based on the value.
This is used for fields like team_id in the Better Stack API which can return: - A number: 12345 - A string: "t1234"
When marshaling: - Pure numeric strings like "1234" are marshaled as JSON numbers: 1234 - Non-numeric strings like "t1234" are marshaled as JSON strings: "t1234"
Example usage in resource_source.go:
type source struct {
TeamId *StringOrInt `json:"team_id,omitempty"`
}
func StringOrIntFromResourceData ¶ added in v0.7.3
func StringOrIntFromResourceData(d *schema.ResourceData, key string) *StringOrInt
StringOrIntFromResourceData creates a StringOrInt from a Terraform resource field. Used in sourceCreate and sourceUpdate to handle fields that can be string or int.
Parameters:
- d: The Terraform resource data
- key: The field name (e.g., "team_id")
Example:
in.TeamId = StringOrIntFromResourceData(d, "team_id")
func (StringOrInt) MarshalJSON ¶ added in v0.7.3
func (s StringOrInt) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface. Used when sending data to the Better Stack API: - If the value is a pure number (e.g., "1234"), marshals as JSON number: 1234 - If the value contains non-numeric characters (e.g., "t1234"), marshals as JSON string: "t1234"
func (StringOrInt) String ¶ added in v0.7.3
func (s StringOrInt) String() string
String returns the underlying string value.
func (*StringOrInt) UnmarshalJSON ¶ added in v0.7.3
func (s *StringOrInt) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface. Used when receiving data from the Better Stack API: - When the JSON value is a string (e.g., "t1234"), stores it as-is - When the JSON value is a number (e.g., 123456), converts it to a string
Source Files
¶
- client.go
- data_collector.go
- data_connection.go
- data_dashboard.go
- data_exploration.go
- data_exploration_alert.go
- data_exploration_group.go
- data_metric.go
- data_source.go
- data_source_source_group.go
- data_warehouse_embedding.go
- provider.go
- ptr.go
- resource.go
- resource_collector.go
- resource_connection.go
- resource_dashboard.go
- resource_errors_application.go
- resource_errors_application_group.go
- resource_exploration.go
- resource_exploration_alert.go
- resource_exploration_group.go
- resource_metric.go
- resource_source.go
- resource_source_group.go
- resource_warehouse_embedding.go
- resource_warehouse_source.go
- resource_warehouse_source_group.go
- resource_warehouse_time_series.go
- type_string_or_int.go