());
112 | }
113 | }
--------------------------------------------------------------------------------
/Examples/README.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | - [General](General/Runner.cs) - for running other examples from the commandline.
4 | - [HttpErrorHandled](General/HttpErrorHandled.cs) - Accessing HTTP headers when an InfluxDBApiException is thrown.
5 | - [IOxExample](IOx/IOxExample.cs) - How to use write and query data from InfluxDB IOx
6 | - [Downsampling](Downsampling/DownsamplingExample.cs) - How to use queries to structure data for downsampling
7 | - [CustomSslCerts](CustomSslCerts/CustomSslCertsExample.cs) - How to configure custom SSL root certificates and proxy in
8 | client
9 |
10 | ## General Runner
11 |
12 | Examples can be run from the directory `Examples/General` by simply calling `dotnet run`
13 |
14 | For example:
15 |
16 | ```bash
17 | Examples/General/$ dotnet run "HttpErrorHandled"
18 | ```
19 |
--------------------------------------------------------------------------------
/InfluxDB3.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31903.59
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{B5669ECE-B3E4-444A-8F06-6E547B6A80C7}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Test", "Client.Test\Client.Test.csproj", "{2B458947-5B2B-4B58-A3F0-758C0B09217E}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Test.Integration", "Client.Test.Integration\Client.Test.Integration.csproj", "{4BE03DEE-47BF-4F7B-8474-4214E643D72E}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomSslCerts", "Examples\CustomSslCerts\CustomSslCerts.csproj", "{2633D8DB-B03F-4F3E-846D-B16C4D4AA6E5}"
13 | EndProject
14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{EFBEAA10-411F-4BDB-A96B-B54632FAE99D}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.IOx", "Examples\IOx\Examples.IOx.csproj", "{B2DA69ED-C21D-4531-A32A-E537DC511785}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Downsampling", "Examples\Downsampling\Downsampling.csproj", "{44C91C8C-B194-48CE-A5B1-763457F118F4}"
19 | EndProject
20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "General", "Examples\General\General.csproj", "{2355049F-531D-4B43-9DFD-D88C75023B04}"
21 | EndProject
22 | Global
23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
24 | Debug|Any CPU = Debug|Any CPU
25 | Release|Any CPU = Release|Any CPU
26 | EndGlobalSection
27 | GlobalSection(SolutionProperties) = preSolution
28 | HideSolutionNode = FALSE
29 | EndGlobalSection
30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
31 | {B5669ECE-B3E4-444A-8F06-6E547B6A80C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {B5669ECE-B3E4-444A-8F06-6E547B6A80C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {B5669ECE-B3E4-444A-8F06-6E547B6A80C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {B5669ECE-B3E4-444A-8F06-6E547B6A80C7}.Release|Any CPU.Build.0 = Release|Any CPU
35 | {2B458947-5B2B-4B58-A3F0-758C0B09217E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36 | {2B458947-5B2B-4B58-A3F0-758C0B09217E}.Debug|Any CPU.Build.0 = Debug|Any CPU
37 | {2B458947-5B2B-4B58-A3F0-758C0B09217E}.Release|Any CPU.ActiveCfg = Release|Any CPU
38 | {2B458947-5B2B-4B58-A3F0-758C0B09217E}.Release|Any CPU.Build.0 = Release|Any CPU
39 | {4BE03DEE-47BF-4F7B-8474-4214E643D72E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40 | {4BE03DEE-47BF-4F7B-8474-4214E643D72E}.Debug|Any CPU.Build.0 = Debug|Any CPU
41 | {4BE03DEE-47BF-4F7B-8474-4214E643D72E}.Release|Any CPU.ActiveCfg = Release|Any CPU
42 | {4BE03DEE-47BF-4F7B-8474-4214E643D72E}.Release|Any CPU.Build.0 = Release|Any CPU
43 | {B2DA69ED-C21D-4531-A32A-E537DC511785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
44 | {B2DA69ED-C21D-4531-A32A-E537DC511785}.Debug|Any CPU.Build.0 = Debug|Any CPU
45 | {B2DA69ED-C21D-4531-A32A-E537DC511785}.Release|Any CPU.ActiveCfg = Release|Any CPU
46 | {B2DA69ED-C21D-4531-A32A-E537DC511785}.Release|Any CPU.Build.0 = Release|Any CPU
47 | {44C91C8C-B194-48CE-A5B1-763457F118F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
48 | {44C91C8C-B194-48CE-A5B1-763457F118F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
49 | {44C91C8C-B194-48CE-A5B1-763457F118F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
50 | {44C91C8C-B194-48CE-A5B1-763457F118F4}.Release|Any CPU.Build.0 = Release|Any CPU
51 | {2355049F-531D-4B43-9DFD-D88C75023B04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52 | {2355049F-531D-4B43-9DFD-D88C75023B04}.Debug|Any CPU.Build.0 = Debug|Any CPU
53 | {2355049F-531D-4B43-9DFD-D88C75023B04}.Release|Any CPU.ActiveCfg = Release|Any CPU
54 | {2355049F-531D-4B43-9DFD-D88C75023B04}.Release|Any CPU.Build.0 = Release|Any CPU
55 | {2633D8DB-B03F-4F3E-846D-B16C4D4AA6E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56 | {2633D8DB-B03F-4F3E-846D-B16C4D4AA6E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
57 | {2633D8DB-B03F-4F3E-846D-B16C4D4AA6E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
58 | {2633D8DB-B03F-4F3E-846D-B16C4D4AA6E5}.Release|Any CPU.Build.0 = Release|Any CPU
59 | EndGlobalSection
60 | GlobalSection(NestedProjects) = preSolution
61 | {B2DA69ED-C21D-4531-A32A-E537DC511785} = {EFBEAA10-411F-4BDB-A96B-B54632FAE99D}
62 | {44C91C8C-B194-48CE-A5B1-763457F118F4} = {EFBEAA10-411F-4BDB-A96B-B54632FAE99D}
63 | {2355049F-531D-4B43-9DFD-D88C75023B04} = {EFBEAA10-411F-4BDB-A96B-B54632FAE99D}
64 | {2633D8DB-B03F-4F3E-846D-B16C4D4AA6E5} = {EFBEAA10-411F-4BDB-A96B-B54632FAE99D}
65 | EndGlobalSection
66 | EndGlobal
67 |
--------------------------------------------------------------------------------
/Keys/Key.public.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfluxCommunity/influxdb3-csharp/71d1c5919f9e1fa1cc798f8e8b397fb9c6de6e62/Keys/Key.public.snk
--------------------------------------------------------------------------------
/Keys/Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfluxCommunity/influxdb3-csharp/71d1c5919f9e1fa1cc798f8e8b397fb9c6de6e62/Keys/Key.snk
--------------------------------------------------------------------------------
/Keys/README.md:
--------------------------------------------------------------------------------
1 | Contents
2 | --------
3 |
4 | - Key.public.snk: Public key to verify strong name of `InfluxDB3.Client`.
5 | - Key.snk: Signing key to provide strong name of `InfluxDB3.Client`.
6 |
7 | [Microsoft guidance: Strong-named assemblies](https://msdn.microsoft.com/en-us/library/wd40t7ad(v=vs.110).aspx)
8 |
9 | Docker
10 | ------
11 |
12 | ```shell
13 | # Get Public Key
14 | docker run -it -v "${PWD}:/opt/app" -w "/opt/app" mono:latest sn -tp Keys/Key.public.snk
15 | ```
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 InfluxData Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | # InfluxDB 3 C# .NET Client
29 |
30 | The C# .NET client that provides an easy and convenient way to interact with InfluxDB 3.
31 | This package supports both writing data to InfluxDB and querying data using the FlightSQL client,
32 | which allows you to execute SQL queries against InfluxDB IOx.
33 |
34 | We offer this [Getting Started: InfluxDB 3.0 C# Client Library](https://www.youtube.com/watch?v=l2e4lXilvLA) video to learn more about the library.
35 |
36 | ## Installation
37 |
38 | Add the latest version of the client to your project:
39 |
40 | ```sh
41 | dotnet add package InfluxDB3.Client
42 | ```
43 |
44 | ## Usage
45 |
46 | To start with the client, import the `InfluxDB3.Client` package and create a `InfluxDBClient` by constructor initializer:
47 |
48 | ```csharp
49 | using System.Threading.Tasks;
50 | using InfluxDB3.Client;
51 | using InfluxDB3.Client.Write;
52 |
53 | namespace InfluxDB3.Examples.IOx;
54 |
55 | public class IOxExample
56 | {
57 | static async Task Main(string[] args)
58 | {
59 | const string host = "https://us-east-1-1.aws.cloud2.influxdata.com";
60 | const string token = "my-token";
61 | const string database = "my-database";
62 |
63 | using var client = new InfluxDBClient(host, token: token, database: database);
64 | }
65 | }
66 | ```
67 |
68 | to insert data, you can use code like this:
69 |
70 | ```csharp
71 | //
72 | // Write by Point
73 | //
74 | var point = PointData.Measurement("temperature")
75 | .SetTag("location", "west")
76 | .SetField("value", 55.15)
77 | .SetTimestamp(DateTime.UtcNow.AddSeconds(-10));
78 | await client.WritePointAsync(point: point);
79 |
80 | //
81 | // Write by LineProtocol
82 | //
83 | const string record = "temperature,location=north value=60.0";
84 | await client.WriteRecordAsync(record: record);
85 | ```
86 |
87 | to query your data, you can use code like this:
88 |
89 | ```csharp
90 | //
91 | // Query by SQL
92 | //
93 | const string sql = "select time,location,value from temperature order by time desc limit 10";
94 | Console.WriteLine("{0,-30}{1,-15}{2,-15}", "time", "location", "value");
95 | await foreach (var row in client.Query(query: sql))
96 | {
97 | Console.WriteLine("{0,-30}{1,-15}{2,-15}", row[0], row[1], row[2]);
98 | }
99 | Console.WriteLine();
100 |
101 | //
102 | // Query by parametrized SQL
103 | //
104 | const string sqlParams = "select time,location,value from temperature where location=$location order by time desc limit 10";
105 | Console.WriteLine("Query by parametrized SQL");
106 | Console.WriteLine("{0,-30}{1,-15}{2,-15}", "time", "location", "value");
107 | await foreach (var row in client.Query(query: sqlParams, namedParameters: new Dictionary { { "location", "west" } }))
108 | {
109 | Console.WriteLine("{0,-30}{1,-15}{2,-15}", row[0], row[1], row[2]);
110 | }
111 | Console.WriteLine();
112 |
113 | //
114 | // Query by InfluxQL
115 | //
116 | const string influxQL =
117 | "select MEAN(value) from temperature group by time(1d) fill(none) order by time desc limit 10";
118 | Console.WriteLine("{0,-30}{1,-15}", "time", "mean");
119 | await foreach (var row in client.Query(query: influxQL, queryType: QueryType.InfluxQL))
120 | {
121 | Console.WriteLine("{0,-30}{1,-15}", row[1], row[2]);
122 | }
123 | ```
124 |
125 | ## Feedback
126 |
127 | If you need help, please use our [Community Slack](https://app.slack.com/huddle/TH8RGQX5Z/C02UDUPLQKA)
128 | or [Community Page](https://community.influxdata.com/).
129 |
130 | New features and bugs can be reported on GitHub:
131 |
132 | ## Contribution
133 |
134 | If you would like to contribute code you can do through GitHub by forking the repository and sending a pull request into
135 | the `main` branch.
136 |
137 | ## License
138 |
139 | The InfluxDB 3 C# .NET Client is released under the [MIT License](https://opensource.org/licenses/MIT).
140 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # folder #
3 | ###############
4 | /**/DROP/
5 | /**/TEMP/
6 | /**/packages/
7 | /**/bin/
8 | /**/obj/
9 | _site
10 |
--------------------------------------------------------------------------------
/docs/api/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # temp file #
3 | ###############
4 | *.yml
5 | .manifest
6 |
--------------------------------------------------------------------------------
/docs/docfx.json:
--------------------------------------------------------------------------------
1 | {
2 | "metadata": [
3 | {
4 | "src": [
5 | {
6 | "files": [
7 | "**/Client/**.csproj"
8 | ],
9 | "src": ".."
10 | }
11 | ],
12 | "dest": "api",
13 | "disableGitFeatures": false,
14 | "properties": {
15 | "TargetFramework": "netstandard2.1"
16 | }
17 | }
18 | ],
19 | "build": {
20 | "content": [
21 | {
22 | "files": [
23 | "api/**.yml",
24 | "api/index.md"
25 | ]
26 | },
27 | {
28 | "files": [
29 | "toc.yml",
30 | "*.md"
31 | ]
32 | }
33 | ],
34 | "resource": [
35 | {
36 | "files": [
37 | "images/**",
38 | "favicon.ico"
39 | ]
40 | }
41 | ],
42 | "overwrite": [
43 | {
44 | "files": [
45 | ],
46 | "exclude": [
47 | "obj/**",
48 | "_site/**"
49 | ]
50 | }
51 | ],
52 | "dest": "_site",
53 | "globalMetadataFiles": [],
54 | "fileMetadataFiles": [],
55 | "template": [
56 | "statictoc"
57 | ],
58 | "globalMetadata": {
59 | "_appLogoPath": "images/influxdata-logo--symbol--white.png",
60 | "_disableContribution": true
61 | },
62 | "postProcessors": [],
63 | "markdownEngineName": "markdig",
64 | "noLangKeyword": false,
65 | "keepFileLink": false,
66 | "cleanupCacheHistory": false,
67 | "disableGitFeatures": false
68 | }
69 | }
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfluxCommunity/influxdb3-csharp/71d1c5919f9e1fa1cc798f8e8b397fb9c6de6e62/docs/favicon.ico
--------------------------------------------------------------------------------
/docs/images/influxdata-logo--symbol--white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfluxCommunity/influxdb3-csharp/71d1c5919f9e1fa1cc798f8e8b397fb9c6de6e62/docs/images/influxdata-logo--symbol--white.png
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | # influxdb3-csharp
2 |
3 | | Client | Description | API |
4 | |----------|------------------------------------------------------------------------------------------|---------------------------------------------------|
5 | | `Client` | The C# .NET client that provides an easy and convenient way to interact with InfluxDB 3. | [InfluxDB3.Client.html](api/InfluxDB3.Client.yml) |
6 |
--------------------------------------------------------------------------------
/docs/publish-site.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # Publish site to GitHub Pages
5 | #
6 | # How to run in Docker:
7 | #
8 | # docker run --rm -it \
9 | # -v "${PWD}/docs":/code/docs \
10 | # -v "${PWD}/.circleci":/code/.circleci \
11 | # -v ~/.ssh:/root/.ssh \
12 | # -v ~/.gitconfig:/root/.gitconfig \
13 | # -w /code \
14 | # bitnami/git:latest /code/docs/publish-site.sh
15 | #
16 |
17 | set -ev
18 |
19 | echo "# Clone client and switch to branch for GH-Pages"
20 | git clone -b gh-pages git@github.com:InfluxCommunity/influxdb3-csharp.git /code/influxdb3-csharp
21 |
22 | echo "# Remove old pages"
23 | rm -r /code/influxdb3-csharp/*
24 |
25 | echo "# Copy new docs"
26 | cp -Rf /code/docs/_site/* /code/influxdb3-csharp/
27 |
28 | echo "# Copy CircleCI"
29 | cp -R /code/.circleci/ /code/influxdb3-csharp/
30 |
31 | echo "# Deploy site"
32 | cd /code/influxdb3-csharp/ || exit
33 | git add -f .
34 | git -c commit.gpgsign=false commit -m "Pushed the latest Docs to GitHub pages [skip CI]"
35 | git push -fq origin gh-pages
36 |
--------------------------------------------------------------------------------
/docs/toc.yml:
--------------------------------------------------------------------------------
1 | - name: InfluxDB3.Client API
2 | href: api/
3 | homepage: api/InfluxDB3.Client.yml
--------------------------------------------------------------------------------
/net_logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------