Skip to content

Commit b17a4ca

Browse files
authored
Merge pull request #27 from IBM/kpi_sev
feat(kpi severity): Add severity for kpi
2 parents 794471d + e0ea982 commit b17a4ca

File tree

4 files changed

+629
-179
lines changed

4 files changed

+629
-179
lines changed

examples/test_findings_v1_examples.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"""
1919

2020
from ibm_cloud_sdk_core import ApiException, read_external_sources
21-
from ibm_cloud_sdk_core.utils import datetime_to_string, string_to_datetime
2221
import os
2322
import pytest
2423
from ibm_scc.findings_v1 import *
@@ -97,6 +96,24 @@ def test_post_graph_example(self):
9796
except ApiException as e:
9897
pytest.fail(str(e))
9998

99+
@needscredentials
100+
def test_list_providers_example(self):
101+
"""
102+
list_providers request example
103+
"""
104+
try:
105+
print('\nlist_providers() result:')
106+
# begin-listProviders
107+
108+
api_list_providers_response = findings_service.list_providers().get_result()
109+
110+
print(json.dumps(api_list_providers_response, indent=2))
111+
112+
# end-listProviders
113+
114+
except ApiException as e:
115+
pytest.fail(str(e))
116+
100117
@needscredentials
101118
def test_create_note_example(self):
102119
"""
@@ -329,24 +346,6 @@ def test_update_occurrence_example(self):
329346
except ApiException as e:
330347
pytest.fail(str(e))
331348

332-
@needscredentials
333-
def test_list_providers_example(self):
334-
"""
335-
list_providers request example
336-
"""
337-
try:
338-
print('\nlist_providers() result:')
339-
# begin-listProviders
340-
341-
api_list_providers_response = findings_service.list_providers().get_result()
342-
343-
print(json.dumps(api_list_providers_response, indent=2))
344-
345-
# end-listProviders
346-
347-
except ApiException as e:
348-
pytest.fail(str(e))
349-
350349
@needscredentials
351350
def test_delete_occurrence_example(self):
352351
"""

ibm_scc/findings_v1.py

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# IBM OpenAPI SDK Code Generator Version: 3.34.1-ad041667-20210617-195430
17+
# IBM OpenAPI SDK Code Generator Version: 3.40.0-910cf8c2-20211006-154754
1818

1919
"""
2020
The Findings API is used to find and display occurrences of security issues in your IBM
2121
Cloud account by using the artifact metadata specification. Findings are summarized in
2222
cards in the Security and Compliance Center that allow you to see the security status of
2323
your account at a glance and start an investigation into any potential issues.
24+
25+
API Version: 1.0.0
2426
"""
2527

2628
from datetime import datetime
@@ -78,7 +80,7 @@ def __init__(self,
7880
:param str account_id: Account ID.
7981
8082
:param Authenticator authenticator: The authenticator specifies the authentication mechanism.
81-
Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md
83+
Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md
8284
about initializing the authenticator of your choice.
8385
"""
8486
if account_id is None:
@@ -148,7 +150,7 @@ def post_graph(self,
148150
headers=headers,
149151
data=data)
150152

151-
response = self.send(request)
153+
response = self.send(request, **kwargs)
152154
return response
153155

154156
#########################
@@ -215,7 +217,7 @@ def list_providers(self,
215217
headers=headers,
216218
params=params)
217219

218-
response = self.send(request)
220+
response = self.send(request, **kwargs)
219221
return response
220222

221223

