provider

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) *schema.Provider

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 ClientConfig struct {
	BaseURL      string
	Token        string
	UserAgent    string
	HTTPClient   *http.Client
	RetryMax     int
	RetryWaitMin time.Duration
	RetryWaitMax time.Duration
	RateLimit    int // requests per second, 0 = no limit
	RateBurst    int // burst size for rate limiter, 0 = use default
}

type Option

type Option func(*provider)

func WithURL

func WithURL(v string) Option

func WithVersion

func WithVersion(v string) Option

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL