Exemplo n.º 1
0
func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	userCli, cliErr := cli.User()

	if cliErr != nil {
		panic(cliErr)
	}

	req := user.GetUserRequest{Username: ""}
	response, userErr := userCli.Get(req)

	if userErr != nil {
		panic(userErr)
	}

	fmt.Printf("Id: %s\n", response.Id)
	fmt.Printf("Username: %s\n", response.Username)
	fmt.Printf("Fullname: %s\n", response.Fullname)
	fmt.Printf("Timezone: %s\n", response.Timezone)
	fmt.Printf("Locale: %s\n", response.Locale)
	fmt.Printf("State: %s\n", response.State)
	fmt.Printf("Escalations: %v\n", response.Escalations)
	fmt.Printf("Schedules: %v\n", response.Schedules)
	fmt.Printf("Role: %v\n", response.Role)
	fmt.Printf("Groups: %v\n", response.Groups)
	fmt.Printf("Contacts: %v\n", response.Contacts)
}
Exemplo n.º 2
0
func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	userCli, cliErr := cli.User()

	if cliErr != nil {
		panic(cliErr)
	}

	req := user.ListUsersRequest{}
	response, userErr := userCli.List(req)

	if userErr != nil {
		panic(userErr)
	}

	for _, user := range response.Users {
		fmt.Printf("Id: %s\n", user.Id)
		fmt.Printf("Username: %s\n", user.Username)
		fmt.Printf("Fullname: %s\n", user.Fullname)
		fmt.Printf("Timezone: %s\n", user.Timezone)
		fmt.Printf("Locale: %s\n", user.Locale)
		fmt.Printf("State: %s\n", user.State)
		fmt.Printf("Escalations: %v\n", user.Escalations)
		fmt.Printf("Schedules: %v\n", user.Schedules)
		fmt.Printf("Role: %v\n", user.Role)
		fmt.Printf("Groups: %v\n", user.Groups)
		fmt.Printf("Contacts: %v\n", user.Contacts)
		fmt.Printf("\n")
	}
}
Exemplo n.º 3
0
func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	userCli, cliErr := cli.User()

	if cliErr != nil {
		panic(cliErr)
	}

	req := user.UpdateUserRequest{Id: "", Fullname: "", Role: "", Locale: "", Timezone: ""}
	response, userErr := userCli.Update(req)

	if userErr != nil {
		panic(userErr)
	}

	fmt.Printf("status: %s\n", response.Status)
	fmt.Printf("code: %d\n", response.Code)
}
Exemplo n.º 4
0
// Client returns a new OpsGenie client
func (c *Config) Client() (*OpsGenieClient, error) {
	opsGenie := new(client.OpsGenieClient)
	opsGenie.SetAPIKey(c.ApiKey)
	client := OpsGenieClient{}

	log.Printf("[INFO] OpsGenie client configured")

	teamsClient, err := opsGenie.Team()
	if err != nil {
		return nil, err
	}
	client.teams = *teamsClient

	usersClient, err := opsGenie.User()
	if err != nil {
		return nil, err
	}
	client.users = *usersClient

	return &client, nil
}