Пример #1
0
 /// <summary>
 /// KeyringUse is used to change the active gossip encryption key
 /// </summary>
 public Task <WriteResult> KeyringUse(string key, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put("/v1/operator/keyring", new KeyringRequest()
     {
         Key = key
     }, q).Execute(ct));
 }
Пример #2
0
        /// <summary>
        /// Acquire is used for a lock acquisition operation. The Key, Flags, Value and Session are respected.
        /// </summary>
        /// <param name="p">The key/value pair to store in Consul</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result indicating if the acquisition attempt succeeded</returns>
        public Task <WriteResult <bool> > Acquire(KVPair p, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            p.Validate();
            var req = _client.Put <byte[], bool>(string.Format("/v1/kv/{0}", p.Key.TrimStart('/')), p.Value, q);

            if (p.Flags > 0)
            {
                req.Params["flags"] = p.Flags.ToString();
            }
            req.Params["acquire"] = p.Session;
            return(req.Execute(ct));
        }
Пример #3
0
        /// <summary>
        /// Acquire is used for a lock acquisition operation. The Key, Flags, Value and Session are respected.
        /// </summary>
        /// <param name="p">The key/value pair to store in Consul</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result indicating if the acquisition attempt succeeded</returns>
        public Task <WriteResult <bool> > Acquire(KVPair p, WriteOptions q)
        {
            p.Validate();
            var req = _client.Put <byte[], bool>(string.Format("/v1/kv/{0}", p.Key), p.Value, q);

            if (p.Flags > 0)
            {
                req.Params["flags"] = p.Flags.ToString();
            }
            req.Params["acquire"] = p.Session;
            return(req.Execute());
        }
Пример #4
0
        /// <summary>
        /// Fire is used to fire a new user event. Only the Name, Payload and Filters are respected. This returns the ID or an associated error. Cross DC requests are supported.
        /// </summary>
        /// <param name="ue">A User Event definition</param>
        /// <param name="q">Customized write options</param>
        /// <returns></returns>
        public async Task <WriteResult <string> > Fire(UserEvent ue, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            var req = _client.Put <byte[], EventCreationResult>(string.Format("/v1/event/fire/{0}", ue.Name), ue.Payload, q);

            if (!string.IsNullOrEmpty(ue.NodeFilter))
            {
                req.Params["node"] = ue.NodeFilter;
            }
            if (!string.IsNullOrEmpty(ue.ServiceFilter))
            {
                req.Params["service"] = ue.ServiceFilter;
            }
            if (!string.IsNullOrEmpty(ue.TagFilter))
            {
                req.Params["tag"] = ue.TagFilter;
            }
            var res = await req.Execute(ct).ConfigureAwait(false);

            return(new WriteResult <string>(res, res.Response.ID));
        }
Пример #5
0
        /// <summary>
        /// Creates a new ACL Policy in Consul
        /// </summary>
        /// <param name="policy">The new ACL PolicyEntry</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 created ACL Policy</returns>
        public async Task <WriteResult <PolicyEntry> > Create(PolicyEntry policy, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <PolicyEntry, PolicyActionResult>("/v1/acl/policy", policy, writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <PolicyEntry>(res, res.Response));
        }
Пример #6
0
        /// <summary>
        /// Create is used to generate a new token with the given parameters
        /// </summary>
        /// <param name="acl">The ACL entry to create</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result containing the newly created ACL token</returns>
        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));
        }
Пример #7
0
 /// <summary>
 /// Register a new catalog item
 /// </summary>
 /// <param name="reg">A catalog registration</param>
 /// <param name="q">Customized write options</param>
 /// <returns>An empty write result</returns>
 public Task <WriteResult> Register(CatalogRegistration reg, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put("/v1/catalog/register", reg, q).Execute(ct));
 }
Пример #8
0
        /// <summary>
        /// Creates a new ACL AuthMethod in Consul
        /// </summary>
        /// <param name="authMethod">The new 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 created ACL AuthMethod</returns>
        public async Task <WriteResult <AuthMethodEntry> > Create(AuthMethodEntry authMethod, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <AuthMethodEntry, AuthMethodActionResult>("/v1/acl/auth-method", authMethod, writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <AuthMethodEntry>(res, res.Response));
        }
Пример #9
0
 public Task <WriteResult> Update(PreparedQueryDefinition query, WriteOptions q)
 {
     return(_client.Put(string.Format("/v1/query/{0}", query.ID), query, q).Execute());
 }
Пример #10
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));
 }
Пример #11
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));
 }
Пример #12
0
 /// <summary>
 /// Register a new catalog item
 /// </summary>
 /// <param name="reg">A catalog registration</param>
 /// <param name="q">Customized write options</param>
 /// <returns>An empty write result</returns>
 public Task <WriteResult> Register(CatalogRegistration reg, WriteOptions q)
 {
     return(_client.Put("/v1/catalog/register", reg, q).Execute());
 }
Пример #13
0
        /// <summary>
        /// Creates a new ACL Token in Consul
        /// </summary>
        /// <param name="token">The new 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> > Create(TokenEntry token, WriteOptions writeOptions, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <TokenEntry, TokenActionResult>("/v1/acl/token", token, writeOptions).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <TokenEntry>(res, res.Response));
        }
Пример #14
0
 /// <summary>
 /// ServiceRegister is used to register a new service with the local agent
 /// </summary>
 /// <param name="service">A service registration object</param>
 /// <returns>An empty write result</returns>
 public Task <WriteResult> ServiceRegister(AgentServiceRegistration service, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put("/v1/agent/service/register", service).Execute(ct));
 }
Пример #15
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));
        }
Пример #16
0
 /// <summary>
 /// ServiceRegister is used to register a new service with the local agent
 /// </summary>
 /// <param name="service">A service registration object</param>
 /// <returns>An empty write result</returns>
 public Task <WriteResult> ServiceRegister(AgentServiceRegistration service)
 {
     return(_client.Put("/v1/agent/service/register", service).Execute());
 }
Пример #17
0
 public Task <WriteResult> Restore(Stream s, WriteOptions q, CancellationToken ct = default(CancellationToken))
 {
     return(_client.Put("/v1/snapshot", s, q).Execute(ct));
 }
Пример #18
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)
 {
     return(_client.Put <object, dynamic>(endpoint, obj, q).Execute());
 }