func Sql_v1beta3_BackupRunsList(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("instance"))
		pathParams = append(pathParams, commands_util.AngrySnakes("backupConfiguration"))

		if len(pathParams) != 0 {
			if strings.Contains("projects/{project}/instances/{instance}/backupRuns", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " --backupConfiguration=VALUE"

		usageBits += " [--maxResults=VALUE]"

		usageBits += " [--pageToken=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.NewBackupRunsService(api_service)

	queryParamNames := map[string]bool{
		"backupConfiguration": true,
		"maxResults":          false,
		"pageToken":           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) != 1 {
		usageFunc()
	}

	expectedParams := []string{
		"project",
		"instance",
	}
	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_instance, err := commands_util.ConvertValue_string(paramValues[1])
	if err != nil {
		return err
	}
	param_backupConfiguration, err := commands_util.ConvertValue_string(flagValues["backupConfiguration"])
	if err != nil {
		return err
	}

	call := service.List(param_project, param_instance, param_backupConfiguration)

	// Set query parameters.
	if value, ok := flagValues["maxResults"]; ok {
		query_maxResults, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.MaxResults(query_maxResults)
	}
	if value, ok := flagValues["pageToken"]; ok {
		query_pageToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.PageToken(query_pageToken)
	}

	response, err := call.Do()
	if err != nil {
		return err
	}

	err = commands_util.PrintResponse(response)
	if err != nil {
		return err
	}

	return nil
}
func Cloudfunctions_v1beta1_ProjectsLocationsList(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}/locations", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " [--filter=VALUE]"

		usageBits += " [--pageSize=VALUE]"

		usageBits += " [--pageToken=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.NewProjectsLocationsService(api_service)

	queryParamNames := map[string]bool{
		"filter":    false,
		"pageSize":  false,
		"pageToken": 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) != 1 {
		usageFunc()
	}

	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.List(param_name)

	// Set query parameters.
	if value, ok := flagValues["filter"]; ok {
		query_filter, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.Filter(query_filter)
	}
	if value, ok := flagValues["pageSize"]; ok {
		query_pageSize, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.PageSize(query_pageSize)
	}
	if value, ok := flagValues["pageToken"]; ok {
		query_pageToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.PageToken(query_pageToken)
	}

	response, err := call.Do()
	if err != nil {
		return err
	}

	err = commands_util.PrintResponse(response)
	if err != nil {
		return err
	}

	return nil
}
Esempio n. 3
0
func Dataflow_v1b3_ProjectsJobsMessagesList(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("jobId"))

		if len(pathParams) != 0 {
			if strings.Contains("v1b3/projects/{projectId}/jobs/{jobId}/messages", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " [--endTime=VALUE]"

		usageBits += " [--minimumImportance=VALUE]"

		usageBits += " [--pageSize=VALUE]"

		usageBits += " [--pageToken=VALUE]"

		usageBits += " [--startTime=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.NewProjectsJobsMessagesService(api_service)

	queryParamNames := map[string]bool{
		"endTime":           false,
		"minimumImportance": false,
		"pageSize":          false,
		"pageToken":         false,
		"startTime":         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) != 1 {
		usageFunc()
	}

	expectedParams := []string{
		"projectId",
		"jobId",
	}
	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_jobId, err := commands_util.ConvertValue_string(paramValues[1])
	if err != nil {
		return err
	}

	call := service.List(param_projectId, param_jobId)

	// Set query parameters.
	if value, ok := flagValues["endTime"]; ok {
		query_endTime, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.EndTime(query_endTime)
	}
	if value, ok := flagValues["minimumImportance"]; ok {
		query_minimumImportance, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.MinimumImportance(query_minimumImportance)
	}
	if value, ok := flagValues["pageSize"]; ok {
		query_pageSize, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.PageSize(query_pageSize)
	}
	if value, ok := flagValues["pageToken"]; ok {
		query_pageToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.PageToken(query_pageToken)
	}
	if value, ok := flagValues["startTime"]; ok {
		query_startTime, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.StartTime(query_startTime)
	}

	response, err := call.Do()
	if err != nil {
		return err
	}

	err = commands_util.PrintResponse(response)
	if err != nil {
		return err
	}

	return nil
}
func Clouduseraccounts_alpha_LinuxGetLinuxAccountViews(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("zone"))
		pathParams = append(pathParams, commands_util.AngrySnakes("instance"))

		if len(pathParams) != 0 {
			if strings.Contains("{project}/zones/{zone}/linuxAccountViews", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " [--filter=VALUE]"

		usageBits += " --instance=VALUE"

		usageBits += " [--maxResults=VALUE]"

		usageBits += " [--orderBy=VALUE]"

		usageBits += " [--pageToken=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.NewLinuxService(api_service)

	queryParamNames := map[string]bool{
		"filter":     false,
		"instance":   true,
		"maxResults": false,
		"orderBy":    false,
		"pageToken":  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) != 1 {
		usageFunc()
	}

	expectedParams := []string{
		"project",
		"zone",
	}
	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_zone, err := commands_util.ConvertValue_string(paramValues[1])
	if err != nil {
		return err
	}
	param_instance, err := commands_util.ConvertValue_string(flagValues["instance"])
	if err != nil {
		return err
	}

	call := service.GetLinuxAccountViews(param_project, param_zone, param_instance)

	// Set query parameters.
	if value, ok := flagValues["filter"]; ok {
		query_filter, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.Filter(query_filter)
	}
	if value, ok := flagValues["maxResults"]; ok {
		query_maxResults, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.MaxResults(query_maxResults)
	}
	if value, ok := flagValues["orderBy"]; ok {
		query_orderBy, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.OrderBy(query_orderBy)
	}
	if value, ok := flagValues["pageToken"]; ok {
		query_pageToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.PageToken(query_pageToken)
	}

	response, err := call.Do()
	if err != nil {
		return err
	}

	err = commands_util.PrintResponse(response)
	if err != nil {
		return err
	}

	return nil
}
func Toolresults_v1beta3_ProjectsHistoriesExecutionsStepsThumbnailsList(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}/thumbnails", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " [--pageSize=VALUE]"

		usageBits += " [--pageToken=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.NewProjectsHistoriesExecutionsStepsThumbnailsService(api_service)

	queryParamNames := map[string]bool{
		"pageSize":  false,
		"pageToken": 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) != 1 {
		usageFunc()
	}

	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.List(param_projectId, param_historyId, param_executionId, param_stepId)

	// Set query parameters.
	if value, ok := flagValues["pageSize"]; ok {
		query_pageSize, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.PageSize(query_pageSize)
	}
	if value, ok := flagValues["pageToken"]; ok {
		query_pageToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.PageToken(query_pageToken)
	}

	response, err := call.Do()
	if err != nil {
		return err
	}

	err = commands_util.PrintResponse(response)
	if err != nil {
		return err
	}

	return nil
}
func Genomics_v1alpha2_PipelinesList(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("v1alpha2/pipelines", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " [--namePrefix=VALUE]"

		usageBits += " [--pageSize=VALUE]"

		usageBits += " [--pageToken=VALUE]"

		usageBits += " [--projectId=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.NewPipelinesService(api_service)

	queryParamNames := map[string]bool{
		"namePrefix": false,
		"pageSize":   false,
		"pageToken":  false,
		"projectId":  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) != 1 {
		usageFunc()
	}

	expectedParams := []string{}
	paramValues := commands_util.SplitParamValues(args[0])
	if len(paramValues) != len(expectedParams) {
		return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
	}

	call := service.List()

	// Set query parameters.
	if value, ok := flagValues["namePrefix"]; ok {
		query_namePrefix, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.NamePrefix(query_namePrefix)
	}
	if value, ok := flagValues["pageSize"]; ok {
		query_pageSize, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.PageSize(query_pageSize)
	}
	if value, ok := flagValues["pageToken"]; ok {
		query_pageToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.PageToken(query_pageToken)
	}
	if value, ok := flagValues["projectId"]; ok {
		query_projectId, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.ProjectId(query_projectId)
	}

	response, err := call.Do()
	if err != nil {
		return err
	}

	err = commands_util.PrintResponse(response)
	if err != nil {
		return err
	}

	return nil
}
func Clouderrorreporting_v1beta1_ProjectsGroupStatsList(context Context, args ...string) error {

	usageFunc := func() {
		usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod)
		var pathParams []string
		pathParams = append(pathParams, commands_util.AngrySnakes("projectName"))

		if len(pathParams) != 0 {
			if strings.Contains("v1beta1/{+projectName}/groupStats", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " [--alignment=VALUE]"

		usageBits += " [--alignmentTime=VALUE]"

		usageBits += " [--groupId=VALUE]"

		usageBits += " [--order=VALUE]"

		usageBits += " [--pageSize=VALUE]"

		usageBits += " [--pageToken=VALUE]"

		usageBits += " [--serviceFilter.service=VALUE]"

		usageBits += " [--serviceFilter.version=VALUE]"

		usageBits += " [--timeRange.period=VALUE]"

		usageBits += " [--timedCountDuration=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.NewProjectsGroupStatsService(api_service)

	queryParamNames := map[string]bool{
		"alignment":             false,
		"alignmentTime":         false,
		"groupId":               false,
		"order":                 false,
		"pageSize":              false,
		"pageToken":             false,
		"serviceFilter.service": false,
		"serviceFilter.version": false,
		"timeRange.period":      false,
		"timedCountDuration":    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) != 1 {
		usageFunc()
	}

	expectedParams := []string{
		"projectName",
	}
	paramValues := commands_util.SplitParamValues(args[0])
	if len(paramValues) != len(expectedParams) {
		return commands_util.ErrForWrongParams(expectedParams, paramValues, args)
	}

	param_projectName, err := commands_util.ConvertValue_string(paramValues[0])
	if err != nil {
		return err
	}

	call := service.List(param_projectName)

	// Set query parameters.
	if value, ok := flagValues["alignment"]; ok {
		query_alignment, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.Alignment(query_alignment)
	}
	if value, ok := flagValues["alignmentTime"]; ok {
		query_alignmentTime, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.AlignmentTime(query_alignmentTime)
	}
	if value, ok := flagValues["groupId"]; ok {
		query_groupId, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.GroupId(query_groupId)
	}
	if value, ok := flagValues["order"]; ok {
		query_order, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.Order(query_order)
	}
	if value, ok := flagValues["pageSize"]; ok {
		query_pageSize, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.PageSize(query_pageSize)
	}
	if value, ok := flagValues["pageToken"]; ok {
		query_pageToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.PageToken(query_pageToken)
	}
	if value, ok := flagValues["serviceFilter_service"]; ok {
		query_serviceFilter_service, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.ServiceFilterService(query_serviceFilter_service)
	}
	if value, ok := flagValues["serviceFilter_version"]; ok {
		query_serviceFilter_version, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.ServiceFilterVersion(query_serviceFilter_version)
	}
	if value, ok := flagValues["timeRange_period"]; ok {
		query_timeRange_period, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.TimeRangePeriod(query_timeRange_period)
	}
	if value, ok := flagValues["timedCountDuration"]; ok {
		query_timedCountDuration, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.TimedCountDuration(query_timedCountDuration)
	}

	response, err := call.Do()
	if err != nil {
		return err
	}

	err = commands_util.PrintResponse(response)
	if err != nil {
		return err
	}

	return nil
}
Esempio n. 8
0
func Bigquery_v2_JobsGetQueryResults(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("jobId"))

		if len(pathParams) != 0 {
			if strings.Contains("projects/{projectId}/queries/{jobId}", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " [--maxResults=VALUE]"

		usageBits += " [--pageToken=VALUE]"

		usageBits += " [--startIndex=VALUE]"

		usageBits += " [--timeoutMs=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.NewJobsService(api_service)

	queryParamNames := map[string]bool{
		"maxResults": false,
		"pageToken":  false,
		"startIndex": false,
		"timeoutMs":  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) != 1 {
		usageFunc()
	}

	expectedParams := []string{
		"projectId",
		"jobId",
	}
	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_jobId, err := commands_util.ConvertValue_string(paramValues[1])
	if err != nil {
		return err
	}

	call := service.GetQueryResults(param_projectId, param_jobId)

	// Set query parameters.
	if value, ok := flagValues["maxResults"]; ok {
		query_maxResults, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.MaxResults(query_maxResults)
	}
	if value, ok := flagValues["pageToken"]; ok {
		query_pageToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.PageToken(query_pageToken)
	}
	if value, ok := flagValues["startIndex"]; ok {
		query_startIndex, err := commands_util.ConvertValue_uint64(value)
		if err != nil {
			return err
		}
		call.StartIndex(query_startIndex)
	}
	if value, ok := flagValues["timeoutMs"]; ok {
		query_timeoutMs, err := commands_util.ConvertValue_int64(value)
		if err != nil {
			return err
		}
		call.TimeoutMs(query_timeoutMs)
	}

	response, err := call.Do()
	if err != nil {
		return err
	}

	err = commands_util.PrintResponse(response)
	if err != nil {
		return err
	}

	return nil
}
Esempio n. 9
0
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
}