Plan

This module provides functionality for working with plans.

class Plan(api, plan_id, data={})[source]

Bases: Base

Parameters:
BASE_ENDPOINT = 'plans/'
__init__(api, plan_id, data={})[source]

Initialize a plan instance.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • plan_id (str) – The id for the plan.

  • data (Dict, optional) – The data of the plan.

classmethod get_plans(api, **kwargs)[source]

Get list of plans with optional filtering and pagination.

Parameters:

api (GeoboxClient) – The GeoboxClient instance for making requests.

Keyword Arguments:
  • q (str) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”

  • search (str) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.

  • search_fields (str) – comma separated list of fields for searching.

  • order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.

  • return_count (bool) – Whether to return total count. default is False.

  • skip (int) – Number of items to skip. default is 0.

  • limit (int) – Number of items to return. default is 10.

  • user_id (int) – Specific user. privileges required.

  • shared (bool) – Whether to return shared plans. default is False.

Returns:

A list of plan instances or the total number of plans.

Return type:

List[Plan] | int

Example

>>> from geobox import GeoboxClient
>>> from geobox.plan import Plan
>>> client = GeoboxClient()
>>> plans = Plan.get_plan(client, q="name LIKE '%My plan%'")
or
>>> plans = client.get_plan(q="name LIKE '%My plan%'")
classmethod create_plan(api, name, plan_color, storage, concurrent_tasks, daily_api_calls, monthly_api_calls, daily_traffic, monthly_traffic, daily_process, monthly_process, number_of_days=None, display_name=None, description=None)[source]

Create a new plan.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • name (str) – The name of the plan.

  • plan_color (str) – hex value of the color. e.g. #000000.

  • storage (int) – storage value in bytes. must be greater that 1.

  • concurrent_tasks (int) – number of concurrent tasks. must be greater that 1.

  • daily_api_calls (int) – number of daily api calls. must be greater that 1.

  • monthly_api_calls (int) – number of monthly api calls. must be greater that 1.

  • daily_traffic (int) – number of daily traffic. must be greater that 1.

  • monthly_traffic (int) – number of monthly traffic. must be greater that 1.

  • daily_process (int) – number of daily processes. must be greater that 1.

  • monthly_process (int) – number of monthly processes. must be greater that 1.

  • number_of_days (int, optional) – number of days. must be greater that 1.

  • display_name (str, optional) – display name of the plan.

  • description (str, optional) – description of the plan.

Returns:

The newly created plan instance.

Return type:

Plan

Raises:

ValidationError – If the plan data is invalid.

Example

>>> from geobox import GeoboxClient
>>> from geobox.plan import Plan
>>> client = GeoboxClient()
>>> plan = Plan.create_plan(client,
...                             name="new_plan",
...                             display_name=" New Plan",
...                             description="new plan description",
...                             plan_color="#000000",
...                             storage=10,
...                             concurrent_tasks=10,
...                             daily_api_calls=10,
...                             monthly_api_calls=10,
...                             daily_traffic=10,
...                             monthly_traffic=10,
...                             daily_process=10,
...                             monthly_process=10,
...                             number_of_days=10)
or
>>> plan = client.create_plan(name="new_plan",
...                             display_name=" New Plan",
...                             description="new plan description",
...                             plan_color="#000000",
...                             storage=10,
...                             concurrent_tasks=10,
...                             daily_api_calls=10,
...                             monthly_api_calls=10,
...                             daily_traffic=10,
...                             monthly_traffic=10,
...                             daily_process=10,
...                             monthly_process=10,
...                             number_of_days=10)
classmethod get_plan(api, plan_id)[source]

Get a plan by its id.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • plan_id (int) – The id of the plan to get.

Returns:

The plan object

Return type:

Plan

Raises:

NotFoundError – If the plan with the specified id is not found.

Example

>>> from geobox import GeoboxClient
>>> from geobox.plan import Plan
>>> client = GeoboxClient()
>>> plan = Plan.get_plan(client, plan_id=1)
or
>>> plan = client.get_plan(plan_id=1)
classmethod get_plan_by_name(api, name)[source]

Get a plan by name

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • name (str) – the name of the plan to get

Returns:

returns the plan if a plan matches the given name, else None

Return type:

Plan | None

Example

>>> from geobox import GeoboxClient
>>> from geobox.plan import Plan
>>> client = GeoboxClient()
>>> plan = Plan.get_plan_by_name(client, name='test')
or
>>> plan = client.get_plan_by_name(name='test')
update(**kwargs)[source]

Update the plan

Keyword Arguments:
  • name (str) – The name of the plan.

  • plan_color (str) – hex value of the color. e.g. #000000.

  • storage (int) – storage value in bytes. must be greater that 1.

  • concurrent_tasks (int) – number of concurrent tasks. must be greater that 1.

  • daily_api_calls (int) – number of daily api calls. must be greater that 1.

  • monthly_api_calls (int) – number of monthly api calls. must be greater that 1.

  • daily_traffic (int) – number of daily traffic. must be greater that 1.

  • monthly_traffic (int) – number of monthly traffic. must be greater that 1.

  • daily_processes (int) – number of daily processes. must be greater that 1.

  • monthly_processes (int) – number of monthly processes. must be greater that 1.

  • number_of_days (int) – number of days. must be greater that 1.

  • display_name (str) – display name of the plan.

  • description (str) – description of the plan.

Returns:

The updated plan data.

Return type:

Dict

Raises:

ValidationError – If the plan data is invalid.

Example

>>> from geobox import GeoboxClient
>>> from geobox.plan import Plan
>>> client = GeoboxClient()
>>> plan = Plan.get_plan(client, plan_id=1)
>>> plan.update(display_name="New Display Name")
delete()[source]

Delete the plan.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.plan import Plan
>>> client = GeoboxClient()
>>> plan = Plan.get_plan(client, plan_id=1)
>>> plan.delete()