using ZB.MOM.WW.ScadaBridge.Commons.Entities.Deployment; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances; using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums; namespace ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories; public interface IDeploymentManagerRepository { // DeploymentRecord /// /// Gets a deployment record by its ID. /// /// The deployment record ID. /// A cancellation token that can be used to cancel the operation. /// The deployment record, or null if not found. Task GetDeploymentRecordByIdAsync(int id, CancellationToken cancellationToken = default); /// /// Gets all deployment records. /// /// A cancellation token that can be used to cancel the operation. /// A read-only list of all deployment records. Task> GetAllDeploymentRecordsAsync(CancellationToken cancellationToken = default); /// /// Gets all deployment records for a specific instance. /// /// The instance ID. /// A cancellation token that can be used to cancel the operation. /// A read-only list of deployment records for the instance. Task> GetDeploymentsByInstanceIdAsync(int instanceId, CancellationToken cancellationToken = default); /// /// Gets the current deployment status for an instance. /// /// The instance ID. /// A cancellation token that can be used to cancel the operation. /// The current deployment record, or null if no deployment exists. Task GetCurrentDeploymentStatusAsync(int instanceId, CancellationToken cancellationToken = default); /// /// Gets a deployment record by deployment ID. /// /// The deployment ID. /// A cancellation token that can be used to cancel the operation. /// The deployment record, or null if not found. Task GetDeploymentByDeploymentIdAsync(string deploymentId, CancellationToken cancellationToken = default); /// /// Adds a new deployment record. /// /// The deployment record to add. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task AddDeploymentRecordAsync(DeploymentRecord record, CancellationToken cancellationToken = default); /// /// Updates an existing deployment record. /// /// The deployment record to update. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task UpdateDeploymentRecordAsync(DeploymentRecord record, CancellationToken cancellationToken = default); /// /// Deletes a deployment record by ID, enforcing optimistic concurrency against the /// supplied . The caller MUST pass the /// RowVersion it last observed on the record so EF emits /// DELETE ... WHERE Id = @id AND RowVersion = @prior. A concurrent edit /// surfaces as /// on , matching the documented /// "Optimistic concurrency is used on deployment status records" design rule. /// /// The deployment record ID to delete. /// The RowVersion the caller observed; used as the optimistic-concurrency token. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task DeleteDeploymentRecordAsync(int id, byte[] expectedRowVersion, CancellationToken cancellationToken = default); // SystemArtifactDeploymentRecord /// /// Gets a system artifact deployment record by ID. /// /// The system artifact deployment record ID. /// A cancellation token that can be used to cancel the operation. /// The system artifact deployment record, or null if not found. Task GetSystemArtifactDeploymentByIdAsync(int id, CancellationToken cancellationToken = default); /// /// Gets all system artifact deployment records. /// /// A cancellation token that can be used to cancel the operation. /// A read-only list of all system artifact deployment records. Task> GetAllSystemArtifactDeploymentsAsync(CancellationToken cancellationToken = default); /// /// Adds a new system artifact deployment record. /// /// The system artifact deployment record to add. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task AddSystemArtifactDeploymentAsync(SystemArtifactDeploymentRecord record, CancellationToken cancellationToken = default); /// /// Updates an existing system artifact deployment record. /// /// The system artifact deployment record to update. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task UpdateSystemArtifactDeploymentAsync(SystemArtifactDeploymentRecord record, CancellationToken cancellationToken = default); /// /// Deletes a system artifact deployment record by ID. /// /// The system artifact deployment record ID to delete. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task DeleteSystemArtifactDeploymentAsync(int id, CancellationToken cancellationToken = default); // WP-8: DeployedConfigSnapshot /// /// Gets the deployed config snapshot for an instance. /// /// The instance ID. /// A cancellation token that can be used to cancel the operation. /// The deployed config snapshot, or null if not found. Task GetDeployedSnapshotByInstanceIdAsync(int instanceId, CancellationToken cancellationToken = default); /// /// Adds a new deployed config snapshot. /// /// The deployed config snapshot to add. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task AddDeployedSnapshotAsync(DeployedConfigSnapshot snapshot, CancellationToken cancellationToken = default); /// /// Updates an existing deployed config snapshot. /// /// The deployed config snapshot to update. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task UpdateDeployedSnapshotAsync(DeployedConfigSnapshot snapshot, CancellationToken cancellationToken = default); /// /// Deletes the deployed config snapshot for an instance. /// /// The instance ID. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task DeleteDeployedSnapshotAsync(int instanceId, CancellationToken cancellationToken = default); // Instance lookups for deployment pipeline /// /// Gets an instance by ID. /// /// The instance ID. /// A cancellation token that can be used to cancel the operation. /// The instance, or null if not found. Task GetInstanceByIdAsync(int instanceId, CancellationToken cancellationToken = default); /// /// Gets an instance by unique name. /// /// The unique instance name. /// A cancellation token that can be used to cancel the operation. /// The instance, or null if not found. Task GetInstanceByUniqueNameAsync(string uniqueName, CancellationToken cancellationToken = default); /// /// Updates an instance. /// /// The instance to update. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task UpdateInstanceAsync(Instance instance, CancellationToken cancellationToken = default); /// /// Removes an instance and everything that depends on it: deployment /// records, deployed config snapshot, attribute/alarm overrides, and /// connection bindings. /// /// The instance ID to delete. /// A cancellation token that can be used to cancel the operation. /// A task representing the asynchronous operation. Task DeleteInstanceAsync(int instanceId, CancellationToken cancellationToken = default); /// /// Saves all pending changes to the database. /// /// A cancellation token that can be used to cancel the operation. /// A task representing the number of entities saved. Task SaveChangesAsync(CancellationToken cancellationToken = default); }