moesifapi


Namemoesifapi JSON
Version 1.5.3 PyPI version JSON
download
home_pagehttps://www.moesif.com/docs/api?python#api-libs
SummaryMoesif API Lib for Python
upload_time2024-10-29 19:01:49
maintainerNone
docs_urlNone
authorMoesif, Inc
requires_pythonNone
licenseApache Software License
keywords log analysis restful api development debug
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MoesifApi Lib for Python

[![Built For][ico-built-for]][link-built-for]
[![Latest Version][ico-version]][link-package]
[![Language Versions][ico-language]][link-language]
[![Software License][ico-license]][link-license]
[![Source Code][ico-source]][link-source]

[Source Code on GitHub](https://github.com/moesif/moesifapi-python)

This SDK uses the Requests library and will work for Python 2.7 — 3.5.

If you are using Django as your platform, we have [moesifapi-python](https://github.com/Moesif/moesifapi-python) middleware, you can use that middleware directly.

__Check out Moesif's [Developer Documentation](https://www.moesif.com/docs) and [Python API Reference](https://www.moesif.com/docs/api?python) to learn more__


## How to install:

```
pip install moesifapi
```

## How to use:

The code uses Python packages named requests, jsonpickle and dateutil.
After having resolved the dependencies, you can easily use the SDK following these steps.

Your Moesif Application Id can be found in the [_Moesif Portal_](https://www.moesif.com/).
After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps. 

You can always find your Moesif Application Id at any time by logging 
into the [_Moesif Portal_](https://www.moesif.com/), click on the top right menu,
 and then clicking _Installation_.

### Create Event

```python
from __future__ import print_function
from moesifapi.moesif_api_client import *
from moesifapi.models import *

client = MoesifAPIClient(my_application_id)
api_client = client.api

# Note: we recommend sending all API Calls via MVC framework middleware.

req_headers = APIHelper.json_deserialize("""  {
  "Host": "api.acmeinc.com",
  "Accept": "*/*",
  "Connection": "Keep-Alive",
  "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)",
  "Content-Type": "application/json",
  "Content-Length": "126",
  "Accept-Encoding": "gzip"
} """)

req_body = APIHelper.json_deserialize( """{
  "items": [
    {
      "type": 1,
      "id": "fwfrf"
    },
    {
      "type": 2,
      "id": "d43d3f"
    }
  ]
}""")

rsp_headers = APIHelper.json_deserialize("""  {
    "Date": "Tue, 23 Aug 2019 23:46:49 GMT",
    "Vary": "Accept-Encoding",
    "Pragma": "no-cache",
    "Expires": "-1",
    "Content-Type": "application/json; charset=utf-8"
    "Cache-Control": "no-cache"
  } """)

rsp_body = APIHelper.json_deserialize( """{
    "Error": "InvalidArgumentException",
    "Message": "Missing field field_a"
  }""")

metadata = APIHelper.json_deserialize("""{
    "field1": "foo",
    "field2": "bar"
  }""")



event_req = EventRequestModel(time = "2019-09-09T04:45:42.914",
    uri = "https://api.acmeinc.com/items/reviews/",
    verb = "PATCH",
    api_version = "1.1.0",
    ip_address = "61.48.220.123",
    headers = req_headers,
    body = req_body)

event_rsp = EventResponseModel(time = "2019-09-09T04:45:42.914",
    status = 500,
    headers = rsp_headers,
    body = rsp_body)

event_model = EventModel(request = event_req,
    response = event_rsp,
    user_id = "12345",
    company_id = "67890",
    session_token = "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f",
    metadata = metadata)


# Perform the API call through the SDK function
api_client.create_event(event_model)


api_client.create_event(my_api_event_model)
```

## Update a Single User

Create or update a user profile in Moesif.
The metadata field can be any customer demographic or other info you want to store.
Only the `userId` field is required.
For details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-a-user).

```python
from moesifapi.moesif_api_client import *
from moesifapi.models import *

api_client = MoesifAPIClient("YOUR_COLLECTOR_APPLICATION_ID").api

# Only user_id is required.
# Campaign object is optional, but useful if you want to track ROI of acquisition channels
# See https://www.moesif.com/docs/api#users for campaign schema
# metadata can be any custom object
user = {
  'user_id': '12345',
  'company_id': '67890', # If set, associate user with a company object
  'campaign': {
    'utm_source': 'google',
    'utm_medium': 'cpc', 
    'utm_campaign': 'adwords',
    'utm_term': 'api+tooling',
    'utm_content': 'landing'
  },
  'metadata': {
    'email': 'john@acmeinc.com',
    'first_name': 'John',
    'last_name': 'Doe',
    'title': 'Software Engineer',
    'sales_info': {
        'stage': 'Customer',
        'lifetime_value': 24000,
        'account_owner': 'mary@contoso.com'
    },
  }
}

update_user = api_client.update_user(user)
```

## Update Users in Batch

Similar to UpdateUser, but used to update a list of users in one batch. 
Only the `userId` field is required.
For details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-users-in-batch).

```python
from moesifapi.moesif_api_client import *
from moesifapi.models import *

api_client = MoesifAPIClient("YOUR_COLLECTOR_APPLICATION_ID").api

userA = {
  'user_id': '12345',
  'company_id': '67890', # If set, associate user with a company object
  'metadata': {
    'email': 'john@acmeinc.com',
    'first_name': 'John',
    'last_name': 'Doe',
    'title': 'Software Engineer',
    'sales_info': {
        'stage': 'Customer',
        'lifetime_value': 24000,
        'account_owner': 'mary@contoso.com'
    },
  }
}

userB = {
  'user_id': '54321',
  'company_id': '67890', # If set, associate user with a company object
  'metadata': {
    'email': 'mary@acmeinc.com',
    'first_name': 'Mary',
    'last_name': 'Jane',
    'title': 'Software Engineer',
    'sales_info': {
        'stage': 'Customer',
        'lifetime_value': 48000,
        'account_owner': 'mary@contoso.com'
    },
  }
}
update_users = api_client.update_users_batch([userA, userB])
```

## Update a Single Company

Create or update a company profile in Moesif.
The metadata field can be any company demographic or other info you want to store.
Only the `companyId` field is required.
For details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-a-company).

```python
from moesifapi.moesif_api_client import *
from moesifapi.models import *

api_client = MoesifAPIClient("YOUR_COLLECTOR_APPLICATION_ID").api

# Only company_id is required.
# Campaign object is optional, but useful if you want to track ROI of acquisition channels
# See https://www.moesif.com/docs/api#update-a-company for campaign schema
# metadata can be any custom object
company = {
  'company_id': '12345',
  'company_domain': 'acmeinc.com', # If domain is set, Moesif will enrich your profiles with publicly available info 
  'campaign': {
    'utm_source': 'google',
    'utm_medium': 'cpc', 
    'utm_campaign': 'adwords',
    'utm_term': 'api+tooling',
    'utm_content': 'landing'
  },
  'metadata': {
    'org_name': 'Acme, Inc',
    'plan_name': 'Free',
    'deal_stage': 'Lead',
    'mrr': 24000,
    'demographics': {
        'alexa_ranking': 500000,
        'employee_count': 47
    },
  }
}

update_company = api_client.update_company(company)
```

## Update Companies in Batch

Similar to updateCompany, but used to update a list of companies in one batch. 
Only the `companyId` field is required.
For details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-companies-in-batch).


