當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Resource.Params方法代碼示例

本文整理匯總了Golang中github.com/rackspace/rack/handler.Resource.Params方法的典型用法代碼示例。如果您正苦於以下問題:Golang Resource.Params方法的具體用法?Golang Resource.Params怎麽用?Golang Resource.Params使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/rackspace/rack/handler.Resource的用法示例。


在下文中一共展示了Resource.Params方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: HandleFlags

func (command *commandUpload) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"container", "name"})
	if err != nil {
		return err
	}

	c := command.Ctx.CLIContext

	opts := osObjects.CreateOpts{
		ContentLength: int64(c.Int("content-length")),
		ContentType:   c.String("content-type"),
	}

	if c.IsSet("content-encoding") && c.String("content-encoding") != "gzip" {
		opts.ContentEncoding = c.String("content-encoding")
	}

	if c.IsSet("metadata") {
		metadata, err := command.Ctx.CheckKVFlag("metadata")
		if err != nil {
			return err
		}
		opts.Metadata = metadata
	}

	resource.Params = &paramsUpload{
		container: c.String("container"),
		object:    c.String("name"),
		opts:      opts,
	}

	return nil
}
開發者ID:nelsnelson,項目名稱:rack,代碼行數:33,代碼來源:upload.go

示例2: HandleFlags

func (command *commandUpload) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"name"})
	if err != nil {
		return err
	}

	opts := &osKeypairs.CreateOpts{
		Name: command.Ctx.CLIContext.String("name"),
	}

	if command.Ctx.CLIContext.IsSet("file") {
		s := command.Ctx.CLIContext.String("file")
		pk, err := ioutil.ReadFile(s)
		if err != nil {
			return err
		}
		opts.PublicKey = string(pk)
	} else if command.Ctx.CLIContext.IsSet("public-key") {
		s := command.Ctx.CLIContext.String("public-key")
		opts.PublicKey = s
	} else {
		return fmt.Errorf("One of 'public-key' and 'file' must be provided.")
	}

	resource.Params = &paramsUpload{
		opts: opts,
	}

	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:30,代碼來源:upload.go

示例3: HandleFlags

