Parses the services dict to get the proper endpoint for the given service.
428915
def _get_service_endpoint(context, svc, region=None, public=True):
    
    region = _safe_region(region)
    # If a specific context is passed, use that. Otherwise, use the global
    # identity reference.
    context = context or identity
    url_type = {True: "public", False: "private"}[public]
    svc_obj = context.services.get(svc)
    if not svc_obj:
        return None
    ep = svc_obj.endpoints.get(region, {}).get(url_type)
    if not ep:
        # Try the "ALL" region, and substitute the actual region
        ep = svc_obj.endpoints.get("ALL", {}).get(url_type)
    return ep
1143845
protected function parse()
    {
        $json = $this->httpResponse->json();

        $this->services = [];

        foreach ($json['objects'] as $serviceJson) {
            $this->services[] = $this->parseService($serviceJson);
        }
    }
1228814
def service_snapshots(service_id)
      return unless service_id
      res = client.hgetall(redis_key(service_id))
      res.values.map{|v| Yajl::Parser.parse(v)}
    end
957020
def getEndpoints(self,typeOfEndpoint=""):
		
		q = {}
		result = asyncResult()
		if typeOfEndpoint:
			q['type'] = typeOfEndpoint
			result.extra['type'] = typeOfEndpoint
		data = self._getURL("/endpoints", query = q)
		result.fill(data)
		if data.status_code == 200:
			result.error = False
		else:
			result.error = response_codes("get_endpoints",data.status_code)
		result.is_done = True
		return result
1215198
def service_endpoints(service_name)
      catalog = extract_value(identity_data, "access", "serviceCatalog") || {}
      service = catalog.detect { |s| s["name"] == service_name } || {}
      service["endpoints"] || []
    end
364291
def service_start(name):
    '''
    
    '''
    r = salt.utils.http.query(DETAILS['url']+'service/start/'+name, decode_type='json', decode=True)
    return r['dict']
780791
def service(self):
        '''
        
        '''
        service_class = getattr(self, 'service_class')
        service = service_class(self.http_request)
        return service
663391
def services(cls):
        """"""
        return cls.json_get('%s/services' % cls.api_url, empty_key=True,
                            send_key=False)
1023831
def as_dictionary(self):
        """"""
        values = {
            'type': self._type,
            self.SERVICE_ENDPOINT: self._service_endpoint,
        }
        if self._consume_endpoint is not None:
            values[self.CONSUME_ENDPOINT] = self._consume_endpoint
        if self._values:
            # add extra service values to the dictionary
            for name, value in self._values.items():
                if isinstance(value, object) and hasattr(value, 'as_dictionary'):
                    value = value.as_dictionary()
                elif isinstance(value, list):
                    value = [v.as_dictionary() if hasattr(v, 'as_dictionary') else v for v in value]

                values[name] = value
        return values
1083950
def get_service(self, name):
    
    return services.get_service(self._get_resource_root(), name, self.name)
677181
def get_service_url(region, endpoint_list, lookup):
    

    for endpoint in endpoint_list:
        region_get = endpoint.get('region', '')
        if region.lower() == region_get.lower():
            return http.parse_url(url=endpoint.get(lookup))
    else:
        raise exceptions.AuthenticationProblem(
            'Region "%s" was not found in your Service Catalog.',
            region
        )
633123
def service_url_parse(url):
    
    endpoint = get_sanitized_endpoint(url)
    url_split_list = url.split(endpoint + '/')
    if len(url_split_list) != 0:
        url_split_list = url_split_list[1].split('/')
    else:
        raise Exception('Wrong url parsed')

    # Remove unnecessary items from list of the split url.
    parsed_url = [s for s in url_split_list if '?' not in s if 'Server' not in s]

    return parsed_url
747922
def get_endpoints(url_base, tenant_id, user, password):
    
    url = 'http://' + url_base + '/v2.0/tokens'
    headers = {'Content-Type': 'application/json'}
    payload = {'auth': {'tenantId': '' + tenant_id + '',
                        'passwordCredentials': {'username':
                        '' + user + '', 'password': '' +
                        password + ''}}}
    try:
        response = requests.post(url, headers=headers,
                                 data=json.dumps(payload))
        response_json = response.json()
        services = response_json['access']['serviceCatalog']
    except Exception as e:
        raise Exception('Error to obtain a image ' + e.message)

    endpoints = {}
    for service in services:
        service_endpoints = {}
        for endpoint in service['endpoints']:
            service_endpoints.update({endpoint['region']:
                                      endpoint['publicURL']})
        endpoints.update({service['type']: service_endpoints})
    return endpoints
356019
def parse_endpoint(inputendpoint_xml)
      hash = Hash.new
      %w{LoadBalancedEndpointSetName LocalPort Name Port Protocol EnableDirectServerReturn LoadBalancerName IdleTimeoutInMinutes}.each do |key|
        hash[key] = xml_content(inputendpoint_xml, key, nil)
      end
      # Protocol could be in there twice... If we have two, pick the second one as the first is for the probe.
      if inputendpoint_xml.css("Protocol").count > 1
        hash["Protocol"] = inputendpoint_xml.css("Protocol")[1].content
      end
      probe = inputendpoint_xml.css("LoadBalancerProbe")
      if probe
        hash["LoadBalancerProbe"] = Hash.new
        %w{Path Port Protocol IntervalInSeconds TimeoutInSeconds}.each do |key|
          hash["LoadBalancerProbe"][key] = xml_content(probe, key, nil)
        end
      end
      hash
    end
1309526
def getEndpoint(self):
        
        port = ''
        endpoint = ''
        keyConfig = self.getKeyConfig()
        if 'port' in keyConfig:
            port = ':' + keyConfig['port']
        elif self._data['port'] != self.PORT:
            port = ':' + self._data['port']
        if 'endpoint' in keyConfig:
            endpoint = keyConfig['endpoint']
        else:
            endpoint = self._data['endpoint']
        return 'https://%s%s/%s/' % (endpoint,
                                     port,
                                     self._data['api_version'])
905846
def factory(self, request, parent=None, name=None):
        
        traverse = request.matchdict['traverse']

        # show documentation at the root path
        if not traverse:
            return {}
        else:
            service = {}
            name = name or traverse[0]

            # look for direct pattern matches
            traversed = '/' + '/'.join(traverse)
            service_type = None
            service_object = None

            for route, endpoint in self.routes:
                result = route.match(traversed)
                if result is not None:
                    request.matchdict = result
                    request.endpoint = endpoint
                    break
            else:
                try:
                    service_type, service_object = self.services[name]
                except KeyError:
                    raise HTTPNotFound()

            if service_type:
                if isinstance(service_type, Endpoint):
                    service[name] = service_type
                elif service_object is None:
                    service[name] = service_type(request)
                else:
                    service[name] = service_type(request, service_object)

            request.api_service = service
            return service
650590
def update_service_endpoints(self, endpoints, project):
        
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url('project', project, 'str')
        content = self._serialize.body(endpoints, '[ServiceEndpoint]')
        response = self._send(http_method='PUT',
                              location_id='e85f1c62-adfc-4b74-b618-11a150fb195e',
                              version='5.0-preview.2',
                              route_values=route_values,
                              content=content)
        return self._deserialize('[ServiceEndpoint]', self._unwrap_collection(response))