From edd3be2d9e78ebbb2ca6c55a90f61b03405468ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Rom=C3=A1n?= Date: Fri, 17 Jul 2026 15:22:24 -0700 Subject: [PATCH 1/2] feat(system): add config submodule Closes: #54 --- README.md | 2 +- .../ignition/gateway/script/__init__.py | 88 ++++ src/system/config.py | 379 ++++++++++++++++++ .../ignition/gateway/script/__init__.pyi | 25 ++ stubs/stubs/system/config.pyi | 80 ++++ 5 files changed, 573 insertions(+), 1 deletion(-) create mode 100644 src/com/inductiveautomation/ignition/gateway/script/__init__.py create mode 100644 src/system/config.py create mode 100644 stubs/stubs/com/inductiveautomation/ignition/gateway/script/__init__.pyi create mode 100644 stubs/stubs/system/config.pyi diff --git a/README.md b/README.md index cf3aa1d..11840ef 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ Automation's `org.json` package, see documentation here: This package includes supporting Jython classes and interfaces. For more information, see documentation here: -. +. #### org.slf4j diff --git a/src/com/inductiveautomation/ignition/gateway/script/__init__.py b/src/com/inductiveautomation/ignition/gateway/script/__init__.py new file mode 100644 index 0000000..ddad74d --- /dev/null +++ b/src/com/inductiveautomation/ignition/gateway/script/__init__.py @@ -0,0 +1,88 @@ +from __future__ import print_function + +__all__ = ["PyResource"] + +from typing import Any, List, Mapping, Optional, Union + +from java.util import Date + +from org.python.core import PyObject, PyTuple + + +class PyResource(PyObject): + def __init__(self, resource=None): + # type: (Any) -> None + super(PyResource, self).__init__() + print(resource) + + def getCollection(self): + # type: () -> Union[str, unicode] + pass + + def getDefiningCollection(self): + # type: () -> Union[str, unicode] + pass + + def getName(self): + # type: () -> Optional[Union[str, unicode]] + pass + + def getResourceType(self): + # type: () -> PyTuple + pass + + def getDocumentation(self): + # type: () -> Optional[Union[str, unicode]] + pass + + def getFiles(self): + # type: () -> Mapping[Union[str, unicode], Any] + pass + + def getFile(self, key): + # type: (Union[str, unicode]) -> Any + pass + + def getConfig(self): + # type: () -> Any + pass + + def getBackupConfig(self): + # type: () -> Any + pass + + def getFileNames(self): + # type: () -> List[Union[str, unicode]] + pass + + def getAttributes(self): + # type: () -> PyObject + pass + + def getAttribute(self, key): + # type: (Union[str, unicode]) -> PyObject + pass + + def getId(self): + # type: () -> Optional[Union[str, unicode]] + pass + + def getLastModificationActor(self): + # type: () -> Optional[Union[str, unicode]] + pass + + def getLastModificationTime(self): + # type: () -> Optional[Date] + pass + + def getResource(self): + # type: () -> Any + pass + + def isEnabled(self): + # type: () -> bool + pass + + def isSingleton(self): + # type: () -> bool + pass diff --git a/src/system/config.py b/src/system/config.py new file mode 100644 index 0000000..c68698c --- /dev/null +++ b/src/system/config.py @@ -0,0 +1,379 @@ +"""Config Functions. + +The following functions allow you to configure various aspects of your +Gateway configuration. +""" + +from __future__ import print_function + +__all__ = [ + "copy", + "create", + "delete", + "getActiveMode", + "getModes", + "getResource", + "getResourceTypes", + "getResources", + "move", + "rename", + "replace", +] + +from typing import Any, Dict, List, Optional, Union + +from com.inductiveautomation.ignition.gateway.script import PyResource + + +def copy( + moduleId, # type: Union[str, unicode] + typeId, # type: Union[str, unicode] + name=None, # type: Union[str, unicode, None] + collection=None, # type: Union[str, unicode, None] + newName=None, # type: Union[str, unicode, None] + newCollection=None, # type: Union[str, unicode, None] + signature=None, # type: Union[str, unicode, None] + actor=None, # type: Union[str, unicode, None] +): + # type: (...) -> PyResource + """Copies a resource to a new name and/or collection. + + When using this function, either the newName or newCollection + parameter must be defined. + + Args: + moduleId: The module ID portion of the resource type identifier. + typeId: The type ID portion of the resource type identifier. + name: The name of the resource. Required for named resources, + but must be omitted for singleton resources. Optional. + collection: The collection containing the resource. If omitted, + uses the active definition. Optional. + newName: The new name for the copied resource. Required if not + changing collection for named resource types. Optional. + newCollection: The new collection for the copied resource. + Required if not changing name for singleton resource types. + Optional. + signature: The hex-encoded signature of the resource. Optional. + actor: A string identifying the actor performing the operation. + If not specified, an identifier will be automatically + generated. Optional. + + Returns: + A PyResource containing the specified parameter attributes of an + existing Gateway resource, which can also be read as plain + Python properties. + """ + print(moduleId, typeId, name, collection, newName, newCollection, signature, actor) + return PyResource() + + +def create( + moduleId, # type: Union[str, unicode] + typeId, # type: Union[str, unicode] + name=None, # type: Union[str, unicode, None] + collection=None, # type: Union[str, unicode, None] + config=None, # type: Optional[Dict[Union[str, unicode], Any]] + backupConfig=None, # type: Optional[Dict[Union[str, unicode], Any]] + files=None, # type: Optional[Dict[Union[str, unicode], Any]] + description=None, # type: Union[str, unicode, None] + enabled=None, # type: Optional[bool] + attributes=None, # type: Optional[Dict[Union[str, unicode], Any]] + actor=None, # type: Union[str, unicode, None] +): + # type: (...) -> PyResource + """Creates a new resource of the specified type. + + Args: + moduleId: The module ID portion of the resource type identifier. + typeId: The type ID portion of the resource type identifier. + name: The name of the resource. Required for named resources, + but must be omitted for singleton resources. Optional. + collection: The collection containing the resource. If omitted, + uses the active definition. Optional. + config: A dictionary representing the resource configuration, + matching the resource type's JSON schema. If not provided, + the files argument must be provided. Optional. + backupConfig: A dictionary representing the backup configuration + for resources that support backup data. Optional. + files: A dictionary of additional files to include with the + resource. Keys are filenames, values can be byte arrays, + strings, lists, or dictionaries. If not provided, the config + argument must be provided. Optional. + description: A description for the resource. Optional. + enabled: Whether the resource should be enabled. If omitted, the + resource will be enabled when created. Optional. + attributes: A dictionary of resource attributes to set. + Optional. + actor: A string identifying the actor performing the operation. + If not specified, an identifier will be automatically + generated. Optional. + + Returns: + A PyResource containing the specified parameter attributes of + your newly created Gateway resource, which can also be read as + plain Python properties. + """ + print( + moduleId, + typeId, + name, + collection, + config, + backupConfig, + files, + description, + enabled, + attributes, + actor, + ) + return PyResource() + + +def delete( + moduleId, # type: Union[str, unicode] + typeId, # type: Union[str, unicode] + name=None, # type: Union[str, unicode, None] + collection=None, # type: Union[str, unicode, None] + signature=None, # type: Union[str, unicode, None] + force=False, # type: bool + actor=None, # type: Union[str, unicode, None] +): + # type: (...) -> None + """Deletes a resource from the Gateway. + + Args: + moduleId: The module ID portion of the resource type identifier. + typeId: The type ID portion of the resource type identifier. + name: The name of the resource. Required for named resources, + but must be omitted for singleton resources. Optional. + collection: The collection containing the resource. If omitted, + uses the active definition. Optional. + signature: The hex-encoded signature of the resource. Optional. + force: f true, deletes the resource even if other resources + reference it. If omitted, default is false. Optional. + actor: A string identifying the actor performing the operation. + If not specified, an identifier will be automatically + generated. Optional. + """ + print(moduleId, typeId, name, collection, signature, force, actor) + + +def getActiveMode(): + # type: () -> Union[str, unicode, None] + """Returns the current deployment mode, or None if no mode is + explicitly active. + + Returns: + The current deployment mode, as a string. + """ + return None + + +def getModes(): + # type: () -> List[Union[str, unicode]] + """Returns a list of all available deployment modes. + + Returns: + A list of strings, containing all the available deployment modes + on the Gateway. + """ + return [] + + +def getResource( + moduleId, # type: Union[str, unicode] + typeId, # type: Union[str, unicode] + name, # type: Union[str, unicode] + collection, # type: Union[str, unicode] +): + # type: (...) -> PyResource + """Returns a resource from the Gateway. + + Args: + moduleId: The module ID portion of the resource type identifier. + typeId: The type ID portion of the resource type identifier. + name: The name of the resource. Required for named resources, + but must be omitted for singleton resources. + collection: The collection containing the resource. If omitted, + uses the active definition. + + Returns: + The specified Gateway resource, as a PyResource that can be read + as plain Python properties. + """ + print(moduleId, typeId, name, collection) + return PyResource() + + +def getResources( + moduleId, # type: Union[str, unicode] + typeId, # type: Union[str, unicode] +): + # type: (...) -> List[PyResource] + """Returns a resource from the Gateway. + + Args: + moduleId: The module ID portion of the resource type identifier. + typeId: The type ID portion of the resource type identifier. + + Returns: + A List of all the resources of the specified type, as a + PyResource. + """ + print(moduleId, typeId) + return [PyResource()] + + +def getResourceTypes(): + # type: () -> List[Any] + """Returns a list of all registered resource types. + + Returns: + A list of tuples containing all the currently registered + resource types on the Gateway. + """ + return [] + + +def move( + moduleId, # type: Union[str, unicode] + typeId, # type: Union[str, unicode] + name=None, # type: Union[str, unicode, None] + collection=None, # type: Union[str, unicode, None] + newCollection=None, # type: Union[str, unicode, None] + signature=None, # type: Union[str, unicode, None] + actor=None, # type: Union[str, unicode, None] +): + # type: (...) -> PyResource + """Moves a resource to a different collection. + + The move operation changes which collection a resource belongs to, + but does not allow renaming. Use the rename() operation to change a + resource's name. + + Args: + moduleId: The module ID portion of the resource type identifier. + typeId: The type ID portion of the resource type identifier. + name: The name of the resource. Required for named resources, + but must be omitted for singleton resources. Optional. + collection: The collection containing the resource. If omitted, + uses the active definition. Optional. + newCollection: The new collection for the copied resource. + Required if not changing name for singleton resource types. + Optional. + signature: The hex-encoded signature of the resource. Optional. + actor: A string identifying the actor performing the operation. + If not specified, an identifier will be automatically + generated. Optional. + + Returns: + The Gateway resource that was moved, which can also be read as + plain Python properties. + """ + print(moduleId, typeId, name, collection, newCollection, signature, actor) + return PyResource() + + +def rename( + moduleId, # type: Union[str, unicode] + typeId, # type: Union[str, unicode] + name=None, # type: Union[str, unicode, None] + collection=None, # type: Union[str, unicode, None] + newName=None, # type: Union[str, unicode, None] + references=None, # type: Union[str, unicode, None] + actor=None, # type: Union[str, unicode, None] +): + # type: (...) -> PyResource + """Renames the specified resource within its current collection. + + Use the move() function to transfer resources between collections. + + Args: + moduleId: The module ID portion of the resource type identifier. + typeId: The type ID portion of the resource type identifier. + name: The name of the resource. Required for named resources, + but must be omitted for singleton resources. Optional. + collection: The collection containing the resource. If omitted, + uses the active definition. Optional. + newName: The new name for the resource. + references: How Ignition should handle references from other + resources to the current value of the resource that is being + renamed. Optional. + actor: A string identifying the actor performing the operation. + If not specified, an identifier will be automatically + generated. Optional. + + Returns: + The resource that was renamed, as a PyResource that can also be + read as plain Python properties. + """ + print(moduleId, typeId, name, collection, newName, references, actor) + return PyResource() + + +def replace( + moduleId, # type: Union[str, unicode] + typeId, # type: Union[str, unicode] + name=None, # type: Union[str, unicode, None] + collection=None, # type: Union[str, unicode, None] + signature=None, # type: Union[str, unicode, None] + config=None, # type: Optional[Dict[Union[str, unicode], Any]] + backupConfig=None, # type: Optional[Dict[Union[str, unicode], Any]] + files=None, # type: Optional[Dict[Union[str, unicode], Any]] + description=None, # type: Union[str, unicode, None] + enabled=None, # type: Optional[bool] + attributes=None, # type: Optional[Dict[Union[str, unicode], Any]] + actor=None, # type: Union[str, unicode, None] +): + # type: (...) -> PyResource + """Copies a resource to a new name and/or collection. + + When using this function, either the newName or newCollection + parameter must be defined. + + Args: + moduleId: The module ID portion of the resource type identifier. + typeId: The type ID portion of the resource type identifier. + name: The name of the resource. Required for named resources, + but must be omitted for singleton resources. Optional. + collection: The collection containing the resource. If omitted, + uses the active definition. Optional. + signature: The hex-encoded signature of the resource. Optional. + config: A dictionary representing the resource configuration, + matching the resource type's JSON schema. If not provided, + the files argument must be provided. Optional. + backupConfig: A dictionary representing the backup configuration + for resources that support backup data. Optional. + files: A dictionary of additional files to include with the + resource. Keys are filenames, values can be byte arrays, + strings, lists, or dictionaries. If not provided, the config + argument must be provided. Optional. + description: A description for the resource. Optional. + enabled: Whether the replacement resource should be enabled. If + omitted, the resource will be in the same state after its + configuration is replaced. Optional. + attributes: A dictionary of resource attributes to set. + Optional. + actor: A string identifying the actor performing the operation. + If not specified, an identifier will be automatically + generated. Optional. + + Returns: + The newly configured resource, as a PyResource that can also be + read as plain Python properties. + """ + print( + moduleId, + typeId, + name, + collection, + signature, + config, + backupConfig, + files, + description, + enabled, + attributes, + actor, + ) + return PyResource() diff --git a/stubs/stubs/com/inductiveautomation/ignition/gateway/script/__init__.pyi b/stubs/stubs/com/inductiveautomation/ignition/gateway/script/__init__.pyi new file mode 100644 index 0000000..fce0b0e --- /dev/null +++ b/stubs/stubs/com/inductiveautomation/ignition/gateway/script/__init__.pyi @@ -0,0 +1,25 @@ +from typing import Any, List, Mapping, Optional, Union + +from java.util import Date +from org.python.core import PyObject, PyTuple + +class PyResource(PyObject): + def __init__(self, resource: Any = ...) -> None: ... + def getCollection(self) -> Union[str, unicode]: ... + def getDefiningCollection(self) -> Union[str, unicode]: ... + def getName(self) -> Optional[Union[str, unicode]]: ... + def getResourceType(self) -> PyTuple: ... + def getDocumentation(self) -> Optional[Union[str, unicode]]: ... + def getFiles(self) -> Mapping[Union[str, unicode], Any]: ... + def getFile(self, key: Union[str, unicode]) -> Any: ... + def getConfig(self) -> Any: ... + def getBackupConfig(self) -> Any: ... + def getFileNames(self) -> List[Union[str, unicode]]: ... + def getAttributes(self) -> PyObject: ... + def getAttribute(self, key: Union[str, unicode]) -> PyObject: ... + def getId(self) -> Optional[Union[str, unicode]]: ... + def getLastModificationActor(self) -> Optional[Union[str, unicode]]: ... + def getLastModificationTime(self) -> Optional[Date]: ... + def getResource(self) -> Any: ... + def isEnabled(self) -> bool: ... + def isSingleton(self) -> bool: ... diff --git a/stubs/stubs/system/config.pyi b/stubs/stubs/system/config.pyi new file mode 100644 index 0000000..534a978 --- /dev/null +++ b/stubs/stubs/system/config.pyi @@ -0,0 +1,80 @@ +from typing import Any, Dict, List, Optional, Union + +from com.inductiveautomation.ignition.gateway.script import PyResource + +def copy( + moduleId: Union[str, unicode], + typeId: Union[str, unicode], + name: Union[str, unicode, None] = ..., + collection: Union[str, unicode, None] = ..., + newName: Union[str, unicode, None] = ..., + newCollection: Union[str, unicode, None] = ..., + signature: Union[str, unicode, None] = ..., + actor: Union[str, unicode, None] = ..., +) -> PyResource: ... +def create( + moduleId: Union[str, unicode], + typeId: Union[str, unicode], + name: Union[str, unicode, None] = ..., + collection: Union[str, unicode, None] = ..., + config: Optional[Dict[Union[str, unicode], Any]] = ..., + backupConfig: Optional[Dict[Union[str, unicode], Any]] = ..., + files: Optional[Dict[Union[str, unicode], Any]] = ..., + description: Union[str, unicode, None] = ..., + enabled: Optional[bool] = ..., + attributes: Optional[Dict[Union[str, unicode], Any]] = ..., + actor: Union[str, unicode, None] = ..., +) -> PyResource: ... +def delete( + moduleId: Union[str, unicode], + typeId: Union[str, unicode], + name: Union[str, unicode, None] = ..., + collection: Union[str, unicode, None] = ..., + signature: Union[str, unicode, None] = ..., + force: bool = ..., + actor: Union[str, unicode, None] = ..., +) -> None: ... +def getActiveMode() -> Union[str, unicode, None]: ... +def getModes() -> List[Union[str, unicode]]: ... +def getResource( + moduleId: Union[str, unicode], + typeId: Union[str, unicode], + name: Union[str, unicode], + collection: Union[str, unicode], +) -> PyResource: ... +def getResources( + moduleId: Union[str, unicode], typeId: Union[str, unicode] +) -> List[PyResource]: ... +def getResourceTypes() -> List[Any]: ... +def move( + moduleId: Union[str, unicode], + typeId: Union[str, unicode], + name: Union[str, unicode, None] = ..., + collection: Union[str, unicode, None] = ..., + newCollection: Union[str, unicode, None] = ..., + signature: Union[str, unicode, None] = ..., + actor: Union[str, unicode, None] = ..., +) -> PyResource: ... +def rename( + moduleId: Union[str, unicode], + typeId: Union[str, unicode], + name: Union[str, unicode, None] = ..., + collection: Union[str, unicode, None] = ..., + newName: Union[str, unicode, None] = ..., + references: Union[str, unicode, None] = ..., + actor: Union[str, unicode, None] = ..., +) -> PyResource: ... +def replace( + moduleId: Union[str, unicode], + typeId: Union[str, unicode], + name: Union[str, unicode, None] = ..., + collection: Union[str, unicode, None] = ..., + signature: Union[str, unicode, None] = ..., + config: Optional[Dict[Union[str, unicode], Any]] = ..., + backupConfig: Optional[Dict[Union[str, unicode], Any]] = ..., + files: Optional[Dict[Union[str, unicode], Any]] = ..., + description: Union[str, unicode, None] = ..., + enabled: Optional[bool] = ..., + attributes: Optional[Dict[Union[str, unicode], Any]] = ..., + actor: Union[str, unicode, None] = ..., +) -> PyResource: ... From d3123ce3acd942c71a9f82fd00c77e87b87a336c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Rom=C3=A1n?= Date: Fri, 17 Jul 2026 15:28:27 -0700 Subject: [PATCH 2/2] style: fix docstring for system.config.replace --- README.md | 4 ++-- src/system/config.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 11840ef..a1a53d3 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Libraries for Java 32.0.1-jre API. For more information, see documentation here: This package includes supporting Inductive Automation's classes and interfaces. For more information, see documentation here: -. +. #### org.apache @@ -133,7 +133,7 @@ This package includes supporting classes and interfaces from Mongo Java driver This package includes supporting classes and interfaces from the Inductive Automation's `org.json` package, see documentation here: - + #### org.python diff --git a/src/system/config.py b/src/system/config.py index c68698c..ee91ebd 100644 --- a/src/system/config.py +++ b/src/system/config.py @@ -326,10 +326,10 @@ def replace( actor=None, # type: Union[str, unicode, None] ): # type: (...) -> PyResource - """Copies a resource to a new name and/or collection. + """Replaces an existing resource completely with a new + configuration. - When using this function, either the newName or newCollection - parameter must be defined. + The resource must already exist. Args: moduleId: The module ID portion of the resource type identifier.