Exemple #1
0
        /// <summary>
        /// Get settings from appservice.
        /// </summary>
        /// <param name="client">The Kudu client.</param>
        /// <returns>The appservice settings.</returns>
        /// <example>
        /// <code>
        /// #addin nuget:?package=Cake.Kudu.Client
        ///
        /// string  baseUri     = EnvironmentVariable("KUDU_CLIENT_BASEURI"),
        ///         userName    = EnvironmentVariable("KUDU_CLIENT_USERNAME"),
        ///         password    = EnvironmentVariable("KUDU_CLIENT_PASSWORD");
        ///
        /// IKuduClient kuduClient = KuduClient(
        ///     baseUri,
        ///     userName,
        ///     password);
        ///
        /// ReadOnlyDictionary&lt;string, string&gt; settings = kuduClient.SettingsGet();
        ///
        /// foreach(var setting in settings)
        /// {
        ///     Information(
        ///         "{0}={1}",
        ///         setting.Key,
        ///         setting.Value);
        /// }
        /// </code>
        /// </example>
        public static IReadOnlyDictionary <string, string> SettingsGet(
            this IKuduClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            return(client.HttpGetJsonObject <Dictionary <string, string> >(
                       "/api/settings"));
        }
Exemple #2
0
        /// <summary>
        /// Lists remote resources for a given path.
        /// </summary>
        /// <param name="client">The Kudu client.</param>
        /// <param name="remotePath">The remote directory path.</param>
        /// <returns><see cref="IKuduVFS"/> instance containing remote directory and file paths.</returns>
        /// <example>
        /// <code>
        /// #addin nuget:?package=Cake.Kudu.Client
        ///
        /// string  baseUri     = EnvironmentVariable("KUDU_CLIENT_BASEURI"),
        ///         userName    = EnvironmentVariable("KUDU_CLIENT_USERNAME"),
        ///         password    = EnvironmentVariable("KUDU_CLIENT_PASSWORD");
        ///
        /// IKuduClient kuduClient = KuduClient(
        ///     baseUri,
        ///     userName,
        ///     password);
        ///
        /// DirectoryPath remotePath = "/site/wwwroot";
        ///
        /// IKuduVFS kuduVFS = kuduClient.VFSList(remotePath);
        ///
        /// Information("Directories and files");
        /// foreach(IKuduPath path in kuduVFS.Entries)
        /// {
        ///     Information(
        ///         "Name: {0}, Size: {1}, Created: {2:yyyy-MM-dd HH:mm:ss}, Modified: {3:yyyy-MM-dd HH:mm:ss}, Mime: {4}",
        ///         path.Name,
        ///         path.Size,
        ///         path.Created,
        ///         path.Modified,
        ///         path.Mime);
        /// }
        ///
        /// Information("Directories");
        /// foreach(IKuduDirectoryPath directoryPath in kuduVFS.Directories)
        /// {
        ///     Information(
        ///         "Directory: {0}, Size: {1}, Created: {2:yyyy-MM-dd HH:mm:ss}, Modified: {3:yyyy-MM-dd HH:mm:ss}, Mime: {4}, Path: {5}",
        ///         directoryPath.Name,
        ///         directoryPath.Size,
        ///         directoryPath.Created,
        ///         directoryPath.Modified,
        ///         directoryPath.Mime,
        ///         directoryPath.Path);
        /// }
        ///
        /// Information("Files");
        /// foreach(IKuduFilePath filePath in kuduVFS.Files)
        /// {
        ///     Information(
        ///         "File: {0}, Size: {1}, Created: {2:yyyy-MM-dd HH:mm:ss}, Modified: {3:yyyy-MM-dd HH:mm:ss}, Mime: {4}, Path: {5}",
        ///         filePath.Name,
        ///         filePath.Size,
        ///         filePath.Created,
        ///         filePath.Modified,
        ///         filePath.Mime,
        ///         filePath.Path);
        /// }
        /// </code>
        /// </example>
        // ReSharper disable once InconsistentNaming
        public static IKuduVFS VFSList(
            this IKuduClient client,
            DirectoryPath remotePath)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (remotePath == null)
            {
                throw new ArgumentNullException(nameof(remotePath));
            }

            var paths = client.HttpGetJsonObject <KuduPath[]>(
                EncodeVFSPath(remotePath));

            return(KuduVFS.ToKuduVfs(remotePath, paths));
        }