Return a Budget with the associated budgetId.

    Args:
      client_customer_id: str Client Customer Id to which the budget belongs.
      budget_id: str id of the budget we want to examine.

    Returns:
      Budget A Budget data object.
544576
def GetBudget(self, client_customer_id, budget_id):
    
    self.client.SetClientCustomerId(client_customer_id)
    selector = {
        'fields': ['BudgetId', 'BudgetName', 'BudgetStatus', 'Amount',
                   'DeliveryMethod', 'BudgetReferenceCount',
                   'IsBudgetExplicitlyShared'],
        'predicates': [
            {
                'field': 'BudgetId',
                'operator': 'EQUALS',
                'values': [budget_id]
            }
        ]
    }
    budgets = self.client.GetService('BudgetService').get(selector)

    if int(budgets['totalNumEntries']) > 0:
      return budgets['entries'][0]
    else:
      return None
1161142
def _CreateBudget(client):
  
  budget_service = client.GetService('BudgetService', version='v201809')

  # Create the campaign budget
  operation = {
      'operand': {
          'name': 'Interplanetary Cruise Budget #%d' % uuid.uuid4(),
          'deliveryMethod': 'STANDARD',
          'amount': {
              'microAmount': 500000
          }
      },
      'operator': 'ADD'
  }

  budget = budget_service.mutate([operation])['value'][0]

  print 'Budget with ID "%d" and name "%s" was created.' % (
      budget['budgetId'], budget['name'])

  return budget
197394
def has_client_id(self, id):
    """"""

    return self.query(Client).filter(Client.id==id).count() != 0
291863
public function retrieveCustomer($customer_id)
    {
        list($response, $statusCode, $httpHeader) = $this->retrieveCustomerWithHttpInfo ($customer_id);
        return $response; 
    }
168122
def _get_management_client(self, client_class):
        
        try:
            client = get_client_from_auth_file(
                client_class, auth_path=self.service_account_file
            )
        except ValueError as error:
            raise AzureCloudException(
                'Service account file format is invalid: {0}.'.format(error)
            )
        except KeyError as error:
            raise AzureCloudException(
                'Service account file missing key: {0}.'.format(error)
            )
        except Exception as error:
            raise AzureCloudException(
                'Unable to create resource management client: '
                '{0}.'.format(error)
            )

        return client
277537
def client_list(self, _type=None):
        
        "Returns a list of currently connected clients"
        if _type is not None:
            client_types = ('normal', 'master', 'replica', 'pubsub')
            if str(_type).lower() not in client_types:
                raise DataError("CLIENT LIST _type must be one of %r" % (
                                client_types,))
            return self.execute_command('CLIENT LIST', Token.get_token('TYPE'),
                                        _type)
        return self.execute_command('CLIENT LIST')
1302855
def list_wallets(self):
        
        response = make_request(
            '{}wallet'.format(self.url),
            timeout=self.timeout,
            client=self._client)
        try:
            total = response['total']
            return {
                'credit': response['credit'],
                'total': WalletTotal(
                    limit=total['limit'],
                    budgeted=total['budgeted'],
                    available=total['available'],
                    unallocated=total['unallocated'],
                    usage=total['usage'],
                    consumed=total['consumed']),
                'wallets': tuple(Wallet(
                    owner=wallet['owner'],
                    wallet=wallet['wallet'],
                    limit=wallet['limit'],
                    budgeted=wallet['budgeted'],
                    unallocated=wallet['unallocated'],
                    available=wallet['available'],
                    consumed=wallet['consumed'],
                    default='default' in wallet)
                    for wallet in response['wallets']),
            }
        except Exception as err:
            log.error(
                'cannot process wallets: invalid JSON response: {!r}'.format(
                    response))
            raise ServerError(
                'unable to get list of wallets: {!r}'.format(err))
625406
def _set_client_id(self, client_id):
        
        with self.lock:
            if self.client_id is None:
                self.client_id = client_id
