本文整理匯總了Golang中cf/errors.NewModelNotFoundError函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewModelNotFoundError函數的具體用法?Golang NewModelNotFoundError怎麽用?Golang NewModelNotFoundError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewModelNotFoundError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FindByHostAndDomain
func (repo *FakeRouteRepository) FindByHostAndDomain(host, domain string) (route models.Route, apiErr error) {
repo.FindByHostAndDomainHost = host
repo.FindByHostAndDomainDomain = domain
if repo.FindByHostAndDomainErr {
apiErr = errors.NewModelNotFoundError("Route", host)
}
if repo.FindByHostAndDomainNotFound {
apiErr = errors.NewModelNotFoundError("Org", host+"."+domain)
}
route = repo.FindByHostAndDomainRoute
return
}
示例2: FindInstanceByName
func (repo CloudControllerServiceRepository) FindInstanceByName(name string) (instance models.ServiceInstance, apiErr errors.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))
resources := new(PaginatedServiceInstanceResources)
apiErr = repo.gateway.GetResource(path, repo.config.AccessToken(), resources)
if apiErr != nil {
return
}
if len(resources.Resources) == 0 {
apiErr = errors.NewModelNotFoundError("Service instance", name)
return
}
instanceResource := resources.Resources[0]
instance = instanceResource.ToModel()
if instanceResource.Entity.ServicePlan.Metadata.Guid != "" {
resource := &ServiceOfferingResource{}
path = fmt.Sprintf("%s/v2/services/%s", repo.config.ApiEndpoint(), instanceResource.Entity.ServicePlan.Entity.ServiceOfferingGuid)
apiErr = repo.gateway.GetResource(path, repo.config.AccessToken(), resource)
instance.ServiceOffering = resource.ToFields()
}
return
}
示例3: FindByUsername
func (repo *FakeUserRepository) FindByUsername(username string) (user models.UserFields, apiErr error) {
repo.FindByUsernameUsername = username
user = repo.FindByUsernameUserFields
if repo.FindByUsernameNotFound {
apiErr = errors.NewModelNotFoundError("User", "")
}
return
}
示例4: FindByName
func (repo *FakeServiceBrokerRepo) FindByName(name string) (serviceBroker models.ServiceBroker, apiErr errors.Error) {
repo.FindByNameName = name
serviceBroker = repo.FindByNameServiceBroker
if repo.FindByNameNotFound {
apiErr = errors.NewModelNotFoundError("Service Broker", name)
}
return
}
示例5: FindByName
func (repo *FakeBuildpackRepository) FindByName(name string) (buildpack models.Buildpack, apiErr error) {
repo.FindByNameName = name
buildpack = repo.FindByNameBuildpack
if repo.FindByNameNotFound {
apiErr = errors.NewModelNotFoundError("Buildpack", name)
}
return
}
示例6: FindByName
func (repo *FakeQuotaRepository) FindByName(name string) (quota models.QuotaFields, apiErr error) {
repo.FindByNameName = name
quota = repo.FindByNameQuota
if repo.FindByNameNotFound {
apiErr = errors.NewModelNotFoundError("Org", name)
}
if repo.FindByNameErr {
apiErr = errors.New("Error finding quota")
}
return
}
示例7: 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
}
示例8: FindByNameInOrg
func (repo CloudControllerDomainRepository) FindByNameInOrg(name string, orgGuid string) (domain models.DomainFields, apiErr error) {
domain, apiErr = repo.findOneWithPath(repo.strategy.OrgDomainURL(orgGuid, name), name)
switch apiErr.(type) {
case *errors.ModelNotFoundError:
domain, apiErr = repo.FindByName(name)
if !domain.Shared {
apiErr = errors.NewModelNotFoundError("Domain", name)
}
}
return
}
示例9: FindByName
func (repo *FakeDomainRepository) FindByName(name string) (domain models.DomainFields, apiErr error) {
repo.FindByNameName = name
domain = repo.FindByNameDomain
if repo.FindByNameNotFound {
apiErr = errors.NewModelNotFoundError("Domain", name)
}
if repo.FindByNameErr {
apiErr = errors.New("Error finding domain")
}
return
}
示例10: findOneWithPath
func (repo CloudControllerDomainRepository) findOneWithPath(path, name string) (domain models.DomainFields, apiErr error) {
foundDomain := false
apiErr = repo.listDomains(path, func(result models.DomainFields) bool {
domain = result
foundDomain = true
return false
})
if apiErr == nil && !foundDomain {
apiErr = errors.NewModelNotFoundError("Domain", name)
}
return
}
示例11: 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&inline-relations-depth=1", spaceGuid, url.QueryEscape("label:"+name)))
if httpErr, ok := err.(errors.HttpError); ok && httpErr.ErrorCode() == errors.BAD_QUERY_PARAM {
offerings, err = repo.findServiceOfferingsByPaginating(spaceGuid, name)
}
if err == nil && len(offerings) == 0 {
err = errors.NewModelNotFoundError("Service offering", name)
}
return
}
示例12: FindServiceOfferingByLabelAndProvider
func (repo CloudControllerServiceRepository) FindServiceOfferingByLabelAndProvider(label, provider string) (offering models.ServiceOffering, apiErr errors.Error) {
path := fmt.Sprintf("%s/v2/services?q=%s", repo.config.ApiEndpoint(), url.QueryEscape("label:"+label+";provider:"+provider))
resources := new(PaginatedServiceOfferingResources)
apiErr = repo.gateway.GetResource(path, repo.config.AccessToken(), resources)
if apiErr != nil {
return
} else if len(resources.Resources) == 0 {
apiErr = errors.NewModelNotFoundError("Service offering", label+" "+provider)
} else {
offering = resources.Resources[0].ToModel()
}
return
}
示例13: FindByNameInOrg
func (repo CloudControllerDomainRepository) FindByNameInOrg(name string, orgGuid string) (domain models.DomainFields, apiErr error) {
domain, apiErr = repo.findOneWithPath(
fmt.Sprintf("/v2/organizations/%s/domains?inline-relations-depth=1&q=%s", orgGuid, url.QueryEscape("name:"+name)),
name)
switch apiErr.(type) {
case errors.ModelNotFoundError:
domain, apiErr = repo.FindByName(name)
if !domain.Shared {
apiErr = errors.NewModelNotFoundError("Domain", name)
}
}
return
}
示例14: FindByName
func (repo CloudControllerQuotaRepository) FindByName(name string) (quota models.QuotaFields, apiErr error) {
path := fmt.Sprintf("%s/v2/quota_definitions?q=%s", repo.config.ApiEndpoint(), 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
}
示例15: FindByLabelAndProvider
func (repo CloudControllerServiceAuthTokenRepository) FindByLabelAndProvider(label, provider string) (authToken models.ServiceAuthTokenFields, apiErr errors.Error) {
path := fmt.Sprintf("%s/v2/service_auth_tokens?q=%s", repo.config.ApiEndpoint(), 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
}