当前位置: 首页>>代码示例>>Golang>>正文


Golang OpsGenieClient.User方法代码示例

本文整理汇总了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)
}
开发者ID:tablexi,项目名称:opsgenie-go-sdk,代码行数:29,代码来源:user_get.go

示例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")
	}
}
开发者ID:tablexi,项目名称:opsgenie-go-sdk,代码行数:32,代码来源:user_list.go

示例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)
}
开发者ID:tablexi,项目名称:opsgenie-go-sdk,代码行数:20,代码来源:user_update.go

示例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
}
开发者ID:hashicorp,项目名称:terraform,代码行数:22,代码来源:config.go


注:本文中的github.com/opsgenie/opsgenie-go-sdk/client.OpsGenieClient.User方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。