/// <summary> /// This method retrieves the names of the of the containers made public on the CDN /// </summary> /// <example> /// <code> /// UserCredentials userCredentials = new UserCredentials("username", "api key"); /// IConnection connection = new Connection(userCredentials); /// List{string} containers = connection.GetPublicContainers(); /// </code> /// </example> /// <returns>A list of the public containers</returns> public List<string> GetPublicContainers() { Log.Info(this, "Getting public containers for user " + _usercreds.Username); try { var getPublicContainers = new GetPublicContainers(CdnManagementUrl); var getPublicContainersResponse = _requestfactory.Submit(getPublicContainers, AuthToken); var containerList = getPublicContainersResponse.ContentBody; getPublicContainersResponse.Dispose(); return containerList.ToList(); } catch (WebException we) { Log.Error(this, "Error getting public containers 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; } }
/// <summary> /// This method retrieves the names of the of the containers made public on the CDN /// </summary> /// <example> /// <code> /// UserCredentials userCredentials = new UserCredentials("username", "api key"); /// IConnection connection = new Connection(userCredentials); /// List{string} containers = connection.GetPublicContainers(); /// </code> /// </example> /// <returns>A list of the public containers</returns> public List<string> GetPublicContainers() { Log.Info(this, "Getting public containers for user " + UserCredentials.Username); try { var getPublicContainers = new GetPublicContainers(CdnManagementUrl, AuthToken); var getPublicContainersResponse = new ResponseFactoryWithContentBody<CloudFilesResponseWithContentBody>().Create(new CloudFilesRequest(getPublicContainers)); var containerList = getPublicContainersResponse.ContentBody; getPublicContainersResponse.Dispose(); return containerList; } catch(WebException we) { Log.Error(this, "Error getting public containers for user " + UserCredentials.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; } }
public void setup() { getPublicContainers = new GetPublicContainers("http://cdnmanagementurl"); }
private List<string> getPublicContainers() { var getPublicContainers = new GetPublicContainers(CdnManagementUrl); var getPublicContainersResponse = _requestfactory.Submit(getPublicContainers, AuthToken); var containerList = getPublicContainersResponse.ContentBody; getPublicContainersResponse.Dispose(); return containerList.ToList(); }