Provision
opengate_data.provision
opengate_data.provision.asset
opengate_data.provision.asset.provision_asset
ProvisionAssetBuilder Objects
class ProvisionAssetBuilder()with_organization_name
def with_organization_name(organization_name: str) -> 'ProvisionAssetBuilder'Specify the organization for the asset.
Arguments:
organization_namestr - The organization for the asset.
Returns:
ProvisionAssetBuilder- Returns self for chaining.
Example:
builder.with_organization_name('organization_name')with_identifier
def with_identifier(identifier: str) -> 'ProvisionAssetBuilder'Specify the identifier for the asset.
Arguments:
identifierstr - The identifier for the asset.
Returns:
ProvisionAssetBuilder- Returns self for chaining.
Example:
builder.with_identifier('identifier')with_flattened
def with_flattened() -> 'ProvisionAssetBuilder'Flatten the data
Returns:
ProvisionAssetBuilder- Returns itself to allow for method chaining.
Example:
builder.with_flattened()with_utc
def with_utc() -> 'ProvisionAssetBuilder'Set UTC flag
Returns:
ProvisionAssetBuilder- Returns itself to allow for method chaining.
Example:
builder.with_utc()with_provision_identifier
def with_provision_identifier(identifier: str) -> 'ProvisionAssetBuilder'Set provision identifier
Returns:
ProvisionAssetBuilder- Returns itself to allow for method chaining.
Example:
builder.with_provision_identifier("identifier")with_provision_channel
def with_provision_channel(channel: str) -> 'ProvisionAssetBuilder'Set provision channel
Returns:
ProvisionAssetBuilder- Returns itself to allow for method chaining.
Example:
builder.with_provision_channel("channel")with_provision_service_group
def with_provision_service_group(
service_group: str) -> 'ProvisionAssetBuilder'Set provision servicegroup
Returns:
ProvisionAssetBuilder- Returns itself to allow for method chaining.
Example:
builder.with_provision_service_group("emptyServiceGroup")with_provision_organization
def with_provision_organization(organization: str) -> 'ProvisionAssetBuilder'Set provision organization
Returns:
ProvisionAssetBuilder- Returns itself to allow for method chaining.
Example:
builder.with_provision_service_group("organization_name")add_provision_datastream_value
def add_provision_datastream_value(datastream: str,
value: Any) -> 'ProvisionAssetBuilder'Add a datastream value to the payload.
Arguments:
datastreamstr - The datastream identifier.valueAny - The value to be added. It Can be a primitive type or a complex object.
Returns:
ProvisionAssetBuilder- Returns itself to allow for method chaining.
Example:
location_value = {
- `"position"` - {
- `"coordinates"` - [
-3.66131084,
40.458442
]
}
}
builder.add_provision_datastream_value("provision.asset.location", location_value)
builder.add_provision_datastream_value("provision.asset.name", "Name")from_dict
def from_dict(dct: dict[str, Any]) -> 'ProvisionAssetBuilder'Loads data as a python dictionary. If you want to enter the dictionary in flattened mode, you need to use with_flattened().
Arguments:
dctdict - The dictionary variable.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Example:
# Mode flattened
builder.with_flattened().from_dict(
{"resourceType":{"_value":{"_current":{"value":"entity.asset"}}},
"provision.asset.identifier":{"_value":{"_current":{"value":"identifier"}}},
"provision.administration.organization":{"_value":{"_current":{"value":"organization"}}},
"provision.asset.description":{"_value":{"_current":{"value":"Descripcion"}}},
"provision.administration.channel":{"_value":{"_current":{"value":"default_channel"}}},
"provision.administration.serviceGroup":{"_value":{"_current":{"value":"emptyServiceGroup"}}},
"provision.asset.location":{"_value":{"_current":{"value":{"position":{"coordinates":[-3.66131084,40.458442]}}}}},
"provision.human.name":{"_value":{"_current":{"value":"Name"}}},
"provision.human.surname":{"_value":{"_current":{"value":"Surname"}}}})
# Mode without flattened
builder.from_dict({
- `"resourceType"` - {
- `"_current"` - {
- `"value"` - "entity.asset"
}
},
- `"provision"` - {
- `"administration"` - {
- `"channel"` - {
- `"_current"` - {
- `"value"` - "battery_channel"
}
},
- `"organization"` - {
- `"_current"` - {
- `"value"` - "battery_organization"
}
},
- `"serviceGroup"` - {
- `"_current"` - {
- `"value"` - "emptyServiceGroup"
}
}
},
- `"asset"` - {
- `"identifier"` - {
- `"_current"` - {
- `"value"` - "worker_battery_id"
}
}
}
}
})from_dataframe
def from_dataframe(df: pd.DataFrame) -> "ProvisionAssetBuilder"Loads data as a pandas DataFrame. Columns must be the names of the datastreams separated with ‘_’ or ‘.’.
Arguments:
dfpd.DataFrame - The DataFrame variable.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Example:
import pandas as pd
data = {
- `'provision_administration_organization_current_value'` - ['base_organization','test_organization'],
- `'provision_device_location_current_value_position_type'` - ['Point','Other_Point'],
- `'provision_device_location_current_value_position_coordinates'` - [[-3.7028,40.41675],[-5.7028,47.41675]],
- `'provision_device_location_current_value_postal'` - ['28013','28050']
}
df = pd.DataFrame(df)
builder.from_dataframe(df)find_one
def find_one() -> 'ProvisionAssetBuilder'Retrieve a single asset.
This method sets up the ProvisionAssetBuilder instance to retrieve a specific assey associated with the specified organization and identifier.
Returns:
ProvisionAssetBuilder- The instance of the ProvisionDeviceBuilder class itself, allowing for method chaining.
Example:
builder.with_organization_name("organization_name").with_identifier("model_identifier").find_one()create
def create() -> 'ProvisionAssetBuilder'Initiates the creation process of a new asset.
This method prepares the ProvisionAssetBuilder instance to create a new asset.
Returns:
ProvisionAssetBuilder- The instance of the ProvisionAssetBuilder class itself, allowing for method chaining.
Example:
builder.with_organization_name("organization_name")
.with_provision_identifier("provision_identifier") .with_provision_organization("provision_organization") .with_provision_channel("provision_channel") .with_provision_service_group("provision_service_group") .add_provision_datastream_value("provision.asset.name", "Name") .create()update
def update() -> 'ProvisionAssetBuilder'Update an existing asset.
This method sets up the ProvisionAssetBuilder instance to update a specific asset associated with the specified organization and identifier.
You can update an asset with a flattened format sending a PUT request using the URL above. You must replace {identifier} with the identifier of the asset you want to update. Also, it is sent a boolean parameter, flattened, to allow sending a flattened JSON format
Returns:
ProvisionAssetBuilder- The instance of the ProvisionAssetBuilder class itself, allowing for method chaining.
Example:
dict_flatenned = {“resourceType”:{"_value":{"_current":{“value”:“entity.asset”}}}, “provision.asset.identifier”:{"_value":{"_current":{“value”:“EntityTest”}}}, “provision.administration.organization”:{"_value":{"_current":{“value”:“orgnization_name”}}}, “provision.administration.channel”:{"_value":{"_current":{“value”:“default_channel”}}}, “provision.administration.serviceGroup”:{"_value":{"_current":{“value”:“emptyServiceGroup” }}},
builder.with_organization_name("organization_name").with_identifier("model_identifier").with_flattened().from_dict(dict_flatenned).update()delete
def delete() -> 'ProvisionAssetBuilder'Delete an existing asset.
This method sets up the ProvisionAssetBuilder instance to delete a specific asset associated with the specified organization and identifier.
Returns:
ProvisionAssetBuilder- The instance of the ProvisionAssetBuilder class itself, allowing for method chaining.
Example:
builder().with_organization('organization_name').with_identifier("identifier").delete()modify
def modify() -> 'ProvisionAssetBuilder'Modify an existing asset.
This method sets up the ProvisionAssetBuilder instance to update a specific asset associated with the specified organization and identifier.
You can update an asset with a flattened format sending a Patch request using the URL above. You must replace {identifier} with the identifier of the asset you want to update. Also, it is sent a boolean parameter, flattened, to allow sending a flattened JSON format
Returns:
ProvisionAssetBuilder- The instance of the ProvisionAssetBuilder class itself, allowing for method chaining.
Example:
dict_flatenned = {"resourceType":{"_value":{"_current":{"value":"entity.asset"}}},
"provision.asset.identifier":{"_value":{"_current":{"value":"EntityTest"}}},
"provision.administration.organization":{"_value":{"_current":{"value":"orgnization_name"}}},
"provision.administration.channel":{"_value":{"_current":{"value":"default_channel"}}},
"provision.administration.serviceGroup":{"_value":{"_current":{"value":"emptyServiceGroup" }}},
builder.with_organization_name("organization_name").with_identifier("model_identifier").with_flattened().from_dict(dict_flatenned).modify()build
def build() -> 'ProvisionAssetBuilder'Finalizes the construction of the asset configuration.
This method prepares the builder to execute the collection by ensuring all necessary configurations are set and validates the overall integrity of the build. It should be called before executing the collection to ensure that the configuration is complete and valid.
The build process involves checking that mandatory fields such as the device identifier are set. It also ensures that method calls that are incompatible with each other (like build and build_execute) are not both used.
Returns:
ProvisionAssetBuilder- Returns itself to allow for method chaining, enabling further actions likeexecute.
Raises:
ValueError- If required configurations are missing or if incompatible methods are used together.
Example:
builder.build()build_execute
def build_execute()Executes the data sets search immediately after building the configuration.
This method is a shortcut that combines building and executing in a single step.
Returns:
dict- A dictionary containing the execution response which includes the status code and potentially other metadata about the execution.
Raises:
ValueError- Ifbuildhas already been called on this builder instance.
Example:
builder.build_execute()execute
def execute() -> str | dict[str, str | int]Execute the configured asset and return the response.
This method executes the operation that has been configured using the builder pattern. It ensures that the build method has been called and that it is the last method invoked before execute. Depending on the configured method (e.g., create, find, update, delete), it calls the appropriate internal execution method.
Returns:
requests.Response- The response object from the executed request.
Raises:
Exception- If thebuildmethod has not been called or if it is not the last method invoked beforeexecute.ValueError- If the configured method is unsupported.
Example:
builder.execute()opengate_data.provision.bulk
opengate_data.provision.bulk.provision_bulk
ProvisionBulkBuilder Objects
class ProvisionBulkBuilder()with_organization_name
def with_organization_name(organization_name: str) -> 'ProvisionBulkBuilder'Specify the organization name.
Arguments:
organization_namestr - The name of the organization name that we want to bulk data.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Example:
builder.with_organization_name('organization_name')with_bulk_action
def with_bulk_action(bulk_action: str) -> 'ProvisionBulkBuilder'Adds the bulk action to the constructor and validates the type.
Arguments:
bulk_actionstr - The bulk action. You can choose between these actions:- CREATE (default)
- UPDATE
- PATCH
- DELETE
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Raises:
ValueError- If the bulk action isn’t one of the mentioned above.
Example:
builder.with_bulk_action('bulk_action')with_bulk_type
def with_bulk_type(bulk_type: str) -> 'ProvisionBulkBuilder'Adds the bulk type to the constructor and validates the type.
Arguments:
bulk_typestr - The bulk type. You can choose between these types:- ENTITIES (default)
- TICKETS
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Raises:
ValueError- If the bulk type isn’t one of the mentioned above.
Example:
builder.with_bulk_type('bulk_type')from_json
def from_json(path: str) -> 'ProvisionBulkBuilder'Loads data as a json file.
Arguments:
pathstr - The path to the json file.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Raises:
FileNotFoundError- If the path isn’t correct or the file doesn’t exist in the selected folder.
Example:
builder.from_json('path_to_json.json')from_csv
def from_csv(path: str) -> 'ProvisionBulkBuilder'Loads data as a csv file.
Arguments:
pathstr - The path to the csv file.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Raises:
FileNotFoundError- If the path isn’t correct or the file doesn’t exist in the selected folder.
Example:
builder.from_csv('path_to_csv.csv')from_excel
def from_excel(path: str) -> 'ProvisionBulkBuilder'Loads data as an Excel file (supports xls and xlsx).
Arguments:
pathstr - The path to the Excel file.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Raises:
FileNotFoundError- If the path isn’t correct or the file doesn’t exist in the selected folder.
Example:
builder.from_excel('path_to_excel.xls')from_dataframe
def from_dataframe(df: pd.DataFrame) -> "ProvisionBulkBuilder"Loads data as a pandas DataFrame. Columns must be the names of the datastreams separated with ‘_’ or ‘.’.
Arguments:
dfpd.DataFrame - The DataFrame variable.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Example:
import pandas as pd
data = {
- `'provision_administration_organization_current_value'` - ['base_organization','test_organization'],
- `'provision_device_location_current_value_position_type'` - ['Point','Other_Point'],
- `'provision_device_location_current_value_position_coordinates'` - [[-3.7028,40.41675],[-5.7028,47.41675]],
- `'provision_device_location_current_value_postal'` - ['28013','28050']
}
df = pd.DataFrame(df)
builder.from_dataframe(df)from_dict
def from_dict(dct: dict[str, Any]) -> "ProvisionBulkBuilder"Loads data as a python dictionary (same structure as ‘from_json’).
Arguments:
dctdict - The dictionary variable.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Example:
builder.from_dict({ … “entities”: [ … { … “provision”: { … “administration”: { … “organization”: {"_current": {“value”: “my_org”}} … }, … “asset”: { … “identifier”: {"_current": {“value”: “asset_123”}} … } … } … } … ] … })
build
def build() -> 'ProvisionBulkBuilder'Finalizes the construction of the provision bulk configuration.
This method prepares the builder to execute the request by ensuring all necessary configurations are set and validates the overall integrity of the build. It should be called before executing the request to ensure that the configuration is complete and valid.
The build process involves checking that mandatory fields such as the organization name are set. It also ensures that method calls that are incompatible with each other (like build and build_execute) are not both used.
Returns:
IotCollectionBuilder- Returns itself to allow for method chaining, enabling further actions likeexecute.
Raises:
ValueError- If required configurations are missing or if incompatible methods are used together.
Example:
builder.build()build_execute
def build_execute(include_payload=False)Executes the provision bulk immediately after building the configuration.
This method is a shortcut that combines building and executing in a single step. It should be used when you want to build and execute the configuration without modifying the builder state in between these operations.
It first validates the build configuration and then executes the request if the validation is successful.
Arguments:
include_payloadbool - Determine if the payload should be included in the response.
Returns:
dict- A dictionary containing the execution response which includes the status code and potentially other metadata about the execution.
Raises:
ValueError- Ifbuildhas already been called on this builder instance, indicating thatbuild_executeis being incorrectly used afterbuild.Exception- If there are issues during the execution process, including network or API errors.
Example:
response = builder.build_execute()execute
def execute(include_payload=False)Executes the provision bulk based on the current configuration of the builder.
Arguments:
include_payloadbool - Determine if the payload should be included in the response.
Returns:
Dict- A dictionary containing the execution response which includes the status code and, optionally, the payload. If an error occurs, a string describing the error is returned.
Raises:
Exception- Ifbuild()has not been called beforeexecute(), or if it was not the last method invoked prior toexecute().
Example:
builder.build()
response = builder.execute(True)opengate_data.provision.devices
opengate_data.provision.devices.provision_device
ProvisionDeviceBuilder
ProvisionDeviceBuilder Objects
class ProvisionDeviceBuilder()Class Provision builder
with_organization_name
def with_organization_name(organization_name: str) -> 'ProvisionDeviceBuilder'Specify the organization for the device.
Arguments:
organization_namestr - The organization for the device.
Returns:
ProvisionDeviceBuilder- Returns self for chaining.
Example:
builder.with_organization_name('organization_name')with_identifier
def with_identifier(identifier: str) -> 'ProvisionDeviceBuilder'Specify the identifier for the device.
Arguments:
identifierstr - The identifier for the device.
Returns:
ProvisionDeviceBuilder- Returns self for chaining.
Example:
builder.with_identifier('identifier')with_flattened
def with_flattened() -> 'ProvisionDeviceBuilder'Flatten the data
Returns:
ProvisionDeviceBuilder- Returns itself to allow for method chaining.
Example:
builder.with_flattened()with_utc
def with_utc() -> 'ProvisionDeviceBuilder'Set UTC flag
Returns:
ProvisionDeviceBuilder- Returns itself to allow for method chaining.
Example:
builder.with_utc()with_provision_identifier
def with_provision_identifier(identifier: str) -> 'ProvisionDeviceBuilder'Set provision identifier
Returns:
ProvisionDeviceBuilder- Returns itself to allow for method chaining.
Example:
builder.with_provision_identifier("identifier")with_provision_channel
def with_provision_channel(channel: str) -> 'ProvisionDeviceBuilder'Set provision channel
Returns:
ProvisionDeviceBuilder- Returns itself to allow for method chaining.
Example:
builder.with_provision_channel("channel")with_provision_service_group
def with_provision_service_group(
service_group: str) -> 'ProvisionDeviceBuilder'Set provision servicegroup
Returns:
ProvisionDeviceBuilder- Returns itself to allow for method chaining.
Example:
builder.with_provision_service_group("emptyServiceGroup")with_provision_organization
def with_provision_organization(organization: str) -> 'ProvisionDeviceBuilder'Set provision organization
Returns:
ProvisionDeviceBuilder- Returns itself to allow for method chaining.
Example:
builder.with_provision_service_group("organization_name")add_provision_datastream_value
def add_provision_datastream_value(datastream: str,
value: Any) -> 'ProvisionDeviceBuilder'Add a datastream value to the payload.
Arguments:
datastreamstr - The datastream identifier.valueAny - The value to be added. It Can be a primitive type or a complex object.
Returns:
ProvisionDeviceBuilder- Returns itself to allow for method chaining.
Example:
location_value = {
- `"position"` - {
- `"coordinates"` - [
-3.66131084,
40.458442
]
}
}
builder.add_provision_datastream_value("provision.device.location", location_value)
builder.add_provision_datastream_value("provision.device.name", "Name")from_dict
def from_dict(dct: dict[str, Any]) -> 'ProvisionDeviceBuilder'Loads data as a python dictionary. If you want to enter the dictionary in flattened mode, you need to use with_flattened().
Arguments:
dctdict - The dictionary variable.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Example:
# Mode flattened
builder.with_flattened().from_dict(
{"resourceType":{"_value":{"_current":{"value":"entity.device"}}},
"provision.device.identifier":{"_value":{"_current":{"value":"identifier"}}},
"provision.administration.organization":{"_value":{"_current":{"value":"organization"}}},
"provision.administration.channel":{"_value":{"_current":{"value":"default_channel"}}},
"provision.administration.serviceGroup":{"_value":{"_current":{"value":"emptyServiceGroup"}}},
"provision.device.location":{"_value":{"_current":{"value":{"position":{"coordinates":[-3.66131084,40.458442]}}}}},
# Mode without flattened
builder.from_dict({
- `"resourceType"` - {
- `"_current"` - {
- `"value"` - "entity.device"
}
},
- `"provision"` - {
- `"administration"` - {
- `"channel"` - {
- `"_current"` - {
- `"value"` - "battery_channel"
}
},
- `"organization"` - {
- `"_current"` - {
- `"value"` - "battery_organization"
}
},
- `"serviceGroup"` - {
- `"_current"` - {
- `"value"` - "emptyServiceGroup"
}
}
},
- `"device"` - {
- `"identifier"` - {
- `"_current"` - {
- `"value"` - "worker_battery_id"
}
}
}
}
})from_dataframe
def from_dataframe(df: pd.DataFrame) -> "ProvisionDeviceBuilder"Loads data as a pandas DataFrame. Columns must be the names of the datastreams separated with ‘_’ or ‘.’.
Arguments:
dfpd.DataFrame - The DataFrame variable.
Returns:
ProvisionBulkBuilder- Returns itself to allow for method chaining.
Example:
import pandas as pd
data = {
- `'provision_administration_organization_current_value'` - ['base_organization','test_organization'],
- `'provision_device_location_current_value_position_type'` - ['Point','Other_Point'],
- `'provision_device_location_current_value_position_coordinates'` - [[-3.7028,40.41675],[-5.7028,47.41675]],
- `'provision_device_location_current_value_postal'` - ['28013','28050']
}
df = pd.DataFrame(df)
builder.from_dataframe(df)find_one
def find_one() -> 'ProvisionDeviceBuilder'Retrieve a single device.
This method sets up the ProvisionDeviceBuilder instance to retrieve a specific assey associated with the specified organization and identifier.
Returns:
ProvisionDeviceBuilder- The instance of the ProvisionDeviceBuilder class itself, allowing for method chaining.
Example:
builder.with_organization_name("organization_name").with_identifier("model_identifier").find_one()create
def create() -> 'ProvisionDeviceBuilder'Initiates the creation process of a new device.
This method prepares the ProvisionDeviceBuilder instance to create a new device.
Returns:
ProvisionDeviceBuilder- The instance of the ProvisionDeviceBuilder class itself, allowing for method chaining.
Example:
builder.with_organization_name("organization_name")
.with_provision_identifier("provision_identifier") .with_provision_organization("provision_organization") .with_provision_channel("provision_channel") .with_provision_service_group("provision_service_group") .add_provision_datastream_value("provision.device.name", "Name") .create()update
def update() -> 'ProvisionDeviceBuilder'Update an existing device.
This method sets up the ProvisionDeviceBuilder instance to update a specific device associated with the specified organization and identifier.
You can update a device with a flattened format sending a PUT request using the URL above. You must replace {identifier} with the identifier of the device you want to update. Also, it is sent a boolean parameter, flattened, to allow sending a flattened JSON format
Returns:
ProvisionDeviceBuilder- The instance of the ProvisionDeviceBuilder class itself, allowing for method chaining.
Example:
dict_flatenned = {“resourceType”:{"_value":{"_current":{“value”:“entity.device”}}}, “provision.device.identifier”:{"_value":{"_current":{“value”:“ManuEntityTests”}}}, “provision.administration.organization”:{"_value":{"_current":{“value”:“orgnization_name”}}}, “provision.administration.channel”:{"_value":{"_current":{“value”:“default_channel”}}}, “provision.administration.serviceGroup”:{"_value":{"_current":{“value”:“emptyServiceGroup”}}},
builder.with_organization_name("organization_name").with_identifier("model_identifier").with_flattened().from_dict(dict_flatenned).update()delete
def delete() -> 'ProvisionDeviceBuilder'Delete an existing device.
This method sets up the ProvisionDeviceBuilder instance to delete a specific device associated with the specified organization and identifier.
Returns:
ProvisionDeviceBuilder- The instance of the ProvisionDeviceBuilder class itself, allowing for method chaining.
Example:
builder().with_organization('organization_name').with_identifier("identifier").delete()build
def build() -> 'ProvisionDeviceBuilder'Finalizes the construction of the device configuration.
This method prepares the builder to execute the collection by ensuring all necessary configurations are set and validates the overall integrity of the build. It should be called before executing the collection to ensure that the configuration is complete and valid.
The build process involves checking that mandatory fields such as the device identifier are set. It also ensures that method calls that are incompatible with each other (like build and build_execute) are not both used.
Returns:
ProvisionDeviceBuilder- Returns itself to allow for method chaining, enabling further actions likeexecute.
Raises:
ValueError- If required configurations are missing or if incompatible methods are used together.
Example:
builder.build()build_execute
def build_execute()Executes the data sets search immediately after building the configuration.
This method is a shortcut that combines building and executing in a single step.
Returns:
dict- A dictionary containing the execution response which includes the status code and potentially other metadata about the execution.
Raises:
ValueError- Ifbuildhas already been called on this builder instance.
Example:
builder.build_execute()execute
def execute() -> str | dict[str, str | int]Execute the configured device and return the response.
This method executes the operation that has been configured using the builder pattern. It ensures that the build method has been called and that it is the last method invoked before execute. Depending on the configured method (e.g., create, find, update, delete), it calls the appropriate internal execution method.
Returns:
requests.Response- The response object from the executed request.
Raises:
Exception- If thebuildmethod has not been called or if it is not the last method invoked beforeexecute.ValueError- If the configured method is unsupported.
Example:
builder.execute()opengate_data.provision.processor
opengate_data.provision.processor.provision_processor
ProvisionProcessorBuilder
ProvisionProcessorBuilder Objects
class ProvisionProcessorBuilder()Provision Processor Builder
with_organization_name
def with_organization_name(
organization_name: str) -> 'ProvisionProcessorBuilder'Specify the organization name.
Arguments:
organization_namestr - The name of the organization.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
builder.with_organization_name('organization_name')with_identifier
def with_identifier(
provision_processor_id: str) -> 'ProvisionProcessorBuilder'Specify the identifier for the provision processor.
Arguments:
provision_processor_idstr - The identifier for the pipeline.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
builder.with_identifier('identifier')with_name
def with_name(provision_processor_name: str) -> 'ProvisionProcessorBuilder'Specify the name for the provision processor.
Arguments:
provision_processor_namestr - The name for the provision processor.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
builder.with_name('name')with_bulk_file
def with_bulk_file(bulk_file: str) -> 'ProvisionProcessorBuilder'Specify the file for bulk processing.
Arguments:
bulk_filestr - The path to the file to be uploaded for bulk processing.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
bulk_file_path = os.path.join(os.path.dirname(__file__), 'file.xlsx')
builder.with_bulk_file('bulk_file_path')with_bulk_process_identitifer
def with_bulk_process_identitifer(
bulk_process_id: str) -> 'ProvisionProcessorBuilder'Specify the identifier for the bulk process identifier.
Arguments:
bulk_process_idstr - The identifier for the bulk process.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
builder.with_bulk_process_identitifer('identifier')bulk
def bulk() -> 'ProvisionProcessorBuilder'Configure the builder for bulk provisioning.
This method sets the necessary headers and URL for performing a bulk provisioning operation.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
bulk_file_path = os.path.join(os.path.dirname(__file__), 'file.xlsx')
builder.with_organization_name('organization_name').with_identifier('identifier').with_bulk_file(bulk_file_path).bulk()find_by_name
def find_by_name() -> 'ProvisionProcessorBuilder'Configure the builder to find a provision processor by name.
This method sets the necessary headers and URL for finding a provision processor by its name.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
builder.with_organization_name('organization_name').with_name('provision_processor_name').find_by_name()bulk_status
def bulk_status() -> 'ProvisionProcessorBuilder'Configure the builder to check the status of a bulk process.
This method sets the necessary headers and URL for checking the status of a bulk process.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
builder.with_organization_name('organization_name').with_bulk_process_identitifer('bulk_process_id').bulk_status()bulk_details
def bulk_details() -> 'ProvisionProcessorBuilder'Configure the builder to get the details of a bulk process.
This method sets the necessary headers and URL for retrieving the details of a bulk process.
Returns:
ProvisionProcessorBuilder- Returns self for chaining.
Example:
builder.with_organization_name('organization_name').with_bulk_process_identitifer('bulk_process_id').bulk_details()build
def build() -> 'ProvisionProcessorBuilder'Finalizes the construction of the IoT collection configuration.
This method prepares the builder to execute the collection by ensuring all necessary configurations are set and validates the overall integrity of the build. It should be called before executing the collection to ensure that the configuration is complete and valid.
The build process involves checking that mandatory fields such as the device identifier are set. It also ensures that method calls that are incompatible with each other (like build and build_execute) are not both used.
Returns:
ProvisionProcessorBuilder- Returns itself to allow for method chaining, enabling further actions likeexecute.
Raises:
ValueError- If required configurations are missing or if incompatible methods are used together.
Example:
builder.build()build_execute
def build_execute()Executes the data sets search immediately after building the configuration.
This method is a shortcut that combines building and executing in a single step.
Returns:
dict- A dictionary containing the execution response which includes the status code and potentially other metadata about the execution.
Raises:
ValueError- Ifbuildhas already been called on this builder instance.
Example:
builder.build_execute()execute
def execute() -> requests.ResponseExecute the configured operation and return the response.
This method executes the operation that has been configured using the builder pattern. It ensures that the build method has been called and that it is the last method invoked before execute. Depending on the configured method (e.g., create, find, update, delete), it calls the appropriate internal execution method.
Returns:
requests.Response- The response object from the executed request.
Raises:
Exception- If thebuildmethod has not been called or if it is not the last method invoked beforeexecute.ValueError- If the configured method is unsupported.
Example:
builder.build_execute()