Пример #1
0
 def __init__(self,
              input: str,
              insecure: bool = False,
              verbose: bool = False):
     self.path = input
     self.log_verbose = verbose
     verify = (
         not insecure
     ) if insecure else None  # set to None so demisto_client will use env var DEMISTO_VERIFY_SSL
     self.client = demisto_client.configure(verify_ssl=verify)
     self.successfully_uploaded_files: List[Tuple[str, str]] = []
     self.failed_uploaded_files: List[Tuple[str, str, str]] = []
     self.unuploaded_due_to_version: List[Tuple[str, str, Version, Version,
                                                Version]] = []
     self.demisto_version = get_demisto_version(self.client)
Пример #2
0
    def upload(self, client: demisto_client = None):
        """
        Upload the integration to demisto_client
        Args:
            client: The demisto_client object of the desired XSOAR machine to upload to.

        Returns:
            The result of the upload command from demisto_client
        """
        if self.is_unify():
            return client.integration_upload(file=self.path)  # type: ignore
        else:
            with tempfile.TemporaryDirectory() as dir:
                unified_files = self._unify(dir)
                for file in unified_files:
                    if (str(file)[-7:] == '_45.yml') == (get_demisto_version(client) < parse('4.6.0')):
                        # The above condition checks that the file ends in `_45.yml' and the version is 4.5 or less
                        # or that the file doesn't end in `_45.yml` and the version is higher than 4.5
                        return client.integration_upload(file=file)  # type: ignore
Пример #3
0
 def __init__(self,
              input: str,
              insecure: bool = False,
              verbose: bool = False,
              pack_names: list = None,
              skip_validation: bool = False,
              detached_files: bool = False,
              reattach: bool = False):
     self.path = input
     self.log_verbose = verbose
     verify = (
         not insecure
     ) if insecure else None  # set to None so demisto_client will use env var DEMISTO_VERIFY_SSL
     self.client = demisto_client.configure(verify_ssl=verify)
     self.successfully_uploaded_files: List[Tuple[str, str]] = []
     self.failed_uploaded_files: List[Tuple[str, str, str]] = []
     self.unuploaded_due_to_version: List[Tuple[str, str, Version, Version,
                                                Version]] = []
     self.demisto_version = get_demisto_version(self.client)
     self.pack_names = pack_names
     self.skip_upload_packs_validation = skip_validation
     self.is_files_to_detached = detached_files
     self.reattach_files = reattach
Пример #4
0
 def is_server_version_ge(self, client, server_version_to_check):
     server_version = get_demisto_version(client)
     return LooseVersion(server_version.base_version) >= LooseVersion(server_version_to_check)  # type: ignore