本文整理汇总了Golang中github.com/skelterjohn/gcloud_apis/commands_util.PopulateRequestFromFilename函数的典型用法代码示例。如果您正苦于以下问题:Golang PopulateRequestFromFilename函数的具体用法?Golang PopulateRequestFromFilename怎么用?Golang PopulateRequestFromFilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PopulateRequestFromFilename函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Clouddebugger_v2_ControllerDebuggeesRegister
func Clouddebugger_v2_ControllerDebuggeesRegister(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
if len(pathParams) != 0 {
if strings.Contains("v2/controller/debuggees/register", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.RegisterDebuggeeRequest{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewControllerDebuggeesService(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.RegisterDebuggeeRequest{}
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{}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
call := service.Register(
request,
)
response, err := call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
}
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:75,代码来源:clouddebugger_v2.go
示例2: Clouddebugger_v2_DebuggerDebuggeesBreakpointsSet
func Clouddebugger_v2_DebuggerDebuggeesBreakpointsSet(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("debuggeeId"))
if len(pathParams) != 0 {
if strings.Contains("v2/debugger/debuggees/{debuggeeId}/breakpoints/set", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
usageBits += " [--clientVersion=VALUE]"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.Breakpoint{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewDebuggerDebuggeesBreakpointsService(api_service)
queryParamNames := map[string]bool{
"clientVersion": 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.Breakpoint{}
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{
"debuggeeId",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_debuggeeId, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
call := service.Set(param_debuggeeId,
request,
)
// Set query parameters.
if value, ok := flagValues["clientVersion"]; ok {
query_clientVersion, err := commands_util.ConvertValue_string(value)
if err != nil {
return err
}
call.ClientVersion(query_clientVersion)
}
response, err := call.Do()
if err != nil {
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:clouddebugger_v2.go
示例3: Clouduseraccounts_alpha_GroupsTestIamPermissions
func Clouduseraccounts_alpha_GroupsTestIamPermissions(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("project"))
pathParams = append(pathParams, commands_util.AngrySnakes("resource"))
if len(pathParams) != 0 {
if strings.Contains("{project}/global/groups/{resource}/testIamPermissions", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.TestPermissionsRequest{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewGroupsService(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.TestPermissionsRequest{}
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{
"project",
"resource",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_project, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
param_resource, err := commands_util.ConvertValue_string(paramValues[1])
if err != nil {
return err
}
call := service.TestIamPermissions(param_project, param_resource,
request,
)
response, err := call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
}
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:89,代码来源:clouduseraccounts_alpha.go
示例4: Cloudfunctions_v1beta1_ProjectsRegionsFunctionsUpdate
func Cloudfunctions_v1beta1_ProjectsRegionsFunctionsUpdate(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("name"))
if len(pathParams) != 0 {
if strings.Contains("v1beta1/{+name}", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.HostedFunction{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewProjectsRegionsFunctionsService(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.HostedFunction{}
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{
"name",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_name, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
call := service.Update(param_name,
request,
)
response, err := call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
}
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:83,代码来源:cloudfunctions_v1beta1.go
示例5: Toolresults_v1beta3_ProjectsHistoriesExecutionsStepsPatch
func Toolresults_v1beta3_ProjectsHistoriesExecutionsStepsPatch(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("projectId"))
pathParams = append(pathParams, commands_util.AngrySnakes("historyId"))
pathParams = append(pathParams, commands_util.AngrySnakes("executionId"))
pathParams = append(pathParams, commands_util.AngrySnakes("stepId"))
if len(pathParams) != 0 {
if strings.Contains("{projectId}/histories/{historyId}/executions/{executionId}/steps/{stepId}", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
usageBits += " [--requestId=VALUE]"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.Step{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewProjectsHistoriesExecutionsStepsService(api_service)
queryParamNames := map[string]bool{
"requestId": 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.Step{}
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{
"projectId",
"historyId",
"executionId",
"stepId",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_projectId, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
param_historyId, err := commands_util.ConvertValue_string(paramValues[1])
if err != nil {
return err
}
param_executionId, err := commands_util.ConvertValue_string(paramValues[2])
if err != nil {
return err
}
param_stepId, err := commands_util.ConvertValue_string(paramValues[3])
if err != nil {
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:toolresults_v1beta3.go
示例6: Bigtableadmin_v2_ProjectsInstancesTablesModifyColumnFamilies
func Bigtableadmin_v2_ProjectsInstancesTablesModifyColumnFamilies(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("projectsId"))
pathParams = append(pathParams, commands_util.AngrySnakes("instancesId"))
pathParams = append(pathParams, commands_util.AngrySnakes("tablesId"))
if len(pathParams) != 0 {
if strings.Contains("v2/projects/{projectsId}/instances/{instancesId}/tables/{tablesId}:modifyColumnFamilies", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.ModifyColumnFamiliesRequest{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewProjectsInstancesTablesService(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.ModifyColumnFamiliesRequest{}
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{
"projectsId",
"instancesId",
"tablesId",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_projectsId, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
param_instancesId, err := commands_util.ConvertValue_string(paramValues[1])
if err != nil {
return err
}
param_tablesId, err := commands_util.ConvertValue_string(paramValues[2])
if err != nil {
return err
}
call := service.ModifyColumnFamilies(param_projectsId, param_instancesId, param_tablesId,
request,
)
response, err := call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
}
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:95,代码来源:bigtableadmin_v2.go
示例7: Toolresults_v1beta3_ProjectsHistoriesExecutionsStepsPublishXunitXmlFiles
func Toolresults_v1beta3_ProjectsHistoriesExecutionsStepsPublishXunitXmlFiles(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("projectId"))
pathParams = append(pathParams, commands_util.AngrySnakes("historyId"))
pathParams = append(pathParams, commands_util.AngrySnakes("executionId"))
pathParams = append(pathParams, commands_util.AngrySnakes("stepId"))
if len(pathParams) != 0 {
if strings.Contains("{projectId}/histories/{historyId}/executions/{executionId}/steps/{stepId}:publishXunitXmlFiles", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.PublishXunitXmlFilesRequest{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewProjectsHistoriesExecutionsStepsService(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.PublishXunitXmlFilesRequest{}
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",
"historyId",
"executionId",
"stepId",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_projectId, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
param_historyId, err := commands_util.ConvertValue_string(paramValues[1])
if err != nil {
return err
}
param_executionId, err := commands_util.ConvertValue_string(paramValues[2])
if err != nil {
return err
}
param_stepId, err := commands_util.ConvertValue_string(paramValues[3])
if err != nil {
return err
}
call := service.PublishXunitXmlFiles(param_projectId, param_historyId, param_executionId, param_stepId,
request,
)
response, err := call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:toolresults_v1beta3.go
示例8: Appengine_v1beta5_AppsServicesPatch
func Appengine_v1beta5_AppsServicesPatch(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("name"))
if len(pathParams) != 0 {
if strings.Contains("v1beta5/{+name}", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
usageBits += " [--mask=VALUE]"
usageBits += " [--migrateTraffic=VALUE]"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.Service{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewAppsServicesService(api_service)
queryParamNames := map[string]bool{
"mask": false,
"migrateTraffic": 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.Service{}
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{
"name",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_name, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
call := service.Patch(param_name,
request,
)
// Set query parameters.
if value, ok := flagValues["mask"]; ok {
query_mask, err := commands_util.ConvertValue_string(value)
if err != nil {
return err
}
call.Mask(query_mask)
}
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:appengine_v1beta5.go
示例9: Cloudresourcemanager_v1beta1_ProjectsCreate
func Cloudresourcemanager_v1beta1_ProjectsCreate(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
if len(pathParams) != 0 {
if strings.Contains("v1beta1/projects", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
usageBits += " [--useLegacyStack=VALUE]"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.Project{})
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{
"useLegacyStack": 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 := commands_util.SplitParamValues(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["useLegacyStack"]; ok {
query_useLegacyStack, err := commands_util.ConvertValue_bool(value)
if err != nil {
return err
}
call.UseLegacyStack(query_useLegacyStack)
}
response, err := call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:cloudresourcemanager_v1beta1.go
示例10: Bigquery_v2_JobsInsert
func Bigquery_v2_JobsInsert(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("projectId"))
if len(pathParams) != 0 {
if strings.Contains("projects/{projectId}/jobs", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.Job{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewJobsService(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.Job{}
if len(args) == 2 {
err = commands_util.PopulateRequestFromFilename(&request, args[1])
if err != nil {
return err
}
}
var media io.Reader
if len(args) == 3 {
if args[2] == "-" {
media = os.Stdin
} else {
media, err = os.Open(args[2])
if err != nil {
return err
}
}
}
keyValues := flagValues
err = commands_util.OverwriteRequestWithValues(&request, keyValues)
if err != nil {
return err
}
expectedParams := []string{
"projectId",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_projectId, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
call := service.Insert(param_projectId,
request,
)
if media != nil {
call.Media(media)
}
response, err := call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
}
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:99,代码来源:bigquery_v2.go
示例11: Container_v1_MasterProjectsZonesAuthenticate
func Container_v1_MasterProjectsZonesAuthenticate(context Context, args ...string) error {
usageFunc := func() {
usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
var pathParams []string
pathParams = append(pathParams, commands_util.AngrySnakes("masterProjectId"))
pathParams = append(pathParams, commands_util.AngrySnakes("zone"))
pathParams = append(pathParams, commands_util.AngrySnakes("projectNumber"))
pathParams = append(pathParams, commands_util.AngrySnakes("clusterId"))
if len(pathParams) != 0 {
if strings.Contains("v1/masterProjects/{masterProjectId}/zones/{zone}/{projectNumber}/{clusterId}/authenticate", "+") {
usageBits += " @" + strings.Join(pathParams, "@")
} else {
usageBits += " " + strings.Join(pathParams, "/")
}
}
usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"
fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
commands_util.PrintRequestExample(&api_client.AuthenticateRequest{})
os.Exit(1)
}
api_service, err := api_client.New(context.Client)
if err != nil {
return err
}
service := api_client.NewMasterProjectsZonesService(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.AuthenticateRequest{}
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{
"masterProjectId",
"zone",
"projectNumber",
"clusterId",
}
paramValues := commands_util.SplitParamValues(args[0])
if len(paramValues) != len(expectedParams) {
return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
}
param_masterProjectId, err := commands_util.ConvertValue_string(paramValues[0])
if err != nil {
return err
}
param_zone, err := commands_util.ConvertValue_string(paramValues[1])
if err != nil {
return err
}
param_projectNumber, err := commands_util.ConvertValue_int64(paramValues[2])
if err != nil {
return err
}
param_clusterId, err := commands_util.ConvertValue_string(paramValues[3])
if err != nil {
return err
}
call := service.Authenticate(param_masterProjectId, param_zone, param_projectNumber, param_clusterId,
request,
)
response, err := call.Do()
if err != nil {
return err
}
err = commands_util.PrintResponse(response)
if err != nil {
return err
}
return nil
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:container_v1.go
注:本文中的github.com/skelterjohn/gcloud_apis/commands_util.PopulateRequestFromFilename函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论