/// <summary> /// This method sets a container as public on the CDN /// </summary> /// <example> /// <code> /// UserCredentials userCredentials = new UserCredentials("username", "api key"); /// IConnection connection = new Connection(userCredentials); /// Uri containerPublicUrl = connection.MarkContainerAsPublic("container name", 12345); /// </code> /// </example> /// <param name="containerName">The name of the container to mark public</param> /// <param name="timeToLiveInSeconds">The maximum time (in seconds) content should be kept alive on the CDN before it checks for freshness.</param> /// <returns>A string representing the URL of the public container or null</returns> /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception> public Uri MarkContainerAsPublic(string containerName, int timeToLiveInSeconds) { if (string.IsNullOrEmpty(containerName)) throw new ArgumentNullException(); Log.Info(this, "Marking container '" + containerName + "' as public with TTL of " + timeToLiveInSeconds + " seconds for user " + _usercreds.Username); try { var request = new MarkContainerAsPublic(CdnManagementUrl, containerName, timeToLiveInSeconds); var response = _requestfactory.Submit(request, AuthToken); return response == null ? null : new Uri(response.Headers[Constants.X_CDN_URI]); } catch (WebException we) { Log.Error(this, "Error marking container '" + containerName + "' as public with TTL of " + timeToLiveInSeconds + " seconds for user " + _usercreds.Username, we); var response = (HttpWebResponse)we.Response; if (response != null && response.StatusCode == HttpStatusCode.Unauthorized) throw new AuthenticationFailedException("You do not have permission to request the list of public containers."); throw; } }
private Uri markContainerAsPublic(string containerName, int timeToLiveInSeconds) { var request = new MarkContainerAsPublic(CdnManagementUrl, containerName, timeToLiveInSeconds); var response = _requestfactory.Submit(request, AuthToken); return response == null ? null : new Uri(response.Headers[Constants.X_CDN_URI]); }
public void setup() { markContainerAsPublic = new MarkContainerAsPublic("http://cdnmanagementurl", "containername"); _mockrequest = new Mock<ICloudFilesRequest>(); }
public void setup() { markContainerAsPublic = new MarkContainerAsPublic("http://cdnmanagementurl", "authtoken", "containername"); }