Skip to content

feat: add support for time based application list filters #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/test_ibm_analytics_engine_api_v3_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_replace_instance_default_runtime_example(self):

response = ibm_analytics_engine_api_service.replace_instance_default_runtime(
instance_id='e64c907a-e82f-46fd-addc-ccfafbd28b09',
spark_version="3.3",
spark_version='3.4',
)
runtime = response.get_result()

Expand All @@ -286,7 +286,7 @@ def test_create_application_example(self):
# begin-create_application

runtime_model = {
'spark_version': '3.3',
'spark_version': '3.4',
}

application_request_application_details_model = {
Expand Down
65 changes: 64 additions & 1 deletion iaesdk/ibm_analytics_engine_api_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,16 @@ def create_application(
return response

def list_applications(
self, instance_id: str, *, state: List[str] = None, limit: int = None, start: str = None, **kwargs
self,
instance_id: str,
*,
state: List[str] = None,
start_time_interval: str = None,
submission_time_interval: str = None,
end_time_interval: str = None,
limit: int = None,
start: str = None,
**kwargs,
) -> DetailedResponse:
"""
List all Spark applications.
Expand All @@ -564,6 +573,27 @@ def list_applications(
associated with the Spark application(s).
:param List[str] state: (optional) List of Spark application states that
will be used to filter the response.
:param str start_time_interval: (optional) Time interval to use for
filtering applications by their start time. Interval is specified in the
format `<lower timestamp limit>,<upper timestamp limit>`. Each timestamp
value must be ISO 8601 compliant. You may also use keywords `BEGINNING` as
a placeholder value for lower timestamp limit and `CURRENT` as a
placeholder value for upper timestamp limit. Note: The lower timestamp
limit is inclusive, whereas the upper timestamp limit is exclusive.
:param str submission_time_interval: (optional) Time interval to use for
filtering applications by their submission time. Interval is specified in
the format `<lower timestamp limit>,<upper timestamp limit>`. Each
timestamp value must be ISO 8601 compliant. You may also use keywords
`BEGINNING` as a placeholder value for lower timestamp limit and `CURRENT`
as a placeholder value for upper timestamp limit. Note: The lower timestamp
limit is inclusive, whereas the upper timestamp limit is exclusive.
:param str end_time_interval: (optional) Time interval to use for filtering
applications by their end time. Interval is specified in the format `<lower
timestamp limit>,<upper timestamp limit>`. Each timestamp value must be ISO
8601 compliant. You may also use keywords `BEGINNING` as a placeholder
value for lower timestamp limit and `CURRENT` as a placeholder value for
upper timestamp limit. Note: The lower timestamp limit is inclusive,
whereas the upper timestamp limit is exclusive.
:param int limit: (optional) Number of application entries to be included
in the response.
:param str start: (optional) Token used to fetch the next or the previous
Expand All @@ -583,6 +613,9 @@ def list_applications(

params = {
'state': convert_list(state),
'start_time_interval': start_time_interval,
'submission_time_interval': submission_time_interval,
'end_time_interval': end_time_interval,
'limit': limit,
'start': start,
}
Expand Down Expand Up @@ -3351,6 +3384,9 @@ def __init__(
client: IbmAnalyticsEngineApiV3,
instance_id: str,
state: List[str] = None,
start_time_interval: str = None,
submission_time_interval: str = None,
end_time_interval: str = None,
limit: int = None,
) -> None:
"""
Expand All @@ -3359,6 +3395,27 @@ def __init__(
associated with the Spark application(s).
:param List[str] state: (optional) List of Spark application states that
will be used to filter the response.
:param str start_time_interval: (optional) Time interval to use for
filtering applications by their start time. Interval is specified in the
format `<lower timestamp limit>,<upper timestamp limit>`. Each timestamp
value must be ISO 8601 compliant. You may also use keywords `BEGINNING` as
a placeholder value for lower timestamp limit and `CURRENT` as a
placeholder value for upper timestamp limit. Note: The lower timestamp
limit is inclusive, whereas the upper timestamp limit is exclusive.
:param str submission_time_interval: (optional) Time interval to use for
filtering applications by their submission time. Interval is specified in
the format `<lower timestamp limit>,<upper timestamp limit>`. Each
timestamp value must be ISO 8601 compliant. You may also use keywords
`BEGINNING` as a placeholder value for lower timestamp limit and `CURRENT`
as a placeholder value for upper timestamp limit. Note: The lower timestamp
limit is inclusive, whereas the upper timestamp limit is exclusive.
:param str end_time_interval: (optional) Time interval to use for filtering
applications by their end time. Interval is specified in the format `<lower
timestamp limit>,<upper timestamp limit>`. Each timestamp value must be ISO
8601 compliant. You may also use keywords `BEGINNING` as a placeholder
value for lower timestamp limit and `CURRENT` as a placeholder value for
upper timestamp limit. Note: The lower timestamp limit is inclusive,
whereas the upper timestamp limit is exclusive.
:param int limit: (optional) Number of application entries to be included
in the response.
"""
Expand All @@ -3367,6 +3424,9 @@ def __init__(
self._page_context = {'next': None}
self._instance_id = instance_id
self._state = state
self._start_time_interval = start_time_interval
self._submission_time_interval = submission_time_interval
self._end_time_interval = end_time_interval
self._limit = limit

def has_next(self) -> bool:
Expand All @@ -3387,6 +3447,9 @@ def get_next(self) -> List[dict]:
result = self._client.list_applications(
instance_id=self._instance_id,
state=self._state,
start_time_interval=self._start_time_interval,
submission_time_interval=self._submission_time_interval,
end_time_interval=self._end_time_interval,
limit=self._limit,
start=self._page_context.get('next'),
).get_result()
Expand Down
6 changes: 3 additions & 3 deletions test/integration/test_ibm_analytics_engine_api_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_get_instance_default_runtime(self):
def test_replace_instance_default_runtime(self):
response = self.ibm_analytics_engine_api_service.replace_instance_default_runtime(
instance_id=self.instance_id,
spark_version='3.3',
spark_version='3.4',
)

assert response.get_status_code() == 200
Expand Down Expand Up @@ -278,8 +278,8 @@ def test_replace_log_forwarding_config(self):
response = self.ibm_analytics_engine_api_service.replace_log_forwarding_config(
instance_id=self.instance_id,
enabled=True,
sources=["spark-driver", "spark-executor"],
tags=["<tag_1>", "<tag_2>", "<tag_n>"],
sources=['spark-driver', 'spark-executor'],
tags=['<tag_1>', '<tag_2>', '<tag_n'],
)

assert response.get_status_code() == 200
Expand Down
Loading