/// <summary> /// Executes specified transaction. /// </summary> public async Task <AResult <T> > Execute <T>(string action) { var request = _requestFactory.Create(HttpMethod.Post, ApiBaseUri.Transaction, ""); var document = new Dictionary <string, object>(); // required document.Add(ParameterName.Action, action); // required if (_readCollections.Count > 0) { document.Add(ParameterName.Collections + ".read", _readCollections); } // required if (_writeCollections.Count > 0) { document.Add(ParameterName.Collections + ".write", _writeCollections); } // optional if (_waitForSync.HasValue) { document.Add(ParameterName.WaitForSync, _waitForSync.Value); } // optional if (_lockTimeout.HasValue) { document.Add(ParameterName.LockTimeout, _lockTimeout.Value); } // optional if (_transactionParams.Count > 0) { document.Add(ParameterName.Params, _transactionParams); } request.SetBody(document); var response = await _connection.Send(request); var result = new AResult <T>(response); switch (response.StatusCode) { case 200: var body = response.ParseBody <Body <T> >(); result.Success = (body != null); result.Value = body.Result; break; case 400: case 404: case 409: case 500: default: throw new ArangoException(response.Body); } return(result); }
/// <summary> /// Creates new or replaces existing AQL user function with specified name and code. /// </summary> public async Task <AResult <bool> > Register(string name, string code) { var request = _requestFactory.Create(HttpMethod.Post, ApiBaseUri.AqlFunction, ""); var document = new Dictionary <string, object>(); // required document.Add(ParameterName.Name, name); // required document.Add(ParameterName.Code, code); // optional if (_isDeterministic.HasValue) { document.Add(ParameterName.IsDeterministic, _isDeterministic.Value.ToString().ToLower()); } request.SetBody(document); var response = await _connection.Send(request); var result = new AResult <bool>(response); switch (response.StatusCode) { case 200: case 201: result.Success = true; result.Value = true; break; case 400: default: // Arango error break; } return(result); }
private async Task <AResult <T> > Request <T>(HttpMethod httpMethod, string relativeUri, string mount, Stream zip = null) { var request = _requestFactory.Create(httpMethod, relativeUri); request.QueryString.Add("mount", mount); request.Body = zip; var response = await _connection.Send(request); var result = new AResult <T>(response); result.Value = response.ParseBody <T>(); return(result); }
private async Task <AResult <T> > Request <T>(HttpMethod httpMethod, string relativeUri) { var request = _requestFactory.Create(httpMethod, relativeUri); if (_body != null) { request.SetBody(_body); } var response = await _connection.Send(request); var result = new AResult <T>(response); result.Value = response.ParseBody <T>(); return(result); }
internal Task <Response> Send(Request request) { return(_connection.Send(request)); }