Skip to content

Commit 0b25ab5

Browse files
authored
Expose cognite client (#27)
Also, bump dependencies
1 parent 8970cb0 commit 0b25ab5

File tree

4 files changed

+44
-35
lines changed

4 files changed

+44
-35
lines changed

ExtractorUtils.Test/CogniteTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,22 @@ public async Task TestCogniteClient()
186186
services.AddCogniteClient("testApp", true, true);
187187
using (var provider = services.BuildServiceProvider()) {
188188
var config = provider.GetRequiredService<CogniteConfig>();
189-
var cogClient = provider.GetRequiredService<Client>();
190-
var ex = await Assert.ThrowsAsync<CogniteUtilsException>(() => cogClient.TestCogniteConfig(null, CancellationToken.None));
189+
var cogniteDestination = provider.GetRequiredService<CogniteDestination>();
190+
var ex = await Assert.ThrowsAsync<CogniteUtilsException>(() => cogniteDestination.CogniteClient.TestCogniteConfig(null, CancellationToken.None));
191191
Assert.Contains("configuration missing", ex.Message);
192192

193193
config.Project = null;
194-
ex = await Assert.ThrowsAsync<CogniteUtilsException>(() => cogClient.TestCogniteConfig(config, CancellationToken.None));
194+
ex = await Assert.ThrowsAsync<CogniteUtilsException>(() => cogniteDestination.CogniteClient.TestCogniteConfig(config, CancellationToken.None));
195195
Assert.Contains("project is not configured", ex.Message);
196196

197197
config.Project = "Bogus";
198-
ex = await Assert.ThrowsAsync<CogniteUtilsException>(() => cogClient.TestCogniteConfig(config, CancellationToken.None));
198+
ex = await Assert.ThrowsAsync<CogniteUtilsException>(() => cogniteDestination.CogniteClient.TestCogniteConfig(config, CancellationToken.None));
199199
Assert.Contains("not associated with project Bogus", ex.Message);
200200
config.Project = _project;
201201

202-
await cogClient.TestCogniteConfig(config, CancellationToken.None);
202+
await cogniteDestination.TestCogniteConfig(CancellationToken.None);
203203

204-
var loginStatus = await cogClient.Login.StatusAsync(CancellationToken.None);
204+
var loginStatus = await cogniteDestination.CogniteClient.Login.StatusAsync(CancellationToken.None);
205205
Assert.True(loginStatus.LoggedIn);
206206
Assert.Equal("testuser", loginStatus.User);
207207
Assert.Equal(_project, loginStatus.Project);
@@ -210,7 +210,7 @@ public async Task TestCogniteClient()
210210
{
211211
Limit = 1
212212
};
213-
var ts = await cogClient.TimeSeries.ListAsync(options);
213+
var ts = await cogniteDestination.CogniteClient.TimeSeries.ListAsync(options);
214214
Assert.Empty(ts.Items);
215215
}
216216

ExtractorUtils.Test/ExtractorUtils.Test.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netcoreapp3.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
8-
<PackageReference Include="xunit" Version="2.4.0" />
9-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
8+
<PackageReference Include="xunit" Version="2.4.1" />
9+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
10+
<PrivateAssets>all</PrivateAssets>
11+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
12+
</PackageReference>
1013
<PackageReference Include="coverlet.collector" Version="1.2.1" />
1114
<PackageReference Include="coverlet.msbuild" Version="2.8.1">
1215
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1316
<PrivateAssets>all</PrivateAssets>
1417
</PackageReference>
15-
<PackageReference Include="Moq" Version="4.13.1" />
18+
<PackageReference Include="Moq" Version="4.14.1" />
1619
</ItemGroup>
1720
<ItemGroup>
1821
<ProjectReference Include="..\ExtractorUtils\ExtractorUtils.csproj" />

ExtractorUtils/Cognite/CogniteDestination.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ namespace Cognite.Extractor.Utils
1616
/// </summary>
1717
public class CogniteDestination
1818
{
19-
private Client _client;
20-
private ILogger<CogniteDestination> _logger;
21-
private CogniteConfig _config;
19+
private readonly Client _client;
20+
private readonly ILogger<CogniteDestination> _logger;
21+
private readonly CogniteConfig _config;
22+
23+
/// <summary>
24+
/// The configured Cognite client used by this destination. Can be used to
25+
/// access the full Cognite API
26+
/// </summary>
27+
public Client CogniteClient => _client;
2228

2329
/// <summary>
2430
/// Initializes the Cognite destination with the provided parameters
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -12,29 +12,29 @@
1212
</Description>
1313
</PropertyGroup>
1414
<ItemGroup>
15-
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath=""/>
15+
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath="" />
1616
</ItemGroup>
1717
<ItemGroup>
18-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3"/>
19-
<PackageReference Include="Serilog" Version="2.9.0"/>
20-
<PackageReference Include="System.Text.Json" Version="4.7.1"/>
21-
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0"/>
22-
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1"/>
23-
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0"/>
24-
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1"/>
25-
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.3"/>
26-
<PackageReference Include="prometheus-net" Version="3.5.0"/>
27-
<PackageReference Include="Polly" Version="7.2.0"/>
28-
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0"/>
29-
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="3.1.3"/>
30-
<PackageReference Include="CogniteSdk" Version="1.0.7"/>
31-
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>
32-
<PackageReference Include="Google.Protobuf" Version="3.11.4"/>
18+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
19+
<PackageReference Include="Serilog" Version="2.9.0" />
20+
<PackageReference Include="System.Text.Json" Version="4.7.1" />
21+
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
22+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
23+
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
24+
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
25+
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.3" />
26+
<PackageReference Include="prometheus-net" Version="3.5.0" />
27+
<PackageReference Include="Polly" Version="7.2.1" />
28+
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0" />
29+
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="3.1.3" />
30+
<PackageReference Include="CogniteSdk" Version="1.0.8" />
31+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
32+
<PackageReference Include="Google.Protobuf" Version="3.12.1" />
3333
</ItemGroup>
3434
<ItemGroup>
35-
<ProjectReference Include="..\Cognite.Config\Cognite.Configuration.csproj"/>
36-
<ProjectReference Include="..\Cognite.Common\Cognite.Common.csproj"/>
37-
<ProjectReference Include="..\Cognite.Metrics\Cognite.Metrics.csproj"/>
38-
<ProjectReference Include="..\Cognite.Logging\Cognite.Logging.csproj"/>
35+
<ProjectReference Include="..\Cognite.Config\Cognite.Configuration.csproj" />
36+
<ProjectReference Include="..\Cognite.Common\Cognite.Common.csproj" />
37+
<ProjectReference Include="..\Cognite.Metrics\Cognite.Metrics.csproj" />
38+
<ProjectReference Include="..\Cognite.Logging\Cognite.Logging.csproj" />
3939
</ItemGroup>
4040
</Project>

0 commit comments

Comments
 (0)