Return the uwnetid.subscription object with the subs_code.
515782
def select_subscription(subs_code, subscriptions):
    
    if subs_code and subscriptions:
        for subs in subscriptions:
            if (subs.subscription_code == subs_code):
                return subs
    return None
1123654
public SubscriptionIndex getSubscriptionIndex()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "getSubscriptionIndex");
            SibTr.exit(tc, "getSubscriptionIndex", _subscriptionIndex);
        }
        return _subscriptionIndex;
    }
670501
def get_office365edu_prod_subs(netid):
    
    subs = get_netid_subscriptions(netid,
                                   Subscription.SUBS_CODE_OFFICE_365)
    if subs is not None:
        for subscription in subs:
            if (subscription.subscription_code ==
                    Subscription.SUBS_CODE_OFFICE_365):
                return subscription
    return None
1359262
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
        return getSubscriptions(null, null);
    }
647197
public SubscriptionEnvelope getSubscription(String subId) throws ApiException {
        ApiResponse<SubscriptionEnvelope> resp = getSubscriptionWithHttpInfo(subId);
        return resp.getData();
    }
606534
public SubscriptionDefinition querySubscription(String subId) 
  throws SIDurableSubscriptionNotFoundException, SINotPossibleInCurrentConfigurationException, SIIncorrectCallException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "querySubscription", subId);

    checkStarted();
    
    if (subId == null)
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "querySubscription", "Exception SubId null");

      throw new SIIncorrectCallException(
        nls.getFormattedMessage(
          "SUBSCRIPTION_DOESNT_EXIST_ERROR_CWSIP0072",
          new Object[] { null,
                         messageProcessor.getMessagingEngineName() },
          null));
    }

    ConsumerDispatcherState subState = null;
    HashMap durableSubs = destinationManager.getDurableSubscriptionsTable();

    synchronized (durableSubs)
    {
      //Look up the consumer dispatcher for this subId in the system durable subs list
      ConsumerDispatcher cd = (ConsumerDispatcher) durableSubs.get(subId);

      if (cd == null)
      {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
          SibTr.exit(tc, "querySubscription", "Subscription not found");

        throw new SIDurableSubscriptionNotFoundException(
          nls.getFormattedMessage(
            "SUBSCRIPTION_DOESNT_EXIST_ERROR_CWSIP0072",
            new Object[] { subId,
                           messageProcessor.getMessagingEngineName() },
            null));
      }

      // Obtain the subscription state from the consumer dispatcher
      subState = cd.getConsumerDispatcherState();
    }
    
    DestinationHandler dest = null;
    try
    {    
      dest = 
        destinationManager.getDestination(subState.getTopicSpaceUuid(), true);
    }
    catch (SITemporaryDestinationNotFoundException e)
    {
      // No FFDC code needed 
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "querySubscription", "SINotPossibleInCurrentConfigurationException");
      throw new SINotPossibleInCurrentConfigurationException(e.getMessage());
    }

    // Create subscription definition
    SubscriptionDefinition subDef =
      new SubscriptionDefinitionImpl(
        dest.getName(),
        subState.getSelectionCriteria().getDiscriminator(),
        subState.getSelectionCriteria().getSelectorString(),
        subState.getSelectionCriteria().getSelectorDomain().toInt(),
        subState.getUser(),
        subState.isNoLocal(),
        subState.getDurableHome());

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "querySubscription", subDef);

    return subDef;
  }
189757
def subscribe(self, user, verbose=None):
        
        if not self.email_enabled:
            raise EmailNotEnabledError("See settings.EMAIL_ENABLED")
        if not user.email:
            raise UserEmailError(f"User {user}'s email address is not defined.")
        response = requests.post(
            f"{self.api_url}/{self.address}/members",
            auth=("api", self.api_key),
            data={
                "subscribed": True,
                "address": user.email,
                "name": f"{user.first_name} {user.last_name}",
                "description": f'{user.userprofile.job_title or ""}',
                "upsert": "yes",
            },
        )
        if verbose:
            sys.stdout.write(
                f"Subscribing {user.email} to {self.address}. "
                f"Got response={response.status_code}.\n"
            )
        return response
