func Genomics_v1alpha2_PipelinesGetControllerConfig(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:getControllerConfig", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

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

		usageBits += " [--validationToken=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{
		"operationId":     false,
		"validationToken": 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.GetControllerConfig()

	// Set query parameters.
	if value, ok := flagValues["operationId"]; ok {
		query_operationId, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.OperationId(query_operationId)
	}
	if value, ok := flagValues["validationToken"]; ok {
		query_validationToken, err := commands_util.ConvertValue_uint64(value)
		if err != nil {
			return err
		}
		call.ValidationToken(query_validationToken)
	}

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

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

	return nil
}
Example #2
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
}