Documentation
¶
Index ¶
- Constants
- Variables
- func IsNotFound(err error) bool
- type DatadogClient
- func (w *DatadogClient) AddUserToRole(ctx context.Context, roleId string, body datadogV2.RelationshipToUser) (*datadogV2.UsersResponse, error)
- func (w *DatadogClient) CreateTeamMembership(ctx context.Context, teamId string, body datadogV2.UserTeamRequest) (*datadogV2.UserTeamResponse, error)
- func (w *DatadogClient) CreateUser(ctx context.Context, req datadogV2.UserCreateRequest) (*datadogV2.UserResponse, error)
- func (w *DatadogClient) DeleteTeamMembership(ctx context.Context, teamId string, userId string) error
- func (w *DatadogClient) DisableUser(ctx context.Context, userId string) error
- func (w *DatadogClient) GetOfficialClient() *datadog.APIClient
- func (w *DatadogClient) GetRestClient() *DatadogRestClient
- func (w *DatadogClient) GetTeamMemberships(ctx context.Context, teamId string, ...) (*datadogV2.UserTeamsResponse, error)
- func (w *DatadogClient) GetUser(ctx context.Context, userId string) (*datadogV2.UserResponse, error)
- func (w *DatadogClient) ListAPIKeys(ctx context.Context, params *datadogV2.ListAPIKeysOptionalParameters) (*datadogV2.APIKeysResponse, error)
- func (w *DatadogClient) ListRoleUsers(ctx context.Context, roleId string, ...) (*datadogV2.UsersResponse, error)
- func (w *DatadogClient) ListRoles(ctx context.Context, params *datadogV2.ListRolesOptionalParameters) (*datadogV2.RolesResponse, error)
- func (w *DatadogClient) ListTeams(ctx context.Context, params *datadogV2.ListTeamsOptionalParameters) (*datadogV2.TeamsResponse, error)
- func (w *DatadogClient) ListUsers(ctx context.Context, params *datadogV2.ListUsersOptionalParameters) (*datadogV2.UsersResponse, error)
- func (w *DatadogClient) RemoveUserFromRole(ctx context.Context, roleId string, body datadogV2.RelationshipToUser) (*datadogV2.UsersResponse, error)
- func (w *DatadogClient) UpdateUser(ctx context.Context, userId string, body datadogV2.UserUpdateRequest) (*datadogV2.UserResponse, error)
- func (w *DatadogClient) Validate(ctx context.Context) (*datadogV1.AuthenticationValidationResponse, error)
- func (w *DatadogClient) ValidateCredentials(ctx context.Context) (*datadogV1.AuthenticationValidationResponse, error)
- type DatadogClientInterface
- type DatadogRestClient
- type OnCallSchedule
- type OnCallScheduleAttributes
- type OnCallSchedulesResponse
- type OnCallUser
- type OnCallUserAttributes
- type OnCallUserResponse
- type PaginationOptions
- type ReqOpt
- type SimpleOnCallScheduleList
Constants ¶
const ( DefaultBaseURL = "https://api.%s" 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 ¶
var ErrNotFound = errors.New("baton-datadog: not found")
ErrNotFound is joined onto errors returned from wrapper methods when the Datadog API responds with HTTP 404. Callers use IsNotFound to detect this without depending on the SDK error message format.
Functions ¶
func IsNotFound ¶ added in v0.1.1
IsNotFound reports whether err was returned for a 404 response.
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 ¶
func (w *DatadogClient) AddUserToRole(ctx context.Context, roleId string, body datadogV2.RelationshipToUser) (*datadogV2.UsersResponse, error)
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
func (w *DatadogClient) CreateUser(ctx context.Context, req datadogV2.UserCreateRequest) (*datadogV2.UserResponse, error)
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) DisableUser ¶ added in v0.1.1
func (w *DatadogClient) DisableUser(ctx context.Context, userId string) error
DisableUser soft-disables a Datadog user. DELETE /api/v2/users/{user_id}. Requires the user_access_manage permission. Datadog has no hard delete; this sets attributes.disabled = true.
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 ¶
func (w *DatadogClient) GetTeamMemberships(ctx context.Context, teamId string, params *datadogV2.GetTeamMembershipsOptionalParameters) (*datadogV2.UserTeamsResponse, error)
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 ¶
func (w *DatadogClient) ListAPIKeys(ctx context.Context, params *datadogV2.ListAPIKeysOptionalParameters) (*datadogV2.APIKeysResponse, error)
ListAPIKeys lists API keys using the REST client.
func (*DatadogClient) ListRoleUsers ¶
func (w *DatadogClient) ListRoleUsers(ctx context.Context, roleId string, params *datadogV2.ListRoleUsersOptionalParameters) (*datadogV2.UsersResponse, error)
ListRoleUsers lists users for a specific role and automatically handles HTTP response body closing.
func (*DatadogClient) ListRoles ¶
func (w *DatadogClient) ListRoles(ctx context.Context, params *datadogV2.ListRolesOptionalParameters) (*datadogV2.RolesResponse, error)
ListRoles lists roles using the REST client.
func (*DatadogClient) ListTeams ¶
func (w *DatadogClient) ListTeams(ctx context.Context, params *datadogV2.ListTeamsOptionalParameters) (*datadogV2.TeamsResponse, error)
ListTeams lists teams using the REST client.
func (*DatadogClient) ListUsers ¶
func (w *DatadogClient) ListUsers(ctx context.Context, params *datadogV2.ListUsersOptionalParameters) (*datadogV2.UsersResponse, error)
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) UpdateUser ¶ added in v0.1.1
func (w *DatadogClient) UpdateUser(ctx context.Context, userId string, body datadogV2.UserUpdateRequest) (*datadogV2.UserResponse, error)
UpdateUser updates a Datadog user. PATCH /api/v2/users/{user_id}. Requires the user_access_manage permission. UserUpdateAttributes exposes name, email, and disabled.
func (*DatadogClient) Validate ¶
func (w *DatadogClient) Validate(ctx context.Context) (*datadogV1.AuthenticationValidationResponse, error)
Validate validates API credentials using the REST client.
func (*DatadogClient) ValidateCredentials ¶
func (w *DatadogClient) ValidateCredentials(ctx context.Context) (*datadogV1.AuthenticationValidationResponse, error)
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, baseURL string) (*DatadogRestClient, error)
NewDatadogRestClient creates a new instance of the REST client. If baseURL is empty, it will be constructed from site using DefaultBaseURL.
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 ¶
func (c *DatadogRestClient) ListOnCallSchedules(ctx context.Context, opts *PaginationOptions) ([]*OnCallSchedule, string, annotations.Annotations, error)
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 ¶
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 ¶
PaginationOptions contains the options for pagination.
type ReqOpt ¶
ReqOpt represents a request option that can be applied to an HTTP request.
func WithPageSize ¶
WithPageSize adds a page size query parameter to the request.
func WithQueryParam ¶
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.