diff --git a/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs b/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs index 103b8430b..92ec71cb9 100644 --- a/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs +++ b/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs @@ -15,14 +15,18 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; -using Duplicati.Library.Interface; using System.Collections.Generic; +using System.Collections.Specialized; using System.Net; -using Duplicati.Library.Utility; -using Newtonsoft.Json; using System.Text; + +using Newtonsoft.Json; + using Duplicati.Library.Backend.GoogleServices; -using System.Collections.Specialized; +using Duplicati.Library.Interface; +using Duplicati.Library.Utility; + + namespace Duplicati.Library.Backend.GoogleCloudStorage { @@ -34,36 +38,10 @@ namespace Duplicati.Library.Backend.GoogleCloudStorage private const string LOCATION_OPTION = "gcs-location"; private const string STORAGECLASS_OPTION = "gcs-storage-class"; - - // From: https://cloud.google.com/storage/docs/bucket-locations - public static readonly KeyValuePair[] KNOWN_GCS_LOCATIONS = new KeyValuePair[] { - new KeyValuePair("(default)", null), - new KeyValuePair("Europe", "EU"), - new KeyValuePair("United States", "US"), - new KeyValuePair("Asia", "ASIA"), - - //Regional buckets: https://cloud.google.com/storage/docs/regional-buckets - new KeyValuePair("Eastern Asia-Pacific", "ASIA-EAST1"), - new KeyValuePair("Central United States 1", "US-CENTRAL1"), - new KeyValuePair("Central United States 2", "US-CENTRAL2"), - new KeyValuePair("Eastern United States 1", "US-EAST1"), - new KeyValuePair("Eastern United States 2", "US-EAST2"), - new KeyValuePair("Eastern United States 3", "US-EAST3"), - new KeyValuePair("Western United States", "US-WEST1"), - }; - - - public static readonly KeyValuePair[] KNOWN_GCS_STORAGE_CLASSES = new KeyValuePair[] { - new KeyValuePair("(default)", null), - new KeyValuePair("Standard", "STANDARD"), - new KeyValuePair("Durable Reduced Availability (DRA)", "DURABLE_REDUCED_AVAILABILITY"), - new KeyValuePair("Nearline", "NEARLINE"), - }; - private string m_bucket; private string m_prefix; private string m_project; - private OAuthHelper m_oauth; + private readonly OAuthHelper m_oauth; private string m_location; private string m_storage_class; @@ -250,9 +228,9 @@ namespace Duplicati.Library.Backend.GoogleCloudStorage StringBuilder locations = new StringBuilder(); StringBuilder storageClasses = new StringBuilder(); - foreach (KeyValuePair s in KNOWN_GCS_LOCATIONS) + foreach (KeyValuePair s in WebApi.GoogleCloudServices.KNOWN_GCS_LOCATIONS) locations.AppendLine(string.Format("{0}: {1}", s.Key, s.Value)); - foreach (KeyValuePair s in KNOWN_GCS_STORAGE_CLASSES) + foreach (KeyValuePair s in WebApi.GoogleCloudServices.KNOWN_GCS_STORAGE_CLASSES) storageClasses.AppendLine(string.Format("{0}: {1}", s.Key, s.Value)); return new List(new ICommandLineArgument[] { diff --git a/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs b/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs index 87f71852b..33ae3e78a 100644 --- a/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs +++ b/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs @@ -19,13 +19,13 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Net; +using System.Text; using Newtonsoft.Json; using Duplicati.Library.Backend.GoogleServices; using Duplicati.Library.Interface; using Duplicati.Library.Utility; -using System.Text; namespace Duplicati.Library.Backend.GoogleDrive { diff --git a/Duplicati/Library/Backend/GoogleServices/WebApi.cs b/Duplicati/Library/Backend/GoogleServices/WebApi.cs index f5f12581b..921e89aa9 100644 --- a/Duplicati/Library/Backend/GoogleServices/WebApi.cs +++ b/Duplicati/Library/Backend/GoogleServices/WebApi.cs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System.Collections.Generic; using System.Collections.Specialized; namespace Duplicati.Library.Backend.WebApi @@ -40,6 +41,33 @@ namespace Duplicati.Library.Backend.WebApi class GoogleCloudServices : Google { + + + // From: https://cloud.google.com/storage/docs/bucket-locations + public static readonly KeyValuePair[] KNOWN_GCS_LOCATIONS = new KeyValuePair[] { + new KeyValuePair("(default)", null), + new KeyValuePair("Europe", "EU"), + new KeyValuePair("United States", "US"), + new KeyValuePair("Asia", "ASIA"), + + //Regional buckets: https://cloud.google.com/storage/docs/regional-buckets + new KeyValuePair("Eastern Asia-Pacific", "ASIA-EAST1"), + new KeyValuePair("Central United States 1", "US-CENTRAL1"), + new KeyValuePair("Central United States 2", "US-CENTRAL2"), + new KeyValuePair("Eastern United States 1", "US-EAST1"), + new KeyValuePair("Eastern United States 2", "US-EAST2"), + new KeyValuePair("Eastern United States 3", "US-EAST3"), + new KeyValuePair("Western United States", "US-WEST1"), + }; + + + public static readonly KeyValuePair[] KNOWN_GCS_STORAGE_CLASSES = new KeyValuePair[] { + new KeyValuePair("(default)", null), + new KeyValuePair("Standard", "STANDARD"), + new KeyValuePair("Durable Reduced Availability (DRA)", "DURABLE_REDUCED_AVAILABILITY"), + new KeyValuePair("Nearline", "NEARLINE"), + }; + public static class Url { public const string API = "https://www.googleapis.com/storage/v1"; public const string UPLOAD = "https://www.googleapis.com/upload/storage/v1";