Akamai.EdgeGrid.OpenAPI.execute C# (CSharp) Метод

execute() статический приватный Метод

static private execute ( string httpMethod, string apiurl, List headers, string clientToken, string accessToken, string secret, string data, string uploadfile, string outputfile, int maxBodySize, string contentType, bool verbose = false ) : void
httpMethod string
apiurl string
headers List
clientToken string
accessToken string
secret string
data string
uploadfile string
outputfile string
maxBodySize int
contentType string
verbose bool
Результат void
        static void execute(string httpMethod, string apiurl, List<string> headers, string clientToken, string accessToken, string secret, string data, string uploadfile, string outputfile, int? maxBodySize, string contentType, bool verbose = false)
        {
            if (apiurl == null || clientToken == null || accessToken == null || secret == null)
            {
                help();
                return;
            }

            EdgeGridV1Signer signer = new EdgeGridV1Signer(null, maxBodySize);
            ClientCredential credential = new ClientCredential(clientToken, accessToken, secret);

            Stream uploadStream = null;
            if (uploadfile != null)
                uploadStream = new FileInfo(uploadfile).OpenRead();
            else if (data != null)
                uploadStream = new MemoryStream(data.ToByteArray());

            var uri = new Uri(apiurl);
            var request = WebRequest.Create(uri);

            foreach (string header in headers) request.Headers.Add(header);
            request.Method = httpMethod;

            Stream output = Console.OpenStandardOutput();
            if (outputfile != null)
                output = new FileInfo(outputfile).OpenWrite();

            if (verbose)
            {
                signer.Sign(request, credential, uploadStream);
                Console.WriteLine("Authorization: {0}", request.Headers.Get("Authorization"));
                Console.WriteLine();
            }

            using (var result = signer.Execute(request, credential, uploadStream))
            {
                using (output)
                {
                    using (result)
                    {
                        byte[] buffer = new byte[1024*1024];
                        int bytesRead = 0;

                        while ((bytesRead = result.Read(buffer, 0, buffer.Length)) != 0)
                        {
                            output.Write(buffer, 0, bytesRead);
                        }
                    }
                }
            }
        }