// GetTenantID returns the tenant ID for the specified service from its cache. If the specified service
// is not in the cache, it uses getServiceFunc to populate the cache (assuming serviceID really exists in the DB).
543336
func (sc *serviceCache) GetTenantID(serviceID string, getServiceFunc GetServiceDetails) (string, error) {
	if cachedSvc, found := sc.lookUpService(serviceID); found {
		return cachedSvc.tenantID, nil
	}

	cachedSvc, err := sc.updateCache(serviceID, getServiceFunc)
	if err != nil {
		return "", err
	}
	return cachedSvc.tenantID, nil
}
435897
func (c *Client) GetServiceID(id int64) (*models.Service, error) {
	params := service.NewGetServiceIDParams().WithID(id).WithTimeout(api.ClientTimeout)
	resp, err := c.Service.GetServiceID(params)
	if err != nil {
		return nil, Hint(err)
	}
	return resp.Payload, nil
}
122959
func (api *TenantsAPI) Get(identity string) (tenant *Tenant, err error) {
	res, err := api.client.restClient.Get(api.getEntityUrl(identity), api.client.options.TokenOptions)
	if err != nil {
		return
	}
	defer res.Body.Close()
	res, err = getError(res)
	if err != nil {
		return
	}
	tenant = &Tenant{}
	if res != nil {
		err = json.NewDecoder(res.Body).Decode(tenant)
		// ID corresponds to the tenant ID found, return tenant
		if err == nil {
			return
		}
	}
	// Find by Name
	uri := api.client.Endpoint + tenantUrl + "?name=" + identity
	res2, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions)

	if err != nil {
		return
	}

	tenants := &Tenants{}
	err = json.Unmarshal(res2, tenants)
	if err != nil {
		return
	}

	if len(tenants.Items) < 1 {
		err = fmt.Errorf("Cannot find a tenant with id or name match %s", identity)
		return
	}

	tenant = &(tenants.Items[0])
	return
}
524938
func (s *ServiceOfferingService) GetServiceOfferingID(name string, opts ...OptionFunc) (string, int, error) {
	p := &ListServiceOfferingsParams{}
	p.p = make(map[string]interface{})

	p.p["name"] = name

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListServiceOfferings(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
	}

	if l.Count == 1 {
		return l.ServiceOfferings[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.ServiceOfferings {
			if v.Name == name {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
542676
func GetInstanceID(
	ctx types.Context, config gofig.Config) (*types.InstanceID, error) {

	d := &driver{}
	d.Init(ctx, config)
	return d.getInstanceID()
}
170403
func (vm *VM) fillServiceOfferingID() error {

	params := url.Values{}
	params.Set("name", strings.ToLower(string(vm.ServiceOffering.Name)))

	client := vm.getExoClient()
	resp, err := client.Request("listServiceOfferings", params)
	if err != nil {
		return fmt.Errorf("Getting service offering ID for %q: %s", vm.ServiceOffering.Name, err)
	}

	so := &egoscale.ListServiceOfferingsResponse{}
	if err := json.Unmarshal(resp, so); err != nil {
		return fmt.Errorf("Decoding response for service offering %q: %s", vm.ServiceOffering.Name, err)
	}

	if so.Count != 1 {
		return fmt.Errorf("Expected 1 service offering matching %q, but returned %d", vm.ServiceOffering.Name, so.Count)
	}

	vm.ServiceOffering.ID = so.ServiceOfferings[0].Id

	return nil
}
236443
func (s *Server) GetServiceDetailsByTenantID(tenantID string, response *[]service.ServiceDetails) error {
	svcs, err := s.f.GetServiceDetailsByTenantID(s.context(), tenantID)
	if err != nil {
		return err
	}
	*response = svcs
	return nil
}
173897
func (c *Client) GetServiceDetailsByTenantID(tenantID string) ([]service.ServiceDetails, error) {
	svcs := []service.ServiceDetails{}
	err := c.call("GetServiceDetailsByTenantID", tenantID, &svcs)
	return svcs, err
}
933644
func getSubnetIDForLB(compute *gophercloud.ServiceClient, node v1.Node) (string, error) {
	ipAddress, err := nodeAddressForLB(&node)
	if err != nil {
		return "", err
	}

	instanceID := node.Spec.ProviderID
	if ind := strings.LastIndex(instanceID, "/"); ind >= 0 {
		instanceID = instanceID[(ind + 1):]
	}

	interfaces, err := getAttachedInterfacesByID(compute, instanceID)
	if err != nil {
		return "", err
	}

	for _, intf := range interfaces {
		for _, fixedIP := range intf.FixedIPs {
			if fixedIP.IPAddress == ipAddress {
				return fixedIP.SubnetID, nil
			}
		}
	}

	return "", ErrNotFound
}
837454
func (d *deployerImpl) getCurrentInstanceID(packageDir string) (string, error) {
	var current string
	var err error
	if runtime.GOOS == "windows" {
		var bytes []byte
		bytes, err = ioutil.ReadFile(filepath.Join(packageDir, currentTxt))
		if err == nil {
			current = strings.TrimSpace(string(bytes))
		}
	} else {
		current, err = os.Readlink(filepath.Join(packageDir, currentSymlink))
	}
	if err != nil {
		if os.IsNotExist(err) {
			return "", nil
		}
		return "", err
	}
	if err = common.ValidateInstanceID(current, common.AnyHash); err != nil {
		return "", fmt.Errorf(
			"pointer to currently installed instance doesn't look like a valid instance id: %s", err)
	}
	return current, nil
}
799177
func AcquireID(l3n4Addr loadbalancer.L3n4Addr, baseID uint32) (*loadbalancer.L3n4AddrID, error) {
	log.WithField(logfields.L3n4Addr, logfields.Repr(l3n4Addr)).Debug("Resolving service")

	if enableGlobalServiceIDs {
		return acquireGlobalID(l3n4Addr, baseID)
	}

	return serviceIDAlloc.acquireLocalID(l3n4Addr, baseID)
}
741397
func (_m *FacadeInterface) GetServiceInstances(ctx datastore.Context, since time.Time, serviceid string) ([]service.Instance, error) {
	ret := _m.Called(ctx, since, serviceid)

	var r0 []service.Instance
	if rf, ok := ret.Get(0).(func(datastore.Context, time.Time, string) []service.Instance); ok {
		r0 = rf(ctx, since, serviceid)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]service.Instance)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(datastore.Context, time.Time, string) error); ok {
		r1 = rf(ctx, since, serviceid)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
73644
func (r *RepositoryRelease) GetID() int64 {
	if r == nil || r.ID == nil {
		return 0
	}
	return *r.ID
}
575879
func (r *Registry) RetrieveServiceDataByIDAndNetwork(id string, ip net.IP, port int, host string) (*ServiceContext, *DependentServiceData, error) {
	sctx, err := r.RetrieveServiceByID(id)
	if err != nil {
		return nil, nil, fmt.Errorf("Services for PU %s not found: %s", id, err)
	}
	data := sctx.dependentServiceCache.Find(ip, port, "", false)
	if data == nil {
		return nil, nil, fmt.Errorf("Service not found for this PU: %s", id)
	}
	serviceData, ok := data.(*DependentServiceData)
	if !ok {
		return nil, nil, fmt.Errorf("Internal server error - bad data types")
	}
	return sctx, serviceData, nil
}
550848
func (a *Client) GetIdentityID(params *GetIdentityIDParams) (*GetIdentityIDOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetIdentityIDParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "GetIdentityID",
		Method:             "GET",
		PathPattern:        "/identity/{id}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetIdentityIDReader{formats: a.formats},
		Context:            params.Context,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	return result.(*GetIdentityIDOK), nil

}
93631
func (_m *ServiceStateManager) AddTenant(tenantID string) error {
	ret := _m.Called(tenantID)

	var r0 error
	if rf, ok := ret.Get(0).(func(string) error); ok {
		r0 = rf(tenantID)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
599743
func (r *RepositoryInvitation) GetID() int64 {
	if r == nil || r.ID == nil {
		return 0
	}
	return *r.ID
}