本文整理匯總了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
}