当前位置: 首页>>代码示例>>Golang>>正文


Golang commands_util.ExtractFlagValues函数代码示例

本文整理汇总了Golang中github.com/skelterjohn/gcloud_apis/commands_util.ExtractFlagValues函数的典型用法代码示例。如果您正苦于以下问题:Golang ExtractFlagValues函数的具体用法?Golang ExtractFlagValues怎么用?Golang ExtractFlagValues使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ExtractFlagValues函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Dataflow_v1b3_ProjectsJobsMessagesList

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
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:dataflow_v1b3.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: Apikeys_v1_ProjectsGetProjectForApiKey

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

		usageBits += " [--apiKey=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{
		"apiKey": 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.GetProjectForApiKey()

	// Set query parameters.
	if value, ok := flagValues["apiKey"]; ok {
		query_apiKey, err := commands_util.ConvertValue_string(value)
		if err != nil {
			return err
		}
		call.ApiKey(query_apiKey)
	}

	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,代码行数:76,代码来源:apikeys_v1.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: 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

示例6: 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

示例7: Runtimeconfig_v1beta1_ProjectsConfigsVariablesDelete

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
}
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:96,代码来源:runtimeconfig_v1beta1.go

示例8: Appengine_v1beta5_AppsGet

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
}
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:84,代码来源:appengine_v1beta5.go

示例9: 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

示例10: 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

示例11: Clouderrorreporting_v1beta1_ProjectsGroupStatsList

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)
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:clouderrorreporting_v1beta1.go

示例12: Bigquery_v2_JobsList

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 {
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:bigquery_v2.go

示例13: 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

示例14: Bigquery_v2_DatasetsDelete

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
}
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:84,代码来源:bigquery_v2.go

示例15: Clouduseraccounts_alpha_LinuxGetAuthorizedKeysView

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
//.........这里部分代码省略.........
开发者ID:skelterjohn,项目名称:gcloud_apis,代码行数:101,代码来源:clouduseraccounts_alpha.go


注:本文中的github.com/skelterjohn/gcloud_apis/commands_util.ExtractFlagValues函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。