```python
from moesifapi.moesif_api_client import *
from moesifapi.models import *

api_client = MoesifAPIClient("YOUR_COLLECTOR_APPLICATION_ID").api

# Only company_id is required.
# Campaign object is optional, but useful if you want to track ROI of acquisition channels
# See https://www.moesif.com/docs/api#update-a-company for campaign schema
# metadata can be any custom object
companies = [{
  'company_id': '67890',
  'company_domain': 'acmeinc.com', # If domain is set, Moesif will enrich your profiles with publicly available info 
  'campaign': {
    'utm_source': 'google',
    'utm_medium': 'cpc', 
    'utm_campaign': 'adwords',
    'utm_term': 'api+tooling',
    'utm_content': 'landing'
  },
  'metadata': {
    'org_name': 'Acme, Inc',
    'plan_name': 'Free',
    'deal_stage': 'Lead',
    'mrr': 24000,
    'demographics': {
        'alexa_ranking': 500000,
        'employee_count': 47
    },
  }
},
{
  'company_id': '09876',
  'company_domain': 'contoso.com', # If domain is set, Moesif will enrich your profiles with publicly available info 
  'campaign': {
    'utm_source': 'facebook',
    'utm_medium': 'cpc', 
    'utm_campaign': 'retargeting'
  },
  'metadata': {
    'org_name': 'Contoso, Inc',
    'plan_name': 'Paid',
    'deal_stage': 'Lead',
    'mrr': 48000,
    'demographics': {
        'alexa_ranking': 500000,
        'employee_count': 53
    },
  }
}]

update_company = api_client.update_companies(companies)
```

