View for getting active service by location
490797
def active_service_location(doc):
    """"""
    if doc.get('state') != 'deactivated':
        for service_id, service in doc.get('services', {}).items():
            if service.get('state') != 'deactivated':
                service['id'] = service_id
                service['organisation_id'] = doc['_id']

                location = service.get('location', None)
                if location:
                    yield location, service
390097
def GetServices(self,filename):
        """"""
        objlist=[]
        for sobj in self.services:
            if sobj.KnowsFile(filename) :
                objlist.append(sobj)

        if len(objlist)==0:
            return None

        return objlist
540841
def array_controller_by_location(self, location):
        
        for member in self.get_members():
            if member.location == location:
                return member
1314279
public static location[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception{
		location obj = new location();
		options option = new options();
		option.set_filter(filter);
		location[] response = (location[]) obj.getfiltered(service, option);
		return response;
	}
1344021
def get_all_services(resource_root, cluster_name="default", view=None):
  
  return call(resource_root.get,
      SERVICES_PATH % (cluster_name,),
      ApiService, True, params=view and dict(view=view) or None)
633916
def get_service_locations(self):
        
        url = URLS['servicelocation']
        headers = {"Authorization": "Bearer {}".format(self.access_token)}
        r = requests.get(url, headers=headers)
        r.raise_for_status()
        return r.json()
463244
private List<ServiceInformation> getServiceInformations(URI location, final Map<String, String> params)
            throws IOException {
        final ReadOnlyDiscoveryClient discoveryClient = getDiscoveryClient(params);

        final String serviceType = params.get("serviceType");

        final List<ServiceInformation> services;

        if (serviceType != null) {
            services = discoveryClient.findAllServiceInformation(location.getHost(), serviceType);
        } else {
            services = discoveryClient.findAllServiceInformation(location.getHost());
        }
        return services;
    }
1083053
def activitypub_object_view(func):
    

    def inner(request, *args, **kwargs):

        def get(request, *args, **kwargs):
            # TODO remove once AP support is more ready
            config = get_configuration()
            if not config.get("activitypub"):
                return func(request, *args, **kwargs)

            fallback = True
            accept = request.META.get('HTTP_ACCEPT', '')
            for content_type in (
                    'application/json', 'application/activity+json', 'application/ld+json',
            ):
                if accept.find(content_type) > -1:
                    fallback = False
                    break
            if fallback:
                return func(request, *args, **kwargs)

            get_object_function = get_function_from_config('get_object_function')
            obj = get_object_function(request)
            if not obj:
                return HttpResponseNotFound()

            as2_obj = obj.as_protocol('activitypub')
            return JsonResponse(as2_obj.to_as2(), content_type='application/activity+json')

        def post(request, *args, **kwargs):
            process_payload_function = get_function_from_config('process_payload_function')
            result = process_payload_function(request)
            if result:
                return JsonResponse({}, content_type='application/json', status=202)
            else:
                return JsonResponse({"result": "error"}, content_type='application/json', status=400)

        if request.method == 'GET':
            return get(request, *args, **kwargs)
        elif request.method == 'POST' and request.path.endswith('/inbox/'):
            return post(request, *args, **kwargs)

        return HttpResponse(status=405)
    return inner
331785
def active(self, date="", page=1, page_size=1000, order_field="email", order_direction="asc", include_tracking_preference=False):
        """"""
        params = {
            "date": date,
            "page": page,
            "pagesize": page_size,
            "orderfield": order_field,
            "orderdirection": order_direction,
            "includetrackingpreference": include_tracking_preference,
        }
        response = self._get(self.uri_for("active"), params=params)
        return json_to_py(response)
717394
def get_active_class_for_request(self, request=None):
        
        parsed_url = urlparse(self.link_url)
        if parsed_url.netloc:
            return ''
        if request.path == parsed_url.path:
            return settings.ACTIVE_CLASS
        if (
            request.path.startswith(parsed_url.path) and
            parsed_url.path != '/'
        ):
            return settings.ACTIVE_ANCESTOR_CLASS
        return ''
847772
def endpoint_get(service, region=None, profile=None, interface=None, **connection_args):
    '''
    
    '''
    auth(profile, **connection_args)
    services = service_list(profile, **connection_args)
    if service not in services:
        return {'Error': 'Could not find the specified service'}
    service_id = services[service]['id']
    endpoints = endpoint_list(profile, **connection_args)

    e = [_f for _f in [e
          if e['service_id'] == service_id and
            (e['region'] == region if region else True) and
            (e['interface'] == interface if interface else True)
            else None for e in endpoints.values()] if _f]
    if len(e) > 1:
        return {'Error': 'Multiple endpoints found ({0}) for the {1} service. Please specify region.'.format(e, service)}
    if len(e) == 1:
        return e[0]
    return {'Error': 'Could not find endpoint for the specified service'}
231699
def list_dfs_services(self, view=None):
    
    if view:
      return self._get_resource_root().get("%s/%s?view=%s" % (self._path(), 'dfsServices', view))
    else:
      return self._get_resource_root().get("%s/%s" % (self._path(), 'dfsServices'))
127737
@View(name = "by_serviceId", map = "function(doc) { if (doc.service) { emit(doc.service.serviceId, doc._id) }}")
    public RegisteredServiceDocument findByServiceId(final String serviceId) {
        return queryView("by_serviceId", serviceId).stream().findFirst().orElse(null);
    }
1087816
def active(self, registered_only=True):
        ""
        visitors = self.filter(
            expiry_time__gt=timezone.now(),
            end_time=None
        )
        if registered_only:
            visitors = visitors.filter(user__isnull=False)
        return visitors
928841
def get_services(cls, request=None):
        
        return {service['name']: reverse(service['list_view'], request=request)
                for service in cls._registry.values()}
235590
def service_location(doc):
    """"""
    for service_id, service in doc.get('services', {}).items():
        service['id'] = service_id
        service['organisation_id'] = doc['_id']

        location = service.get('location', None)
        if location:
            yield location, service
62667
def render(self, context, instance, placeholder):
        '''  '''
        context = super(LocationListPlugin,self).render(context,instance,placeholder)
        context['location_list'] = Location.objects.filter(status=Location.StatusChoices.active)
        return context