Ejemplo n.º 1
0
 /// <summary>
 /// Destroy invalidates a given session
 /// </summary>
 /// <param name="id">The session ID to destroy</param>
 /// <param name="q">Customized write options</param>
 /// <returns>A write result containing the result of the session destruction</returns>
 public Task <WriteResult <bool> > Destroy(string id, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put <object, bool>(string.Format("/v1/session/destroy/{0}", id), null, q).Execute(ct));
 }
Ejemplo n.º 2
0
        public async Task <WriteResult <string> > Create(PreparedQueryDefinition query, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Post <PreparedQueryDefinition, PreparedQueryCreationResult>("/v1/query", query, q).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <string>(res, res.Response.ID));
        }
Ejemplo n.º 3
0
 public Task <WriteResult> Update(PreparedQueryDefinition query, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put(string.Format("/v1/query/{0}", query.ID), query, q).Execute(ct));
 }
Ejemplo n.º 4
0
 internal PostRequest <TIn, TOut> Post <TIn, TOut>(string path, TIn body, WriteOptions opts = null)
 {
     return(new PostRequest <TIn, TOut>(this, path, body, opts ?? WriteOptions.Default));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Deletes an existing ACL Role from Consul
        /// </summary>
        /// <param name="id">The ID of the ACL Role to delete</param>
        /// <param name="writeOptions">Customised write options</param>
        /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
        /// <returns>Success (true) or failure (false)</returns>
        public async Task <WriteResult <bool> > Delete(string id, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.DeleteReturning <bool>($"/v1/acl/role/{id}", writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <bool>(res, res.Response));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Deregister an existing catalog item
 /// </summary>
 /// <param name="reg">A catalog deregistration</param>
 /// <param name="q">Customized write options</param>
 /// <returns>An empty write result</returns>
 public WriteResult Deregister(CatalogDeregistration reg, WriteOptions q)
 {
     return(_client.CreateInWrite <CatalogDeregistration>("/v1/catalog/deregister", reg, q)
            .Execute());
 }
Ejemplo n.º 7
0
 internal EmptyPutRequest <TOut> EmptyPut <TOut>(string path, WriteOptions opts = null)
 {
     return(new EmptyPutRequest <TOut>(this, path, opts ?? WriteOptions.Default));
 }
Ejemplo n.º 8
0
 public Task <WriteResult> Restore(Stream s, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put("/v1/snapshot", s, q).Execute(ct));
 }
Ejemplo n.º 9
0
        public async Task <WriteResult <string> > Create(ACLEntry acl, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <ACLEntry, ACLCreationResult>("/v1/acl/create", acl, q).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <string>(res, res.Response.ID));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Clones an existing ACL Token in Consul
 /// </summary>
 /// <param name="id">The Accessor ID of the ACL Token to clone</param>
 /// <param name="writeOptions">Customized write options</param>
 /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
 /// <returns>A write result containing the created ACL token</returns>
 public Task <WriteResult <TokenEntry> > Clone(string id, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
 {
     return(Clone(id, string.Empty, writeOptions, ct));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Clones an existing ACL Token in Consul
        /// </summary>
        /// <param name="id">The Accessor ID of the ACL Token to clone</param>
        /// <param name="description">The description for the cloned ACL Token</param>
        /// <param name="writeOptions">Customized write options</param>
        /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
        /// <returns>A write result containing the created ACL token</returns>
        public async Task <WriteResult <TokenEntry> > Clone(string id, string description, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var body = new Dictionary <string, string>
            {
                { "Description", description }
            };
            var res = await _client.Put <object, TokenActionResult>($"/v1/acl/token/{id}/clone", body, writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <TokenEntry>(res, res.Response));
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Deletes an existing ACL Token from Consul
 /// </summary>
 /// <param name="id">The Accessor ID of the ACL Token to delete</param>
 /// <param name="writeOptions">Customized write options</param>
 /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
 /// <returns>Success (true) or failure (false)</returns>
 public Task <WriteResult <bool> > Delete(string id, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
 {
     return(_client.DeleteReturning <bool>($"/v1/acl/token/{id}", writeOptions).Execute(ct));
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Updates an existing ACL Token in Consul
        /// </summary>
        /// <param name="token">The modified ACL Token</param>
        /// <param name="writeOptions">Customized write options</param>
        /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
        /// <returns>A write result containing the updated ACL Token</returns>
        public async Task <WriteResult <TokenEntry> > Update(TokenEntry token, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <TokenEntry, TokenActionResult>($"/v1/acl/token/{token.AccessorID}", token, writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <TokenEntry>(res, res.Response));
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Deregister an existing catalog item
 /// </summary>
 /// <param name="reg">A catalog deregistration</param>
 /// <param name="q">Customized write options</param>
 /// <returns>An empty write result</returns>
 public Task <WriteResult> Deregister(CatalogDeregistration reg, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put("/v1/catalog/deregister", reg, q).Execute(ct));
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Login to ACL Auth Method
        /// </summary>
        /// <param name="writeOptions"></param>
        /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
        /// <returns>>A write result containing an ACL Token for the login</returns>
        public async Task <WriteResult <TokenEntry> > Login(WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.PutReturning <TokenEntry>("/v1/acl/login", writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <TokenEntry>(res, res.Response));
        }
Ejemplo n.º 16
0
 public Task <WriteResult> Update(ACLEntry acl, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put("/v1/acl/update", acl, q).Execute(ct));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Logout from ACL Auth Method
 /// </summary>
 /// <param name="writeOptions"></param>
 /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
 /// <returns>A write result</returns>
 public async Task <WriteResult> Logout(WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
 {
     return(await _client.Post($"/v1/acl/logout", writeOptions).Execute(ct));
 }
Ejemplo n.º 18
0
 public Task <WriteResult <bool> > Destroy(string id, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.PutReturning <bool>(string.Format("/v1/acl/destroy/{0}", id), q).Execute(ct));
 }
Ejemplo n.º 19
0
 internal DeleteRequest <T> Delete <T>(string path, WriteOptions opts = null)
 {
     return(new DeleteRequest <T>(this, path, opts ?? WriteOptions.Default));
 }
Ejemplo n.º 20
0
        public async Task <WriteResult <string> > Clone(string id, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.PutReturning <ACLCreationResult>(string.Format("/v1/acl/clone/{0}", id), q).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <string>(res, res.Response.ID));
        }
Ejemplo n.º 21
0
 internal SilentPutRequest Put(string path, WriteOptions opts = null)
 {
     return(new SilentPutRequest(this, path, opts ?? WriteOptions.Default));
 }
Ejemplo n.º 22
0
        public async Task <WriteResult <string> > TranslateRules(string rules, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Post($"/v1/acl/rules/translate", rules, q).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <string>(res, res.Response));
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Write is used to do a PUT request against an endpoint and serialize/deserialized using the standard Consul conventions.
 /// </summary>
 /// <param name="endpoint">The URL endpoint to access</param>
 /// <param name="obj">The object to serialize and send to the endpoint. Must be able to be JSON serialized, or be an object of type byte[], which is sent without serialzation.</param>
 /// <param name="q">Custom write options</param>
 /// <returns>The data returned by the custom endpoint in response to the write request</returns>
 public Task <WriteResult <dynamic> > Write(string endpoint, object obj, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put <object, dynamic>(endpoint, obj, q).Execute(ct));
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Updates an existing ACL Policy in Consul
        /// </summary>
        /// <param name="policy">The modified ACL Policy</param>
        /// <param name="writeOptions">Customised write options</param>
        /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
        /// <returns>A write result containing the updated ACL policy</returns>
        public async Task <WriteResult <PolicyEntry> > Update(PolicyEntry policy, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <PolicyEntry, PolicyActionResult>($"/v1/acl/policy/{policy.ID}", policy, writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <PolicyEntry>(res, res.Response));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Updates an existing ACL Role in Consul
        /// </summary>
        /// <param name="role">The modified ACL Role</param>
        /// <param name="writeOptions">Customised write options</param>
        /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
        /// <returns>A write result containing the updated ACL Role</returns>
        public async Task <WriteResult <RoleEntry> > Update(RoleEntry role, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <RoleEntry, RoleActionResult>($"/v1/acl/role/{role.ID}", role, writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <RoleEntry>(res, res.Response));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Updates an existing ACL AuthMethod in Consul
        /// </summary>
        /// <param name="authMethod">The modified ACL AuthMethod</param>
        /// <param name="writeOptions">Customized write options</param>
        /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
        /// <returns>A write result containing the updated ACL AuthMethod</returns>
        public async Task <WriteResult <AuthMethodEntry> > Update(AuthMethodEntry authMethod, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <AuthMethodEntry, AuthMethodActionResult>($"/v1/acl/auth-method/{authMethod.Name}", authMethod, writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <AuthMethodEntry>(res, res.Response));
        }
Ejemplo n.º 27
0
        public async Task <WriteResult> Delete(string queryID, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.DeleteReturning <string>(string.Format("/v1/query/{0}", queryID), q).Execute(ct).ConfigureAwait(false);

            return(new WriteResult(res));
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Deletes an existing ACL AuthMethod from Consul
 /// </summary>
 /// <param name="name">The name of the ACL AuthMethod to delete</param>
 /// <param name="writeOptions">Customized write options</param>
 /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param>
 /// <returns>Success (true) or failure (false)</returns>
 public Task <WriteResult <bool> > Delete(string name, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
 {
     return(_client.DeleteReturning <bool>($"/v1/acl/auth-method/{name}", writeOptions).Execute(ct));
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Delete is used to delete a single key.
 /// </summary>
 /// <param name="key">The key name to delete</param>
 /// <param name="q">Customized write options</param>
 /// <returns>A write result indicating if the delete attempt succeeded</returns>
 public Task <WriteResult <bool> > Delete(string key, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     KVPair.ValidatePath(key);
     return(_client.DeleteReturning <bool>(string.Format("/v1/kv/{0}", key.TrimStart('/')), q).Execute(ct));
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Create makes a new session. Providing a session entry can customize the session. It can also be null to use defaults.
        /// </summary>
        /// <param name="se">The SessionEntry options to use</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result containing the new session ID</returns>
        public async Task <WriteResult <string> > Create(SessionEntry se, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <SessionEntry, SessionCreationResult>("/v1/session/create", se, q).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <string>(res, res.Response.ID));
        }