// AllApplicationOffers returns all application offers in the model.
492918
func (s *applicationOffers) AllApplicationOffers() (offers []*crossmodel.ApplicationOffer, _ error) {
	applicationOffersCollection, closer := s.st.db().GetCollection(applicationOffersC)
	defer closer()

	var docs []applicationOfferDoc
	err := applicationOffersCollection.Find(bson.D{}).All(&docs)
	if err != nil {
		return nil, errors.Errorf("cannot get all application offers")
	}
	for _, doc := range docs {
		offer, err := s.makeApplicationOffer(doc)
		if err != nil {
			return nil, errors.Trace(err)
		}
		offers = append(offers, offer)
	}
	return offers, nil
}
1127108
func (s *DeleteReservationOutput) SetOfferingType(v string) *DeleteReservationOutput {
	s.OfferingType = &v
	return s
}
1365683
func (s *ReservedDBInstance) SetOfferingType(v string) *ReservedDBInstance {
	s.OfferingType = &v
	return s
}
1164755
func (st *State) GetOfferAccess(offerUUID string, user names.UserTag) (permission.Access, error) {
	perm, err := st.userPermission(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user)))
	if err != nil {
		return "", errors.Trace(err)
	}
	return perm.access(), nil
}
1267078
func (s *applicationOffers) UpdateOffer(offerArgs crossmodel.AddApplicationOfferArgs) (_ *crossmodel.ApplicationOffer, err error) {
	defer errors.DeferredAnnotatef(&err, "cannot update application offer %q", offerArgs.ApplicationName)

	if err := s.validateOfferArgs(offerArgs); err != nil {
		return nil, err
	}
	model, err := s.st.Model()
	if err != nil {
		return nil, errors.Trace(err)
	} else if model.Life() != Alive {
		return nil, errors.Errorf("model is no longer alive")
	}

	offer, err := s.ApplicationOffer(offerArgs.OfferName)
	if err != nil {
		// This will either be NotFound or some other error.
		// In either case, we return the error.
		return nil, errors.Trace(err)
	}
	doc := s.makeApplicationOfferDoc(s.st, offer.OfferUUID, offerArgs)
	var refOps []txn.Op
	if offerArgs.ApplicationName != offer.ApplicationName {
		incRefOp, err := incApplicationOffersRefOp(s.st, offerArgs.ApplicationName)
		if err != nil {
			return nil, errors.Trace(err)
		}
		decRefOp, err := decApplicationOffersRefOp(s.st, offer.ApplicationName)
		if err != nil {
			return nil, errors.Trace(err)
		}
		refOps = append(refOps, incRefOp, decRefOp)
	}
	buildTxn := func(attempt int) ([]txn.Op, error) {
		// If we've tried once already and failed, check that
		// model may have been destroyed.
		if attempt > 0 {
			if err := checkModelActive(s.st); err != nil {
				return nil, errors.Trace(err)
			}
			_, err := s.ApplicationOffer(offerArgs.OfferName)
			if err != nil {
				// This will either be NotFound or some other error.
				// In either case, we return the error.
				return nil, errors.Trace(err)
			}
		}
		ops := []txn.Op{
			model.assertActiveOp(),
			{
				C:      applicationOffersC,
				Id:     doc.DocID,
				Assert: txn.DocExists,
				Update: bson.M{"$set": doc},
			},
		}
		ops = append(ops, refOps...)
		return ops, nil
	}
	err = s.st.db().Run(buildTxn)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return s.makeApplicationOffer(doc)
}
751061
func (c *Client) ListServiceOfferings(p *ListServiceOfferingsParameter) ([]*ServiceOffering, error) {
	obj, err := c.Request("listServiceOfferings", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.([]*ServiceOffering), err
}
401628
func ValidateOfferAccess(access Access) error {
	switch access {
	case ReadAccess, ConsumeAccess, AdminAccess:
		return nil
	}
	return errors.NotValidf("%q offer access", access)
}
1073858
func (s *DescribeReservationOutput) SetOfferingDescription(v string) *DescribeReservationOutput {
	s.OfferingDescription = &v
	return s
}
723782
func (c *Client) allAllocs() map[string]*structs.Allocation {
	ars := c.getAllocRunners()
	allocs := make(map[string]*structs.Allocation, len(ars))
	for _, ar := range ars {
		a := ar.Alloc()
		allocs[a.ID] = a
	}
	return allocs
}
625890
func (api *API) SpectrumApplications(zoneID string) ([]SpectrumApplication, error) {
	uri := "/zones/" + zoneID + "/spectrum/apps"

	res, err := api.makeRequest("GET", uri, nil)
	if err != nil {
		return []SpectrumApplication{}, errors.Wrap(err, errMakeRequestError)
	}

	var spectrumApplications SpectrumApplicationsDetailResponse
	err = json.Unmarshal(res, &spectrumApplications)
	if err != nil {
		return []SpectrumApplication{}, errors.Wrap(err, errUnmarshalError)
	}

	return spectrumApplications.Result, nil
}
1194398
func (s *ReservedNode) SetOfferingType(v string) *ReservedNode {
	s.OfferingType = &v
	return s
}
322689
func (o *Enterprise) SaaSApplicationGroups(info *bambou.FetchingInfo) (SaaSApplicationGroupsList, *bambou.Error) {

	var list SaaSApplicationGroupsList
	err := bambou.CurrentSession().FetchChildren(o, SaaSApplicationGroupIdentity, &list, info)
	return list, err
}
787411
func (*ListingDimensionInfo) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
	return _ListingDimensionInfo_OneofMarshaler, _ListingDimensionInfo_OneofUnmarshaler, _ListingDimensionInfo_OneofSizer, []interface{}{
		(*ListingDimensionInfo_ListingBrand)(nil),
		(*ListingDimensionInfo_HotelId)(nil),
		(*ListingDimensionInfo_HotelClass)(nil),
		(*ListingDimensionInfo_HotelCountryRegion)(nil),
		(*ListingDimensionInfo_HotelState)(nil),
		(*ListingDimensionInfo_HotelCity)(nil),
		(*ListingDimensionInfo_ListingCustomAttribute)(nil),
		(*ListingDimensionInfo_ProductBiddingCategory)(nil),
		(*ListingDimensionInfo_ProductChannel)(nil),
		(*ListingDimensionInfo_ProductChannelExclusivity)(nil),
		(*ListingDimensionInfo_ProductCondition)(nil),
		(*ListingDimensionInfo_ProductItemId)(nil),
		(*ListingDimensionInfo_ProductType)(nil),
		(*ListingDimensionInfo_UnknownListingDimension)(nil),
	}
}
814743
func (s *applicationOffers) ApplicationOfferForUUID(offerUUID string) (*crossmodel.ApplicationOffer, error) {
	offerDoc, err := s.offerQuery(bson.D{{"offer-uuid", offerUUID}})
	if err != nil {
		if err == mgo.ErrNotFound {
			return nil, errors.NotFoundf("application offer %q", offerUUID)
		}
		return nil, errors.Annotatef(err, "cannot load application offer %q", offerUUID)
	}
	return s.makeApplicationOffer(*offerDoc)
}
84225
func (s *ServicesService) AppliedServices(accountID string, domainIdentifier string, options *ListOptions) (*servicesResponse, error) {
	path := versioned(domainServicesPath(accountID, domainIdentifier, ""))
	servicesResponse := &servicesResponse{}

	path, err := addURLQueryOptions(path, options)
	if err != nil {
		return nil, err
	}

	resp, err := s.client.get(path, servicesResponse)
	if err != nil {
		return servicesResponse, err
	}

	servicesResponse.HttpResponse = resp
	return servicesResponse, nil
}
347352
func (o *Me) SaaSApplicationTypes(info *bambou.FetchingInfo) (SaaSApplicationTypesList, *bambou.Error) {

	var list SaaSApplicationTypesList
	err := bambou.CurrentSession().FetchChildren(o, SaaSApplicationTypeIdentity, &list, info)
	return list, err
}
631732
func (api *BaseAPI) applicationOffersFromModel(
	modelUUID string,
	requiredAccess permission.Access,
	filters ...jujucrossmodel.ApplicationOfferFilter,
) ([]params.ApplicationOfferAdminDetails, error) {
	// Get the relevant backend for the specified model.
	backend, releaser, err := api.StatePool.Get(modelUUID)
	if err != nil {
		return nil, errors.Trace(err)
	}
	defer releaser()

	// If requireAdmin is true, the user must be a controller superuser
	// or model admin to proceed.
	isAdmin := false
	err = api.checkAdmin(backend)
	if err != nil && err != common.ErrPerm {
		return nil, errors.Trace(err)
	}
	isAdmin = err == nil
	if requiredAccess == permission.AdminAccess && !isAdmin {
		return nil, common.ErrPerm
	}

	offers, err := api.GetApplicationOffers(backend).ListOffers(filters...)
	if err != nil {
		return nil, errors.Trace(err)
	}

	apiUserTag := api.Authorizer.GetAuthTag().(names.UserTag)
	apiUserDisplayName, err := api.userDisplayName(backend, apiUserTag)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var results []params.ApplicationOfferAdminDetails
	for _, appOffer := range offers {
		userAccess := permission.AdminAccess
		// If the user is not a model admin, they need at least read
		// access on an offer to see it.
		if !isAdmin {
			if userAccess, err = api.checkOfferAccess(backend, appOffer.OfferUUID, requiredAccess); err != nil {
				return nil, errors.Trace(err)
			}
			if userAccess == permission.NoAccess {
				continue
			}
			isAdmin = userAccess == permission.AdminAccess
		}
		offerParams, app, err := api.makeOfferParams(backend, &appOffer)
		// Just because we can't compose the result for one offer, log
		// that and move on to the next one.
		if err != nil {
			logger.Warningf("cannot get application offer: %v", err)
			continue
		}
		offerParams.Users = []params.OfferUserDetails{{
			UserName:    apiUserTag.Id(),
			DisplayName: apiUserDisplayName,
			Access:      string(userAccess),
		}}
		offer := params.ApplicationOfferAdminDetails{
			ApplicationOfferDetails: *offerParams,
		}
		// Only admins can see some sensitive details of the offer.
		if isAdmin {
			if err := api.getOfferAdminDetails(backend, app, &offer); err != nil {
				logger.Warningf("cannot get offer admin details: %v", err)
			}
		}
		results = append(results, offer)
	}
	return results, nil
}