@@ -228,7 +230,6 @@ def create_note(self,
228230
reported_by: 'Reporter',
229231
*,
230232
related_url: List['ApiNoteRelatedUrl'] = None,
231-
expiration_time: datetime = None,
232233
shared: bool = None,
233234
finding: 'FindingType' = None,
234235
kpi: 'KpiType' = None,
@@ -261,8 +262,6 @@ def create_note(self,
261262
:param str id: The ID of the note.
262263
:param Reporter reported_by: The entity reporting a note.
263264
:param List[ApiNoteRelatedUrl] related_url: (optional)
264-
:param datetime expiration_time: (optional) Time of expiration for this
265-
note, null if note does not expire.
266265
:param bool shared: (optional) True if this note can be shared by multiple
267266
accounts.
268267
:param FindingType finding: (optional) FindingType provides details about a
@@ -294,8 +293,6 @@ def create_note(self,
294293
reported_by = convert_model(reported_by)
295294
if related_url is not None:
296295
related_url = [convert_model(x) for x in related_url]
297-
if expiration_time is not None:
298-
expiration_time = datetime_to_string(expiration_time)
299296
if finding is not None:
300297
finding = convert_model(finding)
301298
if kpi is not None:
@@ -319,7 +316,6 @@ def create_note(self,
319316
'id': id,
320317
'reported_by': reported_by,
321318
'related_url': related_url,
322-
'expiration_time': expiration_time,
323319
'shared': shared,
324320
'finding': finding,
325321
'kpi': kpi,
@@ -343,7 +339,7 @@ def create_note(self,
343339
headers=headers,
344340
data=data)
345341

346-
response = self.send(request)
342+
response = self.send(request, **kwargs)
347343
return response
348344

349345

@@ -400,7 +396,7 @@ def list_notes(self,
400396
headers=headers,
401397
params=params)
402398

403-
response = self.send(request)
399+
response = self.send(request, **kwargs)
404400
return response
405401

406402

@@ -452,7 +448,7 @@ def get_note(self,
452448
url=url,
453449
headers=headers)
454450

455-
response = self.send(request)
451+
response = self.send(request, **kwargs)
456452
return response
457453

458454

@@ -466,7 +462,6 @@ def update_note(self,
466462
reported_by: 'Reporter',
467463
*,
468464
related_url: List['ApiNoteRelatedUrl'] = None,
469-
expiration_time: datetime = None,
470465
shared: bool = None,
471466
finding: 'FindingType' = None,
472467
kpi: 'KpiType' = None,
@@ -498,8 +493,6 @@ def update_note(self,
498493
:param str id: The ID of the note.
499494
:param Reporter reported_by: The entity reporting a note.
500495
:param List[ApiNoteRelatedUrl] related_url: (optional)
501-
:param datetime expiration_time: (optional) Time of expiration for this
502-
note, null if note does not expire.
503496
:param bool shared: (optional) True if this note can be shared by multiple
504497
accounts.
505498
:param FindingType finding: (optional) FindingType provides details about a
@@ -533,8 +526,6 @@ def update_note(self,
533526
reported_by = convert_model(reported_by)
534527
if related_url is not None:
535528
related_url = [convert_model(x) for x in related_url]
536-
if expiration_time is not None:
537-
expiration_time = datetime_to_string(expiration_time)
538529
if finding is not None:
539530
finding = convert_model(finding)
540531
if kpi is not None:
@@ -558,7 +549,6 @@ def update_note(self,
558549
'id': id,
559550
'reported_by': reported_by,
560551
'related_url': related_url,
561-
'expiration_time': expiration_time,
562552
'shared': shared,
563553
'finding': finding,
564554
'kpi': kpi,
@@ -582,7 +572,7 @@ def update_note(self,
582572
headers=headers,
583573
data=data)
584574

585-
response = self.send(request)
575+
response = self.send(request, **kwargs)
586576
return response
587577

588578

@@ -633,7 +623,7 @@ def delete_note(self,
633623
url=url,
634624
headers=headers)
635625

636-
response = self.send(request)
626+
response = self.send(request, **kwargs)
637627
return response
638628

639629

@@ -684,7 +674,7 @@ def get_occurrence_note(self,
684674
url=url,
685675
headers=headers)
686676

687-
response = self.send(request)
677+
response = self.send(request, **kwargs)
688678
return response
689679

690680
#########################
@@ -802,7 +792,7 @@ def create_occurrence(self,
802792
headers=headers,
803793
data=data)
804794

805-
response = self.send(request)
795+
response = self.send(request, **kwargs)
806796
return response
807797

808798

@@ -860,7 +850,7 @@ def list_occurrences(self,
860850
headers=headers,
861851
params=params)
862852

863-
response = self.send(request)
853+
response = self.send(request, **kwargs)
864854
return response
865855

866856

@@ -922,7 +912,7 @@ def list_note_occurrences(self,
922912
headers=headers,
923913
params=params)
924914

925-
response = self.send(request)
915+
response = self.send(request, **kwargs)
926916
return response
927917

928918

@@ -973,7 +963,7 @@ def get_occurrence(self,
973963
url=url,
974964
headers=headers)
975965

976-
response = self.send(request)
966+
response = self.send(request, **kwargs)
977967
return response
978968

979969

@@ -1086,7 +1076,7 @@ def update_occurrence(self,
10861076
headers=headers,
10871077
data=data)
10881078

1089-
response = self.send(request)
1079+
response = self.send(request, **kwargs)
10901080
return response
10911081

10921082

@@ -1137,7 +1127,7 @@ def delete_occurrence(self,
11371127
url=url,
11381128
headers=headers)
11391129

1140-
response = self.send(request)
1130+
response = self.send(request, **kwargs)
11411131
return response
11421132

11431133

@@ -1858,27 +1848,34 @@ class KpiType():
18581848
"""
18591849
KpiType provides details about a KPI note.
18601850
1851+
:attr str severity: (optional)
18611852
:attr str aggregation_type: The aggregation type of the KPI values. - SUM: A
18621853
single-value metrics aggregation type that sums up numeric values
18631854
that are extracted from KPI occurrences.
18641855
"""
18651856

18661857
def __init__(self,
1867-
aggregation_type: str) -> None:
1858+
aggregation_type: str,
1859+
*,
1860+
severity: str = None) -> None:
18681861
"""
18691862
Initialize a KpiType object.
18701863
18711864
:param str aggregation_type: The aggregation type of the KPI values. -
18721865
SUM: A single-value metrics aggregation type that sums up numeric
18731866
values
18741867
that are extracted from KPI occurrences.
1868+
:param str severity: (optional)
18751869
"""
1870+
self.severity = severity
18761871
self.aggregation_type = aggregation_type
18771872

18781873
@classmethod
18791874
def from_dict(cls, _dict: Dict) -> 'KpiType':
18801875
"""Initialize a KpiType object from a json dictionary."""
18811876
args = {}
1877+
if 'Severity' in _dict:
1878+
args['severity'] = _dict.get('Severity')
18821879
if 'aggregation_type' in _dict:
18831880
args['aggregation_type'] = _dict.get('aggregation_type')
18841881
else:
@@ -1893,6 +1890,8 @@ def _from_dict(cls, _dict):
18931890
def to_dict(self) -> Dict:
18941891
"""Return a json dictionary representing this model."""
18951892
_dict = {}
1893+
if hasattr(self, 'severity') and self.severity is not None:
1894+
_dict['Severity'] = self.severity
18961895
if hasattr(self, 'aggregation_type') and self.aggregation_type is not None:
18971896
_dict['aggregation_type'] = self.aggregation_type
18981897
return _dict
@@ -1915,6 +1914,16 @@ def __ne__(self, other: 'KpiType') -> bool:
19151914
"""Return `true` when self and other are not equal, false otherwise."""
19161915
return not self == other
19171916

1917+
class SeverityEnum(str, Enum):
1918+
"""
1919+
severity.
1920+
"""
1921+
LOW = 'LOW'
1922+
MEDIUM = 'MEDIUM'
1923+
HIGH = 'HIGH'
1924+
CRITICAL = 'CRITICAL'
1925+
1926+
19181927
class AggregationTypeEnum(str, Enum):
19191928
"""
19201929
The aggregation type of the KPI values. - SUM: A single-value metrics
@@ -2625,8 +2634,6 @@ class ApiNote():
26252634
account.
26262635
- SECTION: The note represents a section in a dashboard.
26272636
:attr List[ApiNoteRelatedUrl] related_url: (optional)
2628-
:attr datetime expiration_time: (optional) Time of expiration for this note,
2629-
null if note does not expire.
26302637
:attr datetime create_time: (optional) Output only. The time this note was
26312638
created. This field can be used as a filter in list requests.
26322639
:attr datetime update_time: (optional) Output only. The time this note was last
@@ -2651,7 +2658,6 @@ def __init__(self,
26512658
reported_by: 'Reporter',
26522659
*,
26532660
related_url: List['ApiNoteRelatedUrl'] = None,
2654-
expiration_time: datetime = None,
26552661
create_time: datetime = None,
26562662
update_time: datetime = None,
26572663
shared: bool = None,
@@ -2676,8 +2682,6 @@ def __init__(self,
26762682
:param str id: The ID of the note.
26772683
:param Reporter reported_by: The entity reporting a note.
26782684
:param List[ApiNoteRelatedUrl] related_url: (optional)
2679-
:param datetime expiration_time: (optional) Time of expiration for this
2680-
note, null if note does not expire.
26812685
:param bool shared: (optional) True if this note can be shared by multiple
26822686
accounts.
26832687
:param FindingType finding: (optional) FindingType provides details about a
@@ -2692,7 +2696,6 @@ def __init__(self,
26922696
self.long_description = long_description
26932697
self.kind = kind
26942698
self.related_url = related_url
2695-
self.expiration_time = expiration_time
26962699
self.create_time = create_time
26972700
self.update_time = update_time
26982701
self.id = id
@@ -2721,8 +2724,6 @@ def from_dict(cls, _dict: Dict) -> 'ApiNote':
27212724
raise ValueError('Required property \'kind\' not present in ApiNote JSON')
27222725
if 'related_url' in _dict:
27232726
args['related_url'] = [ApiNoteRelatedUrl.from_dict(x) for x in _dict.get('related_url')]
2724-
if 'expiration_time' in _dict:
2725-
args['expiration_time'] = string_to_datetime(_dict.get('expiration_time'))
27262727
if 'create_time' in _dict:
27272728
args['create_time'] = string_to_datetime(_dict.get('create_time'))
27282729
if 'update_time' in _dict:
@@ -2763,8 +2764,6 @@ def to_dict(self) -> Dict:
27632764
_dict['kind'] = self.kind
27642765
if hasattr(self, 'related_url') and self.related_url is not None:
27652766
_dict['related_url'] = [x.to_dict() for x in self.related_url]
2766-
if hasattr(self, 'expiration_time') and self.expiration_time is not None:
2767-
_dict['expiration_time'] = datetime_to_string(self.expiration_time)
27682767
if hasattr(self, 'create_time') and getattr(self, 'create_time') is not None:
27692768
_dict['create_time'] = datetime_to_string(getattr(self, 'create_time'))
27702769
if hasattr(self, 'update_time') and getattr(self, 'update_time') is not None:

0 commit comments

Comments
 (0)