// Copyright (C) 2024, The Duplicati Team // https://duplicati.com, hello@duplicati.com // // 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. using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace Duplicati.Library.Interface { /// /// The interface all backends must implement. /// The classes that implements this interface MUST also /// implement a default constructor and a constructor that /// has the signature new(string url, Dictionary<string, string> options). /// The default constructor is used to construct an instance /// so the DisplayName and other values can be read. /// The other constructor is used to do the actual work. /// An instance is never reused. /// public interface IBackend : IDynamicModule, IDisposable { /// /// The localized name to display for this backend /// string DisplayName { get; } /// /// The protocol key, eg. ftp, http or ssh /// string ProtocolKey { get; } /// /// Enumerates a list of files found on the remote location /// /// The list of files IEnumerable List(); /// /// Puts the content of the file to the url passed /// /// The remote filename, relative to the URL /// The local filename /// Token to cancel the operation. Task PutAsync(string remotename, string filename, CancellationToken cancelToken); /// /// Downloads a file with the remote data /// /// The remote filename, relative to the URL /// The local filename void Get(string remotename, string filename); /// /// Deletes the specified file /// /// The remote filename, relative to the URL void Delete(string remotename); /// /// A localized description of the backend, for display in the usage information /// string Description { get; } /// /// The DNS names used to resolve the IP addresses for this backend /// string[] DNSName { get; } /// /// The purpose of this method is to test the connection to the remote backend. /// If any problem is encountered, this method should throw an exception. /// If the encountered problem is a missing target "folder", /// this method should throw a . /// void Test(); /// /// The purpose of this method is to create the underlying "folder". /// This method will be invoked if the method throws a /// . /// Backends that have no "folder" concept should not throw /// a during , /// and this method should throw a . /// void CreateFolder(); } }