## Update a Single Subscription

Create or update a subscription profile in Moesif. The metadata field can store any subscription-related information you wish to keep. The `subscription_id`, `company_id`, and `status` fields are all required. This method is a convenient helper that calls the Moesif API library. For details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-a-subscription).

```python
from moesifapi.moesif_api_client import *
from moesifapi.models import *
from datetime import datetime, timedelta

api_client = MoesifAPIClient("YOUR_COLLECTOR_APPLICATION_ID").api

# Required fields for a subscription update
subscription = {
  'subscription_id': 'sub_3456',
  'company_id': '67890',
  'current_period_start': datetime.utcnow(),
  'current_period_end': datetime.utcnow() + timedelta(days=30),
  'status': 'active',
  # Optional metadata can be any custom object
  'metadata': {
    'string_field': 'value_1',
    'number_field': 0,
    'object_field': {
      'field_1': 'value_1',
      'field_2': 'value_2'
    }
  }
}

update_subscription = api_client.update_subscription(subscription)
```

## Update Subscriptions in Batch

Similar to `updateSubscription`, but used to update a list of subscriptions in one batch. The `subscription_id`, `company_id`, and `status` fields are required for each subscription in the list. This method is a convenient helper that calls the Moesif API library. For details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-subscriptions-in-batch).

```python
from moesifapi.moesif_api_client import *
from moesifapi.models import *
from datetime import datetime, timedelta

api_client = MoesifAPIClient("YOUR_COLLECTOR_APPLICATION_ID").api

# Required fields for subscription updates in a batch
subscriptions = [{
  'subscription_id': 'sub_3456',
  'company_id': '67890',
  'current_period_start': datetime.utcnow(),
  'current_period_end': datetime.utcnow() + timedelta(days=30),
  'status': 'active',
  # Optional metadata can be any custom object
  'metadata': {
    'string_field': 'value_1',
    'number_field': 0,
    'object_field': {
      'field_1': 'value_1',
      'field_2': 'value_2'
    }
  }
}, {
  'subscription_id': 'sub_34567',
  'company_id': '6789',
  'current_period_start': datetime.utcnow(),
  'current_period_end': datetime.utcnow() + timedelta(days=30),
  'status': 'active',
  'metadata': {
    'string_field': 'value_1',
    'number_field': 0,
    'object_field': {
      'field_1': 'value_1',
      'field_2': 'value_2'
    }
  }
}]

update_subscriptions = api_client.update_subscriptions_batch(subscriptions)
```

## How to test:

