/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Opc.Ua.Di.Server.SoftwareUpdate
{
///
/// Storage abstraction over the software-update package layer
/// defined by OPC 10000-100 ยง10.3. Decouples the DI server's
/// state-machine / file-transfer wiring from the actual backing
/// store (in-memory, disk, network share, container image, ...).
///
///
///
/// Implementations must be safe for concurrent calls. The store
/// is consulted both during normal browse / read operations
/// (read-only) and during the file-transfer pipeline that supplies
/// the package binary to the DI SoftwareLoadingType file
/// node.
///
///
/// The default composes over
/// an so any
/// provider already used for the server's FileSystem mount
/// can also serve software packages.
///
///
public interface ISoftwarePackageStore
{
///
/// Enumerates every package currently known to the store.
///
IAsyncEnumerable ListAsync(CancellationToken cancellationToken = default);
///
/// Returns the package whose
/// matches ; or
/// when no such package exists.
///
ValueTask GetAsync(string packageId, CancellationToken cancellationToken = default);
///
/// Returns when the store contains a
/// package with the supplied id.
///
ValueTask ExistsAsync(string packageId, CancellationToken cancellationToken = default);
///
/// Opens the binary payload of the package for reading.
/// Throws when the package
/// does not exist.
///
ValueTask OpenReadAsync(string packageId, CancellationToken cancellationToken = default);
///
/// Adds a new package or replaces an existing one with the
/// same id. The store records the metadata, then copies
/// into its backing storage and
/// returns the final (with the
/// store's computed size and timestamp).
///
ValueTask AddAsync(
SoftwarePackage metadata,
Stream payload,
CancellationToken cancellationToken = default);
///
/// Removes the package with the supplied id. Returns
/// when a package was removed, or
/// when no matching package existed.
///
ValueTask DeleteAsync(string packageId, CancellationToken cancellationToken = default);
}
}