Add api client project

This commit is contained in:
2025-05-24 20:47:01 +02:00
parent a80465c6c1
commit 9904616751
112 changed files with 10946 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MusicCast.Net.Api.Client\MusicCast.Net.Api.Client.csproj" PrivateAssets="*" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,39 @@
// See https://aka.ms/new-console-template for more information
// API requires no authentication, so use the anonymous
// authentication provider
using System.Text.Json;
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using MusicCast.Net.Api.Client;
using MusicCast.Net.Api.Client.YamahaExtendedControl.V1.Main.SetPower;
// API requires no authentication, so use the anonymous
// authentication provider
var authProvider = new AnonymousAuthenticationProvider();
// Create request adapter using the HttpClient-based implementation
using var adapter = new HttpClientRequestAdapter(authProvider);
adapter.BaseUrl = "http://192.168.129.21";
var client = new MusicCastApiClient(adapter);
var status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
Console.WriteLine(status!.Power);
await client.YamahaExtendedControl.V1.Main.SetPower.GetAsync(conf => conf.QueryParameters.Power = GetPowerQueryParameterType.On);
await Task.Delay(5000);
status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
Console.WriteLine(status!.Power);
await client.YamahaExtendedControl.V1.Main.SetPower.GetAsync(r =>
r.QueryParameters.Power = GetPowerQueryParameterType.Standby
);
await Task.Delay(5000);
status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
Console.WriteLine(status!.Power);