721446
def process_subscription_data(post_data):
    """"""
    subscription_data = post_data.pop("subscription", {})
    # As our database saves the auth and p256dh key in separate field,
    # we need to refactor it and insert the auth and p256dh keys in the same dictionary
    keys = subscription_data.pop("keys", {})
    subscription_data.update(keys)
    # Insert the browser name
    subscription_data["browser"] = post_data.pop("browser")
    return subscription_data
127940
def aliasSub(requestContext, seriesList, search, replace):
    
    try:
        seriesList.name = re.sub(search, replace, seriesList.name)
    except AttributeError:
        for series in seriesList:
            series.name = re.sub(search, replace, series.name)
    return seriesList
582999
def getResourceSubscription(self,ep,res):
		'''
		
		'''
		result = asyncResult()
		result.endpoint = ep
		result.resource = res
		data = self._getURL("/subscriptions/"+ep+res)
		if data.status_code == 200: #immediate success
			result.error = False
			result.is_done = True
			result.result = data.content
		else:
			result.error = response_codes("unsubscribe",data.status_code)
			result.is_done = True
		result.raw_data = data.content
		result.status_code = data.status_code
		return result
74630
def update_subscription(netid, action, subscription_code, data_field=None):
    
    url = '/nws/v1/subscription.json'
    action = {
        'uwNetID': netid,
        'action': action,
        'subscriptionCode': str(subscription_code)
    }

    if isinstance(data_field, tuple) and len(data_field) == 2:
        action[data_field[0]] = str(data_field[1])

    body = {'actionList': [action]}
    response = post_resource(url, json.dumps(body))
    return _json_to_subscriptions(response)
769647
def subscriptions_read(self, rid, **kwargs):
        """"""
        return self.__call_api_post('subscriptions.read', rid=rid, kwargs=kwargs)
735239
def subscription_get(subscription_id=None, **kwargs):
    '''
    

    '''
    result = {}

    if not subscription_id:
        subscription_id = kwargs.get('subscription_id')
    elif not kwargs.get('subscription_id'):
        kwargs['subscription_id'] = subscription_id

    subconn = __utils__['azurearm.get_client']('subscription', **kwargs)
    try:
        subscription = subconn.subscriptions.get(
            subscription_id=kwargs.get('subscription_id')
        )

        result = subscription.as_dict()
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('resource', str(exc), **kwargs)
        result = {'error': str(exc)}

    return result
810606
private ControllableSubscription getSubscription(String id) 
  throws SIMPControllableNotFoundException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getSubscription", id);
      
    //id is assumed to be SIBUuid12
    SIBUuid12 uuid = new SIBUuid12(id);
    SubscriptionTypeFilter filter = new SubscriptionTypeFilter();
    filter.LOCAL = Boolean.TRUE;
    ControllableSubscription sub = getSubscriptionIndex().findByUuid(uuid, filter);
    
    // If the sub is null, throw an exception
    if (sub == null)
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(
          tc,
          "getLocalSubscriptionControlByID",
          "SIMPControllableNotFoundException");
          
      throw new SIMPControllableNotFoundException(
        nls.getFormattedMessage(
          "SUBSCRIPTION_NOT_FOUND_ERROR_CWSIP0271",
          new Object[]{id},
          null));  
    }
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getSubscription", sub);
    
    return sub;
  }
1027755
def subscribe(self, subscription_channel, **observer_params):
        
        return self.get_channel(subscription_channel, **observer_params).ensure_started().observer
802223
def get_kerberos_subs(netid):
    
    subs = get_netid_subscriptions(netid, Subscription.SUBS_CODE_KERBEROS)
    if subs is not None:
        for subscription in subs:
            if subscription.subscription_code == Subscription.SUBS_CODE_KERBEROS:
                return subscription
    return None
157375
def api_subscriptions(request, userPk, key=None, hproPk=None):
    """"""

    if not check_api_key(request, key, hproPk):
        return HttpResponseForbidden

    # From UUID to Pk
    from users.models import TechUser

    user = get_object_or_404(TechUser, pk=userPk)

    (_, _, hproject) = getPlugItObject(hproPk)

    retour = user.getActiveSubscriptionLabels(hproject)

    return HttpResponse(json.dumps(retour), content_type="application/json")