├── ConsulSharp
├── ConsulSharp
│ ├── ConsulSharp.png
│ ├── ConsulSharpNuget.png
│ ├── Agent
│ │ ├── Sample.cs
│ │ ├── Check
│ │ │ ├── Check.cs
│ │ │ ├── TcpCheck.cs
│ │ │ ├── ScriptCheck.cs
│ │ │ ├── DockerCheck.cs
│ │ │ ├── DeregisterCheckParmeter.cs
│ │ │ ├── TTLCheck.cs
│ │ │ ├── HttpCheck.cs
│ │ │ ├── TTLCheckOpt.cs
│ │ │ ├── TTLCheckUpdate.cs
│ │ │ ├── ListChecks.cs
│ │ │ └── RegisterCheckParmeter.cs
│ │ ├── Service
│ │ │ ├── ListService.cs
│ │ │ └── RegisterServiceParmeter.cs
│ │ ├── UpdateToken.cs
│ │ ├── Coord.cs
│ │ ├── Gauge.cs
│ │ ├── JoinAgent.cs
│ │ ├── Config.cs
│ │ ├── ReadConfigurationResult.cs
│ │ ├── ViewMetricsResult.cs
│ │ ├── ListMembersParmeter.cs
│ │ ├── EnableMaintenanceMode.cs
│ │ ├── Counter.cs
│ │ └── Member.cs
│ ├── Coordnates
│ │ ├── Coordinate.cs
│ │ ├── CoordnatesCoord.cs
│ │ ├── LanCoordinate.cs
│ │ ├── WANCoordinatesResult.cs
│ │ ├── LANCoordinatesParmeter.cs
│ │ └── CoordnatesGovern.cs
│ ├── Health
│ │ ├── TaggedAddress.cs
│ │ ├── CheckNode.cs
│ │ ├── NodeService.cs
│ │ ├── CheckNodeParmeter.cs
│ │ ├── NodeServiceParmeter.cs
│ │ ├── HealthService.cs
│ │ ├── CheckServiceParmeter.cs
│ │ ├── ListChecksInStateParmeter.cs
│ │ └── HealthGovern.cs
│ ├── PreparedQueries
│ │ ├── ExplainPreparedQueryResult.cs
│ │ ├── DNS.cs
│ │ ├── NodeMeta.cs
│ │ ├── CreatePreparedQueryResult.cs
│ │ ├── ReadPreparedQueryResult.cs
│ │ ├── Template.cs
│ │ ├── RaftIndex.cs
│ │ ├── ExplainPreparedQueryParmeter.cs
│ │ ├── ExecutePreparedQuery
│ │ │ ├── Nodes.cs
│ │ │ ├── Service.cs
│ │ │ ├── Node.cs
│ │ │ └── Check.cs
│ │ ├── ReadPreparedQueryParmeter.cs
│ │ ├── UpdatePreparedQueryParmeter.cs
│ │ ├── ExplainPreparedQuery
│ │ │ └── Service.cs
│ │ ├── Query.cs
│ │ ├── Failover.cs
│ │ ├── ExecutePreparedQueryResult.cs
│ │ ├── ExecutePreparedQueryParmeter.cs
│ │ ├── CreatePreparedQueryParmeter.cs
│ │ ├── Service.cs
│ │ └── PreparedQueriesGovern.cs
│ ├── Transactions
│ │ ├── Result.cs
│ │ ├── Error.cs
│ │ ├── CreateTransactionResult.cs
│ │ ├── CreateTransactionParmeter.cs
│ │ ├── ResultKV.cs
│ │ ├── KV.cs
│ │ └── TransactionsGovern.cs
│ ├── ACL
│ │ ├── BootstrapACLsResult.cs
│ │ ├── ReadACLTokenResult.cs
│ │ ├── ACLTokenParmeter.cs
│ │ ├── ACLReplicationResult.cs
│ │ └── ACLGovern.cs
│ ├── Session
│ │ ├── CreateSessionResult.cs
│ │ ├── ListSessionsForNodeParmeter.cs
│ │ ├── RenewSessionResult.cs
│ │ ├── ListSessionsParmeter.cs
│ │ ├── DeleteSessionParmeter.cs
│ │ ├── ReadSessionResult.cs
│ │ ├── CreateSessionParmeter.cs
│ │ └── SessionGovern.cs
│ ├── Snapshot
│ │ ├── RestoreSnapshotParmeter.cs
│ │ ├── GenerateSnapshotParmeter.cs
│ │ └── SnapshotGovern.cs
│ ├── Catalog
│ │ ├── CatalogEntityService.cs
│ │ ├── ListNodesResult.cs
│ │ ├── ListServicesForNodeResult.cs
│ │ ├── ListServicesForNodeParmeter.cs
│ │ ├── ListServicesParmeter.cs
│ │ ├── DeregisterEntityParmeter.cs
│ │ ├── ListNodesParmeter.cs
│ │ ├── CatalogEntityCheck.cs
│ │ ├── ListNodesForServiceParmeter.cs
│ │ ├── ListNodesForServiceResult.cs
│ │ ├── CatalogEntityParmeter.cs
│ │ └── CatalogGovern.cs
│ ├── Operator
│ │ ├── Area
│ │ │ ├── CreateNetworkAreaResult.cs
│ │ │ ├── ListNetworkAreasParmeter.cs
│ │ │ ├── ListNetworkAreasResult.cs
│ │ │ ├── UpdateNetworkAreaParmeter.cs
│ │ │ ├── ListSpecificNetworkAreaParmeter.cs
│ │ │ ├── JoinNetworkAreaResult.cs
│ │ │ ├── CreateNetworkAreaParmeter.cs
│ │ │ ├── ListNetworkAreaMembersResult.cs
│ │ │ └── OperatorAreaGovern.cs
│ │ ├── Autopilot
│ │ │ ├── ReadHealthParmeter.cs
│ │ │ ├── ReadConfigurationParmeter.cs
│ │ │ ├── ReadHealthResult.cs
│ │ │ ├── ReadConfigurationResult.cs
│ │ │ ├── Server.cs
│ │ │ ├── OperatorAutopilotGovern.cs
│ │ │ └── UpdateConfigurationParmeter.cs
│ │ ├── Segments
│ │ │ ├── ListNetworkSegmentsParmeter.cs
│ │ │ └── OperatorSegmentsGovern.cs
│ │ ├── Raft
│ │ │ ├── ReadConfigurationResult.cs
│ │ │ ├── DeleteRaftPeerParmeter.cs
│ │ │ ├── ReadConfigurationParmeter.cs
│ │ │ ├── Server.cs
│ │ │ └── OperatorRaftGovern.cs
│ │ └── Keyring
│ │ │ ├── ListGossipEncryptionKeysParmeter.cs
│ │ │ ├── AddNewGossipEncryptionKeyParmeter.cs
│ │ │ ├── ListGossipEncryptionKeysResult.cs
│ │ │ └── OperatorKeyringGovern.cs
│ ├── BaseService.cs
│ ├── FieldNameAttribute.cs
│ ├── BaseNode.cs
│ ├── KV
│ │ ├── DeleteKeyParmter.cs
│ │ ├── ReadKeyResult.cs
│ │ ├── ReadKeyParmeter.cs
│ │ ├── CreateUpdateKeyParmeter.cs
│ │ └── KVGovern.cs
│ ├── ConsulSharp.csproj
│ ├── Event
│ │ ├── ListEventParmeter.cs
│ │ ├── FireEvent.cs
│ │ ├── FireEventParmeter.cs
│ │ └── EventGovern.cs
│ ├── BaseCheckNode.cs
│ ├── Status
│ │ └── StatusGovern.cs
│ └── BaseGovern.cs
├── ConsulSharpSample2
│ ├── packages.config
│ ├── App.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── ConsulSharpSample2.csproj
├── ConsulSharpSample
│ └── ConsulSharpSample.csproj
└── ConsulSharp.sln
├── README.md
├── .gitattributes
└── .gitignore
/ConsulSharp/ConsulSharp/ConsulSharp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/axzxs2001/ConsulSharp/HEAD/ConsulSharp/ConsulSharp/ConsulSharp.png
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/ConsulSharpNuget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/axzxs2001/ConsulSharp/HEAD/ConsulSharp/ConsulSharp/ConsulSharpNuget.png
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharpSample2/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharpSample2/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Sample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// Sample
9 | ///
10 | public class Sample : Counter
11 | {
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Coordnates/Coordinate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Coordinates
6 | {
7 | ///
8 | /// Coordinate
9 | ///
10 | public class LanCoordinateResult: Coordinate
11 | {
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/Check.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | public abstract class Check
8 | {
9 | public string ID
10 | { get; set; }
11 | public string Name
12 | { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharpSample/ConsulSharpSample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/TaggedAddress.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// TaggedAddress
9 | ///
10 | public class TaggedAddress
11 | {
12 | public string Lan { get; set; }
13 | public string Wan { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExplainPreparedQueryResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Explain Prepared Query Result
9 | ///
10 | public class ExplainPreparedQueryResult
11 | {
12 | public Query Query { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/DNS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// DNS
9 | ///
10 | public class DNS
11 | {
12 | ///
13 | /// TTL
14 | ///
15 | public string TTL { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Transactions/Result.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Transactions
6 | {
7 | ///
8 | /// Result
9 | ///
10 | public class Result
11 | {
12 | ///
13 | /// Result KV
14 | ///
15 | public ResultKV KV { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/ACL/BootstrapACLsResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.ACL
6 | {
7 | ///
8 | /// Bootstrap ACLs
9 | ///
10 | public class BootstrapACLsResult
11 | {
12 | ///
13 | /// token
14 | ///
15 | public string ID { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/TcpCheck.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | public class TcpCheck : Check
8 | {
9 | public string Tcp
10 | { get; set; }
11 |
12 | public string Interval
13 | { get; set; }
14 |
15 | public string TimeOut
16 | { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Session/CreateSessionResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Session
6 | {
7 | ///
8 | /// Create Session Result
9 | ///
10 | public class CreateSessionResult
11 | {
12 | ///
13 | /// ID
14 | ///
15 | public string ID { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/CheckNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Health
6 | {
7 | ///
8 | /// List Checks for Node
9 | ///
10 | public class CheckNodeResult: BaseCheckNode
11 | {
12 | ///
13 | /// id
14 | ///
15 | public string ID { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/NodeMeta.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// NodeMeta
9 | ///
10 | public class NodeMeta
11 | {
12 | ///
13 | /// Instance Type
14 | ///
15 | public string Instance_Type { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Service/ListService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Service
6 | {
7 | ///
8 | /// list service
9 | ///
10 | public class ListService : BaseService
11 | {
12 | ///
13 | /// address
14 | ///
15 | public string Address { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/UpdateToken.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// Update ACL Tokens
9 | ///
10 | public class UpdateTokenParmeter
11 | {
12 | ///
13 | /// Specifies the ACL token to set.
14 | ///
15 | public string Token { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Snapshot/RestoreSnapshotParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Snapshot
6 | {
7 | ///
8 | /// Restore Snapshot Parmeter
9 | ///
10 | public class RestoreSnapshotParmeter
11 | {
12 | ///
13 | /// DC
14 | ///
15 | public string DC { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/CatalogEntityService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// catalog entity service
9 | ///
10 | public class CatalogEntityService:BaseService
11 | {
12 | ///
13 | /// address
14 | ///
15 | public string Address { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Coordnates/CoordnatesCoord.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Coordinates
6 | {
7 | ///
8 | /// Coordnates coord
9 | ///
10 | public class CoordnatesCoord : Coord
11 | {
12 | ///
13 | /// height
14 | ///
15 | public double Height { get; set; }
16 |
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/CreatePreparedQueryResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Create Prepared Query Result
9 | ///
10 | public class CreatePreparedQueryResult
11 | {
12 | ///
13 | /// ID
14 | ///
15 | public string ID { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/CreateNetworkAreaResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Area
6 | {
7 | ///
8 | /// Create Network Area Parmter
9 | ///
10 | public class CreateNetworkAreaResult
11 | {
12 | ///
13 | /// ID
14 | ///
15 | public string ID { get; set; }
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/ScriptCheck.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | ///
8 | /// script check
9 | ///
10 | public class ScriptCheck : Check
11 | {
12 | public string[] Args
13 | { get; set; }
14 |
15 | public string Interval
16 | { get; set; }
17 |
18 | public string TimeOut
19 | { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/DockerCheck.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | public class DockerCheck : Check
8 | {
9 | public string Docker_Container_ID
10 | { get; set; }
11 | public string Shell
12 | { get; set; }
13 | public string[] Args
14 | { get; set; }
15 | public string Interval
16 | { get; set; }
17 |
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ReadPreparedQueryResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Read Prepared Query Result
9 | ///
10 | public class ReadPreparedQueryResult: CreatePreparedQueryParmeter
11 | {
12 | ///
13 | /// RaftIndex
14 | ///
15 | public RaftIndex RaftIndex { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Transactions/Error.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Transactions
6 | {
7 | ///
8 | /// Error
9 | ///
10 | public class Error
11 | {
12 | ///
13 | /// OpIndex
14 | ///
15 | public int OpIndex { get; set; }
16 | ///
17 | /// What
18 | ///
19 | public string What { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/DeregisterCheckParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | ///
8 | /// Deregister Check Parmeter
9 | ///
10 | public class DeregisterCheckParmeter
11 | {
12 | ///
13 | /// Specifies the unique ID of the check to deregister. This is specified as part of the URL.
14 | ///
15 | public string Check_ID { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/Template.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Template
9 | ///
10 | public class Template
11 | {
12 | ///
13 | /// Type
14 | ///
15 | public string Type { get; set; }
16 | ///
17 | /// Regexp
18 | ///
19 | public string Regexp { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/TTLCheck.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | ///
8 | /// ttl check
9 | ///
10 | public class TTLCheck : Check
11 | {
12 | ///
13 | /// ttl
14 | ///
15 | public string Ttl
16 | { get; set; }
17 | ///
18 | /// notes
19 | ///
20 | public string Notes
21 | { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/RaftIndex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// RaftIndex
9 | ///
10 | public class RaftIndex
11 | {
12 | ///
13 | /// Create Index
14 | ///
15 | public int CreateIndex { get; set;}
16 | ///
17 | /// Modify Index
18 | ///
19 | public int ModifyIndex { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/ListNodesResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// Health Node
9 | ///
10 | public class ListNodesResult: BaseNode
11 | {
12 | ///
13 | /// Create Index
14 | ///
15 | public int CreateIndex { get; set; }
16 | ///
17 | /// Modify Index
18 | ///
19 | public int ModifyIndex { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Session/ListSessionsForNodeParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Session
6 | {
7 | ///
8 | /// List Sessions For Node Parmeter
9 | ///
10 | public class ListSessionsForNodeParmeter
11 | {
12 | ///
13 | /// Node
14 | ///
15 | public string Node { get; set; }
16 | ///
17 | /// DC
18 | ///
19 | public string DC { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Session/RenewSessionResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Session
6 | {
7 | ///
8 | /// Renew Session Result
9 | ///
10 | public class RenewSessionResult : ReadSessionResult
11 | {
12 | ///
13 | /// Behavior
14 | ///
15 | public string Behavior { get; set; }
16 | ///
17 | /// TTL
18 | ///
19 | public string TTL { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/ACL/ReadACLTokenResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.ACL
6 | {
7 | ///
8 | /// Read ACL Token
9 | ///
10 | public class ReadACLTokenResult : ACLTokenParmeter
11 | {
12 | ///
13 | /// Create Index
14 | ///
15 | public int CreateIndex { get; set; }
16 | ///
17 | /// Modify Index
18 | ///
19 | public int ModifyIndex { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Transactions/CreateTransactionResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Transactions
6 | {
7 | ///
8 | /// Create Transaction Result
9 | ///
10 | public class CreateTransactionResult
11 | {
12 | ///
13 | /// Result
14 | ///
15 | public Result[] Results{get;set;}
16 |
17 | ///
18 | /// Error
19 | ///
20 | public Error[] Errors { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/ListNetworkAreasParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Area
6 | {
7 | ///
8 | /// List Network Areas Parmeter
9 | ///
10 | public class ListNetworkAreasParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as a URL query parameter.
14 | ///
15 | public string DC { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Autopilot/ReadHealthParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Autopilot
6 | {
7 | ///
8 | /// Read Health Parmeter
9 | ///
10 | public class ReadHealthParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query string.
14 | ///
15 | public string DC { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExplainPreparedQueryParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Explain Prepared Query Parmeter
9 | ///
10 | public class ExplainPreparedQueryParmeter
11 | {
12 | ///
13 | /// UUID
14 | ///
15 | public string UUID { get; set; }
16 | ///
17 | /// DC
18 | ///
19 | public string DC { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/ListServicesForNodeResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// List Services for Node
9 | ///
10 | public class ListServicesForNodeResult
11 | {
12 | ///
13 | /// node
14 | ///
15 | public BaseNode Node { get; set; }
16 | ///
17 | /// services
18 | ///
19 | public Dictionary Services { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Segments/ListNetworkSegmentsParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Segments
6 | {
7 | ///
8 | /// List Network Segments Parmeter
9 | ///
10 | public class ListNetworkSegmentsParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as a URL query parameter.
14 | ///
15 | public string DC { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/HttpCheck.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | public class HttpCheck:Check
8 | {
9 | public string Http
10 | { get; set; }
11 |
12 | public bool Tls_Skip_Verify
13 | { get; set; }
14 |
15 | public string Method
16 | { get; set; }
17 |
18 | public object Header
19 | { get; set; }
20 |
21 | public string Interval
22 | { get; set; }
23 |
24 | public string TimeOut
25 | { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Coord.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// coord
9 | ///
10 | public class Coord
11 | {
12 | ///
13 | /// adjustment
14 | ///
15 | public int Adjustment { get; set; }
16 | ///
17 | /// error
18 | ///
19 | public double Error { get; set; }
20 | ///
21 | /// vec
22 | ///
23 | public int[] Vec { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Session/ListSessionsParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Session
6 | {
7 | ///
8 | /// List Sessions Parmeter
9 | ///
10 | public class ListSessionsParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter. Using this across datacenters is not recommended.
14 | ///
15 | public string DC { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Gauge.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// gauge
9 | ///
10 | public class Gauge
11 | {
12 | ///
13 | /// name
14 | ///
15 | public string Name { get; set; }
16 |
17 | ///
18 | /// value
19 | ///
20 | public long Value { get; set; }
21 |
22 | ///
23 | /// labels
24 | ///
25 | public object Labels { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Coordnates/LanCoordinate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Coordinates
6 | {
7 | ///
8 | /// Coordinate
9 | ///
10 | public class Coordinate
11 | {
12 | ///
13 | /// Node
14 | ///
15 | public string Node { get; set; }
16 |
17 | ///
18 | /// Segment
19 | ///
20 | public string Segment { get; set; }
21 | ///
22 | /// Coord
23 | ///
24 | public CoordnatesCoord Coord { get; set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExecutePreparedQuery/Nodes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries.ExecutePreparedQuery
6 | {
7 | ///
8 | /// Nodes
9 | ///
10 | public class Nodes
11 | {
12 | ///
13 | /// Node
14 | ///
15 | public Node Node { get; set; }
16 | ///
17 | /// Service
18 | ///
19 | public Service Service { get; set; }
20 | ///
21 | /// Checks
22 | ///
23 | public Check[] Checks { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/TTLCheckOpt.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | ///
8 | /// TTL Check Pass Parmeter
9 | ///
10 | public class TTLCheckPassParmeter
11 | {
12 | ///
13 | /// Specifies the unique ID of the check to use. This is specified as part of the URL.
14 | ///
15 | public string Check_ID { get; set; }
16 |
17 | ///
18 | /// Specifies a human-readable message. This will be passed through to the check's Output field.
19 | ///
20 | public string Note { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Coordnates/WANCoordinatesResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Coordinates
6 | {
7 | ///
8 | /// Read WAN Coordinates
9 | ///
10 | public class WANCoordinatesResult
11 | {
12 | ///
13 | /// datacenter
14 | ///
15 | public string Datacenter { get; set; }
16 |
17 | ///
18 | /// area id
19 | ///
20 | public string AreaID { get; set; }
21 |
22 | ///
23 | /// Coordinates
24 | ///
25 | public Coordinate[] Coordinates { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/ListNetworkAreasResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Area
6 | {
7 | ///
8 | /// List Network Areas Result
9 | ///
10 | public class ListNetworkAreasResult
11 | {
12 | ///
13 | /// ID
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Peer Datacenter
18 | ///
19 | public string PeerDatacenter { get; set; }
20 | ///
21 | /// Retry Join
22 | ///
23 | public string[] RetryJoin { get; set; }
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/NodeService.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Agent.Service;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace ConsulSharp.Health
7 | {
8 | ///
9 | /// List Nodes for Service
10 | ///
11 | public class ListNodeForServiceResult
12 | {
13 | ///
14 | /// node
15 | ///
16 | public BaseNode Node { get; set; }
17 | ///
18 | /// service
19 | ///
20 | public ListService Service { get; set; }
21 |
22 | ///
23 | /// checks
24 | ///
25 | public BaseCheckNode Checks { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/JoinAgent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// Join Agent Parmeter
9 | ///
10 | public class JoinAgentParmeter
11 | {
12 | ///
13 | /// Specifies the address of the other agent to join. This is specified as part of the URL.
14 | ///
15 | public string Address { get; set; }
16 |
17 | ///
18 | /// Specifies to try and join over the WAN pool. This is only optional for agents running in server mode. This is specified as part of the URL as a query parameter
19 | ///
20 | public bool Wan { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/BaseService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// node services
9 | ///
10 | public class BaseService
11 | {
12 | ///
13 | /// id
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// service name
18 | ///
19 | public string Service { get; set; }
20 | ///
21 | /// service tags
22 | ///
23 | public string[] Tags { get; set; }
24 | ///
25 | /// port
26 | ///
27 | public int Port { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/CheckNodeParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Health
6 | {
7 | ///
8 | /// List Checks for Node
9 | ///
10 | public class ListCheckForNodeParmeter
11 | {
12 | ///
13 | /// Specifies the name or ID of the node to query. This is specified as part of the URL
14 | ///
15 | public string Node { get; set; }
16 | ///
17 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string DC { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Raft/ReadConfigurationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Raft
6 | {
7 | ///
8 | /// Read Configuration Result
9 | ///
10 | public class ReadConfigurationResult
11 | {
12 | ///
13 | /// Servers is has information about the servers in the Raft peer configuration:
14 | ///
15 | public Server[] Servers { get; set; }
16 |
17 | ///
18 | /// Index is the Raft corresponding to this configuration. The latest configuration may not yet be committed if changes are in flight.
19 | ///
20 | public int Index { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Keyring/ListGossipEncryptionKeysParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Keyring
6 | {
7 |
8 | ///
9 | /// List Gossip Encryption Keys Parmeter
10 | ///
11 | public class ListGossipEncryptionKeysParmeter
12 | {
13 | ///
14 | /// Specifies the relay factor. Setting this to a non-zero value will cause nodes to relay their responses through this many randomly-chosen other nodes in the cluster. The maximum allowed value is 5. This is specified as part of the URL as a query parameter.
15 | ///
16 | [FieldName("relay-factor")]
17 | public int RelayFactor { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/UpdateNetworkAreaParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Area
6 | {
7 | ///
8 | /// Update Network Area Parmeter
9 | ///
10 | public class UpdateNetworkAreaParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as a URL query parameter.
14 | ///
15 | public string DC { get; set; }
16 | ///
17 | /// Specifies whether gossip over this area should be encrypted with TLS if possible.
18 | ///
19 | public bool UseTLS { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/ListSpecificNetworkAreaParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Area
6 | {
7 | ///
8 | /// List Specific Network Area Parmeter
9 | ///
10 | public class NetworkAreaParmeter
11 | {
12 | ///
13 | /// Specifies the UUID of the area to list. This is specified as part of the URL.
14 | ///
15 | public string UUID { get; set;}
16 | ///
17 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as a URL query parameter.
18 | ///
19 | public string DC { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/FieldNameAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// Change Field Name
9 | ///
10 | [AttributeUsage(AttributeTargets.Property,AllowMultiple =false)]
11 | public class FieldNameAttribute:Attribute
12 | {
13 | ///
14 | /// ctor
15 | ///
16 | /// Field Name
17 | public FieldNameAttribute(string changeFieldName)
18 | {
19 | ChangeFieldName = changeFieldName;
20 |
21 | }
22 | ///
23 | /// Changed Field
24 | ///
25 | public string ChangeFieldName { get;private set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Transactions/CreateTransactionParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Transactions
6 | {
7 | ///
8 | /// Create Transaction Parmeter
9 | ///
10 | public class CreateTransactionParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
14 | ///
15 | public string DC { get; set; }
16 |
17 | ///
18 | /// KV is the only available operation type, though other types may be added in the future.
19 | ///
20 | public KV KV { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/ListServicesForNodeParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// List Services for Node Parmeter
9 | ///
10 | public class ListServicesForNodeParmeter
11 | {
12 | ///
13 | /// Specifies the name of the node for which to list services. This is specified as part of the URL.
14 | ///
15 | public string Node { get; set; }
16 |
17 | ///
18 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
19 | ///
20 | public string DC { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ReadPreparedQueryParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Read Prepared Query Parmeter
9 | ///
10 | public class ReadPreparedQueryParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
14 | ///
15 | public string DC { get; set; }
16 | ///
17 | /// Specifies the UUID of the query to update. This is required and is specified as part of the URL path.
18 | ///
19 | public string UUID { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/UpdatePreparedQueryParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Update Prepared Query Parmeter
9 | ///
10 | public class UpdatePreparedQueryParmeter
11 | {
12 | ///
13 | /// Specifies the UUID of the query to update. This is required and is specified as part of the URL path.
14 | ///
15 | public string UUID { get; set; }
16 | ///
17 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string DC { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExecutePreparedQuery/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries.ExecutePreparedQuery
6 | {
7 | ///
8 | /// ExecutePreparedQuery Result Service
9 | ///
10 | public class Service
11 | {
12 | ///
13 | /// ID
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// service
18 | ///
19 | public string service { get; set; }
20 | ///
21 | /// Tags
22 | ///
23 | public string[] Tags { get; set; }
24 | ///
25 | /// Port
26 | ///
27 | public int Port { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/NodeServiceParmeter.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace ConsulSharp
7 | {
8 | ///
9 | /// List Nodes for Service parmeter
10 | ///
11 | public class ListNodeForServiceParmeter:CheckServiceParmeter
12 | {
13 | ///
14 | /// Specifies the tag to filter the list. This is specifies as part of the URL as a query parameter.
15 | ///
16 | public string Tag { get; set; }
17 | ///
18 | /// Specifies that the server should return only nodes with all checks in the passing state. This can be used to avoid additional filtering on the client side.
19 | ///
20 | public bool passing { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Session/DeleteSessionParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Session
6 | {
7 | ///
8 | /// Delete Session Parmeter
9 | ///
10 | public class DeleteSessionParmeter
11 | {
12 |
13 | ///
14 | /// Specifies the UUID of the session to destroy. This is required and is specified as part of the URL path.
15 | ///
16 | public string UUID { get; set; }
17 | ///
18 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter. Using this across datacenters is not recommended.
19 | ///
20 | public string DC { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Autopilot/ReadConfigurationParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Autopilot
6 | {
7 | ///
8 | /// Read Configuration Parmeter
9 | ///
10 | public class ReadConfigurationParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query string.
14 | ///
15 | public string DC { get; set; }
16 | ///
17 | /// If the cluster does not currently have a leader an error will be returned. You can use the ?stale query parameter to read the Raft configuration from any of the Consul servers.
18 | ///
19 | public bool Stale { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Config.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// config
9 | ///
10 | public class Config
11 | {
12 | ///
13 | /// datacenter
14 | ///
15 | public string Datacenter
16 | { get; set; }
17 | ///
18 | /// node name
19 | ///
20 | public string NodeName
21 | { get; set; }
22 | ///
23 | /// is server
24 | ///
25 | public bool Server { get; set; }
26 | ///
27 | /// revision
28 | ///
29 | public string Revision { get; set; }
30 | ///
31 | /// version
32 | ///
33 | public string Version { get; set; }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Session/ReadSessionResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Session
6 | {
7 | ///
8 | /// Read Session Result
9 | ///
10 | public class ReadSessionResult
11 | {
12 | ///
13 | /// LockDelay
14 | ///
15 | public double LockDelay { get; set; }
16 | ///
17 | /// Checks
18 | ///
19 | public string[] Checks { get; set; }
20 | ///
21 | /// Node
22 | ///
23 | public string Node { get; set; }
24 | ///
25 | /// ID
26 | ///
27 | public string ID { get; set; }
28 | ///
29 | /// CreateIndex
30 | ///
31 | public long CreateIndex { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/JoinNetworkAreaResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Area
6 | {
7 | ///
8 | /// Join Network Area Result
9 | ///
10 | public class JoinNetworkAreaResult
11 | {
12 | ///
13 | /// Address has the address requested to join.
14 | ///
15 | public string Address { get; set; }
16 | ///
17 | /// Joined will be true if the Consul server at the given address was successfully joined into the network area. Otherwise, this will be false and Error will have a human-readable message about why the join didn't succeed.
18 | ///
19 | public bool Joined { get; set; }
20 | ///
21 | /// Error
22 | ///
23 | public string Error { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/ReadConfigurationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// Read Configuration
9 | ///
10 | public class ReadConfigurationResult
11 | {
12 | ///
13 | /// config
14 | ///
15 | public Config Config { get; set; }
16 |
17 | ///
18 | /// debug config
19 | ///
20 | public object DebugConfig { get; set; }
21 | ///
22 | /// coord
23 | ///
24 | public Coord Coord { get; set; }
25 | ///
26 | /// member
27 | ///
28 | public Member Member { get; set; }
29 |
30 | ///
31 | /// meta
32 | ///
33 | public object Meta { get; set; }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/ViewMetricsResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// View Metrics Result
9 | ///
10 | public class ViewMetricsResult
11 | {
12 | ///
13 | /// timestamp
14 | ///
15 | public DateTime Timestamp { get; set; }
16 | ///
17 | /// gauges
18 | ///
19 | public Gauge[] Gauges { get; set; }
20 | ///
21 | /// points
22 | ///
23 | public double[] Points { get; set; }
24 | ///
25 | /// counters
26 | ///
27 | public Counter[] Counters { get; set; }
28 | ///
29 | /// samples
30 | ///
31 | public Sample[] Samples { get; set; }
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Keyring/AddNewGossipEncryptionKeyParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Keyring
6 | {
7 |
8 | ///
9 | /// Add New Gossip Encryption Key Parmeter
10 | ///
11 | public class AddNewGossipEncryptionKeyParmeter
12 | {
13 | ///
14 | /// Specifies the relay factor. Setting this to a non-zero value will cause nodes to relay their responses through this many randomly-chosen other nodes in the cluster. The maximum allowed value is 5. This is specified as part of the URL as a query parameter.
15 | ///
16 | [FieldName("relay-factor")]
17 | public int RelayFactor { get; set; }
18 | ///
19 | /// Specifies the encryption key to install into the cluster.
20 | ///
21 | public string Key { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Raft/DeleteRaftPeerParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Raft
6 | {
7 | ///
8 | /// Delete Raft Peer Parmeter
9 | ///
10 | public class DeleteRaftPeerParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query string.
14 | ///
15 | public string DC { get; set; }
16 | ///
17 | /// SSpecifies the ID or address (IP:port) of the raft peer to remove.
18 | ///
19 | public string ID { get; set; }
20 | ///
21 | /// Specifies the ID or address (IP:port) of the raft peer to remove.
22 | ///
23 | public string Address { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Autopilot/ReadHealthResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Autopilot
6 | {
7 | ///
8 | /// Read Health Result
9 | ///
10 | public class ReadHealthResult
11 | {
12 | ///
13 | /// Healthy is whether all the servers are currently healthy.
14 | ///
15 | public bool Healthy { get; set; }
16 |
17 |
18 | ///
19 | /// FailureTolerance is the number of redundant healthy servers that could be fail without causing an outage(this would be 2 in a healthy cluster of 5 servers).
20 | ///
21 | public int FailureTolerance { get; set; }
22 | ///
23 | /// Servers holds detailed health information on each server:
24 | ///
25 | public Server[] Servers { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/TTLCheckUpdate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | ///
8 | /// TTL Check Update Parmeter
9 | ///
10 | public class TTLCheckUpdateParmeter
11 | {
12 | ///
13 | /// Specifies the unique ID of the check to use. This is specified as part of the URL.
14 | ///
15 | public string Check_ID
16 | { get; set; }
17 | ///
18 | /// Specifies the status of the check. Valid values are "passing", "warning", and "critical".
19 | ///
20 | public string Status
21 | { get; set; }
22 | ///
23 | /// Specifies a human-readable message. This will be passed through to the check's Output field.
24 | ///
25 | public string Output
26 | { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/ListServicesParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// List Service Parmeter
9 | ///
10 | public class ListServicesParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
14 | ///
15 | public string DC { get; set; }
16 |
17 | ///
18 | /// Specifies a desired node metadata key/value pair of the form key:value. This parameter can be specified multiple times, and will filter the results to nodes with the specified key/value pairs. This is specified as part of the URL as a query parameter.
19 | ///
20 | [FieldName("Node-Meta")]
21 | public string NodeMeta { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExplainPreparedQuery/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries.ExplainPreparedQuery
6 | {
7 | ///
8 | /// Explain Prepared Query Service
9 | ///
10 | public class Service
11 | {
12 | ///
13 | /// service
14 | ///
15 | public string service { get; set; }
16 | ///
17 | /// Failover
18 | ///
19 | public Failover Failover { get; set; }
20 | ///
21 | /// OnlyPassing
22 | ///
23 | public bool OnlyPassing { get; set; }
24 | ///
25 | /// Tags
26 | ///
27 | public string[] Tags { get; set; }
28 | ///
29 | /// NodeMeta
30 | ///
31 | public NodeMeta NodeMeta { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/BaseNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// Health Node
9 | ///
10 | public class BaseNode
11 | {
12 | ///
13 | /// Node ID
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Node
18 | ///
19 | public string Node { get; set; }
20 | ///
21 | /// Address
22 | ///
23 | public string Address { get; set; }
24 | ///
25 | /// Datacenter
26 | ///
27 | public string Datacenter { get; set; }
28 | ///
29 | /// Tagged Addresses
30 | ///
31 | public TaggedAddress TaggedAddresses { get; set; }
32 | ///
33 | /// Meta
34 | ///
35 | public object Meta { get; set;}
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/ACL/ACLTokenParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.ACL
6 | {
7 | ///
8 | /// Create ACL Token
9 | ///
10 | public class ACLTokenParmeter
11 | {
12 | ///
13 | /// Specifies the ID of the ACL. If not provided, a UUID is generated.
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Specifies a human-friendly name for the ACL token.
18 | ///
19 | public string Name { get; set; }
20 | ///
21 | /// Specifies the type of ACL token. Valid values are: client and management.
22 | ///
23 | public string Type { get; set; }
24 |
25 | ///
26 | ///Specifies rules for this ACL token. The format of the Rules property is documented in the ACL Guide.
27 | ///
28 | public string Rules { get; set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Transactions/ResultKV.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Transactions
6 | {
7 | ///
8 | /// Transactions Back KV
9 | ///
10 | public class ResultKV
11 | {
12 | ///
13 | /// LockIndex
14 | ///
15 | public int LockIndex { get; set; }
16 | ///
17 | /// Key
18 | ///
19 | public string Key { get; set; }
20 | ///
21 | /// Flags
22 | ///
23 | public int Flags { get; set; }
24 | ///
25 | /// Value
26 | ///
27 | public string Value { get; set; }
28 | ///
29 | /// CreateIndex
30 | ///
31 | public int CreateIndex { get; set; }
32 | ///
33 | /// ModifyIndex
34 | ///
35 | public int ModifyIndex { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/Query.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Query
9 | ///
10 | public class Query
11 | {
12 | ///
13 | /// ID
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Name
18 | ///
19 | public string Name { get; set; }
20 | ///
21 | /// Session
22 | ///
23 | public string Session { get; set; }
24 | ///
25 | /// Token
26 | ///
27 | public string Token { get; set; }
28 | ///
29 | /// Template
30 | ///
31 | public Template Template { get; set; }
32 | ///
33 | /// Explain Prepared Query
34 | ///
35 | public ExplainPreparedQuery.Service Service { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/ListMembersParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent
6 | {
7 | ///
8 | /// List Members Parmeter
9 | ///
10 | public class ListMembersParmeter
11 | {
12 | ///
13 | /// Specifies to list WAN members instead of the LAN members (which is the default). This is only eligible for agents running in server mode. This is specified as part of the URL as a query parameter.
14 | ///
15 | public bool Wan { get; set; }
16 | ///
17 | /// (Enterprise-only) Specifies the segment to list members for. If left blank, this will query for the default segment when connecting to a server and the agent's own segment when connecting to a client (clients can only be part of one network segment). When querying a server, setting this to the special string _all will show members in all segments.
18 | ///
19 | public string Segment { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExecutePreparedQuery/Node.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries.ExecutePreparedQuery
6 | {
7 | ///
8 | ///
9 | ///
10 | public class Node
11 | {
12 | ///
13 | /// Node ID
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Node
18 | ///
19 | public string node { get; set; }
20 | ///
21 | /// Address
22 | ///
23 | public string Address { get; set; }
24 | ///
25 | /// Datacenter
26 | ///
27 | public string Datacenter { get; set; }
28 | ///
29 | /// Tagged Addresses
30 | ///
31 | public TaggedAddress TaggedAddresses { get; set; }
32 | ///
33 | /// Note Meta
34 | ///
35 | public object NoteMeta { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Segments/OperatorSegmentsGovern.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.Threading.Tasks;
3 |
4 | namespace ConsulSharp.Operator.Segments
5 | {
6 | ///
7 | /// Operator Segments Govern
8 | ///
9 | public class OperatorSegmentsGovern : Govern
10 | {
11 |
12 | ///
13 | /// ctor
14 | ///
15 | /// Base Address
16 | public OperatorSegmentsGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
17 | {
18 | }
19 | ///
20 | /// This endpoint lists all network areas.
21 | ///
22 | /// List Network Segments Parmeter
23 | ///
24 | public async Task ListNetworkSegments(ListNetworkSegmentsParmeter listNetworkSegmentsParmeter)
25 | {
26 | return await Get("/operator/segment", listNetworkSegmentsParmeter);
27 | }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Raft/ReadConfigurationParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Raft
6 | {
7 | ///
8 | /// Read Configuration Parmeter
9 | ///
10 |
11 | public class ReadConfigurationParmeter
12 | {
13 | ///
14 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query string.
15 | ///
16 | public string DC { get; set; }
17 | ///
18 | /// If the cluster does not currently have a leader an error will be returned. You can use the ?stale query parameter to read the Raft configuration from any of the Consul servers. Not setting this will choose the default consistency mode which will forward the reqest to the leader for processing but not re-confirm the server is still the leader before returning results. See default consistency for more details.
19 | ///
20 | public bool Stale { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/DeregisterEntityParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// Deregister Entity Parmeter
9 | ///
10 | public class DeregisterEntityParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter, which defaults to the agent's datacenter if not provided.
14 | ///
15 | public string Datacenter { get; set; }
16 | ///
17 | /// Specifies the ID of the node. If no other values are provided, this node, all its services, and all its checks are removed.
18 | ///
19 | public string Node { get; set; }
20 | ///
21 | /// Specifies the ID of the check to remove.
22 | ///
23 | public string CheckID { get; set; }
24 | ///
25 | /// Specifies the ID of the service to remove. The service and all associated checks will be removed.
26 | ///
27 | public string ServiceID { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/KV/DeleteKeyParmter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.KV
6 | {
7 | ///
8 | /// Delete Key Parmter
9 | ///
10 | public class DeleteKeyParmeter
11 | {
12 | ///
13 | /// Specifies the path of the key to delete.
14 | ///
15 | public string Key { get; set; }
16 | ///
17 | /// Specifies to delete all keys which have the specified prefix. Without this, only a key with an exact match will be deleted.
18 | ///
19 | public bool Recurse { get; set; }
20 |
21 | ///
22 | /// Specifies to use a Check-And-Set operation. This is very useful as a building block for more complex synchronization primitives. Unlike PUT, the index must be greater than 0 for Consul to take any action: a 0 index will not delete the key. If the index is non-zero, the key is only deleted if the index matches the ModifyIndex of that key.
23 | ///
24 | public int Cas { get; set; }
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharpSample2/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ConsulSharpSample2")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ConsulSharpSample2")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("a4fce303-db77-46bd-afcf-1e956228c2b2")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/ConsulSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | GuiSuwei
6 | GuiSuwei
7 | The consul HTTP API implemented with C#.
8 | https://github.com/axzxs2001/ConsulSharp
9 | https://en.gravatar.com/userimage/127492023/ffea227158c9cc0eb0624078fe9750cf.png
10 | https://github.com/axzxs2001/ConsulSharp
11 | git
12 | consul
13 | true
14 | 1.0.2.0
15 | 1.0.0.3
16 | 0.2.0
17 | false
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/EnableMaintenanceMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// Enable Maintenance Mode Parmeter
9 | ///
10 | public class EnableMaintenanceModeParmeter
11 | {
12 | ///
13 | /// Specifies the ID of the service to put in maintenance mode. This is specified as part of the URL.
14 | ///
15 | public string ServiceID { get; set; }
16 |
17 | ///
18 | /// Specifies whether to enable or disable maintenance mode. This is specified as part of the URL as a query string parameter.
19 | ///
20 | public bool Enable { get; set; }
21 | ///
22 | /// Specifies a text string explaining the reason for placing the node into maintenance mode. This is simply to aid human operators. If no reason is provided, a default value will be used instead. This is specified as part of the URL as a query string parameter, and, as such, must be URI-encoded.
23 | ///
24 | public string Reason { get; set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Event/ListEventParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Event
6 | {
7 | ///
8 | /// List Event
9 | ///
10 | public class ListEventParmeter
11 | {
12 | ///
13 | /// Specifies the name of the event to filter. This is specified as part of the URL as a query parameter.
14 | ///
15 | public string Name { get; set; }
16 |
17 | ///
18 | /// Specifies a regular expression to filter by node name. This is specified as part of the URL as a query parameter.
19 | ///
20 | public string Node { get; set; }
21 |
22 | ///
23 | /// Specifies a regular expression to filter by service name. This is specified as part of the URL as a query parameter.
24 | ///
25 | public string Service { get; set; }
26 |
27 | ///
28 | /// Specifies a regular expression to filter by tag. This is specified as part of the URL as a query parameter.
29 | ///
30 | public string Tag { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Counter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// counter
9 | ///
10 | public class Counter
11 | {
12 | ///
13 | /// name
14 | ///
15 | public string Name { get; set; }
16 | ///
17 | /// count
18 | ///
19 | public int Count { get; set; }
20 |
21 | ///
22 | /// sum
23 | ///
24 | public int Sum { get; set; }
25 | ///
26 | /// min
27 | ///
28 | public int Min { get; set; }
29 | ///
30 | /// max
31 | ///
32 | public int Max { get; set; }
33 | ///
34 | /// mean
35 | ///
36 | public int Mean { get; set; }
37 | ///
38 | /// stddev
39 | ///
40 | public int Stddev { get; set; }
41 |
42 | ///
43 | /// labels
44 | ///
45 | public object Labels { get; set; }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Coordnates/LANCoordinatesParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Coordinates
6 | {
7 | ///
8 | /// Read LAN Coordinates for all nodes
9 | ///
10 | public class LANCoordinatesParmeter
11 | {
12 | ///
13 | /// Node
14 | ///
15 | public string Node
16 | { get; set; }
17 | ///
18 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
19 | ///
20 | public string DC
21 | { get; set; }
22 |
23 | ///
24 | /// (Enterprise-only) Specifies the segment to list members for. If left blank, this will query for the default segment when connecting to a server and the agent's own segment when connecting to a client (clients can only be part of one network segment). When querying a server, setting this to the special string _all will show members in all segments.
25 | ///
26 | public string Segment
27 | { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Event/FireEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Event
6 | {
7 | ///
8 | /// Fire Event
9 | ///
10 | public class FireEvent
11 | {
12 | ///
13 | /// id
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// name
18 | ///
19 | public string Name { get; set; }
20 | ///
21 | /// payload
22 | ///
23 | public string Payload { get; set; }
24 | ///
25 | /// node filter
26 | ///
27 | public string NodeFilter { get; set; }
28 | ///
29 | /// service filter
30 | ///
31 | public string ServiceFilter { get; set; }
32 | ///
33 | /// tag filter
34 | ///
35 | public string TagFilter { get; set; }
36 | ///
37 | /// version
38 | ///
39 | public int Version { get; set; }
40 | ///
41 | /// ltime
42 | ///
43 | public int LTime { get; set; }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Keyring/ListGossipEncryptionKeysResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Keyring
6 | {
7 | ///
8 | /// List Gossip Encryption Keys Result
9 | ///
10 | public class ListGossipEncryptionKeysResult
11 | {
12 | ///
13 | /// WAN is true if the block refers to the WAN ring of that datacenter (rather than LAN).
14 | ///
15 | public bool WAN { get; set; }
16 | ///
17 | /// Datacenter is the datacenter the block refers to.
18 | ///
19 | public string Datacenter { get; set; }
20 | ///
21 | /// Segment is the network segment the block refers to.
22 | ///
23 | public string Segment { get; set; }
24 | ///
25 | /// Keys is a map of each gossip key to the number of nodes it's currently installed on.
26 | ///
27 | public Dictionary Keys { get; set; }
28 | ///
29 | /// NumNodes is the total number of nodes in the datacenter.
30 | ///
31 | public int NumNodes { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/Failover.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Failover
9 | ///
10 | public class Failover
11 | {
12 | ///
13 | /// Specifies that the query will be forwarded to up to NearestN other datacenters based on their estimated network round trip time using Network Coordinates from the WAN gossip pool. The median round trip time from the server handling the query to the servers in the remote datacenter is used to determine the priority.
14 | ///
15 | public int NearestN { get; set; }
16 | ///
17 | /// Specifies a fixed list of remote datacenters to forward the query to if there are no healthy nodes in the local datacenter. Datacenters are queried in the order given in the list. If this option is combined with NearestN, then the NearestN queries will be performed first, followed by the list given by Datacenters. A given datacenter will only be queried one time during a failover, even if it is selected by both NearestN and is listed in Datacenters.
18 | ///
19 | public string[] Datacenters { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/ListNodesParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// List Nodes Parmeter
9 | ///
10 | public class ListNodesParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
14 | ///
15 | public string DC{ get; set; }
16 | ///
17 | /// Specifies a node name to sort the node list in ascending order based on the estimated round trip time from that node. Passing ?near=_agent will use the agent's node for the sort. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string Near { get; set; }
20 |
21 | ///
22 | /// Specifies a desired node metadata key/value pair of the form key:value. This parameter can be specified multiple times, and will filter the results to nodes with the specified key/value pairs. This is specified as part of the URL as a query parameter.
23 | ///
24 | [FieldName("Node-Meta")]
25 | public string NodeMeta { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExecutePreparedQuery/Check.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries.ExecutePreparedQuery
6 | {
7 | ///
8 | /// Check
9 | ///
10 | public class Check
11 | {
12 | ///
13 | /// node
14 | ///
15 | public string Node { get; set; }
16 | ///
17 | /// check id
18 | ///
19 | public string CheckID { get; set; }
20 | ///
21 | /// name
22 | ///
23 | public string Name { get; set; }
24 | ///
25 | /// status
26 | ///
27 | public string Status { get; set; }
28 | ///
29 | /// notes
30 | ///
31 | public string Notes { get; set; }
32 | ///
33 | /// output
34 | ///
35 | public string Output { get; set; }
36 | ///
37 | /// service id
38 | ///
39 | public string ServiceID { get; set; }
40 | ///
41 | /// service name
42 | ///
43 | public string ServiceName { get; set; }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Snapshot/GenerateSnapshotParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Snapshot
6 | {
7 | ///
8 | /// Generate Snapshot Parmeter
9 | ///
10 | public class GenerateSnapshotParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
14 | ///
15 | public string DC { get; set; }
16 | ///
17 | /// Specifies that any follower may reply. By default requests are forwarded to the leader. Followers may be faster to respond, but may have stale data. To support bounding the acceptable staleness of snapshots, responses provide the X-Consul-LastContact header containing the time in milliseconds that a server was last contacted by the leader node. The X-Consul-KnownLeader header also indicates if there is a known leader. These can be used by clients to gauge the staleness of a snapshot and take appropriate action. The stale mode is particularly useful for taking a snapshot of a cluster in a failed state with no current leader.
18 | ///
19 | public bool Stale { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/CatalogEntityCheck.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// Catalog Entity Check
9 | ///
10 | public class Check
11 | {
12 | ///
13 | /// Node Name
14 | ///
15 | public string Node
16 | { get; set; }
17 | ///
18 | /// Check ID
19 | ///
20 | public string CheckID
21 | { get; set; }
22 | ///
23 | /// Check Name
24 | ///
25 | public string Name
26 | { get; set; }
27 |
28 | ///
29 | /// Check Status(passing, warning, or critical)
30 | ///
31 | public string Status
32 | { get; set; }
33 |
34 | ///
35 | /// Notes
36 | ///
37 | public string Notes
38 | { get; set; }
39 |
40 | ///
41 | /// Service ID
42 | ///
43 | public string ServiceID
44 | { get; set; }
45 |
46 | ///
47 | /// Definition
48 | ///
49 | public object Definition { get; set; }
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Transactions/KV.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Transactions
6 | {
7 | ///
8 | /// Transactions KV
9 | ///
10 | public class KV
11 | {
12 | ///
13 | /// Specifies the type of operation to perform.Please see the table below for available verbs.
14 | ///
15 | public string Verb { get; set; }
16 | ///
17 | /// Specifies the full path of the entry.
18 | ///
19 | public string Key { get; set; }
20 | ///
21 | /// Specifies a base64-encoded blob of data.Values cannot be larger than 512kB.
22 | ///
23 | public string Value { get; set; }
24 | ///
25 | /// Specifies an opaque unsigned integer that can be attached to each entry.Clients can choose to use this however makes sense for their application. Index(int: 0) - Specifies an index.See the table below for more information.
26 | ///
27 | public int Flags { get; set; }
28 | ///
29 | ///Specifies a session.See the table below for more information.
30 | ///
31 | public string Session { get; set; }
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Raft/Server.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Raft
6 | {
7 | ///
8 | /// Raft Read Configuration Server Result
9 | ///
10 | public class Server
11 | {
12 | ///
13 | /// Servers is has information about the servers in the Raft peer configuration:
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Node is the node name of the server, as known to Consul, or "(unknown)" if the node is stale and not known.
18 | ///
19 | public string Node { get; set; }
20 | ///
21 | /// Address is the IP:port for the server.
22 | ///
23 | public string Address { get; set; }
24 | ///
25 | /// Leader is either "true" or "false" depending on the server's role in the Raft configuration.
26 | ///
27 | public bool Leader { get; set; }
28 | ///
29 | /// Voter is "true" or "false", indicating if the server has a vote in the Raft configuration. Future versions of Consul may add support for non-voting servers.
30 | ///
31 | public bool Voter { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/BaseCheckNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// Checks for Node
9 | ///
10 | public class BaseCheckNode
11 | {
12 | ///
13 | /// node
14 | ///
15 | public string Node { get; set; }
16 | ///
17 | /// check id
18 | ///
19 | public string CheckID { get; set; }
20 | ///
21 | /// name
22 | ///
23 | public string Name { get; set; }
24 | ///
25 | /// status
26 | ///
27 | public string Status { get; set; }
28 | ///
29 | /// notes
30 | ///
31 | public string Notes { get; set; }
32 | ///
33 | /// output
34 | ///
35 | public string Output { get; set; }
36 | ///
37 | /// service id
38 | ///
39 | public string ServiceID { get; set; }
40 | ///
41 | /// service name
42 | ///
43 | public string ServiceName { get; set; }
44 | ///
45 | /// service tags
46 | ///
47 | public string[] ServiceTags { get; set; }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/HealthService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Health
6 | {
7 | ///
8 | /// Health Service
9 | ///
10 | public class HealthService
11 | {
12 | ///
13 | /// Service ID
14 | ///
15 | public string ID
16 | { get; set; }
17 | ///
18 | /// Service Name
19 | ///
20 | public string Service
21 | { get; set; }
22 | ///
23 | /// Service Tags
24 | ///
25 | public string[] Tags
26 | { get; set; }
27 | ///
28 | /// Service Address
29 | ///
30 | public string Address
31 | { get; set; }
32 | ///
33 | /// Service Port
34 | ///
35 | public int Port
36 | { get; set; }
37 | ///
38 | /// Service Enable Tag Override
39 | ///
40 | public bool EnableTagOverride
41 | { get; set; }
42 | ///
43 | /// Crete Index
44 | ///
45 | public int CreateIndex { get; set; }
46 | ///
47 | /// Modify Index
48 | ///
49 | public int ModifyIndex { get; set; }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/CheckServiceParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Health
6 | {
7 | ///
8 | /// List Checks for Service parmeter
9 | ///
10 | public class CheckServiceParmeter
11 | {
12 | ///
13 | /// Specifies the service to list checks for. This is provided as part of the URL.
14 | ///
15 | public string Service { get; set; }
16 | ///
17 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string DC { get; set; }
20 | ///
21 | /// Specifies a node name to sort the node list in ascending order based on the estimated round trip time from that node. Passing ?near=_agent will use the agent's node for the sort. This is specified as part of the URL as a query parameter.
22 | ///
23 | public string Near { get; set; }
24 | ///
25 | /// Specifies a desired node metadata key/value pair of the form key:value. This parameter can be specified multiple times, and will filter the results to nodes with the specified key/value pairs. This is specified as part of the URL as a query parameter.
26 | ///
27 | public string Node_Meta{get;set;}
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Status/StatusGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.Status
11 | {
12 | ///
13 | /// Status Govern
14 | ///
15 | public class StatusGovern : Govern
16 | {
17 | ///
18 | /// ctor
19 | ///
20 | /// Base Address
21 | public StatusGovern(string baseAddress = "http://localhost:8500"):base(baseAddress)
22 | {
23 | }
24 |
25 | ///
26 | /// This endpoint returns the Raft leader for the datacenter in which the agent is running.
27 | ///
28 | ///
29 | public async Task GetRaftLeader()
30 | {
31 | return await Get($"/status/leader");
32 | }
33 | ///
34 | /// This endpoint retrieves the Raft peers for the datacenter in which the the agent is running. This list of peers is strongly consistent and can be useful in determining when a given server has successfully joined the cluster.
35 | ///
36 | ///
37 | public async Task ListRaftPeers()
38 | {
39 | return await Get($"/status/peers");
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Event/FireEventParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Event
6 | {
7 | ///
8 | /// Fire Event
9 | ///
10 | public class FireEventParmeter
11 | {
12 | ///
13 | /// Specifies the name of the event to fire. This is specified as part of the URL. This name must not start with an underscore, since those are reserved for Consul internally.
14 | ///
15 | public string Name { get; set; }
16 | ///
17 | ///Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string DC { get; set; }
20 |
21 | ///
22 | /// Specifies a regular expression to filter by node name. This is specified as part of the URL as a query parameter.
23 | ///
24 | public string Node { get; set; }
25 |
26 | ///
27 | /// Specifies a regular expression to filter by service name. This is specified as part of the URL as a query parameter.
28 | ///
29 | public string Service { get; set; }
30 |
31 | ///
32 | /// Specifies a regular expression to filter by tag. This is specified as part of the URL as a query parameter.
33 | ///
34 | public string Tag { get; set; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExecutePreparedQueryResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Execute Prepared Query Result
9 | ///
10 | public class ExecutePreparedQueryResult
11 | {
12 | ///
13 | /// Service has the service name that the query was selecting. This is useful for context in case an empty list of nodes is returned.
14 | ///
15 | public string Service { get; set; }
16 | ///
17 | /// Nodes contains the list of healthy nodes providing the given service, as specified by the constraints of the prepared query.
18 | ///
19 | public ExecutePreparedQuery.Nodes[] Nodes { get; set; }
20 | ///
21 | /// DNS has information used when serving the results over DNS. This is just a copy of the structure given when the prepared query was created.
22 | ///
23 | public DNS DNS { get; set; }
24 |
25 | ///
26 | /// Datacenter has the datacenter that ultimately provided the list of nodes and Failovers has the number of remote datacenters that were queried while executing the query. This provides some insight into where the data came from. This will be zero during non-failover operations where there were healthy nodes found in the local datacenter.
27 | ///
28 | public string Datacenter { get; set; }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/ListChecksInStateParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Health
6 | {
7 | ///
8 | /// List Checks In State Parmeter
9 | ///
10 | public class ListChecksInStateParmeter
11 | {
12 | ///
13 | /// Specifies the state to query. Spported states are any, passing, warning, or critical. The any state is a wildcard that can be used to return all checks.
14 | ///
15 | public string State { get; set; }
16 | ///
17 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string DC { get; set; }
20 | ///
21 | /// Specifies a node name to sort the node list in ascending order based on the estimated round trip time from that node. Passing ?near=_agent will use the agent's node for the sort. This is specified as part of the URL as a query parameter.
22 | ///
23 | public string Near { get; set; }
24 | ///
25 | /// Specifies a desired node metadata key/value pair of the form key:value. This parameter can be specified multiple times, and will filter the results to nodes with the specified key/value pairs. This is specified as part of the URL as a query parameter.
26 | ///
27 | public string Node_Meta { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/ExecutePreparedQueryParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// ExecutePreparedQueryParmeter
9 | ///
10 | public class ExecutePreparedQueryParmeter
11 | {
12 | ///
13 | /// Specifies the UUID of the query to execute. This is required and is specified as part of the URL path. This can also be the name of an existing prepared query, or a name that matches a prefix name for a prepared query template.
14 | ///
15 | public string UUID { get; set; }
16 |
17 | ///
18 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
19 | ///
20 | public string DC { get; set; }
21 |
22 | ///
23 | /// Specifies to sort the resulting list in ascending order based on the estimated round trip time from that node. Passing ?near=_agent will use the agent's node for the sort. If this is not present, the default behavior will shuffle the nodes randomly each time the query is executed.
24 | ///
25 | public string Near { get; set; }
26 |
27 | ///
28 | /// Limit the size of the list to the given number of nodes. This is applied after any sorting or shuffling.
29 | ///
30 | public int Limit { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/CreateNetworkAreaParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Area
6 | {
7 | ///
8 | /// Create Network Area Parmter
9 | ///
10 | public class CreateNetworkAreaParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as a URL query parameter.
14 | ///
15 | public string DC { get; set; }
16 | ///
17 | /// Specifes the name of the Consul datacenter that will be joined the Consul servers in the current datacenter to form the area.Only one area is allowed for each possible PeerDatacenter, and a datacenter cannot form an area with itself.
18 | ///
19 | public string PeerDatacenter { get; set; }
20 | ///
21 | /// Specifies a list of Consul servers to attempt to join. Servers can be given as IP, IP:port, hostname, or hostname:port. Consul will spawn a background task that tries to periodically join the servers in this list and will run until a join succeeds. If this list is not supplied, joining can be done with a call to the join endpoint once the network area is created.
22 | ///
23 | public string[] RetryJoin { get; set; }
24 | ///
25 | /// Specifies whether gossip over this area should be encrypted with TLS if possible.
26 | ///
27 | public bool UseTLS { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Autopilot/ReadConfigurationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Autopilot
6 | {
7 | ///
8 | /// Read Configuration Result
9 | ///
10 | public class ReadConfigurationResult
11 | {
12 | ///
13 | /// CleanupDeadServers
14 | ///
15 | public bool CleanupDeadServers { get; set; }
16 | ///
17 | /// LastContactThreshold
18 | ///
19 | public string LastContactThreshold { get; set; }
20 | ///
21 | /// MaxTrailingLogs
22 | ///
23 | public int MaxTrailingLogs { get; set; }
24 | ///
25 | /// ServerStabilizationTime
26 | ///
27 | public string ServerStabilizationTime { get; set; }
28 | ///
29 | /// RedundancyZoneTag
30 | ///
31 | public string RedundancyZoneTag { get; set; }
32 | ///
33 | /// DisableUpgradeMigration
34 | ///
35 | public bool DisableUpgradeMigration { get; set; }
36 | ///
37 | /// UpgradeVersionTag
38 | ///
39 | public string UpgradeVersionTag { get; set; }
40 | ///
41 | /// CreateIndex
42 | ///
43 | public int CreateIndex { get; set; }
44 | ///
45 | /// ModifyIndex
46 | ///
47 | public int ModifyIndex { get; set; }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Member.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp
6 | {
7 | ///
8 | /// List Members
9 | ///
10 | public class Member
11 | {
12 | ///
13 | /// name
14 | ///
15 | public string Name { get; set; }
16 | ///
17 | /// address
18 | ///
19 | public string Addr { get; set; }
20 | ///
21 | /// port
22 | ///
23 | public int Port { get; set; }
24 | ///
25 | /// tags
26 | ///
27 | public Dictionary Tags { get; set; }
28 | ///
29 | /// status
30 | ///
31 | public int Status { get; set; }
32 | ///
33 | /// protocol min
34 | ///
35 | public int ProtocolMin { get; set; }
36 | ///
37 | /// protocol max
38 | ///
39 | public int ProtocolMax { get; set; }
40 | ///
41 | /// protocol cur
42 | ///
43 | public int ProtocolCur { get; set; }
44 | ///
45 | /// delegate min
46 | ///
47 | public int DelegateMin { get; set; }
48 | ///
49 | /// delegate max
50 | ///
51 | public int DelegateMax { get; set; }
52 | ///
53 | /// delegate cur
54 | ///
55 | public int DelegateCur { get; set; }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/KV/ReadKeyResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.KV
6 | {
7 | ///
8 | /// Read Key Result
9 | ///
10 | public class ReadKeyResult
11 | {
12 | ///
13 | /// CreateIndex
14 | ///
15 | public int CreateIndex { get; set; }
16 | ///
17 | /// ModifyIndex
18 | ///
19 | public int ModifyIndex { get; set; }
20 | ///
21 | /// LockIndex
22 | ///
23 | public int LockIndex { get; set; }
24 | ///
25 | /// Key
26 | ///
27 | public string Key { get; set; }
28 | ///
29 | /// Flags
30 | ///
31 | public int Flags { get; set; }
32 | ///
33 | /// Value
34 | ///
35 | public string Value { get; set; }
36 | ///
37 | /// Decode Value
38 | ///
39 | public string DecodeValue
40 | {
41 | get
42 | {
43 | if (!string.IsNullOrEmpty(Value))
44 | {
45 | byte[] bytes = Convert.FromBase64String(Value);
46 | return Encoding.UTF8.GetString(bytes);
47 | }
48 | else
49 | {
50 | return null;
51 | }
52 | }
53 | }
54 | ///
55 | /// Session
56 | ///
57 | public string Session { get; set; }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/ListNodesForServiceParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// List Nodes For Service Parmeter
9 | ///
10 | public class ListNodesForServiceParmeter
11 | {
12 | ///
13 | /// Specifies the name of the service for which to list nodes. This is specified as part of the URL.
14 | ///
15 | public string Service { get; set; }
16 | ///
17 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string DC { get; set; }
20 |
21 | ///
22 | /// Specifies the tag to filter on.
23 | ///
24 | public string Tag { get; set; }
25 |
26 | ///
27 | /// Specifies a node name to sort the node list in ascending order based on the estimated round trip time from that node. Passing ?near=_agent will use the agent's node for the sort. This is specified as part of the URL as a query parameter.
28 | ///
29 | public string Near { get; set; }
30 | ///
31 | /// Specifies a desired node metadata key/value pair of the form key:value. This parameter can be specified multiple times, and will filter the results to nodes with the specified key/value pairs. This is specified as part of the URL as a query parameter.
32 | ///
33 | [FieldName("Node-Meta")]
34 | public string NodeMeta { get; set; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/KV/ReadKeyParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.KV
6 | {
7 | ///
8 | /// Read Key Parmeter
9 | ///
10 | public class ReadKeyParmeter
11 | {
12 | ///
13 | /// Specifies the path of the key to read.
14 | ///
15 | public string Key { get; set; }
16 | ///
17 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string DC { get; set; }
20 | ///
21 | /// Specifies if the lookup should be recursive and key treated as a prefix instead of a literal match. This is specified as part of the URL as a query parameter.
22 | ///
23 | public bool Recurse { get; set; }
24 | ///
25 | /// Specifies the response is just the raw value of the key, without any encoding or metadata. This is specified as part of the URL as a query parameter.
26 | ///
27 | public bool Raw { get; set; }
28 | ///
29 | /// Specifies to return only keys (no values or metadata). Specifying this implies recurse. This is specified as part of the URL as a query parameter.
30 | ///
31 | public bool Keys { get; set; }
32 | ///
33 | /// Specifies the character to use as a separator for recursive lookups. This is specified as part of the URL as a query parameter.
34 | ///
35 | public string Separator { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ConsulSharp
2 | A set of c# API to call the consul HTTP API!
3 |
4 | consul http api:https://www.consul.io/api/index.html
5 |
6 | 
7 |
8 | ### Usage:
9 |
10 | Install-Package ConsulSharp -Version 0.1.1
11 |
12 | ```c#
13 | ///
14 | /// Read Key
15 | ///
16 | private static void ReadKey()
17 | {
18 | var kvGovern = new KVGovern();
19 | var result = kvGovern.ReadKey(new ReadKeyParmeter { Key = "lisconnectionstring" }).GetAwaiter().GetResult();
20 | Console.WriteLine(EntityToString(result));
21 | }
22 |
23 | ///
24 | /// List Nodes
25 | ///
26 | private static void ListNodes()
27 | {
28 | var catalogGovern = new CatalogGovern();
29 | var result = catalogGovern.ListNodes(new ListNodesParmeter { DC = "dc1" }).GetAwaiter().GetResult();
30 | Console.WriteLine(EntityToString(result));
31 | }
32 |
33 | ///
34 | /// Register Service
35 | ///
36 | private static void RegisterService()
37 | {
38 | var agentGovern = new AgentGovern();
39 | var result = agentGovern.RegisterServices(new RegisterServiceParmeter
40 | {
41 | ID = "test0001",
42 | Name = "test0001",
43 | Address = "http://165.125.1.12",
44 | Port = 80,
45 | Tags = new string[] { "His"}
46 | }).GetAwaiter().GetResult();
47 | Console.WriteLine($"result={result.result}");
48 | Console.WriteLine($"back content={result.backJson}");
49 | }
50 | ```
51 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Event/EventGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.Event
11 | {
12 | ///
13 | /// Event Govern
14 | ///
15 | public class EventGovern : Govern
16 | {
17 | ///
18 | /// ctor
19 | ///
20 | /// Base Address
21 | public EventGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
22 | {
23 | }
24 | ///
25 | /// Fire Event,This endpoint triggers a new user event.
26 | ///
27 | /// Fire Event Parmeter
28 | ///
29 | public async Task<(bool result, FireEvent fireEvent)> FireEvent(FireEventParmeter fireEventParmeter)
30 | {
31 | return await Put(fireEventParmeter, $"/event/fire/{fireEventParmeter.Name}");
32 | }
33 | ///
34 | /// Fire Event,This endpoint returns the most recent events known by the agent. As a consequence of how the event command works, each agent may have a different view of the events. Events are broadcast using the gossip protocol, so they have no global ordering nor do they make a promise of delivery.
35 | ///
36 | /// List Event Parmeter
37 | ///
38 | public async Task EventList(ListEventParmeter listEventParmeter)
39 | {
40 | return await Get($"/event/list", listEventParmeter);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/ListChecks.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | ///
8 | /// Health Check,List Checks
9 | ///
10 | public class ListChecks
11 | {
12 | ///
13 | /// Node Name
14 | ///
15 | public string Node
16 | { get; set; }
17 | ///
18 | /// Check ID
19 | ///
20 | public string CheckID
21 | { get; set; }
22 | ///
23 | /// Check Name
24 | ///
25 | public string Name
26 | { get; set; }
27 |
28 | ///
29 | /// Check Status(passing, warning, or critical)
30 | ///
31 | public string Status
32 | { get; set; }
33 |
34 | ///
35 | /// Notes
36 | ///
37 | public string Notes
38 | { get; set; }
39 |
40 | ///
41 | /// Output
42 | ///
43 | public string Output
44 | { get; set; }
45 | ///
46 | /// Service ID
47 | ///
48 | public string ServiceID
49 | { get; set; }
50 | ///
51 | /// Service Name
52 | ///
53 | public string ServiceName { get; set; }
54 | ///
55 | /// Service Tags
56 | ///
57 | public string[] ServiceTags { get; set; }
58 | ///
59 | /// Definition
60 | ///
61 | public object Definition { get; set; }
62 | ///
63 | /// Create Index
64 | ///
65 | public int CreateIndex { get; set; }
66 | ///
67 | /// Modify Index
68 | ///
69 | public int ModifyIndex { get; set; }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/CreatePreparedQueryParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Create Prepared Query Parmeter
9 | ///
10 | public class CreatePreparedQueryParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
14 | ///
15 | public string DC { get; set; }
16 | ///
17 | /// Specifies an optional friendly name that can be used to execute a query instead of using its ID.
18 | ///
19 | public string Name { get; set; }
20 | ///
21 | /// Specifies the ID of an existing session. This provides a way to automatically remove a prepared query when the given session is invalidated. If not given the prepared query must be manually removed when no longer needed.
22 | ///
23 | public string Session { get; set; }
24 | ///
25 | /// Specifies the ACL token to use each time the query is executed. This allows queries to be executed by clients with lesser or even no ACL Token, so this should be used with care. The token itself can only be seen by clients with a management token. If the Token field is left blank or omitted, the client's ACL Token will be used to determine if they have access to the service being queried. If the client does not supply an ACL Token, the anonymous token will be used.
26 | ///
27 | public string Token { get; set; }
28 | ///
29 | /// Specifies the structure to define the query's behavior.
30 | ///
31 | public Service Service { get; set; }
32 | ///
33 | /// Specifies the TTL duration when query results are served over DNS. If this is specified, it will take precedence over any Consul agent-specific configuration.
34 | ///
35 | public DNS DNS { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/ListNodesForServiceResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Catalog
6 | {
7 | ///
8 | /// List Nodes For Service Result
9 | ///
10 | public class ListNodesForServiceResult
11 | {
12 | ///
13 | /// ID
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Node
18 | ///
19 | public string Node { get; set; }
20 | ///
21 | /// Address
22 | ///
23 | public string Address { get; set; }
24 | ///
25 | /// Datacenter
26 | ///
27 | public string Datacenter { get; set; }
28 | ///
29 | /// TaggedAddres
30 | ///
31 | public TaggedAddress TaggedAddresses { get; set; }
32 | ///
33 | /// Node Meta
34 | ///
35 | public object NodeMeta { get; set; }
36 |
37 | ///
38 | /// Create Index
39 | ///
40 | public int CreateIndex { get; set; }
41 |
42 | ///
43 | /// Modify Index
44 | ///
45 | public int ModifyIndex { get; set; }
46 |
47 | ///
48 | /// Service Address
49 | ///
50 | public string ServiceAddress { get; set; }
51 | ///
52 | /// Service Enable Tag Override
53 | ///
54 | public bool ServiceEnableTagOverride { get; set; }
55 |
56 | ///
57 | /// Service ID
58 | ///
59 | public string ServiceID { get; set; }
60 | ///
61 | /// Service Name
62 | ///
63 | public string ServiceName { get; set; }
64 | ///
65 | /// Service Port
66 | ///
67 | public int ServicePort { get; set; }
68 |
69 | ///
70 | /// Service Tags
71 | ///
72 | public string[] ServiceTags { get; set; }
73 |
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27130.2026
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsulSharp", "ConsulSharp\ConsulSharp.csproj", "{4AA600F5-0295-4889-88B9-F9AF31B24C5D}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsulSharpSample", "ConsulSharpSample\ConsulSharpSample.csproj", "{8261AD35-9611-43C6-BF5B-879FAC592BE7}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsulSharpSample2", "ConsulSharpSample2\ConsulSharpSample2.csproj", "{A4FCE303-DB77-46BD-AFCF-1E956228C2B2}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {4AA600F5-0295-4889-88B9-F9AF31B24C5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {4AA600F5-0295-4889-88B9-F9AF31B24C5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {4AA600F5-0295-4889-88B9-F9AF31B24C5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {4AA600F5-0295-4889-88B9-F9AF31B24C5D}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {8261AD35-9611-43C6-BF5B-879FAC592BE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {8261AD35-9611-43C6-BF5B-879FAC592BE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {8261AD35-9611-43C6-BF5B-879FAC592BE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {8261AD35-9611-43C6-BF5B-879FAC592BE7}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {A4FCE303-DB77-46BD-AFCF-1E956228C2B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {A4FCE303-DB77-46BD-AFCF-1E956228C2B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {A4FCE303-DB77-46BD-AFCF-1E956228C2B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {A4FCE303-DB77-46BD-AFCF-1E956228C2B2}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {274B031B-6255-4F0C-B478-1F9980CBEEC1}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Snapshot/SnapshotGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.Snapshot
11 | {
12 | ///
13 | /// Snapshot Govern
14 | ///
15 | public class SnapshotGovern : Govern
16 | {
17 | ///
18 | /// ctor
19 | ///
20 | /// Base Address
21 | public SnapshotGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
22 | {
23 | }
24 |
25 | ///
26 | /// This endpoint generates and returns an atomic, point-in-time snapshot of the Consul server state. Snapshots are exposed as gzipped tar archives which internally contain the Raft metadata required to restore, as well as a binary serialized version of the Consul server state.The contents are covered internally by SHA-256 hashes.These hashes are verified during snapshot restore operations.The structure of the archive is internal to Consul and not intended to be used other than for restore operations.The archives are not designed to be modified before a restore.
27 | ///
28 | ///
29 | ///
30 | public async Task GenerateSnapshot(GenerateSnapshotParmeter generateSnapshotParmeter)
31 | {
32 | return await Get($"/snapshot", generateSnapshotParmeter);
33 | }
34 |
35 | ///
36 | /// The body of the request should be a snapshot archive returned from a previous call to the GET method.
37 | ///
38 | /// Restore Snapshot Result
39 | ///
40 | public async Task<(bool result, string restoreSnapshotResult)>
41 | RestoreSnapshot(RestoreSnapshotParmeter restoreSnapshotParmeter)
42 | {
43 | return await Put(restoreSnapshotParmeter, $"/snapshot");
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Session/CreateSessionParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Session
6 | {
7 | ///
8 | /// Create Session Parmeter
9 | ///
10 | public class CreateSessionParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter. Using this across datacenters is not recommended.
14 | ///
15 | public string DC { get; set; }
16 | ///
17 | /// Specifies the duration for the lock delay.
18 | ///
19 | public string LockDelay { get; set; }
20 | ///
21 | /// Specifies the name of the node.This must refer to a node that is already registered.
22 | ///
23 | public string Node { get; set; }
24 | ///
25 | /// Specifies a human-readable name for the session.
26 | ///
27 | public string Name { get; set; }
28 | ///
29 | /// specifies a list of associated health checks.It is highly recommended that, if you override this list, you include the default serfHealth.
30 | ///
31 | public string[] Checks { get; set; }
32 | ///
33 | /// Controls the behavior to take when a session is invalidated. Valid values are:
34 | /// release - causes any locks that are held to be released
35 | /// delete - causes any locks that are held to be deleted
36 | ///
37 | public string Behavior { get; set; }
38 | ///
39 | /// Specifies the number of seconds(between 10s and 86400s). If provided, the session is invalidated if it is not renewed before the TTL expires.The lowest practical TTL should be used to keep the number of managed sessions low. When locks are forcibly expired, such as during a leader election, sessions may not be reaped for up to double this TTL, so long TTL values (> 1 hour) should be avoided.
40 | ///
41 | public string TTL { get; set; }
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Transactions/TransactionsGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.Transactions
11 | {
12 | ///
13 | /// Transactions Govern
14 | ///
15 | public class TransactionsGovern : Govern
16 | {
17 | ///
18 | /// ctor
19 | ///
20 | /// Base Address
21 | public TransactionsGovern(string baseAddress = "http://localhost:8500"):base(baseAddress)
22 | {
23 | }
24 | ///
25 | /// This endpoint permits submitting a list of operations to apply to the KV store inside of a transaction. If any operation fails, the transaction is rolled back and none of the changes are applied.
26 | ///If the transaction does not contain any write operations then it will be fast-pathed internally to an endpoint that works like other reads, except that blocking queries are not currently supported.In this mode, you may supply the ?stale or ?consistent query parameters with the request to control consistency.To support bounding the acceptable staleness of data, read-only transaction responses provide the X-Consul-LastContact header containing the time in milliseconds that a server was last contacted by the leader node.The X-Consul-KnownLeader header also indicates if there is a known leader.These won't be present if the transaction contains any write operations, and any consistency query parameters will be ignored, since writes are always managed by the leader via the Raft consensus protocol.
27 | ///
28 | /// Create Transaction Parmeter
29 | ///
30 | public async Task<(bool result, CreateTransactionResult createTransactionResult)> CreateTransaction(CreateTransactionParmeter createTransactionParmeter)
31 | {
32 | return await Put(createTransactionParmeter, $"/txn");
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Raft/OperatorRaftGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using ConsulSharp.Operator.Area;
10 | using ConsulSharp.Operator.Autopilot;
11 | using ConsulSharp.Operator.Keyring;
12 | namespace ConsulSharp.Operator.Raft
13 | {
14 | ///
15 | /// Operator Raft Govern
16 | ///
17 | public class OperatorRaftGovern : Govern
18 | {
19 |
20 | ///
21 | /// ctor
22 | ///
23 | /// Base Address
24 | public OperatorRaftGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
25 | {
26 | }
27 | ///
28 | /// This endpoint reads the current raft configuration.
29 | ///
30 | ///
31 | ///
32 | public async Task ReadConfiguration(ReadConfigurationParmeter readConfigurationParmeter)
33 | {
34 | return await Get("/operator/raft/configuration", readConfigurationParmeter);
35 | }
36 |
37 | ///
38 | /// This endpoint removes the Consul server with given address from the Raft configuration.There are rare cases where a peer may be left behind in the Raft configuration even though the server is no longer present and known to the cluster.This endpoint can be used to remove the failed server so that it is no longer affects the Raft quorum.If ACLs are enabled, the client will need to supply an ACL Token with operator write privileges.
39 | ///
40 | /// Delete Raft Peer Parmeter
41 | ///
42 | public async Task<(bool result, string backResult)> DeleteGossipEncryptionKey(DeleteRaftPeerParmeter deleteRaftPeerParmeter)
43 | {
44 | return await Delete(deleteRaftPeerParmeter, " /operator/raft/peer");
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/ListNetworkAreaMembersResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Area
6 | {
7 | ///
8 | /// List Network Area Members Result
9 | ///
10 | public class ListNetworkAreaMembersResult
11 | {
12 | ///
13 | /// ID is the node ID of the server.
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Name is the node name of the server, with its datacenter appended.
18 | ///
19 | public string Name { get; set; }
20 | ///
21 | /// Addr is the IP address of the node.
22 | ///
23 | public string Addr { get; set; }
24 | ///
25 | /// Port is the server RPC port of the node.
26 | ///
27 | public int Port { get; set; }
28 | ///
29 | /// Datacenter is the node's Consul datacenter.
30 | ///
31 | public string Datacenter { get; set; }
32 | ///
33 | /// Role is always "server" since only Consul servers can participate in network areas.
34 | ///
35 | public string Role { get; set; }
36 | ///
37 | /// Build has the Consul version running on the node.
38 | ///
39 | public string Build { get; set; }
40 | ///
41 | /// Protocol is the protocol version being spoken by the node.
42 | ///
43 | public string Protocol { get; set; }
44 | ///
45 | /// Status is the current health status of the node, as determined by the network area distributed failure detector. This will be "alive", "leaving", "left", or "failed". A "failed" status means that other servers are not able to probe this server over its server RPC interface.
46 | ///
47 | public string Status { get; set; }
48 | ///
49 | /// RTT is an estimated network round trip time from the server answering the query to the given server, in nanoseconds. This is computed using network coordinates.
50 | ///
51 | public string RTT { get; set; }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.PreparedQueries
6 | {
7 | ///
8 | /// Service
9 | ///
10 | public class Service
11 | {
12 | ///
13 | /// Specifies the name of the service to query.
14 | ///
15 | public string service { get; set; }
16 | ///
17 | /// contains two fields, both of which are optional, and determine what happens if no healthy nodes are available in the local datacenter when the query is executed. It allows the use of nodes in other datacenters with very little configuration.
18 | ///
19 | public Failover Failover { get; set; }
20 | ///
21 | /// Specifies a node to sort near based on distance sorting using Network Coordinates. The nearest instance to the specified node will be returned first, and subsequent nodes in the response will be sorted in ascending order of estimated round-trip times. If the node given does not exist, the nodes in the response will be shuffled. Using _agent is supported, and will automatically return results nearest the agent servicing the request. If unspecified, the response will be shuffled by default.
22 | ///
23 | public string Near { get; set; }
24 | ///
25 | /// Specifies the behavior of the query's health check filtering. If this is set to false, the results will include nodes with checks in the passing as well as the warning states. If this is set to true, only nodes with checks in the passing state will be returned.
26 | ///
27 | public bool OnlyPassing { get; set; }
28 |
29 | ///
30 | /// Specifies a list of service tags to filter the query results. For a service to pass the tag filter it must have all of the required tags, and none of the excluded tags (prefixed with !).
31 | ///
32 | public string[] Tags { get; set; }
33 | ///
34 | /// Specifies a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.
35 | ///
36 | public NodeMeta NodeMeta { get; set; }
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/ACL/ACLReplicationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.ACL
6 | {
7 | ///
8 | /// Check ACL Replication
9 | ///
10 | public class ACLReplicationResult
11 | {
12 | ///
13 | /// reports whether ACL replication is enabled for the datacenter.
14 | ///
15 | public bool Enabled { get; set; }
16 | ///
17 | /// reports whether the ACL replication process is running. The process may take approximately 60 seconds to begin running after a leader election occurs.
18 | ///
19 | public bool Running { get; set; }
20 | ///
21 | /// is the authoritative ACL datacenter that ACLs are being replicated from, and will match the acl_datacenter configuration.
22 | ///
23 | public string SourceDatacenter { get; set; }
24 | ///
25 | /// is the last index that was successfully replicated. You can compare this to the X-Consul-Index header returned by the /v1/acl/list endpoint to determine if the replication process has gotten all available ACLs. Replication runs as a background process approximately every 30 seconds, and that local updates are rate limited to 100 updates/second, so so it may take several minutes to perform the initial sync of a large set of ACLs. After the initial sync, replica lag should be on the order of about 30 seconds.
26 | ///
27 | public int ReplicatedIndex { get; set; }
28 | ///
29 | /// is the UTC time of the last successful sync operation. Since ACL replication is done with a blocking query, this may not update for up to 5 minutes if there have been no ACL changes to replicate. A zero value of "0001-01-01T00:00:00Z" will be present if no sync has been successful.
30 | ///
31 | public string LastSuccess { get; set; }
32 | ///
33 | /// is the UTC time of the last error encountered during a sync operation. If this time is later than LastSuccess, you can assume the replication process is not in a good state. A zero value of "0001-01-01T00:00:00Z" will be present if no sync has resulted in an error.
34 | ///
35 | public string LastError { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Autopilot/Server.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Autopilot
6 | {
7 | ///
8 | /// Read Health Server
9 | ///
10 | public class Server
11 | {
12 | ///
13 | /// ID is the Raft ID of the server.
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Name is the node name of the server.
18 | ///
19 | public string Name { get; set; }
20 | ///
21 | /// Address is the address of the server.
22 | ///
23 | public string Address { get; set; }
24 | ///
25 | /// SerfStatus is the SerfHealth check status for the server.
26 | ///
27 | public string SerfStatus { get; set; }
28 | ///
29 | /// Version is the Consul version of the server.
30 | ///
31 | public string Version { get; set; }
32 | ///
33 | /// Leader is whether this server is currently the leader.
34 | ///
35 | public bool Leader { get; set; }
36 | ///
37 | /// LastContact is the time elapsed since this server's last contact with the leader.
38 | ///
39 | public string LastContact { get; set; }
40 | ///
41 | /// LastTerm is the server's last known Raft leader term.
42 | ///
43 | public int LastTerm { get; set; }
44 | ///
45 | /// LastIndex is the index of the server's last committed Raft log entry.
46 | ///
47 | public int LastIndex { get; set; }
48 | ///
49 | /// Healthy is whether the server is healthy according to the current Autopilot configuration.
50 | ///
51 | public bool Healthy { get; set; }
52 | ///
53 | /// Voter is whether the server is a voting member of the Raft cluster.
54 | ///
55 | public bool Voter { get; set; }
56 | ///
57 | /// StableSince is the time this server has been in its current Healthy state.
58 | ///
59 | public string StableSince { get; set; }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/KV/CreateUpdateKeyParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.KV
6 | {
7 | ///
8 | /// Create Update Key Parmeter
9 | ///
10 | public class CreateUpdateKeyParmeter
11 | {
12 | ///
13 | /// Specifies the path of the key to read.
14 | ///
15 | public string Key { get; set; }
16 | ///
17 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
18 | ///
19 | public string DC { get; set; }
20 | ///
21 | /// Specifies an unsigned value between 0 and (2^64)-1. Clients can choose to use this however makes sense for their application. This is specified as part of the URL as a query parameter.
22 | ///
23 | public int Flags { get; set; }
24 | ///
25 | /// Specifies to use a Check-And-Set operation. This is very useful as a building block for more complex synchronization primitives. If the index is 0, Consul will only put the key if it does not already exist. If the index is non-zero, the key is only set if the index matches the ModifyIndex of that key.
26 | ///
27 | public int Cas { get; set; }
28 | ///
29 | /// Specifies to use a lock acquisition operation. This is useful as it allows leader election to be built on top of Consul. If the lock is not held and the session is valid, this increments the LockIndex and sets the Session value of the key in addition to updating the key contents. A key does not need to exist to be acquired. If the lock is already held by the given session, then the LockIndex is not incremented but the key contents are updated. This lets the current lock holder update the key contents without having to give up the lock and reacquire it.
30 | ///
31 | public string Acquire{ get; set; }
32 | ///
33 | /// Specifies to use a lock release operation. This is useful when paired with ?acquire= as it allows clients to yield a lock. This will leave the LockIndex unmodified but will clear the associated Session of the key. The key must be held by this session to be unlocked.
34 | public string Release { get; set; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Autopilot/OperatorAutopilotGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 |
8 | using System.Threading.Tasks;
9 | namespace ConsulSharp.Operator.Autopilot
10 | {
11 | ///
12 | /// Operator Autopilot Govern
13 | ///
14 | public class OperatorAutopilotGovern : Govern
15 | {
16 |
17 | ///
18 | /// ctor
19 | ///
20 | /// Base Address
21 | public OperatorAutopilotGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
22 | {
23 | }
24 |
25 | #region Autopilot
26 | ///
27 | /// This endpoint retrieves its latest Autopilot configuration.
28 | ///
29 | /// Read Configuration Result
30 | ///
31 | public async Task ReadConfiguration(ReadConfigurationParmeter readConfigurationParmeter)
32 | {
33 | return await Get("/operator/autopilot/configuration", readConfigurationParmeter);
34 | }
35 |
36 | ///
37 | /// This endpoint updates the Autopilot configuration of the cluster.
38 | ///
39 | /// Update Configuration Parmeter
40 | ///
41 | public async Task<(bool result, string jsonContent)> UpdateConfiguration(UpdateConfigurationParmeter updateConfigurationParmeter)
42 | {
43 | return await Put(updateConfigurationParmeter, "/operator/autopilot/configuration");
44 | }
45 | ///
46 | /// This endpoint queries the health of the autopilot status.
47 | ///
48 | /// Read Health Parmeter
49 | ///
50 | public async Task ReadHealth(ReadHealthParmeter readHealthParmeter)
51 | {
52 | return await Get("/operator/autopilot/health", readHealthParmeter);
53 | }
54 |
55 |
56 | #endregion
57 |
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/KV/KVGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.KV
11 | {
12 | ///
13 | /// KV Govern
14 | ///
15 | public class KVGovern: Govern
16 | {
17 | ///
18 | /// ctor
19 | ///
20 | /// Base Address
21 | public KVGovern(string baseAddress = "http://localhost:8500"):base(baseAddress)
22 | {
23 | }
24 |
25 | ///
26 | /// This endpoint returns the specified key. If no key exists at the given path, a 404 is returned instead of a 200 response.For multi-key reads, please consider using transaction.
27 | ///
28 | /// Read Key Parmeter
29 | ///
30 | public async Task ReadKey(ReadKeyParmeter readKeyParmeter)
31 | {
32 | return await Get($"/kv/{readKeyParmeter.Key}", readKeyParmeter);
33 | }
34 |
35 | ///
36 | /// Even though the return type is application/json, the value is either true or false, indicating whether the create/update succeeded.The table below shows this endpoint's support for blocking queries, consistency modes, and required ACLs.
37 | ///
38 | /// Create Update Key Parmeter
39 | /// value
40 | ///
41 | public async Task<(bool result, bool createUpdateResult)> CreateUpdateKey(CreateUpdateKeyParmeter createUpdateKeyParmeter,object value)
42 | {
43 | return await Put(createUpdateKeyParmeter,value, $"/kv/{createUpdateKeyParmeter.Key}");
44 | }
45 | ///
46 | /// This endpoint deletes a single key or all keys sharing a prefix.
47 | ///
48 | /// Delete Key Parmeter
49 | ///
50 | public async Task<(bool result, bool deleteResult)> DeleteKey(DeleteKeyParmeter deleteKeyParmeter)
51 | {
52 | return await Delete(deleteKeyParmeter, $"/kv/{deleteKeyParmeter.Key}");
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Coordnates/CoordnatesGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.Coordinates
11 | {
12 | ///
13 | /// Coordnates Govern
14 | ///
15 | public class CoordnatesGovern : Govern
16 | {
17 |
18 | ///
19 | /// ctor
20 | ///
21 | /// Base Address
22 | public CoordnatesGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
23 | {
24 | }
25 | ///
26 | /// This endpoint returns the WAN network coordinates for all Consul servers, organized by datacenters. It serves data out of the server's local Serf data, so its results may vary as requests are handled by different servers in the cluster.
27 | ///
28 | ///
29 | public async Task ReadWANCoordinates()
30 | {
31 | return await Get($"/coordinate/datacenters");
32 | }
33 | ///
34 | /// This endpoint returns the LAN network coordinates for all nodes in a given datacenter.
35 | ///
36 | /// LAN Coordinates Parmeter
37 | ///
38 | public async Task ReadLANCoordinatesForAllNodes(LANCoordinatesParmeter lANCoordinatesParmeter)
39 | {
40 | return await Get($"/coordinate/nodes", lANCoordinatesParmeter);
41 | }
42 | ///
43 | /// This endpoint returns the LAN network coordinates for the given node.
44 | ///
45 | /// LAN Coordinates Parmeter
46 | ///
47 | public async Task ReadLANCoordinatesForANodes(LANCoordinatesParmeter lANCoordinatesParmeter)
48 | {
49 | return await Get($"/coordinate/node/{lANCoordinatesParmeter.Node}", lANCoordinatesParmeter);
50 | }
51 |
52 | ///
53 | /// This endpoint updates the LAN network coordinates for a node in a given datacenter.
54 | ///
55 | ///
56 | /// datacenter
57 | public async Task<(bool result, LANCoordinatesParmeter lanCoordinates)> UpdateLANCoordinatesForANode(Coordinate coordinate,string dc)
58 | {
59 | return await Put(coordinate, $"/coordinate/update?dc={dc}");
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Autopilot/UpdateConfigurationParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Operator.Autopilot
6 | {
7 | ///
8 | /// Update Configuration Parmeter
9 | ///
10 | public class UpdateConfigurationParmeter
11 | {
12 | ///
13 | /// Specifies the datacenter to query.This will default to the datacenter of the agent being queried.This is specified as part of the URL as a query string.
14 | ///
15 | public string DC { get; set; }
16 |
17 | ///
18 | /// Specifies to use a Check-And-Set operation.The update will only happen if the given index matches the ModifyIndex of the configuration at the time of writing.
19 |
20 | ///
21 | public int Cas { get; set; }
22 |
23 | ///
24 | /// Specifies automatic removal of dead server nodes periodically and whenever a new server is added to the cluster.
25 | ///
26 | public bool CleanupDeadServers { get; set; }
27 | ///
28 | /// Specifies the maximum amount of time a server can go without contact from the leader before being considered unhealthy.Must be a duration value such as 10s.
29 | ///
30 | public string LastContactThreshold { get; set; }
31 | ///
32 | /// specifies the maximum number of log entries that a server can trail the leader by before being considered unhealthy.
33 | ///
34 | public int MaxTrailingLogs { get; set; }
35 | ///
36 | /// Specifies the minimum amount of time a server must be stable in the 'healthy' state before being added to the cluster.Only takes effect if all servers are running Raft protocol version 3 or higher.Must be a duration value such as 30s.
37 | ///
38 | public string ServerStabilizationTime { get; set; }
39 |
40 | ///
41 | /// Controls the node-meta key to use when Autopilot is separating servers into zones for redundancy.Only one server in each zone can be a voting member at one time.If left blank, this feature will be disabled.
42 | ///
43 | public string RedundancyZoneTag { get; set; }
44 |
45 | ///
46 | /// Disables Autopilot's upgrade migration strategy in Consul Enterprise of waiting until enough newer-versioned servers have been added to the cluster before promoting any of them to voters.
47 | ///
48 | public bool DisableUpgradeMigration { get; set; }
49 | ///
50 | /// Controls the node-meta key to use for version info when performing upgrade migrations.If left blank, the Consul version will be used.
51 | ///
52 | public string UpgradeVersionTag { get; set; }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/CatalogEntityParmeter.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | namespace ConsulSharp.Catalog
4 | {
5 | ///
6 | /// Register Entity Parmeter
7 | ///
8 | public class RegisterEntityParmeter
9 | {
10 | ///
11 | /// An optional UUID to assign to the service. If not provided, one is generated. This must be a 36-character UUID.
12 | ///
13 | public string ID { get; set; }
14 | ///
15 | /// Specifies the datacenter, which defaults to the agent's datacenter if not provided.
16 | ///
17 | public string Datacenter { get; set; }
18 |
19 | ///
20 | /// Specifies the node ID to register.
21 | ///
22 | public string Node { get; set; }
23 | ///
24 | /// Specifies the address to register.
25 | ///
26 | public string Address { get; set; }
27 | ///
28 | /// Specifies the tagged addresses.
29 | ///
30 | public TaggedAddress TaggedAddresses { get; set; }
31 | ///
32 | /// Specifies arbitrary KV metadata pairs for filtering purposes.
33 | ///
34 | public object NodeMeta { get; set; }
35 | ///
36 | /// Specifies to register a service. If ID is not provided, it will be defaulted to the value of the Service.Service property. Only one service with a given ID may be present per node. The service Tags, Address, and Port fields are all optional.
37 | ///
38 | public CatalogEntityService Service { get; set; }
39 | ///
40 | /// Specifies to register a check. The register API manipulates the health check entry in the Catalog, but it does not setup the script, TTL, or HTTP check to monitor the node's health. To truly enable a new health check, the check must either be provided in agent configuration or set via the agent endpoint.The CheckID can be omitted and will default to the value of Name. As with Service.ID, the CheckID must be unique on this node. Notes is an opaque field that is meant to hold human-readable text. If a ServiceID is provided that matches the ID of a service on that node, the check is treated as a service level health check, instead of a node level health check. The Status must be one of passing, warning, or critical.The Definition field can be provided with details for a TCP or HTTP health check.For more information, see the Health Checks page.Multiple checks can be provided by replacing Check with Checks and sending an array of Check objects.
41 | ///
42 | public ConsulSharp.Catalog.Check Check { get; set; }
43 | ///
44 | /// Specifies whether to skip updating the node part of the registration. Useful in the case where only a health check or service entry on a node needs to be updated.
45 | ///
46 | public bool SkipNodeUpdate { get; set; }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharpSample2/ConsulSharpSample2.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {A4FCE303-DB77-46BD-AFCF-1E956228C2B2}
8 | Exe
9 | ConsulSharpSample2
10 | ConsulSharpSample2
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {4aa600f5-0295-4889-88b9-f9af31b24c5d}
58 | ConsulSharp
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Health/HealthGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.Health
11 | {
12 | ///
13 | /// Health Govern
14 | ///
15 | public class HealthGovern : Govern
16 | {
17 |
18 | ///
19 | /// ctor
20 | ///
21 | /// Base Address
22 | public HealthGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
23 | {
24 | }
25 |
26 | ///
27 | /// This endpoint returns the checks specific to the node provided on the path.
28 | ///
29 | /// Check Node Parmeter
30 | ///
31 | public async Task ListChecksForNode(ListCheckForNodeParmeter checkNodeParmeter)
32 | {
33 | return await Get($"/health/node/{checkNodeParmeter.Node}", checkNodeParmeter);
34 | }
35 |
36 |
37 | ///
38 | ///List Checks for Service,This endpoint returns the checks associated with the service provided on the path.
39 | ///
40 | /// Check Service Parmeter
41 | ///
42 | public async Task ListChecksForService(CheckServiceParmeter checkServiceParmeter)
43 | {
44 | return await Get($"/health/checks/{checkServiceParmeter.Service}", checkServiceParmeter);
45 | }
46 |
47 | ///
48 | ///List Nodes for Service,This endpoint returns the nodes providing the service indicated on the path. Users can also build in support for dynamic load balancing and other features by incorporating the use of health checks.
49 | ///
50 | /// Node Service Parmeter
51 | ///
52 | public async Task ListNodeForService(ListNodeForServiceParmeter listNodeForServiceParmeter)
53 | {
54 | return await Get($"/health/service/{listNodeForServiceParmeter.Service}", listNodeForServiceParmeter);
55 | }
56 |
57 |
58 | ///
59 | ///List Checks in State,This endpoint returns the checks in the state provided on the path.
60 | ///
61 | /// Check Service Parmeter
62 | ///
63 | public async Task ListChecksInState(ListChecksInStateParmeter listChecksInStateParmeter)
64 | {
65 | return await Get($"/health/state/{listChecksInStateParmeter.State}", listChecksInStateParmeter);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Service/RegisterServiceParmeter.cs:
--------------------------------------------------------------------------------
1 | using AgentCheck=ConsulSharp.Agent.Check;
2 |
3 | namespace ConsulSharp.Agent.Service
4 | {
5 | ///
6 | /// Register Service Parmeter
7 | ///
8 | public class RegisterServiceParmeter
9 | {
10 | ///
11 | /// Specifies a unique ID for this service. This must be unique per agent. This defaults to the Name parameter if not provided.
12 | ///
13 | public string ID
14 | { get; set; }
15 | ///
16 | /// Specifies the logical name of the service. Many service instances may share the same logical service name.
17 | ///
18 | public string Name
19 | { get; set; }
20 | ///
21 | /// Specifies a list of tags to assign to the service. These tags can be used for later filtering and are exposed via the APIs.
22 | ///
23 | public string[] Tags
24 | {
25 | get; set;
26 | }
27 | ///
28 | /// Specifies the address of the service. If not provided, the agent's address is used as the address for the service during DNS queries.
29 | ///
30 | public string Address
31 | { get; set; }
32 | ///
33 | /// Port
34 | ///
35 | public int Port
36 | { get; set; }
37 | ///
38 | /// Specifies to disable the anti-entropy feature for this service's tags. If EnableTagOverride is set to true then external agents can update this service in the catalog and modify the tags. Subsequent local sync operations by this agent will ignore the updated tags. For instance, if an external agent modified both the tags and the port for this service and EnableTagOverride was set to true then after the next sync cycle the service's port would revert to the original value but the tags would maintain the updated value. As a counter example, if an external agent modified both the tags and port for this service and EnableTagOverride was set to false then after the next sync cycle the service's port and the tags would revert to the original value and all modifications would be lost.
39 | ///
40 | public bool EnableTagOverride
41 | { get; set; }
42 | ///
43 | /// Specifies a list of checks. Please see the check documentation for more information about the accepted fields. If you don't provide a name or id for the check then they will be generated. To provide a custom id and/or name set the CheckID and/or Name field. The automatically generated Name and CheckID depend on the position of the check within the array, so even though the behavior is deterministic, it is recommended for all checks to either let consul set the CheckID by leaving the field empty/omitting it or to provide a unique value.
44 | ///
45 | public AgentCheck.Check[] Checks
46 | { get; set; }
47 | ///
48 | /// Specifies a check. Please see the check documentation for more information about the accepted fields. If you don't provide a name or id for the check then they will be generated. To provide a custom id and/or name set the CheckID and/or Name field.
49 | ///
50 | public AgentCheck.Check Check { get; set; }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Keyring/OperatorKeyringGovern.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.Threading.Tasks;
3 | namespace ConsulSharp.Operator.Keyring
4 | {
5 | ///
6 | /// Operator Keyring Govern
7 | ///
8 | public class OperatorKeyringGovern : Govern
9 | {
10 |
11 | ///
12 | /// ctor
13 | ///
14 | /// Base Address
15 | public OperatorKeyringGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
16 | {
17 | }
18 |
19 | #region Keyring
20 | ///
21 | /// This endpoint lists the gossip encryption keys installed on both the WAN and LAN rings of every known datacenter.If ACLs are enabled, the client will need to supply an ACL Token with keyring read privileges.
22 | ///
23 | /// List Gossip Encryption Keys Parmeter
24 | ///
25 | public async Task ListGossipEncryptionKeys(ListGossipEncryptionKeysParmeter listGossipEncryptionKeysParmeter)
26 | {
27 | return await Get("/operator/keyring", listGossipEncryptionKeysParmeter);
28 | }
29 | ///
30 | /// This endpoint installs a new gossip encryption key into the cluster.
31 | ///
32 | /// Add New Gossip Encryption Key Parmeter
33 | ///
34 | public async Task<(bool result, ListGossipEncryptionKeysResult[] listGossipEncryptionKeysResults)> AddNewGossipEncryptionKey(AddNewGossipEncryptionKeyParmeter addNewGossipEncryptionKeyParmeter)
35 | {
36 | return await Post(addNewGossipEncryptionKeyParmeter, "/operator/keyring");
37 | }
38 |
39 | ///
40 | /// This endpoint changes the primary gossip encryption key. The key must already be installed before this operation can succeed.
41 | ///
42 | /// Add New Gossip Encryption Key Parmeter
43 | ///
44 | public async Task<(bool result, string backResult)> ChangePrimaryGossipEncryptionKey(AddNewGossipEncryptionKeyParmeter addNewGossipEncryptionKeyParmeter)
45 | {
46 | return await Put(addNewGossipEncryptionKeyParmeter, "/operator/keyring");
47 | }
48 | ///
49 | /// This endpoint removes a gossip encryption key from the cluster. This operation may only be performed on keys which are not currently the primary key.
50 | ///
51 | /// Add New Gossip Encryption Key Parmeter
52 | ///
53 | public async Task<(bool result, string backResult)> DeleteGossipEncryptionKey(AddNewGossipEncryptionKeyParmeter addNewGossipEncryptionKeyParmeter)
54 | {
55 | return await Delete(addNewGossipEncryptionKeyParmeter, "/operator/keyring");
56 | }
57 | #endregion
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Session/SessionGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.Session
11 | {
12 | ///
13 | /// Session Govern
14 | ///
15 | public class SessionGovern : Govern
16 | {
17 | ///
18 | /// ctor
19 | ///
20 | /// Base Address
21 | public SessionGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
22 | {
23 | }
24 | ///
25 | /// This endpoint initializes a new session. Sessions must be associated with a node and may be associated with any number of checks.
26 | ///
27 | /// Create Session Parmeter
28 | ///
29 | public async Task<(bool result, CreateSessionResult createSessionResult)> CreateSession(CreateSessionParmeter createSessionParmeter)
30 | {
31 | return await Put(createSessionParmeter, $"/session/create");
32 | }
33 | ///
34 | /// This endpoint destroys the session with the given name. If the session UUID is malformed, an error is returned. If the session UUID does not exist or already expired, a 200 is still returned (the operation is idempotent).
35 | ///
36 | /// Delete Session Parmeter
37 | ///
38 | public async Task<(bool result, bool deleteSessionResult)> DeleteSession(DeleteSessionParmeter deleteSessionParmeter)
39 | {
40 | return await Put(deleteSessionParmeter, $"/session/destroy/{deleteSessionParmeter.UUID}");
41 | }
42 |
43 | ///
44 | /// This endpoint returns the requested session information.
45 | ///
46 | /// Read Session Parmeter
47 | ///
48 | public async Task ReadSession(DeleteSessionParmeter readSessionParmeter)
49 | {
50 | return await Get($"/session/info/{readSessionParmeter.UUID}", readSessionParmeter);
51 | }
52 |
53 | ///
54 | /// This endpoint returns the active sessions for a given node.
55 | ///
56 | /// List Sessions For Node Parmeter
57 | ///
58 | public async Task ListSessionsForNode(ListSessionsForNodeParmeter listSessionsForNodeParmeter)
59 | {
60 | return await Get($"/Session/node/{listSessionsForNodeParmeter.Node}", listSessionsForNodeParmeter);
61 | }
62 | ///
63 | /// This endpoint returns the list of active sessions.
64 | ///
65 | /// List Sessions Parmeter
66 | ///
67 | public async Task ListSessions(ListSessionsParmeter listSessionsParmeter)
68 | {
69 | return await Get($"/Session/list", listSessionsParmeter);
70 | }
71 |
72 | ///
73 | /// This endpoint renews the given session. This is used with sessions that have a TTL, and it extends the expiration by the TTL.
74 | ///
75 | /// Renew Session Parmeter
76 | ///
77 | public async Task RenewSession(DeleteSessionParmeter renewSessionParmeter)
78 | {
79 | return await Get($"/Session/list", renewSessionParmeter);
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/PreparedQueries/PreparedQueriesGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.PreparedQueries
11 | {
12 | ///
13 | /// Prepared Queries Govern
14 | ///
15 | public class PreparedQueriesGovern : Govern
16 | {
17 | ///
18 | /// ctor
19 | ///
20 | /// Base Address
21 | public PreparedQueriesGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
22 | {
23 | }
24 | ///
25 | /// This endpoint creates a new prepared query and returns its ID if it is created successfully.
26 | ///
27 | /// Create Prepared Query Parmeter
28 | ///
29 | public async Task<(bool result, CreatePreparedQueryResult createPreparedQueryResult)> CreatePreparedQuery(CreatePreparedQueryParmeter createPreparedQueryParmeter)
30 | {
31 | return await Post(createPreparedQueryParmeter, $"/query");
32 | }
33 |
34 | ///
35 | /// This endpoint returns a list of all prepared queries.
36 | ///
37 | /// Read Prepared Query Parmeter
38 | ///
39 | public async Task ReadPreparedQuery(ReadPreparedQueryParmeter readPreparedQueryParmeter)
40 | {
41 | return await Get($"/query", readPreparedQueryParmeter);
42 | }
43 |
44 | ///
45 | /// This endpoint updates an existing prepared query. If no query exists by the given ID, an error is returned.
46 | ///
47 | /// Update Prepared Query Parmeter
48 | ///
49 | public async Task<(bool result, string backResult)> UpdatePreparedQuery(UpdatePreparedQueryParmeter updatePreparedQueryParmeter)
50 | {
51 | return await Put(updatePreparedQueryParmeter, $"/query");
52 | }
53 | ///
54 | /// This endpoint deletes an existing prepared query. If no query exists by the given ID, an error is returned.
55 | ///
56 | /// Update Prepared Query Parmeter
57 | ///
58 | public async Task<(bool result, string backResult)> DeletePreparedQuery(UpdatePreparedQueryParmeter updatePreparedQueryParmeter)
59 | {
60 | return await Delete(updatePreparedQueryParmeter, $"/query");
61 | }
62 |
63 |
64 |
65 | ///
66 | /// This endpoint executes an existing prepared query. If no query exists by the given ID, an error is returned.
67 | ///
68 | /// Execute Prepared Query Parmeter
69 | ///
70 | public async Task ExecutePreparedQuery(ExecutePreparedQueryParmeter executePreparedQueryParmeter)
71 | {
72 | return await Get($"/query/execute", executePreparedQueryParmeter);
73 | }
74 | ///
75 | /// This endpoint generates a fully-rendered query for a given name, post interpolation.
76 | ///
77 | /// Explain Prepared Query Parmeter
78 | ///
79 | public async Task ExplainPreparedQuery(ExplainPreparedQueryParmeter explainPreparedQueryParmeter)
80 | {
81 | return await Get($"/query/explain", explainPreparedQueryParmeter);
82 | }
83 |
84 |
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Operator/Area/OperatorAreaGovern.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace ConsulSharp.Operator.Area
4 | {
5 | ///
6 | /// Operator Area Govern
7 | ///
8 | public class OperatorAreaGovern : Govern
9 | {
10 |
11 | ///
12 | /// ctor
13 | ///
14 | /// Base Address
15 | public OperatorAreaGovern(string baseAddress = "http://127.0.0.1:8500") : base(baseAddress)
16 | {
17 | }
18 |
19 | #region Area
20 | ///
21 | /// This endpoint creates a new network area and returns its ID if it is created successfully.
22 | ///
23 | /// Create Network Area Parmeter
24 | ///
25 | public async Task<(bool result, CreateNetworkAreaResult createNetworkAreaResult)> CreateNetworkArea(CreateNetworkAreaParmeter createNetworkAreaParmeter)
26 | {
27 | return await Post(createNetworkAreaParmeter, $"/operator/area");
28 | }
29 | ///
30 | /// his endpoint lists all network areas.
31 | ///
32 | /// List Network Areas Parmeter
33 | ///
34 | public async Task ListNetworkAreas(ListNetworkAreasParmeter listNetworkAreasParmeter)
35 | {
36 | return await Get("/operator/area", listNetworkAreasParmeter);
37 | }
38 | ///
39 | /// This endpoint updates a network area to the given configuration.
40 | ///
41 | /// Update Network Area Parmeter
42 | ///
43 | public async Task<(bool result, string backString)> UpdateNetworkArea(UpdateNetworkAreaParmeter updateNetworkAreaParmeter)
44 | {
45 | return await Put(updateNetworkAreaParmeter, "/operator/area");
46 | }
47 |
48 | ///
49 | /// This endpoint lists a specific network area.
50 | ///
51 | /// ListSpecificNetworkAreaParmeter
52 | ///
53 | public async Task ListSpecificNetworkArea(NetworkAreaParmeter listSpecificNetworkAreaParmeter)
54 | {
55 | return await Get("/operator/area", listSpecificNetworkAreaParmeter);
56 | }
57 |
58 | ///
59 | /// This endpoint deletes a specific network area.
60 | ///
61 | /// Delete Network Area Parmeter
62 | ///
63 | public async Task<(bool result, string backString)> DeleteNetworkArea(NetworkAreaParmeter listSpecificNetworkAreaParmeter)
64 | {
65 | return await Delete(listSpecificNetworkAreaParmeter, "/operator/area");
66 | }
67 |
68 |
69 | ///
70 | /// This endpoint attempts to join the given Consul servers into a specific network area.
71 | ///
72 | /// List Specific Network Area Parmeter
73 | ///
74 | public async Task<(bool result, JoinNetworkAreaResult[] joinNetworkAreaResults)> JoinNetworkArea(NetworkAreaParmeter listSpecificNetworkAreaParmeter)
75 | {
76 | return await Put(listSpecificNetworkAreaParmeter, " /operator/area/join");
77 | }
78 |
79 | ///
80 | /// This endpoint provides a listing of the Consul servers present in a specific network area.
81 | ///
82 | /// List Specific Network Area Parmeter
83 | ///
84 | public async Task<(bool result, ListNetworkAreaMembersResult[] listNetworkAreaMembersResults)> ListNetworkAreaMembers(NetworkAreaParmeter listSpecificNetworkAreaParmeter)
85 | {
86 | return await Put(listSpecificNetworkAreaParmeter, "/operator/area/members");
87 | }
88 | #endregion
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Catalog/CatalogGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.Catalog
11 | {
12 | ///
13 | /// Service Govern
14 | ///
15 | public class CatalogGovern : Govern
16 | {
17 |
18 | ///
19 | /// ctor
20 | ///
21 | /// Base Address
22 | public CatalogGovern(string baseAddress = "http://localhost:8500") : base(baseAddress)
23 | {
24 | }
25 |
26 | #region catalog
27 | ///
28 | /// This endpoint is a low-level mechanism for registering or updating entries in the catalog. It is usually preferable to instead use the agent endpoints for registration as they are simpler and perform anti-entropy.
29 | ///
30 | ///
31 | /// Catalog Entity Parmeter
32 | public async Task<(bool result, string backJson)> RegisterEntity(RegisterEntityParmeter catalogEntityParmeter)
33 | {
34 | return await Put(catalogEntityParmeter, $"/catalog/register");
35 | }
36 | ///
37 | /// This endpoint is a low-level mechanism for directly removing entries from the Catalog. It is usually preferable to instead use the agent endpoints for deregistration as they are simpler and perform anti-entropy.
38 | ///
39 | ///
40 | /// Deregister Entity Parmeter
41 | public async Task<(bool result, string backJson)> DeregisterCatalog(DeregisterEntityParmeter deregisterEntityParmeter)
42 | {
43 | return await Put(deregisterEntityParmeter, $"/catalog/deregister");
44 | }
45 |
46 | ///
47 | /// This endpoint returns the list of all known datacenters. The datacenters will be sorted in ascending order based on the estimated median round trip time from the server to the servers in that datacenter. This endpoint does not require a cluster leader and will succeed even during an availability outage.Therefore, it can be used as a simple check to see if any Consul servers are routable.
48 | ///
49 | ///
50 | public async Task ListDatacenters()
51 | {
52 | return await Get("/catalog/datacenters");
53 | }
54 | ///
55 | /// This endpoint and returns the nodes registered in a given datacenter.
56 | ///
57 | ///
58 | /// List Nodes Parmeter
59 | public async Task ListNodes(ListNodesParmeter listNodesParmeter)
60 | {
61 | return await Get("/catalog/nodes", listNodesParmeter);
62 | }
63 |
64 | ///
65 | /// This endpoint returns the node's registered services.
66 | ///
67 | /// List Services For Node Parmeter
68 | ///
69 | public async Task ListServicesForNode(ListServicesForNodeParmeter listServicesForNodeParmeter)
70 | {
71 | return await Get($"/catalog/node", listServicesForNodeParmeter);
72 | }
73 | ///
74 | /// This endpoint returns the services registered in a given datacenter.
75 | ///
76 | /// List Services Parmeter
77 | ///
78 |
79 | public async Task> ListServices(ListServicesParmeter listServicesParmeter)
80 | {
81 | return await Get, ListServicesParmeter>("/catalog/services", listServicesParmeter);
82 | }
83 |
84 |
85 | ///
86 | /// This endpoint returns the nodes providing a service in a given datacenter.
87 | ///
88 | /// List Nodes For Service Parmeter
89 | ///
90 | public async Task ListNodesForService(ListNodesForServiceParmeter listNodesForServiceParmeter)
91 | {
92 | return await Get($"/catalog/service/{listNodesForServiceParmeter.Service}", listNodesForServiceParmeter);
93 | }
94 | #endregion
95 |
96 |
97 |
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/Agent/Check/RegisterCheckParmeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ConsulSharp.Agent.Check
6 | {
7 | ///
8 | /// register Check
9 | ///
10 | public class RegisterCheckParmeter
11 | {
12 | ///
13 | /// Specifies a unique ID for this check on the node. This defaults to the "Name" parameter, but it may be necessary to provide an ID for uniqueness.
14 | ///
15 | public string ID { get; set; }
16 | ///
17 | /// Specifies the name of the check.
18 | ///
19 | public string Name { get; set; }
20 | ///
21 | /// Specifies the frequency at which to run this check. This is required for HTTP and TCP checks.
22 | ///
23 | public string Interval { get; set; }
24 |
25 | ///
26 | /// Specifies arbitrary information for humans. This is not used by Consul internally.
27 | ///
28 | public string Notes { get; set; }
29 | ///
30 | /// Specifies that checks associated with a service should deregister after this time. This is specified as a time duration with suffix like "10m". If a check is in the critical state for more than this configured value, then its associated service (and all of its associated checks) will automatically be deregistered. The minimum timeout is 1 minute, and the process that reaps critical services runs every 30 seconds, so it may take slightly longer than the configured timeout to trigger the deregistration. This should generally be configured with a timeout that's much, much longer than any expected recoverable outage for the given service.
31 | ///
32 | public string DeregisterCriticalServiceAfter { get; set; }
33 | ///
34 | /// Specifies command arguments to run to update the status of the check. Prior to Consul 1.0, checks used a single Script field to define the command to run, and would always run in a shell. In Consul 1.0, the Args array was added so that checks can be run without a shell. The Script field is deprecated, and you should include the shell in the Args to run under a shell, eg. "args": ["sh", "-c", "..."].
35 | ///
36 | public string[] Args { get; set; }
37 | ///
38 | /// Specifies that the check is a Docker check, and Consul will evaluate the script every Interval in the given container using the specified Shell. Note that Shell is currently only supported for Docker checks.
39 | ///
40 | public string DockerContainerID { get; set; }
41 | ///
42 | /// shell
43 | ///
44 | public string Shell { get; set; }
45 | ///
46 | /// Specifies an HTTP check to perform a GET request against the value of HTTP (expected to be a URL) every Interval. If the response is any 2xx code, the check is passing. If the response is 429 Too Many Requests, the check is warning. Otherwise, the check is critical. HTTP checks also support SSL. By default, a valid SSL certificate is expected. Certificate verification can be controlled using the
47 | ///
48 | public string HTTP { get; set; }
49 | ///
50 | /// Specifies a different HTTP method to be used for an HTTP check. When no value is specified, GET is used.
51 | ///
52 | public string Method { get; set; }
53 | ///
54 | /// Specifies a set of headers that should be set for HTTP checks. Each header can have multiple values.
55 | ///
56 | public object Header { get; set; }
57 | ///
58 | /// Specifies a TCP to connect against the value of TCP (expected to be an IP or hostname plus port combination) every Interval. If the connection attempt is successful, the check is passing. If the connection attempt is unsuccessful, the check is critical. In the case of a hostname that resolves to both IPv4 and IPv6 addresses, an attempt will be made to both addresses, and the first successful connection attempt will result in a successful check.
59 | ///
60 | public string TCP { get; set; }
61 |
62 | ///
63 | /// Specifies this is a TTL check, and the TTL endpoint must be used periodically to update the state of the check.
64 | ///
65 | public string TTL { get; set; }
66 | ///
67 | /// Specifies if the certificate for an HTTPS check should not be verified.
68 | ///
69 | public string TLSSkipVerify { get; set; }
70 |
71 | ///
72 | /// Specifies the ID of a service to associate the registered check with an existing service provided by the agent.
73 | ///
74 | public string ServiceID { get; set; }
75 |
76 | ///
77 | /// Specifies the initial status of the health check.
78 | ///
79 | public string Satus { get; set; }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/ACL/ACLGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp.ACL
11 | {
12 | ///
13 | /// ACL Govern
14 | ///
15 | public class ACLGovern: Govern
16 | {
17 |
18 | ///
19 | /// ctor
20 | ///
21 | /// Base Address
22 | public ACLGovern(string baseAddress = "http://localhost:8500"):base(baseAddress)
23 | {
24 | }
25 | ///
26 | /// Bootstrap ACLs,This endpoint does a special one-time bootstrap of the ACL system, making the first management token if the acl_master_token is not specified in the Consul server configuration, and if the cluster has not been bootstrapped previously. This is available in Consul 0.9.1 and later, and requires all Consul servers to be upgraded in order to operate.
27 | ///
28 | ///
29 | public async Task<(bool result, BootstrapACLsResult backBootstrapACLs)> BootstrapACLs()
30 | {
31 | return await Put("", $"/acl/bootstrap");
32 | }
33 |
34 | ///
35 | /// Create ACL Token,This endpoint makes a new ACL token.
36 | ///
37 | ///
38 | /// ACL Token Parmeter
39 | public async Task<(bool result, BootstrapACLsResult backBootstrapACLs)> CreateACLToken(ACLTokenParmeter aclTokenParmeter)
40 | {
41 | return await Put< ACLTokenParmeter, BootstrapACLsResult>(aclTokenParmeter, $"/acl/create");
42 | }
43 |
44 | ///
45 | /// Update ACL Token,This endpoint is used to modify the policy for a given ACL token. Instead of generating a new token ID, the ID field must be provided.
46 | ///
47 | ///
48 | /// ACL Token Parmeter
49 | public async Task<(bool result, string backJson)> UpdateACLToken(ACLTokenParmeter aclTokenParmeter)
50 | {
51 | return await Put(aclTokenParmeter, $"/acl/update");
52 | }
53 |
54 | ///
55 | /// Delete ACL Token,This endpoint deletes an ACL token with the given ID.
56 | ///
57 | ///
58 | /// Specifies the UUID of the ACL token to destroy. This is required and is specified as part of the URL path.
59 | public async Task<(bool result, string backJson)> DeleteACLToken(string uuid)
60 | {
61 | return await Put("", $"/acl/destroy/{uuid}");
62 | }
63 |
64 | ///
65 | /// Read ACL Token,This endpoint reads an ACL token with the given ID.
66 | ///
67 | /// Specifies the UUID of the ACL token to read. This is required and is specified as part of the URL path.
68 | ///
69 | public async Task ReadACLToken(string uuid)
70 | {
71 | return await Get($"/acl/info/{uuid}");
72 | }
73 |
74 | ///
75 | /// Clone ACL Token,This endpoint clones an ACL and returns a new token ID. This allows a token to serve as a template for others, making it simple to generate new tokens without complex rule management.
76 | ///
77 | /// Specifies the UUID of the ACL token to read. This is required and is specified as part of the URL path.
78 | ///
79 | public async Task<(bool result, BootstrapACLsResult bootstrapACLsResult)> CloneACLToken(string uuid)
80 | {
81 | return await Put("", $"/acl/clone/{uuid}");
82 | }
83 |
84 | ///
85 | /// List ACLs,his endpoint lists all the active ACL tokens.
86 | ///
87 | ///
88 | public async Task ListACLs()
89 | {
90 | return await Get($"/acl/list");
91 | }
92 |
93 | ///
94 | /// Check ACL Replication,This endpoint returns the status of the ACL replication process in the datacenter. This is intended to be used by operators, or by automation checking the health of ACL replication.
95 | ///
96 | /// Specifies the datacenter to query. This will default to the datacenter of the agent being queried. This is specified as part of the URL as a query parameter.
97 | ///
98 | public async Task CheckACLReplication(string dc)
99 | {
100 | return await Get($"/acl/replication/{dc}");
101 | }
102 |
103 |
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/ConsulSharp/ConsulSharp/BaseGovern.cs:
--------------------------------------------------------------------------------
1 | using ConsulSharp.Health;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ConsulSharp
11 | {
12 | ///
13 | /// Service Govern
14 | ///
15 | public class Govern
16 | {
17 | HttpClient client;
18 |
19 | ///
20 | /// url prefix
21 | ///
22 | readonly string urlPrefix = "v1";
23 | ///
24 | /// base address
25 | ///
26 | protected string _baseAddress;
27 | ///
28 | /// ctor
29 | ///
30 | /// Base Address
31 | public Govern(string baseAddress = "http://127.0.0.1:8500")
32 | {
33 | _baseAddress = baseAddress;
34 | client = new HttpClient();
35 | }
36 | #region base method
37 | ///
38 | /// get
39 | ///
40 | /// back type
41 | /// request url
42 | /// datacenter
43 | ///
44 | public async Task Get(string url, string dataCenter = null)
45 | {
46 | client.BaseAddress = new Uri($"{_baseAddress}{(!string.IsNullOrEmpty(dataCenter) ? $"?dc={dataCenter}" : "")}");
47 | var response = await client.GetAsync($"/{urlPrefix}/{url}");
48 | var json = await response.Content.ReadAsStringAsync();
49 | if (!string.IsNullOrEmpty(json))
50 | {
51 | try
52 | {
53 | var entity = JsonConvert.DeserializeObject(json);
54 | return entity;
55 | }
56 | catch (JsonReaderException)
57 | {
58 | throw new ApplicationException($"back content is error formatter:{json}");
59 | }
60 | }
61 | else
62 | {
63 | throw new ApplicationException($"back content is empty.");
64 | }
65 | }
66 | ///
67 | /// get
68 | ///
69 | /// in parmeter
70 | /// out parmeter
71 | /// put url
72 | /// in entity
73 | ///
74 | public async Task Get(string url, W inEntity) where W : class, new()
75 | {
76 |
77 | client.BaseAddress = new Uri($"{_baseAddress}");
78 | var parString = GetUrlParmeter(inEntity);
79 | if (!string.IsNullOrEmpty(parString))
80 | {
81 | url += $"?{parString}";
82 | }
83 | var response = await client.GetAsync($"/{urlPrefix}/{url}");
84 | var json = await response.Content.ReadAsStringAsync();
85 | if (!string.IsNullOrEmpty(json))
86 | {
87 | try
88 | {
89 | var entity = JsonConvert.DeserializeObject(json);
90 | return entity;
91 | }
92 | catch (JsonReaderException)
93 | {
94 | throw new ApplicationException($"back content is error formatter:{json}");
95 | }
96 | }
97 | else
98 | {
99 | throw new ApplicationException($"back content is empty.");
100 | }
101 | }
102 |
103 | string GetUrlParmeter(W inEntity) where W : class, new()
104 | {
105 | var parmeterString = new StringBuilder();
106 | foreach (var pro in inEntity.GetType().GetProperties())
107 | {
108 | //if ((pro.GetValue(inEntity, null)) != pro.PropertyType.)
109 | {
110 | var proName = pro.Name;
111 | var atts = pro.GetCustomAttributes(typeof(FieldNameAttribute), false);
112 | if (atts.Length > 0)
113 | {
114 | proName = (atts[0] as FieldNameAttribute).ChangeFieldName;
115 | }
116 | parmeterString.Append($"{proName}={pro.GetValue(inEntity, null)}&");
117 | }
118 | }
119 | return parmeterString.ToString().Trim('&');
120 | }
121 |
122 | ///
123 | /// put
124 | ///
125 | /// register type
126 | /// register entity
127 | /// put url
128 | ///
129 | public async Task<(bool result, string backJson)> Put(T entity, string url)
130 | {
131 | client.BaseAddress = new Uri(_baseAddress);
132 | var json = JsonConvert.SerializeObject(entity);
133 | var stream = new MemoryStream(Encoding.Default.GetBytes(json));
134 | var content = new StreamContent(stream);
135 | var response = await client.PutAsync($"/{urlPrefix}/{url}", content);
136 | var backJson = await response.Content.ReadAsStringAsync();
137 | return (result: response.StatusCode == System.Net.HttpStatusCode.OK, backJson: backJson);
138 | }
139 | ///
140 | /// put
141 | ///
142 | /// put url
143 | ///
144 | public async Task<(bool result, string backJson)> Put(string url)
145 | {
146 | var client = new HttpClient();
147 | client.BaseAddress = new Uri(_baseAddress);
148 | var response = await client.PutAsync($"/{urlPrefix}/{url}", null);
149 | var backJson = await response.Content.ReadAsStringAsync();
150 | return (result: response.StatusCode == System.Net.HttpStatusCode.OK, backJson: backJson);
151 | }
152 |
153 | ///
154 | /// post
155 | ///
156 | /// register type
157 | /// register entity
158 | /// put url
159 | ///
160 | public async Task<(bool result, string backJson)> Post(T entity, string url)
161 | {
162 |
163 | client.BaseAddress = new Uri(_baseAddress);
164 | var json = JsonConvert.SerializeObject(entity);
165 | var stream = new MemoryStream(Encoding.Default.GetBytes(json));
166 | var content = new StreamContent(stream);
167 | var response = await client.PostAsync($"/{urlPrefix}/{url}", content);
168 | var backJson = await response.Content.ReadAsStringAsync();
169 | return (result: response.StatusCode == System.Net.HttpStatusCode.OK, backJson: backJson);
170 | }
171 |
172 | ///
173 | /// Post with parmeter and back parmeter
174 | ///
175 | /// in parmeter
176 | /// out parmeter
177 | /// in entity
178 | /// put url
179 | ///
180 | public async Task<(bool result, W backEntity)> Post(T entity, string url)
181 | {
182 | var backResult = await Post(entity, url);
183 | if (!backResult.result)
184 | {
185 | throw new Exception($"back content:{backResult.backJson}");
186 | }
187 | var backEntity = JsonConvert.DeserializeObject(backResult.backJson);
188 | return (backResult.result, backEntity);
189 | }
190 |
191 |
192 | ///
193 | /// put with parmeter and back parmeter
194 | ///
195 | /// in parmeter
196 | /// out parmeter
197 | /// in entity
198 | /// put url
199 | ///
200 | public async Task<(bool result, W backEntity)> Put(T entity, string url)
201 | {
202 | var backResult = await Put(entity, url);
203 | if (!backResult.result)
204 | {
205 | throw new Exception(backResult.backJson);
206 | }
207 | var backEntity = JsonConvert.DeserializeObject(backResult.backJson);
208 | return (backResult.result, backEntity);
209 | }
210 | ///
211 | /// put ,parmeter with url
212 | ///
213 | /// in parmeter
214 | /// out parmeter
215 | /// in entity
216 | /// value
217 | /// put url
218 | ///
219 | public async Task<(bool result, W backEntity)> Put(T entity, object value, string url) where T : class, new()
220 | {
221 |
222 | var parString = GetUrlParmeter(entity);
223 | if (!string.IsNullOrEmpty(parString))
224 | {
225 | url += $"?{parString}";
226 | }
227 | var backResult = await Put(value, url);
228 | if (!backResult.result)
229 | {
230 | throw new Exception(backResult.backJson);
231 | }
232 | var backEntity = JsonConvert.DeserializeObject(backResult.backJson);
233 | return (backResult.result, backEntity);
234 | }
235 | ///
236 | /// delete
237 | ///
238 | /// in parmeter
239 | /// out parmeter
240 | /// in entity
241 | /// delete url
242 | ///
243 | public async Task<(bool result, W backEntity)> Delete(T entity, string url) where T : class, new()
244 | {
245 | client.BaseAddress = new Uri(_baseAddress);
246 | var parString = GetUrlParmeter(entity);
247 | if (!string.IsNullOrEmpty(parString))
248 | {
249 | url += $"?{parString}";
250 | }
251 | var response = await client.DeleteAsync($"/{urlPrefix}/{url}");
252 | var backJson = await response.Content.ReadAsStringAsync();
253 | var backResult = (result: response.StatusCode == System.Net.HttpStatusCode.OK, backJson: backJson);
254 | if (!backResult.result)
255 | {
256 | throw new Exception(backResult.backJson);
257 | }
258 | var backEntity = JsonConvert.DeserializeObject(backResult.backJson);
259 | return (backResult.result, backEntity);
260 | }
261 |
262 | #endregion
263 |
264 |
265 |
266 | }
267 | }
268 |
--------------------------------------------------------------------------------