public void setup()
 {
     getPublicContainerInformation = new GetPublicContainerInformation("http://storageurl", "containername");
 }
        /// <summary>
        /// Retrieves a Container object containing the public CDN information
        /// </summary>
        /// <example>
        /// <code>
        /// UserCredentials userCredentials = new UserCredentials("username", "api key");
        /// IConnection connection = new Connection(userCredentials);
        /// Container container = connection.GetPublicContainerInformation("container name")
        /// </code>
        /// </example>
        /// <param name="containerName">The name of the container to query about</param>
        /// <returns>An instance of Container with appropriate CDN information or null</returns>
        /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
        public Container GetPublicContainerInformation(string containerName)
        {
            if (string.IsNullOrEmpty(containerName))
                throw new ArgumentNullException();

            Log.Info(this, "Getting public container "
                    + containerName + " information for user "
                    + _usercreds.Username);

            try
            {
                var request = new GetPublicContainerInformation(CdnManagementUrl, containerName);
                var response = _requestfactory.Submit(request, AuthToken);
                return response == null ?
                    null
                    : new Container(containerName) { CdnUri = response.Headers[Constants.X_CDN_URI], TTL = Convert.ToInt32(response.Headers[Constants.X_CDN_TTL]) };
            }
            catch (WebException ex)
            {
                Log.Error(this, "Error getting public container "
                    + containerName + " information for user "
                    + _usercreds.Username, ex);

                var webResponse = (HttpWebResponse)ex.Response;
                if (webResponse != null && webResponse.StatusCode == HttpStatusCode.Unauthorized)
                    throw new UnauthorizedAccessException("Your authorization credentials are invalid or have expired.");
                if (webResponse != null && webResponse.StatusCode == HttpStatusCode.NotFound)
                    throw new ContainerNotFoundException("The specified container does not exist.");
                throw;
            }
        }
Example #3
0
 private Container getPublicContainerInformation(string containerName)
 {
     var request = new GetPublicContainerInformation(CdnManagementUrl, containerName);
     var response = _requestfactory.Submit(request, AuthToken);
     return response == null ?
                                 null
                : new Container(containerName) { CdnUri = response.Headers[Constants.X_CDN_URI], TTL = Convert.ToInt32(response.Headers[Constants.X_CDN_TTL]) };
 }