本文整理汇总了Golang中github.com/opsgenie/opsgenie-go-sdk/client.OpsGenieClient.User方法的典型用法代码示例。如果您正苦于以下问题:Golang OpsGenieClient.User方法的具体用法?Golang OpsGenieClient.User怎么用?Golang OpsGenieClient.User使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/opsgenie/opsgenie-go-sdk/client.OpsGenieClient
的用法示例。
在下文中一共展示了OpsGenieClient.User方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
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)
}
示例2: main
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")
}
}
示例3: main
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)
}
示例4: Client
// 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
}