本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/errors.NewModelNotFoundError函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewModelNotFoundError函數的具體用法?Golang NewModelNotFoundError怎麽用?Golang NewModelNotFoundError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewModelNotFoundError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Find
func (repo CloudControllerRouteRepository) Find(host string, domain models.DomainFields, path string, port int) (models.Route, error) {
var route models.Route
queryString := queryStringForRouteSearch(host, domain.GUID, path, port)
q := struct {
Query string `url:"q"`
InlineRelationsDepth int `url:"inline-relations-depth"`
}{queryString, 1}
opt, _ := query.Values(q)
found := false
apiErr := repo.gateway.ListPaginatedResources(
repo.config.APIEndpoint(),
fmt.Sprintf("/v2/routes?%s", opt.Encode()),
resources.RouteResource{},
func(resource interface{}) bool {
keepSearching := true
route = resource.(resources.RouteResource).ToModel()
if doesNotMatchVersionSpecificAttributes(route, path, port) {
return keepSearching
}
found = true
return !keepSearching
})
if apiErr == nil && !found {
apiErr = errors.NewModelNotFoundError("Route", host)
}
return route, apiErr
}
示例2: FindByUsername
func (repo CloudControllerUserRepository) FindByUsername(username string) (models.UserFields, error) {
uaaEndpoint, apiErr := repo.getAuthEndpoint()
var user models.UserFields
if apiErr != nil {
return user, apiErr
}
usernameFilter := neturl.QueryEscape(fmt.Sprintf(`userName Eq "%s"`, username))
path := fmt.Sprintf("%s/Users?attributes=id,userName&filter=%s", uaaEndpoint, usernameFilter)
users, apiErr := repo.updateOrFindUsersWithUAAPath([]models.UserFields{}, path)
if apiErr != nil {
errType, ok := apiErr.(errors.HTTPError)
if ok {
if errType.StatusCode() == 403 {
return user, errors.NewAccessDeniedError()
}
}
return user, apiErr
} else if len(users) == 0 {
return user, errors.NewModelNotFoundError("User", username)
}
return users[0], apiErr
}
示例3: FindInstanceByName
func (repo CloudControllerServiceRepository) FindInstanceByName(name string) (instance models.ServiceInstance, apiErr error) {
path := fmt.Sprintf("%s/v2/spaces/%s/service_instances?return_user_provided_service_instances=true&q=%s&inline-relations-depth=1", repo.config.APIEndpoint(), repo.config.SpaceFields().GUID, url.QueryEscape("name:"+name))
responseJSON := new(resources.PaginatedServiceInstanceResources)
apiErr = repo.gateway.GetResource(path, responseJSON)
if apiErr != nil {
return
}
if len(responseJSON.Resources) == 0 {
apiErr = errors.NewModelNotFoundError("Service instance", name)
return
}
instanceResource := responseJSON.Resources[0]
instance = instanceResource.ToModel()
if instanceResource.Entity.ServicePlan.Metadata.GUID != "" {
resource := &resources.ServiceOfferingResource{}
path = fmt.Sprintf("%s/v2/services/%s", repo.config.APIEndpoint(), instanceResource.Entity.ServicePlan.Entity.ServiceOfferingGUID)
apiErr = repo.gateway.GetResource(path, resource)
instance.ServiceOffering = resource.ToFields()
}
return
}
示例4: FindByName
func (repo *OldFakeBuildpackRepository) FindByName(name string) (buildpack models.Buildpack, apiErr error) {
repo.FindByNameName = name
buildpack = repo.FindByNameBuildpack
if repo.FindByNameNotFound {
apiErr = errors.NewModelNotFoundError("Buildpack", name)
}
return
}
示例5: FindServiceOfferingByLabelAndProvider
func (repo CloudControllerServiceRepository) FindServiceOfferingByLabelAndProvider(label, provider string) (models.ServiceOffering, error) {
path := fmt.Sprintf("/v2/services?q=%s", url.QueryEscape("label:"+label+";provider:"+provider))
offerings, apiErr := repo.getServiceOfferings(path)
if apiErr != nil {
return models.ServiceOffering{}, apiErr
} else if len(offerings) == 0 {
apiErr = errors.NewModelNotFoundError("Service offering", label+" "+provider)
return models.ServiceOffering{}, apiErr
}
return offerings[0], apiErr
}
示例6: FindServiceOfferingsForSpaceByLabel
func (repo CloudControllerServiceRepository) FindServiceOfferingsForSpaceByLabel(spaceGUID, name string) (offerings models.ServiceOfferings, err error) {
offerings, err = repo.getServiceOfferings(fmt.Sprintf("/v2/spaces/%s/services?q=%s", spaceGUID, url.QueryEscape("label:"+name)))
if httpErr, ok := err.(errors.HTTPError); ok && httpErr.ErrorCode() == errors.BadQueryParameter {
offerings, err = repo.findServiceOfferingsByPaginating(spaceGUID, name)
}
if err == nil && len(offerings) == 0 {
err = errors.NewModelNotFoundError("Service offering", name)
}
return
}
示例7: FindByName
func (repo CloudControllerQuotaRepository) FindByName(name string) (quota models.QuotaFields, apiErr error) {
path := fmt.Sprintf("/v2/quota_definitions?q=%s", url.QueryEscape("name:"+name))
quotas, apiErr := repo.findAllWithPath(path)
if apiErr != nil {
return
}
if len(quotas) == 0 {
apiErr = errors.NewModelNotFoundError("Quota", name)
return
}
quota = quotas[0]
return
}
示例8: FindByLabelAndProvider
func (repo CloudControllerServiceAuthTokenRepository) FindByLabelAndProvider(label, provider string) (authToken models.ServiceAuthTokenFields, apiErr error) {
path := fmt.Sprintf("/v2/service_auth_tokens?q=%s", url.QueryEscape("label:"+label+";provider:"+provider))
authTokens, apiErr := repo.findAllWithPath(path)
if apiErr != nil {
return
}
if len(authTokens) == 0 {
apiErr = errors.NewModelNotFoundError("Service Auth Token", label+" "+provider)
return
}
authToken = authTokens[0]
return
}
示例9: FindByGUID
func (repo CloudControllerSpaceQuotaRepository) FindByGUID(guid string) (quota models.SpaceQuota, apiErr error) {
quotas, apiErr := repo.FindByOrg(repo.config.OrganizationFields().GUID)
if apiErr != nil {
return
}
for _, quota := range quotas {
if quota.GUID == guid {
return quota, nil
}
}
apiErr = errors.NewModelNotFoundError("Space Quota", guid)
return models.SpaceQuota{}, apiErr
}
示例10: FindByNameAndOrgGUID
func (repo CloudControllerSpaceQuotaRepository) FindByNameAndOrgGUID(spaceQuotaName string, orgGUID string) (models.SpaceQuota, error) {
quotas, apiErr := repo.FindByOrg(orgGUID)
if apiErr != nil {
return models.SpaceQuota{}, apiErr
}
for _, quota := range quotas {
if quota.Name == spaceQuotaName {
return quota, nil
}
}
apiErr = errors.NewModelNotFoundError("Space Quota", spaceQuotaName)
return models.SpaceQuota{}, apiErr
}
示例11: FindByName
func (repo CloudControllerStackRepository) FindByName(name string) (stack models.Stack, apiErr error) {
path := fmt.Sprintf("/v2/stacks?q=%s", url.QueryEscape("name:"+name))
stacks, apiErr := repo.findAllWithPath(path)
if apiErr != nil {
return
}
if len(stacks) == 0 {
apiErr = errors.NewModelNotFoundError("Stack", name)
return
}
stack = stacks[0]
return
}
示例12: findOneWithPath
func (repo CloudControllerDomainRepository) findOneWithPath(path, name string) (models.DomainFields, error) {
var domain models.DomainFields
foundDomain := false
err := repo.listDomains(path, func(result models.DomainFields) bool {
domain = result
foundDomain = true
return false
})
if err == nil && !foundDomain {
err = errors.NewModelNotFoundError("Domain", name)
}
return domain, err
}
示例13: FindByNameInOrg
func (repo CloudControllerDomainRepository) FindByNameInOrg(name string, orgGUID string) (models.DomainFields, error) {
domain, err := repo.findOneWithPath(repo.strategy.OrgDomainURL(orgGUID, name), name)
switch err.(type) {
case *errors.ModelNotFoundError:
domain, err = repo.FindSharedByName(name)
if err != nil {
return models.DomainFields{}, err
}
if !domain.Shared {
err = errors.NewModelNotFoundError("Domain", name)
}
}
return domain, err
}
示例14: FindByName
func (repo CloudControllerBuildpackRepository) FindByName(name string) (buildpack models.Buildpack, apiErr error) {
foundIt := false
apiErr = repo.gateway.ListPaginatedResources(
repo.config.APIEndpoint(),
fmt.Sprintf("%s?q=%s", buildpacksPath, url.QueryEscape("name:"+name)),
resources.BuildpackResource{},
func(resource interface{}) bool {
buildpack = resource.(resources.BuildpackResource).ToFields()
foundIt = true
return false
})
if !foundIt {
apiErr = errors.NewModelNotFoundError("Buildpack", name)
}
return
}
示例15: ReadFromSpace
func (repo CloudControllerRepository) ReadFromSpace(name string, spaceGUID string) (app models.Application, apiErr error) {
path := fmt.Sprintf("%s/v2/spaces/%s/apps?q=%s&inline-relations-depth=1", repo.config.APIEndpoint(), spaceGUID, url.QueryEscape("name:"+name))
appResources := new(resources.PaginatedApplicationResources)
apiErr = repo.gateway.GetResource(path, appResources)
if apiErr != nil {
return
}
if len(appResources.Resources) == 0 {
apiErr = errors.NewModelNotFoundError("App", name)
return
}
res := appResources.Resources[0]
app = res.ToModel()
return
}