func (command *commandList) HandleFlags(resource *handler.Resource) error {
	c := command.Ctx.CLIContext
	opts := &osNetworks.ListOpts{
		Name:     c.String("name"),
		TenantID: c.String("tenant-id"),
		Status:   c.String("status"),
		Marker:   c.String("marker"),
		Limit:    c.Int("limit"),
	}
	if c.IsSet("up") {
		upRaw := c.String("up")
		up, err := strconv.ParseBool(upRaw)
		if err != nil {
			return fmt.Errorf("Invalid value for flag `up`: %s. Options are: true, false", upRaw)
		}
		opts.AdminStateUp = &up
	}
	if c.IsSet("shared") {
		sharedRaw := c.String("shared")
		shared, err := strconv.ParseBool(sharedRaw)
		if err != nil {
			return fmt.Errorf("Invalid value for flag `shared`: %s. Options are: true, false", sharedRaw)
		}
		opts.Shared = &shared
	}
	resource.Params = &paramsList{
		opts:     opts,
		allPages: c.Bool("all-pages"),
	}
	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:31,代碼來源:list.go

示例4: HandleFlags

func (command *commandListEvents) HandleFlags(resource *handler.Resource) error {
	if err := command.Ctx.CheckFlagsSet([]string{"name"}); err != nil {
		return err
	}

	c := command.Ctx.CLIContext
	name := c.String("stack-name")
	id := c.String("stack-id")
	name, id, err := stackcommands.IDAndName(command.Ctx.ServiceClient, name, id)
	if err != nil {
		return err
	}
	opts := &osStackEvents.ListResourceEventsOpts{
		ResourceActions:  strings.Split(c.String("resource-actions"), ","),
		ResourceStatuses: strings.Split(c.String("resource-statuses"), ","),
		ResourceTypes:    strings.Split(c.String("resource-types"), ","),
		SortKey:          osStackEvents.SortKey(c.String("sort-key")),
		SortDir:          osStackEvents.SortDir(c.String("sort-dir")),
	}

	resource.Params = &paramsListEvents{
		opts:         opts,
		stackName:    name,
		stackID:      id,
		resourceName: c.String("name"),
	}
	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:28,代碼來源:listevents.go

示例5: HandleFlags

func (command *commandUploadDir) HandleFlags(resource *handler.Resource) error {
	if err := command.Ctx.CheckFlagsSet([]string{"container"}); err != nil {
		return err
	}

	c := command.Ctx.CLIContext
	containerName := c.String("container")
	if err := CheckContainerExists(command.Ctx.ServiceClient, containerName); err != nil {
		return err
	}

	opts := objects.CreateOpts{
		ContentType: c.String("content-type"),
	}

	conc := c.Int("concurrency")
	if conc <= 0 {
		conc = 100
	}

	resource.Params = &paramsUploadDir{
		container:   containerName,
		dir:         c.String("dir"),
		opts:        opts,
		concurrency: conc,
		quiet:       c.Bool("quiet"),
		recurse:     c.Bool("recurse"),
	}

	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:31,代碼來源:uploaddir.go

示例6: HandleFlags

func (command *commandCreate) HandleFlags(resource *handler.Resource) error {
	c := command.Ctx.CLIContext

	err := command.Ctx.CheckFlagsSet([]string{"name"})
	if err != nil {
		return err
	}

	opts := &osServers.CreateImageOpts{
		Name: c.String("name"),
	}

	if c.IsSet("metadata") {
		metadata, err := command.Ctx.CheckKVFlag("metadata")
		if err != nil {
			return err
		}
		opts.Metadata = metadata
	}

	resource.Params = &paramsCreate{
		opts: opts,
	}

	if c.IsSet("server-id") {
		resource.Params.(*paramsCreate).serverID = c.String("server-id")
		return nil
	}

	serverID, err := osServers.IDFromName(command.Ctx.ServiceClient, c.String("server-name"))
	resource.Params.(*paramsCreate).serverID = serverID

	return err
}
開發者ID:ktbartholomew,項目名稱:rack,代碼行數:34,代碼來源:create.go

示例7: HandleFlags

func (command *commandUpdate) HandleFlags(resource *handler.Resource) error {
	portID, err := command.Ctx.IDOrName(osPorts.IDFromName)
	if err != nil {
		return err
	}

	c := command.Ctx.CLIContext
	opts := &osPorts.UpdateOpts{
		Name:     c.String("rename"),
		DeviceID: c.String("device-id"),
	}

	if c.IsSet("up") {
		upRaw := c.String("up")
		up, err := strconv.ParseBool(upRaw)
		if err != nil {
			return fmt.Errorf("Invalid value for flag `up`: %s. Options are: true, false", upRaw)
		}
		opts.AdminStateUp = &up
	}

	if c.IsSet("security-groups") {
		opts.SecurityGroups = strings.Split(c.String("security-groups"), ",")
	}

	resource.Params = &paramsUpdate{
		portID: portID,
		opts:   opts,
	}

	return nil
}
開發者ID:smashwilson,項目名稱:rack,代碼行數:32,代碼來源:update.go

示例8: HandleFlags

func (command *commandValidate) HandleFlags(resource *handler.Resource) error {
	c := command.Ctx.CLIContext
	opts := osStackTemplates.ValidateOpts{}

	// check if either template url or template file is set
	if c.IsSet("template-file") {
		abs, err := filepath.Abs(c.String("template-file"))
		if err != nil {
			return err
		}
		template, err := ioutil.ReadFile(abs)
		if err != nil {
			return err
		}
		opts.Template = string(template)
	} else if c.IsSet("template-url") {
		opts.TemplateURL = c.String("template-url")
	} else {
		return errors.New("Neither template-file nor template-url specified")
	}

	resource.Params = &paramsValidate{
		opts: &opts,
	}
	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:26,代碼來源:validate.go

示例9: HandleFlags

func (command *commandGetMetadata) HandleFlags(resource *handler.Resource) error {
	serverID, err := command.Ctx.IDOrName(osServers.IDFromName)
	resource.Params = &paramsGetMetadata{
		serverID: serverID,
	}
	return err
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:7,代碼來源:getmetadata.go

示例10: HandleFlags

func (command *commandCreate) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"size"})
	if err != nil {
		return err
	}

	c := command.Ctx.CLIContext

	wait := false
	if c.IsSet("wait-for-completion") {
		wait = true
	}

	opts := &osVolumes.CreateOpts{
		Size:        c.Int("size"),
		Name:        c.String("name"),
		Description: c.String("description"),
		VolumeType:  c.String("volume-type"),
	}

	resource.Params = &paramsCreate{
		wait: wait,
		opts: opts,
	}

	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:27,代碼來源:create.go

示例11: HandleFlags

func (command *commandEmpty) HandleFlags(resource *handler.Resource) error {
	resource.Params = &paramsEmpty{
		quiet:       command.Ctx.CLIContext.Bool("quiet"),
		concurrency: command.Ctx.CLIContext.Int("concurrency"),
	}
	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:7,代碼來源:empty.go

示例12: HandleFlags

func (command *commandUpload) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"container"})
	if err != nil {
		return err
	}

	c := command.Ctx.CLIContext
	containerName := c.String("container")

	if err := CheckContainerExists(command.Ctx.ServiceClient, containerName); err != nil {
		return err
	}

	opts := osObjects.CreateOpts{
		ContentLength: int64(c.Int("content-length")),
		ContentType:   c.String("content-type"),
	}

	if c.IsSet("metadata") {
		metadata, err := command.Ctx.CheckKVFlag("metadata")
		if err != nil {
			return err
		}
		opts.Metadata = metadata
	}

	resource.Params = &paramsUpload{
		container: containerName,
		opts:      opts,
	}

	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:33,代碼來源:upload.go

示例13: HandleFlags

func (command *commandDelete) HandleFlags(resource *handler.Resource) error {
	resource.Params = &paramsDelete{
		purge:       command.Ctx.CLIContext.Bool("purge"),
		quiet:       command.Ctx.CLIContext.Bool("quiet"),
		concurrency: command.Ctx.CLIContext.Int("concurrency"),
	}
	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:8,代碼來源:delete.go

示例14: HandleFlags

func (command *commandGetMetadata) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"name"})
	if err != nil {
		return err
	}

	resource.Params = &paramsGetMetadata{
		containerName: command.Ctx.CLIContext.String("name"),
	}
	return err
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:11,代碼來源:getmetadata.go

示例15: HandleFlags

func (command *commandList) HandleFlags(resource *handler.Resource) error {
	c := command.Ctx.CLIContext

	opts := &osStackResources.ListOpts{
		Depth: c.Int("depth"),
	}
	resource.Params = &paramsList{
		opts: opts,
	}
	return nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:11,代碼來源:list.go


注:本文中的github.com/rackspace/rack/handler.Resource.Params方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。