public Task <HttpMonitor> GetByIdAsync(HttpMonitorId id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var uri     = _configs.DocumentCollectionUri;
            var options = new FeedOptions()
            {
                MaxItemCount = 1
            };

            var querySpec = new SqlQuerySpec
            {
                QueryText  = "select * from root r where (r.id = @id and r._type = @type)",
                Parameters = new SqlParameterCollection
                {
                    new SqlParameter("@id", id.ToString()),
                    new SqlParameter("@type", DocumentType)
                }
            };

            return(_client.CreateDocumentQuery <HttpMonitor>(uri, querySpec, options)
                   .AsDocumentQuery()
                   .FirstOrDefaultAsync());
        }
        public Task <IEnumerable <HttpMonitorCheck> > GetAsync(HttpMonitorId httpMonitorId)
        {
            if (httpMonitorId == null)
            {
                throw new ArgumentNullException(nameof(httpMonitorId));
            }

            var uri = _configs.DocumentCollectionUri;

            var querySpec = new SqlQuerySpec
            {
                QueryText  = "select * from root r where (r.httpMonitorId = @httpMonitorId and r._type = @type)",
                Parameters = new SqlParameterCollection
                {
                    new SqlParameter("@httpMonitorId", httpMonitorId.ToString()),
                    new SqlParameter("@type", DocumentType)
                }
            };

            return(_client.CreateDocumentQuery <HttpMonitorCheck>(uri, querySpec)
                   .AsDocumentQuery()
                   .ToEnumerableAsync());
        }
        public async Task DeleteAsync(HttpMonitorId id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var uri = _configs.DocumentUri(id.ToString());

            try
            {
                // todo: doesn't check type
                await _client.DeleteDocumentAsync(uri);
            }
            catch (DocumentClientException ex)
            {
                // don't throw if document not found
                if (ex.StatusCode != HttpStatusCode.NotFound)
                {
                    throw;
                }
            }
        }