protected override void ProcessRecord()
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(Base64AuthCreds))
                {
                    var hash = new Hashtable();
                    hash["x-csod-session-token"] = Session.Token;
                    hash["Authorization"]        = string.Format("Basic {0}", Base64AuthCreds);

                    WriteObject(hash);
                }
                else
                {
                    var time   = DateTime.HasValue ? DateTime.Value : System.DateTime.UtcNow;
                    var uri    = new Uri(Url);
                    var method = Method.ToUpper();

                    var hash = new Hashtable();
                    hash["x-csod-date"]          = time.ToString("yyyy-MM-ddTHH:mm:ss.000");
                    hash["x-csod-session-token"] = Session.Token;

                    var stringToSign = RestImplementation.ConstructStringToSign(method, hash, uri.AbsolutePath);
                    var sig          = RestImplementation.SignString512(stringToSign, Session.Secret);
                    hash["x-csod-signature"] = sig;

                    WriteObject(hash);
                }
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex,
                                           ex.GetType().Name,
                                           ErrorCategory.InvalidOperation,
                                           this.GetType().Name));
            }
        }
        protected override void ProcessRecord()
        {
            try
            {
                if (string.IsNullOrWhiteSpace(Alias))
                {
                    Alias = Guid.NewGuid().ToString();
                }
                string uri     = string.Format(_uri, UserName, Alias);
                var    domain  = new Uri("https://" + Domain);
                var    getUri  = new Uri(domain, uri);
                var    session = RestImplementation.PostWithKey(getUri, ApiKey, ApiSecret, DateTime.UtcNow);

                // Return from the cmdlet
                WriteObject(session);
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex,
                                           ex.GetType().Name,
                                           ErrorCategory.InvalidOperation,
                                           this.GetType().Name));
            }
        }
Пример #3
0
 public Task MarkAsReadAsync(RestRequestOptions options = null)
 => RestImplementation.MarkAsReadAsync(this, options);