Skip to content
Open
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: 4 additions & 0 deletions .changelog/5494.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Renamed the Collection content item type to Knowledge.
type: internal
pr_number: 5494
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
commonfields:
id: sample_collection
id: sample_knowledge
version: -1
name: Sample Collection
name: Sample Knowledge
description: |-
A sample collection for testing purposes.
A sample knowledge for testing purposes.
marketplaces:
- platform
supportedModules:
Expand Down
48 changes: 0 additions & 48 deletions TestSuite/collection.py

This file was deleted.

48 changes: 48 additions & 0 deletions TestSuite/knowledge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from pathlib import Path
from typing import Optional

from TestSuite.yml import YAML, yaml


class Knowledge(YAML):
def __init__(self, tmpdir: Path, name: str, repo):
# Create directory for the knowledge
self._tmpdir_knowledge_path = tmpdir / name
self._tmpdir_knowledge_path.mkdir(exist_ok=True)

# Save entities
self.name = name
self._repo = repo
self.repo_path = repo.path
self.path = str(self._tmpdir_knowledge_path)

super().__init__(
tmp_path=self._tmpdir_knowledge_path / f"{self.name}.yml",
repo_path=str(repo.path),
)

def build(
self,
yml: Optional[dict] = None,
):
"""Writes not None objects to files."""
if yml is not None:
self.write_dict(yml)

def create_default_knowledge(
self,
name: str = "sample_knowledge",
knowledge_id: str = "sample_knowledge_id",
):
"""Creates a new knowledge with basic data.

Args:
name: The name of the new knowledge, default is "sample_knowledge".
knowledge_id: The ID of the new knowledge, default is "sample_knowledge_id".
"""
default_knowledge_dir = Path(__file__).parent / "assets" / "default_knowledge"
with open(default_knowledge_dir / "knowledge-sample.yml") as yml_file:
yml = yaml.load(yml_file)
yml["commonfields"]["id"] = knowledge_id
yml["name"] = name
self.build(yml=yml)
24 changes: 12 additions & 12 deletions TestSuite/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
CASE_FIELDS_DIR,
CASE_LAYOUT_RULES_DIR,
CASE_LAYOUTS_DIR,
COLLECTIONS_DIR,
CORRELATION_RULES_DIR,
DEFAULT_IMAGE_BASE64,
KNOWLEDGE_DIR,
LAYOUT_RULES_DIR,
MODELING_RULES_DIR,
PARSING_RULES_DIR,
Expand All @@ -27,7 +27,6 @@
from TestSuite.case_layout import CaseLayout
from TestSuite.case_layout_rule import CaseLayoutRule
from TestSuite.classifier import Classifier
from TestSuite.collection import Collection
from TestSuite.content_list import ContentList
from TestSuite.correlation_rule import CorrelationRule
from TestSuite.dashboard import Dashboard
Expand All @@ -43,6 +42,7 @@
from TestSuite.integration import Integration
from TestSuite.job import Job
from TestSuite.json_based import JSONBased
from TestSuite.knowledge import Knowledge
from TestSuite.layout import Layout
from TestSuite.layout_rule import LayoutRule
from TestSuite.mapper import Mapper
Expand Down Expand Up @@ -129,7 +129,7 @@ def __init__(self, packs_dir: Path, name: str, repo):
self.agentix_actions: List[AgentixAction] = list()
self.agentix_agents: List[AgentixAgent] = list()
self.agentix_skills: List[AgentixSkill] = list()
self.collections: List[Collection] = list()
self.knowledges: List[Knowledge] = list()

# Create base pack
self._pack_path = packs_dir / self.name
Expand Down Expand Up @@ -279,8 +279,8 @@ def __init__(self, packs_dir: Path, name: str, repo):
self._agentix_skills_path = self._pack_path / AGENTIX_SKILLS_DIR
self._agentix_skills_path.mkdir(exist_ok=True)

self._collections_path = self._pack_path / COLLECTIONS_DIR
self._collections_path.mkdir(exist_ok=True)
self._knowledges_path = self._pack_path / KNOWLEDGE_DIR
self._knowledges_path.mkdir(exist_ok=True)

super().__init__(self._pack_path)

