本文整理汇总了Golang中github.com/GoogleCloudPlatform/gcloud/gcloud_apis/commands_util.OverwriteRequestWithValues函数的典型用法代码示例。如果您正苦于以下问题:Golang OverwriteRequestWithValues函数的具体用法?Golang OverwriteRequestWithValues怎么用?Golang OverwriteRequestWithValues使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OverwriteRequestWithValues函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Test_v1_ProjectsDevicesCreate
func Test_v1_ProjectsDevicesCreate(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewProjectsDevicesService(api_service)
args, flagValues, err := commands_util.ExtractFlagValues(args)
if err != nil {
return err
}
// Only positional arguments should remain in args.
if len(args) == 0 || len(args) > 2 {
usageFunc()
}
request := &api_client.Device{}
if len(args) == 2 {
err = commands_util.PopulateRequestFromFilename(&request, args[1])
if err != nil {
return err
}
}
keyValues := flagValues
err = commands_util.OverwriteRequestWithValues(&request, keyValues)
if err != nil {
return err
}
expectedParams := []string{
"projectId",
}
paramValues := strings.Split(args[0], "/")
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_projectId := paramValues[0]
call := service.Create(param_projectId,
request,
)
var response *api_client.Device
response, err = call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
}
开发者ID:EDMunplugged,项目名称:gcloud,代码行数:69,代码来源:test_v1.go
示例2: Developerprojects_v1_ProjectsCreate
func Developerprojects_v1_ProjectsCreate(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
usageBits += " [--appengineStorageLocation=VALUE]"
usageBits += " [--createAppengineProject=VALUE]"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewProjectsService(api_service)
queryParamNames := map[string]bool{
"appengineStorageLocation": false,
"createAppengineProject": false,
}
args, flagValues, err := commands_util.ExtractFlagValues(args)
if err != nil {
return err
}
for k, r := range queryParamNames {
if _, ok := flagValues[k]; r && !ok {
return fmt.Errorf("missing required flag %q", "--"+k)
}
}
// Only positional arguments should remain in args.
if len(args) == 0 || len(args) > 2 {
usageFunc()
}
request := &api_client.Project{}
if len(args) == 2 {
err = commands_util.PopulateRequestFromFilename(&request, args[1])
if err != nil {
return err
}
}
// Any flags that aren't query parameters are applied to the request.
keyValues := map[string]string{}
for k, v := range flagValues {
if _, ok := queryParamNames[k]; !ok {
keyValues[k] = v
}
}
err = commands_util.OverwriteRequestWithValues(&request, keyValues)
if err != nil {
return err
}
expectedParams := []string{}
paramValues := strings.Split(args[0], "/")
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
call := service.Create(
request,
)
// Set query parameters.
if value, ok := flagValues["appengineStorageLocation"]; ok {
query_appengineStorageLocation, err := commands_util.ConvertValue_string(value)
if err != nil {
return err
}
call.AppengineStorageLocation(query_appengineStorageLocation)
}
if value, ok := flagValues["createAppengineProject"]; ok {
query_createAppengineProject, err := commands_util.ConvertValue_bool(value)
if err != nil {
return err
}
call.CreateAppengineProject(query_createAppengineProject)
}
var response *api_client.Project
response, err = call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
//.........这里部分代码省略.........
开发者ID:EDMunplugged,项目名称:gcloud,代码行数:101,代码来源:developerprojects_v1.go
示例3: Replicapool_v1beta1_PoolsUpdatetemplate
func Replicapool_v1beta1_PoolsUpdatetemplate(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewPoolsService(api_service)
args, flagValues, err := commands_util.ExtractFlagValues(args)
if err != nil {
return err
}
// Only positional arguments should remain in args.
if len(args) == 0 || len(args) > 2 {
usageFunc()
}
request := &api_client.Template{}
if len(args) == 2 {
err = commands_util.PopulateRequestFromFilename(&request, args[1])
if err != nil {
return err
}
}
keyValues := flagValues
err = commands_util.OverwriteRequestWithValues(&request, keyValues)
if err != nil {
return err
}
expectedParams := []string{
"projectName",
"zone",
"poolName",
}
paramValues := strings.Split(args[0], "/")
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_projectName := paramValues[0]
param_zone := paramValues[1]
param_poolName := paramValues[2]
call := service.Updatetemplate(param_projectName, param_zone, param_poolName,
request,
)
err = call.Do()
if err != nil {
return err
}
return nil
}
开发者ID:EDMunplugged,项目名称:gcloud,代码行数:67,代码来源:replicapool_v1beta1.go
示例4: Logging_v1beta3_ProjectsLogsSinksPatch
func Logging_v1beta3_ProjectsLogsSinksPatch(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
usageBits += " --sink=VALUE"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewProjectsLogsSinksService(api_service)
queryParamNames := map[string]bool{
"sink": true,
}
args, flagValues, err := commands_util.ExtractFlagValues(args)
if err != nil {
return err
}
for k, r := range queryParamNames {
if _, ok := flagValues[k]; r && !ok {
return fmt.Errorf("missing required flag %q", "--"+k)
}
}
// Only positional arguments should remain in args.
if len(args) == 0 || len(args) > 2 {
usageFunc()
}
request := &api_client.LogSink{}
if len(args) == 2 {
err = commands_util.PopulateRequestFromFilename(&request, args[1])
if err != nil {
return err
}
}
// Any flags that aren't query parameters are applied to the request.
keyValues := map[string]string{}
for k, v := range flagValues {
if _, ok := queryParamNames[k]; !ok {
keyValues[k] = v
}
}
err = commands_util.OverwriteRequestWithValues(&request, keyValues)
if err != nil {
return err
}
expectedParams := []string{
"sinkName",
}
paramValues := strings.Split(args[0], "/")
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_sinkName := paramValues[0]
param_sink, err := commands_util.ConvertValue_string(flagValues["sink"])
if err != nil {
return err
}
call := service.Patch(param_sinkName, param_sink,
request,
)
var response *api_client.LogSink
response, err = call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
}
开发者ID:EDMunplugged,项目名称:gcloud,代码行数:91,代码来源:logging_v1beta3.go
注:本文中的github.com/GoogleCloudPlatform/gcloud/gcloud_apis/commands_util.OverwriteRequestWithValues函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论