You can test the SDK with automatically generated test
cases. unittest is used as the testing framework and nose is used as the test
runner. You can run the tests as follows:

  1. Manually clone the git repo
  2. From terminal/cmd navigate to the root directory of the SDK.
  3. Invoke 'pip install -r requirements.txt'
  4. Add your own application id to 'test/controllers/controller_test_base'
  5. Invoke 'pytest tests/controllers/test_api_controller.py'

  [ico-built-for]: https://img.shields.io/badge/built%20for-python-blue.svg
  [ico-version]: https://img.shields.io/pypi/v/moesifapi.svg
  [ico-language]: https://img.shields.io/pypi/pyversions/moesifapi.svg
  [ico-license]: https://img.shields.io/badge/License-Apache%202.0-green.svg
  [ico-source]: https://img.shields.io/github/last-commit/moesif/moesifapi-python.svg?style=social

  [link-built-for]: https://www.python.org/
  [link-package]: https://pypi.python.org/pypi/moesifapi
  [link-language]: https://pypi.python.org/pypi/moesifapi
  [link-license]: https://raw.githubusercontent.com/Moesif/moesifapi-python/master/LICENSE
  [link-source]: https://github.com/Moesif/moesifapi-python

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.moesif.com/docs/api?python#api-libs",
    "name": "moesifapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "log analysis restful api development debug",
    "author": "Moesif, Inc",
    "author_email": "derric@moesif.com",
    "download_url": "https://files.pythonhosted.org/packages/21/69/2fc23979ea0f6f4b9b964334d129800bf2c76d42b2954be68c96b971dae8/moesifapi-1.5.3.tar.gz",
    "platform": null,
    "description": "# MoesifApi Lib for Python\n\n[![Built For][ico-built-for]][link-built-for]\n[![Latest Version][ico-version]][link-package]\n[![Language Versions][ico-language]][link-language]\n[![Software License][ico-license]][link-license]\n[![Source Code][ico-source]][link-source]\n\n[Source Code on GitHub](https://github.com/moesif/moesifapi-python)\n\nThis SDK uses the Requests library and will work for Python 2.7 \u2014 3.5.\n\nIf you are using Django as your platform, we have [moesifapi-python](https://github.com/Moesif/moesifapi-python) middleware, you can use that middleware directly.\n\n__Check out Moesif's [Developer Documentation](https://www.moesif.com/docs) and [Python API Reference](https://www.moesif.com/docs/api?python) to learn more__\n\n\n## How to install:\n\n```\npip install moesifapi\n```\n\n## How to use:\n\nThe code uses Python packages named requests, jsonpickle and dateutil.\nAfter having resolved the dependencies, you can easily use the SDK following these steps.\n\nYour Moesif Application Id can be found in the [_Moesif Portal_](https://www.moesif.com/).\nAfter signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps. \n\nYou can always find your Moesif Application Id at any time by logging \ninto the [_Moesif Portal_](https://www.moesif.com/), click on the top right menu,\n and then clicking _Installation_.\n\n### Create Event\n\n```python\nfrom __future__ import print_function\nfrom moesifapi.moesif_api_client import *\nfrom moesifapi.models import *\n\nclient = MoesifAPIClient(my_application_id)\napi_client = client.api\n\n# Note: we recommend sending all API Calls via MVC framework middleware.\n\nreq_headers = APIHelper.json_deserialize(\"\"\"  {\n  \"Host\": \"api.acmeinc.com\",\n  \"Accept\": \"*/*\",\n  \"Connection\": \"Keep-Alive\",\n  \"User-Agent\": \"Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)\",\n  \"Content-Type\": \"application/json\",\n  \"Content-Length\": \"126\",\n  \"Accept-Encoding\": \"gzip\"\n} \"\"\")\n\nreq_body = APIHelper.json_deserialize( \"\"\"{\n  \"items\": [\n    {\n      \"type\": 1,\n      \"id\": \"fwfrf\"\n    },\n    {\n      \"type\": 2,\n      \"id\": \"d43d3f\"\n    }\n  ]\n}\"\"\")\n\nrsp_headers = APIHelper.json_deserialize(\"\"\"  {\n    \"Date\": \"Tue, 23 Aug 2019 23:46:49 GMT\",\n    \"Vary\": \"Accept-Encoding\",\n    \"Pragma\": \"no-cache\",\n    \"Expires\": \"-1\",\n    \"Content-Type\": \"application/json; charset=utf-8\"\n    \"Cache-Control\": \"no-cache\"\n  } \"\"\")\n\nrsp_body = APIHelper.json_deserialize( \"\"\"{\n    \"Error\": \"InvalidArgumentException\",\n    \"Message\": \"Missing field field_a\"\n  }\"\"\")\n\nmetadata = APIHelper.json_deserialize(\"\"\"{\n    \"field1\": \"foo\",\n    \"field2\": \"bar\"\n  }\"\"\")\n\n\n\nevent_req = EventRequestModel(time = \"2019-09-09T04:45:42.914\",\n    uri = \"https://api.acmeinc.com/items/reviews/\",\n    verb = \"PATCH\",\n    api_version = \"1.1.0\",\n    ip_address = \"61.48.220.123\",\n    headers = req_headers,\n    body = req_body)\n\nevent_rsp = EventResponseModel(time = \"2019-09-09T04:45:42.914\",\n    status = 500,\n    headers = rsp_headers,\n    body = rsp_body)\n\nevent_model = EventModel(request = event_req,\n    response = event_rsp,\n    user_id = \"12345\",\n    company_id = \"67890\",\n    session_token = \"23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f\",\n    metadata = metadata)\n\n\n# Perform the API call through the SDK function\napi_client.create_event(event_model)\n\n\napi_client.create_event(my_api_event_model)\n```\n\n## Update a Single User\n\nCreate or update a user profile in Moesif.\nThe metadata field can be any customer demographic or other info you want to store.\nOnly the `userId` field is required.\nFor details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-a-user).\n\n```python\nfrom moesifapi.moesif_api_client import *\nfrom moesifapi.models import *\n\napi_client = MoesifAPIClient(\"YOUR_COLLECTOR_APPLICATION_ID\").api\n\n# Only user_id is required.\n# Campaign object is optional, but useful if you want to track ROI of acquisition channels\n# See https://www.moesif.com/docs/api#users for campaign schema\n# metadata can be any custom object\nuser = {\n  'user_id': '12345',\n  'company_id': '67890', # If set, associate user with a company object\n  'campaign': {\n    'utm_source': 'google',\n    'utm_medium': 'cpc', \n    'utm_campaign': 'adwords',\n    'utm_term': 'api+tooling',\n    'utm_content': 'landing'\n  },\n  'metadata': {\n    'email': 'john@acmeinc.com',\n    'first_name': 'John',\n    'last_name': 'Doe',\n    'title': 'Software Engineer',\n    'sales_info': {\n        'stage': 'Customer',\n        'lifetime_value': 24000,\n        'account_owner': 'mary@contoso.com'\n    },\n  }\n}\n\nupdate_user = api_client.update_user(user)\n```\n\n## Update Users in Batch\n\nSimilar to UpdateUser, but used to update a list of users in one batch. \nOnly the `userId` field is required.\nFor details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-users-in-batch).\n\n```python\nfrom moesifapi.moesif_api_client import *\nfrom moesifapi.models import *\n\napi_client = MoesifAPIClient(\"YOUR_COLLECTOR_APPLICATION_ID\").api\n\nuserA = {\n  'user_id': '12345',\n  'company_id': '67890', # If set, associate user with a company object\n  'metadata': {\n    'email': 'john@acmeinc.com',\n    'first_name': 'John',\n    'last_name': 'Doe',\n    'title': 'Software Engineer',\n    'sales_info': {\n        'stage': 'Customer',\n        'lifetime_value': 24000,\n        'account_owner': 'mary@contoso.com'\n    },\n  }\n}\n\nuserB = {\n  'user_id': '54321',\n  'company_id': '67890', # If set, associate user with a company object\n  'metadata': {\n    'email': 'mary@acmeinc.com',\n    'first_name': 'Mary',\n    'last_name': 'Jane',\n    'title': 'Software Engineer',\n    'sales_info': {\n        'stage': 'Customer',\n        'lifetime_value': 48000,\n        'account_owner': 'mary@contoso.com'\n    },\n  }\n}\nupdate_users = api_client.update_users_batch([userA, userB])\n```\n\n## Update a Single Company\n\nCreate or update a company profile in Moesif.\nThe metadata field can be any company demographic or other info you want to store.\nOnly the `companyId` field is required.\nFor details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-a-company).\n\n```python\nfrom moesifapi.moesif_api_client import *\nfrom moesifapi.models import *\n\napi_client = MoesifAPIClient(\"YOUR_COLLECTOR_APPLICATION_ID\").api\n\n# Only company_id is required.\n# Campaign object is optional, but useful if you want to track ROI of acquisition channels\n# See https://www.moesif.com/docs/api#update-a-company for campaign schema\n# metadata can be any custom object\ncompany = {\n  'company_id': '12345',\n  'company_domain': 'acmeinc.com', # If domain is set, Moesif will enrich your profiles with publicly available info \n  'campaign': {\n    'utm_source': 'google',\n    'utm_medium': 'cpc', \n    'utm_campaign': 'adwords',\n    'utm_term': 'api+tooling',\n    'utm_content': 'landing'\n  },\n  'metadata': {\n    'org_name': 'Acme, Inc',\n    'plan_name': 'Free',\n    'deal_stage': 'Lead',\n    'mrr': 24000,\n    'demographics': {\n        'alexa_ranking': 500000,\n        'employee_count': 47\n    },\n  }\n}\n\nupdate_company = api_client.update_company(company)\n```\n\n## Update Companies in Batch\n\nSimilar to updateCompany, but used to update a list of companies in one batch. \nOnly the `companyId` field is required.\nFor details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-companies-in-batch).\n\n\n```python\nfrom moesifapi.moesif_api_client import *\nfrom moesifapi.models import *\n\napi_client = MoesifAPIClient(\"YOUR_COLLECTOR_APPLICATION_ID\").api\n\n# Only company_id is required.\n# Campaign object is optional, but useful if you want to track ROI of acquisition channels\n# See https://www.moesif.com/docs/api#update-a-company for campaign schema\n# metadata can be any custom object\ncompanies = [{\n  'company_id': '67890',\n  'company_domain': 'acmeinc.com', # If domain is set, Moesif will enrich your profiles with publicly available info \n  'campaign': {\n    'utm_source': 'google',\n    'utm_medium': 'cpc', \n    'utm_campaign': 'adwords',\n    'utm_term': 'api+tooling',\n    'utm_content': 'landing'\n  },\n  'metadata': {\n    'org_name': 'Acme, Inc',\n    'plan_name': 'Free',\n    'deal_stage': 'Lead',\n    'mrr': 24000,\n    'demographics': {\n        'alexa_ranking': 500000,\n        'employee_count': 47\n    },\n  }\n},\n{\n  'company_id': '09876',\n  'company_domain': 'contoso.com', # If domain is set, Moesif will enrich your profiles with publicly available info \n  'campaign': {\n    'utm_source': 'facebook',\n    'utm_medium': 'cpc', \n    'utm_campaign': 'retargeting'\n  },\n  'metadata': {\n    'org_name': 'Contoso, Inc',\n    'plan_name': 'Paid',\n    'deal_stage': 'Lead',\n    'mrr': 48000,\n    'demographics': {\n        'alexa_ranking': 500000,\n        'employee_count': 53\n    },\n  }\n}]\n\nupdate_company = api_client.update_companies(companies)\n```\n\n## Update a Single Subscription\n\nCreate or update a subscription profile in Moesif. The metadata field can store any subscription-related information you wish to keep. The `subscription_id`, `company_id`, and `status` fields are all required. This method is a convenient helper that calls the Moesif API library. For details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-a-subscription).\n\n```python\nfrom moesifapi.moesif_api_client import *\nfrom moesifapi.models import *\nfrom datetime import datetime, timedelta\n\napi_client = MoesifAPIClient(\"YOUR_COLLECTOR_APPLICATION_ID\").api\n\n# Required fields for a subscription update\nsubscription = {\n  'subscription_id': 'sub_3456',\n  'company_id': '67890',\n  'current_period_start': datetime.utcnow(),\n  'current_period_end': datetime.utcnow() + timedelta(days=30),\n  'status': 'active',\n  # Optional metadata can be any custom object\n  'metadata': {\n    'string_field': 'value_1',\n    'number_field': 0,\n    'object_field': {\n      'field_1': 'value_1',\n      'field_2': 'value_2'\n    }\n  }\n}\n\nupdate_subscription = api_client.update_subscription(subscription)\n```\n\n## Update Subscriptions in Batch\n\nSimilar to `updateSubscription`, but used to update a list of subscriptions in one batch. The `subscription_id`, `company_id`, and `status` fields are required for each subscription in the list. This method is a convenient helper that calls the Moesif API library. For details, visit the [Python API Reference](https://www.moesif.com/docs/api?python#update-subscriptions-in-batch).\n\n```python\nfrom moesifapi.moesif_api_client import *\nfrom moesifapi.models import *\nfrom datetime import datetime, timedelta\n\napi_client = MoesifAPIClient(\"YOUR_COLLECTOR_APPLICATION_ID\").api\n\n# Required fields for subscription updates in a batch\nsubscriptions = [{\n  'subscription_id': 'sub_3456',\n  'company_id': '67890',\n  'current_period_start': datetime.utcnow(),\n  'current_period_end': datetime.utcnow() + timedelta(days=30),\n  'status': 'active',\n  # Optional metadata can be any custom object\n  'metadata': {\n    'string_field': 'value_1',\n    'number_field': 0,\n    'object_field': {\n      'field_1': 'value_1',\n      'field_2': 'value_2'\n    }\n  }\n}, {\n  'subscription_id': 'sub_34567',\n  'company_id': '6789',\n  'current_period_start': datetime.utcnow(),\n  'current_period_end': datetime.utcnow() + timedelta(days=30),\n  'status': 'active',\n  'metadata': {\n    'string_field': 'value_1',\n    'number_field': 0,\n    'object_field': {\n      'field_1': 'value_1',\n      'field_2': 'value_2'\n    }\n  }\n}]\n\nupdate_subscriptions = api_client.update_subscriptions_batch(subscriptions)\n```\n\n## How to test:\n\nYou can test the SDK with automatically generated test\ncases. unittest is used as the testing framework and nose is used as the test\nrunner. You can run the tests as follows:\n\n  1. Manually clone the git repo\n  2. From terminal/cmd navigate to the root directory of the SDK.\n  3. Invoke 'pip install -r requirements.txt'\n  4. Add your own application id to 'test/controllers/controller_test_base'\n  5. Invoke 'pytest tests/controllers/test_api_controller.py'\n\n  [ico-built-for]: https://img.shields.io/badge/built%20for-python-blue.svg\n  [ico-version]: https://img.shields.io/pypi/v/moesifapi.svg\n  [ico-language]: https://img.shields.io/pypi/pyversions/moesifapi.svg\n  [ico-license]: https://img.shields.io/badge/License-Apache%202.0-green.svg\n  [ico-source]: https://img.shields.io/github/last-commit/moesif/moesifapi-python.svg?style=social\n\n  [link-built-for]: https://www.python.org/\n  [link-package]: https://pypi.python.org/pypi/moesifapi\n  [link-language]: https://pypi.python.org/pypi/moesifapi\n  [link-license]: https://raw.githubusercontent.com/Moesif/moesifapi-python/master/LICENSE\n  [link-source]: https://github.com/Moesif/moesifapi-python\n",
    "bugtrack_url": null,
    "license": "Apache Software License",
    "summary": "Moesif API Lib for Python",
    "version": "1.5.3",
    "project_urls": {
        "Homepage": "https://www.moesif.com/docs/api?python#api-libs"
    },
    "split_keywords": [
        "log",
        "analysis",
        "restful",
        "api",
        "development",
        "debug"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd1e05fe50bef169d964f5f7bcd65e12571bbefc14940ffd6022663a541c65fa",
                "md5": "0620967f251c2f48e233b85035319e1b",
                "sha256": "1147be61bef430cb30746f39eb6b1dfebc8129ee6249fb207aad9356b3593ce1"
            },
            "downloads": -1,
            "filename": "moesifapi-1.5.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0620967f251c2f48e233b85035319e1b",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 45398,
            "upload_time": "2024-10-29T19:01:48",
            "upload_time_iso_8601": "2024-10-29T19:01:48.573688Z",
            "url": "https://files.pythonhosted.org/packages/bd/1e/05fe50bef169d964f5f7bcd65e12571bbefc14940ffd6022663a541c65fa/moesifapi-1.5.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21692fc23979ea0f6f4b9b964334d129800bf2c76d42b2954be68c96b971dae8",
                "md5": "cee62341d54b128214ed7dacd8a39822",
                "sha256": "3df255a468f31eedfe55eabf261b1e64cc26137ea458c22781426a56aed5ad73"
            },
            "downloads": -1,
            "filename": "moesifapi-1.5.3.tar.gz",
            "has_sig": false,
            "md5_digest": "cee62341d54b128214ed7dacd8a39822",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 39462,
            "upload_time": "2024-10-29T19:01:49",
            "upload_time_iso_8601": "2024-10-29T19:01:49.930040Z",
            "url": "https://files.pythonhosted.org/packages/21/69/2fc23979ea0f6f4b9b964334d129800bf2c76d42b2954be68c96b971dae8/moesifapi-1.5.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-29 19:01:49",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "moesifapi"
}
        
Elapsed time: 0.67203s