public virtual AccountResponse GetCDNAccount(string url, string token, Dictionary <string, string> headers, Dictionary <string, string> query, bool full_listing) { headers["X-Auth-Token"] = token; query["format"] = "xml"; var request = _http_factory.GetHttpRequest("GET", url, headers, query); var response = request.GetResponse(); var reader = new XmlTextReader(response.ResponseStream); var containers = new List <Dictionary <string, string> >(); var info = new Dictionary <string, string>(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name != "xml" && reader.Name != "container" && reader.Name != "account") { var key = reader.Name; reader.Read(); Console.WriteLine(key + ":" + reader.Value); info.Add(key, reader.Value); } break; case XmlNodeType.EndElement: if (reader.Name == "container") { containers.Add(info); info = new Dictionary <string, string>(); } break; } } if (full_listing) { do { int nmarker = containers.Count - 1; query["marker"] = containers[nmarker]["name"]; var tmp = GetCDNAccount(url, token, headers, query, false); if (tmp.Containers.Count > 0) { containers.AddRange(tmp.Containers); } else { break; } } while (true); } response.Close(); return(new AccountResponse(response.Headers, response.Reason, response.Status, containers)); }
/// <summary> /// Gets Your Auth Info. /// </summary> /// <returns> /// <paramref><name>Openstack.Swift.AuthResponse</name></paramref> </returns> /// <param name='url'> /// <see cref="string"/> of the Storage Url you would like to make a request to. /// </param> /// <param name='user'> /// <see cref="string"/> Your username /// </param> /// <param name='key'> /// <see cref="string"/> Your ApiKey /// </param> /// <param name='headers'> /// <see><cref>T:System.Collections.Generic.Dictionary{string,string}</cref></see> Custom headers for your request. /// </param> /// <param name='query'> /// <see><cref>T:System.Collections.Generic.Dictionary{string,string}</cref></see> Custom query strings used for your request. /// </param> /// <param name='snet'> /// <see cref="System.Boolean"/> /// </param> public override AuthResponse GetAuth(string url, string user, string key, Dictionary <string, string> headers, Dictionary <string, string> query, bool snet) { headers["X-Auth-User"] = user; headers["X-Auth-Key"] = key; IHttpRequest request = _http_factory.GetHttpRequest("GET", url, headers, query); IHttpResponse response = request.GetResponse(); headers = response.Headers; if (snet) { var uri = new Uri(headers["x-storage-url"]); headers["x-storage-url"] = uri.Scheme + "://snet-" + uri.Host + uri.PathAndQuery; } response.Close(); return(new AuthResponse(headers, response.Reason, response.Status)); }