600591
def get_address(customer_id, data):
    
    Address = client.model('party.address')

    addresses = Address.find(
        [('party', '=', customer_id)],
        fields=[
            'name', 'street', 'street_bis', 'city', 'zip',
            'subdivision.code', 'country.code'
        ]
    )
    for address in addresses:
        if (
                address['name'] == data['name'] and
                address['street'] == data['street'] and
                address['street_bis'] == data['street_bis'] and
                address['city'] == data['city'] and
                address['zip'] == data['zip'] and
                address['subdivision.code'].endswith(data['state']) and
                address['country.code'] == data['country']):
            return address['id']
1306123
def verify_client_id(self):
        

        from .models import Client
        from .exceptions.invalid_client import ClientDoesNotExist
        from .exceptions.invalid_request import ClientNotProvided

        if self.client_id:
            try:
                self.client = Client.objects.for_id(self.client_id)
            # Catching also ValueError for the case when client_id doesn't contain an integer.
            except (Client.DoesNotExist, ValueError):
                raise ClientDoesNotExist()
        else:
            raise ClientNotProvided()
201936
def getClientUID(self):
        
        request = self.getRequest()
        if request:
            client = request.getClient()
            if client:
                return client.UID()
494868
def get_recurring_bill_by_client(self, *, customer_id, date_begin=None, date_final=None):
        
        params = {
            "customerId": customer_id,
        }
        if date_begin and date_final:
            params['dateBegin'] = date_begin.strftime('%Y-%m-%d')
            params['dateFinal'] = date_final.strftime('%Y-%m-%d')
        return self.client._get(self.url + 'recurringBill', params=params, headers=self.get_headers())
386397
def get(self):
    """"""
    client_customer_id = self.request.get('clientCustomerId')

    template_values = {
        'back_url': '/showAccounts',
        'back_msg': 'View Accounts.',
        'ccid': client_customer_id,
        'logout_url': users.create_logout_url('/'),
        'user_nickname': users.get_current_user().nickname()
    }

    try:
      try:
        app_user = InitUser()

        # Load Client instance.
        handler = APIHandler(app_user.client_id,
                             app_user.client_secret,
                             app_user.refresh_token,
                             app_user.adwords_manager_cid,
                             app_user.developer_token)

        campaigns = handler.GetCampaigns(client_customer_id)
      except Exception, e:
        template_values['error'] = str(e)
    finally:
      # Use template to write output to the page.
      template_values['campaigns'] = campaigns
      path = os.path.join(os.path.dirname(__file__),
                          '../templates/show_campaigns.html')
      self.response.out.write(template.render(path, template_values))
299299
def find_by_id(self, project_membership, params={}, **options): 
        
        path = "/project_memberships/%s" % (project_membership)
        return self.client.get(path, params, **options)
539847
def retrieve_customer(customer_id, opts = {})
      data, _status_code, _headers = retrieve_customer_with_http_info(customer_id, opts)
      return data
    end
1325459
def get_product(membersuite_id, client=None):
    
    if not membersuite_id:
        return None

    client = client or get_new_client(request_session=True)

    object_query = "SELECT Object() FROM PRODUCT WHERE ID = '{}'".format(
        membersuite_id)

    result = client.execute_object_query(object_query)

    msql_result = result["body"]["ExecuteMSQLResult"]

    if msql_result["Success"]:
        membersuite_object_data = (msql_result["ResultValue"]
                                   ["SingleObject"])
    else:
        raise ExecuteMSQLError(result=result)

    return Product(membersuite_object_data=membersuite_object_data)
616453
def _get_client_by_id(self, client_id):
    
    client = self.grr_api.Client(client_id)
    print('Checking for client approval')
    self._check_approval_wrapper(client, client.ListFlows)
    print('{0:s}: Client approval is valid'.format(client_id))
    return client.Get()