本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/models.SecurityGroup.Spaces方法的典型用法代碼示例。如果您正苦於以下問題:Golang SecurityGroup.Spaces方法的具體用法?Golang SecurityGroup.Spaces怎麽用?Golang SecurityGroup.Spaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/models.SecurityGroup
的用法示例。
在下文中一共展示了SecurityGroup.Spaces方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Read
func (repo cloudControllerSecurityGroupRepo) Read(name string) (models.SecurityGroup, error) {
path := fmt.Sprintf("/v2/security_groups?q=%s", url.QueryEscape("name:"+name))
group := models.SecurityGroup{}
foundGroup := false
err := repo.gateway.ListPaginatedResources(
repo.config.ApiEndpoint(),
path,
resources.SecurityGroupResource{},
func(resource interface{}) bool {
if asgr, ok := resource.(resources.SecurityGroupResource); ok {
group = asgr.ToModel()
foundGroup = true
}
return false
},
)
if err != nil {
return group, err
}
if !foundGroup {
return group, errors.NewModelNotFoundError("security group", name)
}
err = repo.gateway.ListPaginatedResources(
repo.config.ApiEndpoint(),
group.SpaceUrl+"?inline-relations-depth=1",
resources.SpaceResource{},
func(resource interface{}) bool {
if asgr, ok := resource.(resources.SpaceResource); ok {
group.Spaces = append(group.Spaces, asgr.ToModel())
return true
}
return false
},
)
return group, err
}