Expand Down Expand Up @@ -896,16 +896,16 @@ def create_agentix_skill(
self.agentix_skills.append(agentix_skill)
return agentix_skill

def create_collection(
def create_knowledge(
self,
name: Optional[str] = None,
yml: Optional[dict] = None,
) -> Collection:
) -> Knowledge:
if name is None:
name = f"collection-{len(self.collections)}"
collection = Collection(self._collections_path, name, self._repo)
collection.build(
name = f"knowledge-{len(self.knowledges)}"
knowledge = Knowledge(self._knowledges_path, name, self._repo)
knowledge.build(
yml,
)
self.collections.append(collection)
return collection
self.knowledges.append(knowledge)
return knowledge
14 changes: 7 additions & 7 deletions demisto_sdk/commands/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def strip_cr_registry_prefix(image: str) -> str:
AGENTIX_ACTIONS_DIR = "AgentixActions"
AGENTIX_AGENTS_DIR = "AgentixAgents"
AGENTIX_SKILLS_DIR = "AgentixSkills"
COLLECTIONS_DIR = "Collections"
KNOWLEDGE_DIR = "Knowledge"

# NAMES OF ENTITIES

Expand Down Expand Up @@ -302,7 +302,7 @@ class FileType(StrEnum):
AGENTIX_AGENT = "agentixagent"
AGENTIX_ACTION = "agentixaction"
AGENTIX_SKILL = "agentixskill"
COLLECTION = "collection"
KNOWLEDGE = "knowledge"


RN_HEADER_BY_FILE_TYPE = {
Expand Down Expand Up @@ -346,7 +346,7 @@ class FileType(StrEnum):
FileType.AGENTIX_AGENT: "Agents",
FileType.AGENTIX_ACTION: "Actions",
FileType.AGENTIX_SKILL: "Skills",
FileType.COLLECTION: "Collections",
FileType.KNOWLEDGE: "Knowledge",
}

FILE_TYPE_BY_RN_HEADER = {
Expand Down Expand Up @@ -391,7 +391,7 @@ class FileType(StrEnum):
FileType.CASE_FIELD.value: CASE_FIELDS_DIR,
FileType.CASE_LAYOUT.value: CASE_LAYOUTS_DIR,
FileType.CASE_LAYOUT_RULE.value: CASE_LAYOUT_RULES_DIR,
FileType.COLLECTION.value: COLLECTIONS_DIR,
FileType.KNOWLEDGE.value: KNOWLEDGE_DIR,
}

SIEM_ONLY_ENTITIES = [
Expand Down Expand Up @@ -458,7 +458,7 @@ class FileType(StrEnum):
AGENTIX_ACTIONS_DIR,
AGENTIX_AGENTS_DIR,
AGENTIX_SKILLS_DIR,
COLLECTIONS_DIR,
KNOWLEDGE_DIR,
]

CONTENT_ENTITY_UPLOAD_ORDER = [
Expand Down Expand Up @@ -1662,7 +1662,7 @@ class PB_Status:
FileType.AGENTIX_ACTION: "8.12.0",
FileType.AGENTIX_AGENT: "8.12.0",
FileType.AGENTIX_SKILL: "8.15.0",
FileType.COLLECTION: "8.15.0",
FileType.KNOWLEDGE: "8.15.0",
}

DEFAULT_PYTHON_VERSION = "3.11"
Expand Down Expand Up @@ -2337,7 +2337,7 @@ class PlaybookTaskType(StrEnum):
TITLE = "title"
SECTION = "section"
STANDARD = "standard"
COLLECTION = "collection"
KNOWLEDGE = "knowledge"
AI_TASK = "aiTask"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from .agentix_agent.agentix_agent import AgentixAgent
from .agentix_action.agentix_action import AgentixAction
from .agentix_skill.agentix_skill import AgentixSkill
from .collection.collection import Collection
from .knowledge.knowledge import Knowledge

__all__ = [
name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
YAMLContentObject,
)

COLLECTION = "collection"
KNOWLEDGE = "knowledge"


class Collection(YAMLContentObject):
class Knowledge(YAMLContentObject):
def __init__(self, path: Union[Path, str]):
super().__init__(path, COLLECTION)
super().__init__(path, KNOWLEDGE)

def upload(self, client: demisto_client):
pass

def type(self):
return FileType.COLLECTION
return FileType.KNOWLEDGE
4 changes: 2 additions & 2 deletions demisto_sdk/commands/common/content/objects_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
ChangeLog,
Classifier,
ClassifierMapper,
Collection,
Contributors,
CorrelationRule,
Dashboard,
Expand All @@ -30,6 +29,7 @@
IndicatorType,
Integration,
Job,
Knowledge,
Layout,
LayoutRule,
LayoutsContainer,
Expand Down Expand Up @@ -108,7 +108,7 @@
FileType.AGENTIX_ACTION: AgentixAction,
FileType.AGENTIX_AGENT: AgentixAgent,
FileType.AGENTIX_SKILL: AgentixSkill,
FileType.COLLECTION: Collection,
FileType.KNOWLEDGE: Knowledge,
}

TYPE_CONVERSION_BY_FILE_NAME = {
Expand Down
2 changes: 1 addition & 1 deletion demisto_sdk/commands/common/schemas/agentixagent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mapping:
type: seq
sequence:
- type: str
collectionids:
knowledgeids:
type: seq
sequence:
- type: str
Expand Down
12 changes: 6 additions & 6 deletions demisto_sdk/commands/common/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
API_MODULES_PACK,
ASSETS_MODELING_RULES_DIR,
CLASSIFIERS_DIR,
COLLECTIONS_DIR,
CONF_JSON_FILE_NAME,
CONNECTORS_FOLDER,
CONTENT_ENTITIES_DIRS,
Expand All @@ -87,6 +86,7 @@
INTEGRATIONS_DIR,
ISO_TIMESTAMP_FORMAT,
JOBS_DIR,
KNOWLEDGE_DIR,
LAYOUT_RULES_DIR,
LAYOUTS_DIR,
LISTS_DIR,
Expand Down Expand Up @@ -1858,8 +1858,8 @@ def find_type_by_path(path: Union[str, Path] = "") -> Optional[FileType]:
elif AGENTIX_SKILLS_DIR in path.parts:
return FileType.AGENTIX_SKILL

elif COLLECTIONS_DIR in path.parts:
return FileType.COLLECTION
elif KNOWLEDGE_DIR in path.parts:
return FileType.KNOWLEDGE

elif path.name == FileType.PACK_IGNORE:
return FileType.PACK_IGNORE
Expand Down Expand Up @@ -1928,7 +1928,6 @@ def find_type(
CaseLayout,
CaseLayoutRule,
Classifier,
Collection,
CorrelationRule,
Dashboard,
GenericDefinition,
Expand All @@ -1941,6 +1940,7 @@ def find_type(
IndicatorType,
Integration,
Job,
Knowledge,
Layout,
LayoutRule,
Mapper,
Expand Down Expand Up @@ -2128,8 +2128,8 @@ def find_type(
if AgentixSkill.match(_dict, Path(path)):
return FileType.AGENTIX_SKILL

if Collection.match(_dict, Path(path)):
return FileType.COLLECTION
if Knowledge.match(_dict, Path(path)):
return FileType.KNOWLEDGE

return None

Expand Down
Loading
Loading