Skip to content

Commit

Permalink
SP38
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjojeejoseph committed Dec 16, 2024
1 parent 4781f5d commit ea427cc
Show file tree
Hide file tree
Showing 83 changed files with 13,699 additions and 2,108 deletions.
2 changes: 1 addition & 1 deletion cvpysdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"""

__author__ = 'Commvault Systems Inc.'
__version__ = '11.36.1'
__version__ = '11.38'
239 changes: 107 additions & 132 deletions cvpysdk/activateapps/compliance_utils.py

Large diffs are not rendered by default.

259 changes: 255 additions & 4 deletions cvpysdk/activateapps/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,74 @@ class PlanConstants:
"planId": 0
}
}
},
6: {
"ciPolicyInfo": {
"ciPolicy": {
"policyType": 5,
"detail": {
"ciPolicy": {
"opType": 2,
"enableExactSearch": False,
"ciPolicyType": 5,
"filters": {
"fileFilters": {
"includeDocTypes": "",
"minDocSize": 0,
"maxDocSize": 50
}
}
}
}
}
},
"eePolicyInfo": {},
"exchange": {},
"office365Info": {
"o365Exchange": {
"mbArchiving": {
"policyType": 1,
"agentType": {
"appTypeId": 137
},
"detail": {
"emailPolicy": {
"emailPolicyType": 1,
"archivePolicy": {
"primaryMailbox": True,
"contentIndexProps": {}
}
}
}
}
},
"o365CloudOffice": {
"caBackup": {
"policyType": 6,
"detail": {
"cloudAppPolicy": {
"cloudAppPolicyType": 1,
"backupPolicy": {
"onedrivebackupPolicy": {},
"spbackupPolicy": {},
"teamsbackupPolicy": {}
}
}
}

}

}

},

"summary": {
"plan": {
"planName": "",
"planId": 0
}
}

}
}

Expand Down Expand Up @@ -927,6 +995,9 @@ class TagConstants:
class ComplianceConstants:
"""Class to maintain all the Compliance search related constants"""

SOLR_FIELD_FILE_NAME = "fileName"
SOLR_FIELD_SIZE = "sizeKB"

VIEW_PERMISSION = {
"permissionId": 31,
"_type_": 122,
Expand All @@ -951,11 +1022,16 @@ class ComplianceConstants:
"_type_": 122
}

PERMISSION_ADD_NAME = "Add"
PERMISSION_DELETE_NAME = "Delete"
PERMISSION_DOWNLOAD_NAME = "Download"
PERMISSION_VIEW_NAME = "View"

PERMISSIONS = {
"Add": ADD_PERMISSION,
"Delete": DELETE_PERMISSION,
"Download": DOWNLOAD_PERMISSION,
"View": VIEW_PERMISSION
PERMISSION_ADD_NAME: ADD_PERMISSION,
PERMISSION_DELETE_NAME: DELETE_PERMISSION,
PERMISSION_DOWNLOAD_NAME: DOWNLOAD_PERMISSION,
PERMISSION_VIEW_NAME: VIEW_PERMISSION
}

EXPORT_SET_SHARE_REQUEST_JSON = {
Expand All @@ -982,3 +1058,178 @@ class ComplianceConstants:
]
}
}

class AppTypes(Enum):
EXCHANGE = "EXCHANGE"
EXCHANGE_JOURNAL = "EXCHANGE_JOURNAL"
SHAREPOINT = "SHAREPOINT"
ONEDRIVE = "ONEDRIVE"
TEAMS = "TEAMS"
FILE_SYSTEM = "FILE_SYSTEM"

class ExportTypes(Enum):
CAB = "CAB"
PST = "PST"

RESTORE_TYPE = {
ExportTypes.PST: 1,
ExportTypes.CAB: 2
}

FILE_TYPE = "File"
EMAIL_TYPE = "Email"
FILE_TYPES = [AppTypes.FILE_SYSTEM, AppTypes.SHAREPOINT, AppTypes.ONEDRIVE, AppTypes.TEAMS]
EMAIL_TYPES = [AppTypes.EXCHANGE, AppTypes.EXCHANGE_JOURNAL]

FILE_FILTERS_KEY = "fileFilter"
FILE_FILTERS = [
{
"filter": {
"interFilterOP": "FTAnd",
"filters": [
{
"field": "CISTATE",
"intraFieldOp": "FTOr",
"fieldValues": {
"values": [
"0",
"1",
"12",
"13",
"14",
"15",
"1014",
"3333",
"3334",
"3335"
]
}
}
]
}
}
]

EMAIL_FILTERS_KEY = "emailView"

ONEDRIVE_FACET = "200118"
TEAMS_FACET = "200128"
SHAREPOINT_FACET = "78"
CUSTOM_FACETS = {
AppTypes.ONEDRIVE: ONEDRIVE_FACET,
AppTypes.TEAMS: TEAMS_FACET,
AppTypes.SHAREPOINT: SHAREPOINT_FACET
}

CUSTOM_FACETS_NAME = {
AppTypes.TEAMS: "TEAMS_NAME",
AppTypes.SHAREPOINT: "CUSTODIAN",
AppTypes.ONEDRIVE: "CUSTODIAN"
}

FACET_KEY = "facetRequest"
FILE_FACET = [
{
"count": 4,
"name": "CUSTODIAN"
},
{
"count": 4,
"name": "APPTYPE",
"searchFieldName": "APPTYPE",
"stringParameter": [
{
"name": "33",
"custom": True
},
{
"name": "29",
"custom": True
},
{
"name": "63",
"custom": True
},
{
"name": "21",
"custom": True
}
]
}
]
CUSTOM_FACET = [
{
"count": 4,
"name": "CUSTODIAN"
},
{
"count": 4,
"name": "APPTYPE",
"searchFieldName": "APPTYPE",
"stringParameter": [
{
"name": None,
"custom": True
}
]
}
]

RESPONSE_FIELD_LIST = ("DATA_TYPE,CLIENTNAME,CONTENTID,CV_OBJECT_GUID,PARENT_GUID,CV_TURBO_GUID,"
"AFILEID,AFILEOFFSET,COMMCELLNO,MODIFIEDTIME,SIZEINKB,BACKUPTIME,CISTATE,DATE_DELETED,"
"TEAMS_ITEM_ID,TEAMS_ITEM_NAME,TEAMS_NAME,TEAMS_SMTP,TEAMS_ITEM_TYPE,TEAMS_CHANNEL_TYPE,"
"TEAMS_TAB_TYPE,TEAMS_GROUP_VISIBILITY,TEAMS_GUID,TEAMS_CONV_ITEM_TYPE,"
"TEAMS_CONV_MESSAGE_TYPE,TEAMS_CONV_SUBJECT,TEAMS_CONV_IMPORTANCE,TEAMS_CONV_SENDER_TYPE,"
"TEAMS_CONV_SENDER_NAME,TEAMS_CONV_HAS_REPLIES,CI_URL,TEAMS_DRIVE_FOLDER_TYPE,APPTYPE,APPID")

COMPLIANCE_SEARCH_JSON = {
"mode": 2,
"facetRequests": {},
"advSearchGrp": {
"commonFilter": [
{
"filter": {
"filters": [
{
"field": "CI_STATUS",
"intraFieldOp": 0,
"fieldValues": {
"values": [
"1",
"3"
]
}
}
]
}
}
],
"cvSearchKeyword": {
"isExactWordsOptionSelected": False,
"keyword": None
},
"galaxyFilter": [
{
"applicationType": None
}
]
},
"userInformation": {
"userGuid": None
},
"listOfCIServer": [
{
"cloudID": None
}
],
"searchProcessingInfo": {
"resultOffset": 0,
"pageSize": 50,
"queryParams": [
{
"param": "ENABLE_NEW_COMPLIANCE_SEARCH",
"value": "true"
}
]
}
}
9 changes: 7 additions & 2 deletions cvpysdk/activateapps/ediscovery_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,8 @@ def add_fs_data_source(self, server_name, data_source_name, inventory_name, plan
"propertyValue": inventory_resp['operatingSystem'] if not is_server_group else ""
})
if is_commvault_client:
del request_json['datasources'][0]['accessNodes']
if 'access_node' not in kwargs:
del request_json['datasources'][0]['accessNodes']
request_json['datasources'][0]['properties'].append({
"propertyName": "ClientId",
"propertyValue": str(self._commcell_object.clients.get(server_name).client_id)
Expand Down Expand Up @@ -1949,7 +1950,11 @@ def add_fs_data_source(self, server_name, data_source_name, inventory_name, plan
"propertyValue": str(EdiscoveryConstants.CrawlType.BACKUP_V2.value)
})
else:
if not is_commvault_client:
request_json['datasources'][0]['properties'].append({
"propertyName": "crawltype",
"propertyValue": str(EdiscoveryConstants.CrawlType.LIVE.value)
})
if not is_commvault_client or 'access_node' in kwargs:
request_json['datasources'][0]['properties'].append({
"propertyName": "username",
"propertyValue": kwargs.get('user_name', '')
Expand Down
5 changes: 2 additions & 3 deletions cvpysdk/activateapps/entity_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ def add(self, classifier_name, content_analyzer, description="Created from CvPyS

if not isinstance(classifier_name, str) or not isinstance(content_analyzer, str):
raise SDKException('Classifier', '101')
if not self._commcell_object.content_analyzers.has_cloud(content_analyzer):
if not self._commcell_object.content_analyzers.has_client(content_analyzer):
raise SDKException('Classifier', '102', "Given CA cloud doesn't exists on this commcell")
ca_obj = self._commcell_object.content_analyzers.get(content_analyzer)
request_json = copy.deepcopy(ClassifierConstants.CREATE_REQUEST_JSON)
Expand All @@ -1884,7 +1884,6 @@ def add(self, classifier_name, content_analyzer, description="Created from CvPyS
ca_details_json['caUrl'] = ca_obj.cloud_url
ca_details_json['clientId'] = int(ca_obj.client_id)
ca_details_json['cloudName'] = content_analyzer
ca_details_json['cloudId'] = int(ca_obj.cloud_id)
port_no = int(ca_obj.cloud_url.split(":")[2])
# update if it is not default port no of 22000
if port_no != 22000:
Expand Down Expand Up @@ -2489,7 +2488,7 @@ def _get_entity_properties(self):
if 'CAUsedInTraining' in self._entity_xml['classifierDetails']:
trained_ca = self._entity_xml['classifierDetails']['CAUsedInTraining']
# Mandatory trained CA fields. so no need to use dict.get()
self._trained_ca_cloud_id = int(trained_ca['cloudId'])
self._trained_ca_cloud_id = int(trained_ca['clientId'])
self._last_training_time = trained_ca.get('lastModelTrainTime', 0)
if 'syncedContentAnalyzers' in self._entity_xml['classifierDetails'] and self._entity_xml[
'classifierDetails']['syncedContentAnalyzers'] is not None:
Expand Down
32 changes: 32 additions & 0 deletions cvpysdk/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,3 +1279,35 @@ def disable(self):
def refresh(self):
"""Refresh the properties of the Alert."""
self._get_alert_properties()

def trigger_test_alert(self):
"""
Method to trigger the test alert
Raises:
SDKException:
if failed to trigger test alert
if response is empty
if response is not success
"""
test_request = self._services['ALERT_TEST'] % (self.alert_id)

flag, response = self._cvpysdk_object.make_request('POST', test_request)

if not flag:
response_string = self._update_response_(response.text)
raise SDKException('Response', '101', response_string)

if not response.json():
raise SDKException('Response', '102')

error_code = response.json().get('errorCode', -1)

if error_code != 0:
error_message = response.json().get('errorMessage', '')

raise SDKException(
'Alert', '102', f'Failed to trigger the test Alert. Error: ["{error_message}"]'
)
3 changes: 3 additions & 0 deletions cvpysdk/backupset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,9 @@ def _prepare_browse_json(self, options):
if options['_custom_queries']:
request_json['queries'] = options['_custom_queries']

if options.get('live_browse', False):
request_json['options']['liveBrowse'] = True

return request_json

def _process_browse_all_versions_response(self, result_set, options):
Expand Down
Loading

0 comments on commit ea427cc

Please sign in to comment.