client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnCallSchedulesEndpoint = "/api/v2/on-call/schedules"
	OnCallUserEndpoint      = "/api/v2/on-call/schedules/%s/on-call"

	// PageSize is the page size for pagination.
	// note: (docs stand that the maximum allowed by Datadog API is 100, but we can only get pages with 50 elements).
	PageSize = 50
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DatadogClient

type DatadogClient struct {
	// contains filtered or unexported fields
}

DatadogClient wraps the Datadog REST client to provide a clean interface for all endpoints. This client delegates to the DatadogRestClient which already handles HTTP response body closing correctly.

func NewDatadogClient

func NewDatadogClient(restClient *DatadogRestClient, officialClient *datadog.APIClient, site, apiKey, appKey string) *DatadogClient

NewDatadogClient creates a new client that uses the custom REST client.

func (*DatadogClient) AddUserToRole

AddUserToRole adds a user to a role and automatically handles HTTP response body closing.

func (*DatadogClient) CreateTeamMembership

func (w *DatadogClient) CreateTeamMembership(ctx context.Context, teamId string, body datadogV2.UserTeamRequest) (*datadogV2.UserTeamResponse, error)

CreateTeamMembership creates a team membership and automatically handles HTTP response body closing.

func (*DatadogClient) CreateUser added in v0.1.0

CreateUser creates a Datadog user using the official V2 API client and closes the HTTP response body.

func (*DatadogClient) DeleteTeamMembership

func (w *DatadogClient) DeleteTeamMembership(ctx context.Context, teamId string, userId string) error

DeleteTeamMembership deletes a team membership and automatically handles HTTP response body closing.

func (*DatadogClient) GetOfficialClient

func (w *DatadogClient) GetOfficialClient() *datadog.APIClient

GetOfficialClient returns the underlying official Datadog API client for operations that need it.

func (*DatadogClient) GetRestClient

func (w *DatadogClient) GetRestClient() *DatadogRestClient

GetRestClient returns the underlying REST client.

func (*DatadogClient) GetTeamMemberships

GetTeamMemberships gets team memberships and automatically handles HTTP response body closing.

func (*DatadogClient) GetUser

func (w *DatadogClient) GetUser(ctx context.Context, userId string) (*datadogV2.UserResponse, error)

GetUser gets a user by ID and automatically handles HTTP response body closing.

func (*DatadogClient) ListAPIKeys

ListAPIKeys lists API keys using the REST client.

func (*DatadogClient) ListRoleUsers

ListRoleUsers lists users for a specific role and automatically handles HTTP response body closing.

func (*DatadogClient) ListRoles

ListRoles lists roles using the REST client.

func (*DatadogClient) ListTeams

ListTeams lists teams using the REST client.

func (*DatadogClient) ListUsers

ListUsers lists users using the REST client.

func (*DatadogClient) RemoveUserFromRole

func (w *DatadogClient) RemoveUserFromRole(ctx context.Context, roleId string, body datadogV2.RelationshipToUser) (*datadogV2.UsersResponse, error)

RemoveUserFromRole removes a user from a role and automatically handles HTTP response body closing.

func (*DatadogClient) Validate

Validate validates API credentials using the REST client.

func (*DatadogClient) ValidateCredentials

ValidateCredentials validates API credentials and automatically handles HTTP response body closing.

type DatadogClientInterface

type DatadogClientInterface interface {
	ListOnCallSchedules(ctx context.Context, opts *PaginationOptions) ([]*OnCallSchedule, string, annotations.Annotations, error)
	GetScheduleOnCallUser(ctx context.Context, scheduleID string) (*OnCallUserResponse, annotations.Annotations, error)
}

DatadogClientInterface defines the interface for Datadog client operations.

type DatadogRestClient

type DatadogRestClient struct {
	// contains filtered or unexported fields
}

DatadogRestClient is a client for Datadog REST API. that is not available in the official client library.

func NewDatadogRestClient

func NewDatadogRestClient(ctx context.Context, site string, apiKey string, appKey string) (*DatadogRestClient, error)

NewDatadogRestClient creates a new instance of the REST client.

func (*DatadogRestClient) GetScheduleOnCallUser

func (c *DatadogRestClient) GetScheduleOnCallUser(ctx context.Context, scheduleID string) (*OnCallUserResponse, annotations.Annotations, error)

GetScheduleOnCallUser gets the user who is currently on-call for a specific schedule.

func (*DatadogRestClient) ListOnCallSchedules

ListOnCallSchedules lists on-call schedules with optional pagination.

type OnCallSchedule

type OnCallSchedule struct {
	ID         string                   `json:"id"`
	Type       string                   `json:"type"`
	Attributes OnCallScheduleAttributes `json:"attributes"`
}

OnCallSchedule represents an on-call schedule in Datadog.

type OnCallScheduleAttributes

type OnCallScheduleAttributes struct {
	Name     string `json:"name"`
	TimeZone string `json:"time_zone"`
}

OnCallScheduleAttributes represents the attributes of an on-call schedule.

type OnCallSchedulesResponse

type OnCallSchedulesResponse struct {
	Data []*OnCallSchedule `json:"data"`
	Meta struct {
		Page struct {
			Type        string `json:"type"`
			Number      int    `json:"number"`
			Size        int    `json:"size"`
			Total       int    `json:"total"`
			FirstNumber int    `json:"first_number"`
			PrevNumber  *int   `json:"prev_number"`
			NextNumber  *int   `json:"next_number"`
			LastNumber  int    `json:"last_number"`
		} `json:"page"`
	} `json:"meta"`
}

OnCallSchedulesResponse represents the response of the on-call schedules API.

type OnCallUser

type OnCallUser struct {
	ID         string               `json:"id"`
	Type       string               `json:"type"`
	Attributes OnCallUserAttributes `json:"attributes"`
}

OnCallUser represents an on-call user in Datadog.

type OnCallUserAttributes

type OnCallUserAttributes struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

OnCallUserAttributes represents the attributes of an on-call user.

type OnCallUserResponse

type OnCallUserResponse struct {
	Data OnCallUser `json:"data"`
}

OnCallUserResponse represents the response of the on-call user API.

type PaginationOptions

type PaginationOptions struct {
	PageSize   int
	PageNumber int
}

PaginationOptions contains the options for pagination.

type ReqOpt

type ReqOpt func(*http.Request) *http.Request

ReqOpt represents a request option that can be applied to an HTTP request.

func WithPage

func WithPage(page int) ReqOpt

WithPage adds a page number query parameter to the request.

func WithPageSize

func WithPageSize(pageSize int) ReqOpt

WithPageSize adds a page size query parameter to the request.

func WithQueryParam

func WithQueryParam(key, value string) ReqOpt

WithQueryParam adds a query parameter to the request.

type SimpleOnCallScheduleList

type SimpleOnCallScheduleList struct {
	Schedules []OnCallSchedule `json:"schedules"`
}

SimpleOnCallScheduleList represents a simple list of schedules without pagination metadata.

Jump to

Keyboard shortcuts

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