Module pypowerautomate.actions.dataoperation
Expand source code
from typing import List, Dict
from .base import BaseAction
class TableFormat:
"""
Enumerates the supported formats for table creation actions.
"""
csv = "CSV"
html = "HTML"
class SelectAction(BaseAction):
"""
Defines a selection action similar to the `map` function, transforming an input array or list into a new structure based on specified key-value pairs.
"""
def __init__(self, name: str, inputs: List | str, key: str = None, value: str = None, select: str = None):
"""
Initializes a new instance of SelectAction.
Args:
name (str): The name of the action.
inputs (List | str): The input list or a Power Automate expression that evaluates to an array.
key (str, optional): The key used in the output dictionary, only required if select is not provided.
value (str, optional): The value associated with each key in the output dictionary, only required if select is not provided.
select (str, optional): A pre-formed selection string defining how inputs are mapped to outputs.
"""
super().__init__(name)
self.type = "Select"
self.inputs = {"from": inputs, "select": {key: value} if key and value else select}
def export(self) -> Dict:
"""
Exports the configuration of the SelectAction for use in a workflow.
Returns:
Dict: A dictionary containing the configuration of this action.
"""
d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs}
return d
class CreateTableAction(BaseAction):
"""
Defines an action to create a table from an array of dictionaries or an expression that evaluates to such an array, formatted as CSV or HTML.
"""
def __init__(self, name: str, inputs: List[Dict] | str, format: str):
"""
Initializes a new instance of CreateTableAction.
Args:
name (str): The name of the action.
inputs (List[Dict] | str): The input data or a Power Automate expression that evaluates to an object array.
format (str): The format of the output table (e.g., TableFormat.csv, TableFormat.html).
"""
super().__init__(name)
self.type = "Table"
self.inputs = {"from": inputs, "format": format}
def export(self) -> Dict:
"""
Exports the configuration of the CreateTableAction for use in a workflow.
Returns:
Dict: A dictionary containing the configuration of this action.
"""
d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs}
return d
class ComposeAction(BaseAction):
"""
Defines an action to compose data into a specified structure, typically used for constructing new data objects.
"""
def __init__(self, name: str, inputs: List | Dict | str):
"""
Initializes a new instance of ComposeAction.
Args:
name (str): The name of the action.
inputs (List | Dict | str): The input data or expression that defines the output structure.
"""
super().__init__(name)
self.type = "Compose"
self.inputs = inputs
def export(self) -> Dict:
"""
Exports the configuration of the ComposeAction for use in a workflow.
Returns:
Dict: A dictionary containing the configuration of this action.
"""
d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs}
return d
class FilterArrayAction(BaseAction):
"""
Defines an action to filter elements of an array based on a specified condition, similar to the `filter` function.
"""
def __init__(self, name: str, inputs: List | str, where: str):
"""
Initializes a new instance of FilterArrayAction.
Args:
name (str): The name of the action.
inputs (List | str): The input array or a Power Automate expression that evaluates to an array.
where (str): A Power Automate expression used to evaluate each element of the array.
"""
super().__init__(name)
self.type = "Query"
self.inputs = {"from": inputs, "where": where}
def export(self) -> Dict:
"""
Exports the configuration of the FilterArrayAction for use in a workflow.
Returns:
Dict: A dictionary containing the configuration of this action.
"""
d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs}
return d
class JoinAction(BaseAction):
"""
Defines an action to concatenate elements of an array into a single string, separated by a specified delimiter.
"""
def __init__(self, name: str, inputs: List | str, join_with: str):
"""
Initializes a new instance of JoinAction.
Args:
name (str): The name of the action.
inputs (List | str): The input array or a Power Automate expression that evaluates to an array.
join_with (str): The delimiter used to join the array elements.
"""
super().__init__(name)
self.type = "Join"
self.inputs = {"from": inputs, "joinWith": join_with}
def export(self) -> Dict:
"""
Exports the configuration of the JoinAction for use in a workflow.
Returns:
Dict: A dictionary containing the configuration of this action.
"""
d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs}
return d
Classes
class ComposeAction (name: str, inputs: Union[List, Dict, str])
-
Defines an action to compose data into a specified structure, typically used for constructing new data objects.
Initializes a new instance of ComposeAction.
Args
name
:str
- The name of the action.
inputs (List | Dict | str): The input data or expression that defines the output structure.
Expand source code
class ComposeAction(BaseAction): """ Defines an action to compose data into a specified structure, typically used for constructing new data objects. """ def __init__(self, name: str, inputs: List | Dict | str): """ Initializes a new instance of ComposeAction. Args: name (str): The name of the action. inputs (List | Dict | str): The input data or expression that defines the output structure. """ super().__init__(name) self.type = "Compose" self.inputs = inputs def export(self) -> Dict: """ Exports the configuration of the ComposeAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Ancestors
Methods
def export(self) ‑> Dict
-
Exports the configuration of the ComposeAction for use in a workflow.
Returns
Dict
- A dictionary containing the configuration of this action.
Expand source code
def export(self) -> Dict: """ Exports the configuration of the ComposeAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Inherited members
class CreateTableAction (name: str, inputs: Union[List[Dict], str], format: str)
-
Defines an action to create a table from an array of dictionaries or an expression that evaluates to such an array, formatted as CSV or HTML.
Initializes a new instance of CreateTableAction.
Args
name
:str
- The name of the action.
- inputs (List[Dict] | str): The input data or a Power Automate expression that evaluates to an object array.
format
:str
- The format of the output table (e.g., TableFormat.csv, TableFormat.html).
Expand source code
class CreateTableAction(BaseAction): """ Defines an action to create a table from an array of dictionaries or an expression that evaluates to such an array, formatted as CSV or HTML. """ def __init__(self, name: str, inputs: List[Dict] | str, format: str): """ Initializes a new instance of CreateTableAction. Args: name (str): The name of the action. inputs (List[Dict] | str): The input data or a Power Automate expression that evaluates to an object array. format (str): The format of the output table (e.g., TableFormat.csv, TableFormat.html). """ super().__init__(name) self.type = "Table" self.inputs = {"from": inputs, "format": format} def export(self) -> Dict: """ Exports the configuration of the CreateTableAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Ancestors
Methods
def export(self) ‑> Dict
-
Exports the configuration of the CreateTableAction for use in a workflow.
Returns
Dict
- A dictionary containing the configuration of this action.
Expand source code
def export(self) -> Dict: """ Exports the configuration of the CreateTableAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Inherited members
class FilterArrayAction (name: str, inputs: Union[List, str], where: str)
-
Defines an action to filter elements of an array based on a specified condition, similar to the
filter
function.Initializes a new instance of FilterArrayAction.
Args
name
:str
- The name of the action.
- inputs (List | str): The input array or a Power Automate expression that evaluates to an array.
where
:str
- A Power Automate expression used to evaluate each element of the array.
Expand source code
class FilterArrayAction(BaseAction): """ Defines an action to filter elements of an array based on a specified condition, similar to the `filter` function. """ def __init__(self, name: str, inputs: List | str, where: str): """ Initializes a new instance of FilterArrayAction. Args: name (str): The name of the action. inputs (List | str): The input array or a Power Automate expression that evaluates to an array. where (str): A Power Automate expression used to evaluate each element of the array. """ super().__init__(name) self.type = "Query" self.inputs = {"from": inputs, "where": where} def export(self) -> Dict: """ Exports the configuration of the FilterArrayAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Ancestors
Methods
def export(self) ‑> Dict
-
Exports the configuration of the FilterArrayAction for use in a workflow.
Returns
Dict
- A dictionary containing the configuration of this action.
Expand source code
def export(self) -> Dict: """ Exports the configuration of the FilterArrayAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Inherited members
class JoinAction (name: str, inputs: Union[List, str], join_with: str)
-
Defines an action to concatenate elements of an array into a single string, separated by a specified delimiter.
Initializes a new instance of JoinAction.
Args
name
:str
- The name of the action.
- inputs (List | str): The input array or a Power Automate expression that evaluates to an array.
join_with
:str
- The delimiter used to join the array elements.
Expand source code
class JoinAction(BaseAction): """ Defines an action to concatenate elements of an array into a single string, separated by a specified delimiter. """ def __init__(self, name: str, inputs: List | str, join_with: str): """ Initializes a new instance of JoinAction. Args: name (str): The name of the action. inputs (List | str): The input array or a Power Automate expression that evaluates to an array. join_with (str): The delimiter used to join the array elements. """ super().__init__(name) self.type = "Join" self.inputs = {"from": inputs, "joinWith": join_with} def export(self) -> Dict: """ Exports the configuration of the JoinAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Ancestors
Methods
def export(self) ‑> Dict
-
Exports the configuration of the JoinAction for use in a workflow.
Returns
Dict
- A dictionary containing the configuration of this action.
Expand source code
def export(self) -> Dict: """ Exports the configuration of the JoinAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Inherited members
class SelectAction (name: str, inputs: Union[List, str], key: str = None, value: str = None, select: str = None)
-
Defines a selection action similar to the
map
function, transforming an input array or list into a new structure based on specified key-value pairs.Initializes a new instance of SelectAction.
Args
name
:str
- The name of the action.
- inputs (List | str): The input list or a Power Automate expression that evaluates to an array.
key
:str
, optional- The key used in the output dictionary, only required if select is not provided.
value
:str
, optional- The value associated with each key in the output dictionary, only required if select is not provided.
select
:str
, optional- A pre-formed selection string defining how inputs are mapped to outputs.
Expand source code
class SelectAction(BaseAction): """ Defines a selection action similar to the `map` function, transforming an input array or list into a new structure based on specified key-value pairs. """ def __init__(self, name: str, inputs: List | str, key: str = None, value: str = None, select: str = None): """ Initializes a new instance of SelectAction. Args: name (str): The name of the action. inputs (List | str): The input list or a Power Automate expression that evaluates to an array. key (str, optional): The key used in the output dictionary, only required if select is not provided. value (str, optional): The value associated with each key in the output dictionary, only required if select is not provided. select (str, optional): A pre-formed selection string defining how inputs are mapped to outputs. """ super().__init__(name) self.type = "Select" self.inputs = {"from": inputs, "select": {key: value} if key and value else select} def export(self) -> Dict: """ Exports the configuration of the SelectAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Ancestors
Methods
def export(self) ‑> Dict
-
Exports the configuration of the SelectAction for use in a workflow.
Returns
Dict
- A dictionary containing the configuration of this action.
Expand source code
def export(self) -> Dict: """ Exports the configuration of the SelectAction for use in a workflow. Returns: Dict: A dictionary containing the configuration of this action. """ d = {"metadata": self.metadata, "type": self.type, "runAfter": self.runafter, "inputs": self.inputs} return d
Inherited members
class TableFormat
-
Enumerates the supported formats for table creation actions.
Expand source code
class TableFormat: """ Enumerates the supported formats for table creation actions. """ csv = "CSV" html = "HTML"
Class variables
var csv
var html