Пример #1
0
func Clouddebugger_v2_DebuggerDebuggeesList(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/debugger/debuggees", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

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

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

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

	queryParamNames := map[string]bool{
		"clientVersion":   false,
		"includeInactive": false,
		"project":         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["clientVersion"]; ok {
		query_clientVersion, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.ClientVersion(query_clientVersion)
	}
	if value, ok := flagValues["includeInactive"]; ok {
		query_includeInactive, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.IncludeInactive(query_includeInactive)
	}
	if value, ok := flagValues["project"]; ok {
		query_project, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.Project(query_project)
	}

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

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

	return nil
}
func Runtimeconfig_v1beta1_ProjectsConfigsVariablesDelete(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("configsId"))
		pathParams = append(pathParams, commands_util.AngrySnakes("variablesId"))

		if len(pathParams) != 0 {
			if strings.Contains("v1beta1/projects/{projectsId}/configs/{configsId}/variables/{variablesId}", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

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

	queryParamNames := map[string]bool{
		"recursive": 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{
		"projectsId",
		"configsId",
		"variablesId",
	}
	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_configsId, err := commands_util.ConvertValue_string(paramValues[1])
	if err != nil {
		return err
	}
	param_variablesId, err := commands_util.ConvertValue_string(paramValues[2])
	if err != nil {
		return err
	}

	call := service.Delete(param_projectsId, param_configsId, param_variablesId)

	// Set query parameters.
	if value, ok := flagValues["recursive"]; ok {
		query_recursive, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.Recursive(query_recursive)
	}

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

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

	return nil
}
Пример #3
0
func Clouddebugger_v2_ControllerDebuggeesBreakpointsList(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/controller/debuggees/{debuggeeId}/breakpoints", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

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

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

	queryParamNames := map[string]bool{
		"successOnTimeout": false,
		"waitToken":        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{
		"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.List(param_debuggeeId)

	// Set query parameters.
	if value, ok := flagValues["successOnTimeout"]; ok {
		query_successOnTimeout, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.SuccessOnTimeout(query_successOnTimeout)
	}
	if value, ok := flagValues["waitToken"]; ok {
		query_waitToken, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.WaitToken(query_waitToken)
	}

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

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

	return nil
}
func Deploymentmanager_alpha_DeploymentsUpdate(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("deployment"))

		if len(pathParams) != 0 {
			if strings.Contains("{project}/global/deployments/{deployment}", "+") {
				usageBits += " @" + strings.Join(pathParams, "@")
			} else {
				usageBits += " " + strings.Join(pathParams, "/")
			}
		}

		usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*"

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

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

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

		fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits)
		commands_util.PrintRequestExample(&api_client.Deployment{})

		os.Exit(1)
	}

	api_service, err := api_client.New(context.Client)
	if err != nil {
		return err
	}
	service := api_client.NewDeploymentsService(api_service)

	queryParamNames := map[string]bool{
		"createPolicy": false,
		"deletePolicy": false,
		"preview":      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.Deployment{}
	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{
		"project",
		"deployment",
	}
	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_deployment, err := commands_util.ConvertValue_string(paramValues[1])
	if err != nil {
		return err
	}

	call := service.Update(param_project, param_deployment,
		request,
	)

	// Set query parameters.
	if value, ok := flagValues["createPolicy"]; ok {
		query_createPolicy, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.CreatePolicy(query_createPolicy)
	}
	if value, ok := flagValues["deletePolicy"]; ok {
		query_deletePolicy, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.DeletePolicy(query_deletePolicy)
	}
	if value, ok := flagValues["preview"]; ok {
		query_preview, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.Preview(query_preview)
	}

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

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

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

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

		usageBits += " --instance=VALUE"

		usageBits += " [--login=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{
		"instance": true,
		"login":    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",
		"user",
	}
	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_user, err := commands_util.ConvertValue_string(paramValues[2])
	if err != nil {
		return err
	}
	param_instance, err := commands_util.ConvertValue_string(flagValues["instance"])
	if err != nil {
		return err
	}

	call := service.GetAuthorizedKeysView(param_project, param_zone, param_user, param_instance)

	// Set query parameters.
	if value, ok := flagValues["login"]; ok {
		query_login, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.Login(query_login)
	}

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

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

	return nil
}
Пример #6
0
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)
	}
	if value, ok := flagValues["migrateTraffic"]; ok {
		query_migrateTraffic, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.MigrateTraffic(query_migrateTraffic)
	}

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

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

	return nil
}
Пример #7
0
func Appengine_v1beta5_AppsGet(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 += " [--ensureResourcesExist=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.NewAppsService(api_service)

	queryParamNames := map[string]bool{
		"ensureResourcesExist": 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.Get(param_name)

	// Set query parameters.
	if value, ok := flagValues["ensureResourcesExist"]; ok {
		query_ensureResourcesExist, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.EnsureResourcesExist(query_ensureResourcesExist)
	}

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

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

	return nil
}
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
	}

	return nil
}
Пример #9
0
func Bigquery_v2_JobsList(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 += " [--allUsers=VALUE]"

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

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

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

		usageBits += " [--stateFilter=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{
		"allUsers":    false,
		"maxResults":  false,
		"pageToken":   false,
		"projection":  false,
		"stateFilter": 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",
	}
	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.List(param_projectId)

	// Set query parameters.
	if value, ok := flagValues["allUsers"]; ok {
		query_allUsers, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.AllUsers(query_allUsers)
	}
	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["projection"]; ok {
		query_projection, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.Projection(query_projection)
	}
	if value, ok := flagValues["stateFilter"]; ok {
		query_stateFilter, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.StateFilter(query_stateFilter)
	}

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

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

	return nil
}
Пример #10
0
func Bigquery_v2_DatasetsDelete(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("datasetId"))

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

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

	queryParamNames := map[string]bool{
		"deleteContents": 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",
		"datasetId",
	}
	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_datasetId, err := commands_util.ConvertValue_string(paramValues[1])
	if err != nil {
		return err
	}

	call := service.Delete(param_projectId, param_datasetId)

	// Set query parameters.
	if value, ok := flagValues["deleteContents"]; ok {
		query_deleteContents, err := commands_util.ConvertValue_bool(value)
		if err != nil {
			return err
		}
		call.DeleteContents(query_deleteContents)
	}

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

	return nil
}