diff --git a/.gitignore b/.gitignore index d472256..01ca0e7 100644 --- a/.gitignore +++ b/.gitignore @@ -254,3 +254,5 @@ paket-files/ /Secrets/client_id.json /libmp3lame.32.dll /libmp3lame.64.dll + +/Tools/ \ No newline at end of file diff --git a/App.xaml.cs b/App.xaml.cs deleted file mode 100644 index c9e3456..0000000 --- a/App.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace GoogleAssistantWindows -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} diff --git a/CopySettingsToUserFolder.ps1 b/CopySettingsToUserFolder.ps1 new file mode 100644 index 0000000..ce5e8c6 --- /dev/null +++ b/CopySettingsToUserFolder.ps1 @@ -0,0 +1,2 @@ +Copy-Item "GAssistant\Secrets\client_id.json" -Destination $env:APPDATA\GAssistant\ +Copy-Item "GAssistant\settings.json" -Destination $env:APPDATA\GAssistant\ \ No newline at end of file diff --git a/DownloadTools.ps1 b/DownloadTools.ps1 new file mode 100644 index 0000000..565c8f5 --- /dev/null +++ b/DownloadTools.ps1 @@ -0,0 +1,13 @@ +New-Item Tools -type directory -Force + +Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Grpc.Tools/ -OutFile grpc.zip + +Remove-Item Tools\Grpc\* -recurse +Expand-Archive grpc.zip -DestinationPath Tools\Grpc +Remove-Item grpc.zip + +Invoke-WebRequest -Uri https://github.com/google/protobuf/releases/download/v3.5.0/protoc-3.5.0-win32.zip -OutFile protoc.zip + +Remove-Item Tools\Protoc\* -recurse +Expand-Archive protoc.zip -DestinationPath Tools\Protoc +Remove-Item protoc.zip \ No newline at end of file diff --git a/GAssistant.Store/GAssistant.Store.wapproj b/GAssistant.Store/GAssistant.Store.wapproj new file mode 100644 index 0000000..90b0e52 --- /dev/null +++ b/GAssistant.Store/GAssistant.Store.wapproj @@ -0,0 +1,62 @@ + + + + 15.0 + + + + Debug + x86 + + + Release + x86 + + + Debug + x64 + + + Release + x64 + + + Debug + AnyCPU + + + Release + AnyCPU + + + + $(MSBuildExtensionsPath)\Microsoft\DesktopBridge\ + + + + fa7bbace-16a0-4c8c-a5e6-f3f149add7bf + 10.0.17763.0 + 10.0.17134.0 + en-US + GAssistant.Store_TemporaryKey.pfx + ..\GAssistant\GoogleAssistantWindows.csproj + + + + Designer + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GAssistant.Store/Images/LockScreenLogo.scale-200.png b/GAssistant.Store/Images/LockScreenLogo.scale-200.png new file mode 100644 index 0000000..735f57a Binary files /dev/null and b/GAssistant.Store/Images/LockScreenLogo.scale-200.png differ diff --git a/GAssistant.Store/Images/Square150x150Logo.scale-200.png b/GAssistant.Store/Images/Square150x150Logo.scale-200.png new file mode 100644 index 0000000..af49fec Binary files /dev/null and b/GAssistant.Store/Images/Square150x150Logo.scale-200.png differ diff --git a/GAssistant.Store/Images/Square44x44Logo.scale-200.png b/GAssistant.Store/Images/Square44x44Logo.scale-200.png new file mode 100644 index 0000000..ce342a2 Binary files /dev/null and b/GAssistant.Store/Images/Square44x44Logo.scale-200.png differ diff --git a/GAssistant.Store/Images/Square44x44Logo.targetsize-24_altform-unplated.png b/GAssistant.Store/Images/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000..f6c02ce Binary files /dev/null and b/GAssistant.Store/Images/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/GAssistant.Store/Images/StoreLogo.png b/GAssistant.Store/Images/StoreLogo.png new file mode 100644 index 0000000..7385b56 Binary files /dev/null and b/GAssistant.Store/Images/StoreLogo.png differ diff --git a/GAssistant.Store/Images/Wide310x150Logo.scale-200.png b/GAssistant.Store/Images/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000..288995b Binary files /dev/null and b/GAssistant.Store/Images/Wide310x150Logo.scale-200.png differ diff --git a/GAssistant.Store/Package.appxmanifest b/GAssistant.Store/Package.appxmanifest new file mode 100644 index 0000000..dbc15c1 --- /dev/null +++ b/GAssistant.Store/Package.appxmanifest @@ -0,0 +1,50 @@ + + + + + + + + GAssistant.Store + Pieter + Images\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App.config b/GAssistant/App.config similarity index 76% rename from App.config rename to GAssistant/App.config index 7307ce9..05504db 100644 --- a/App.config +++ b/GAssistant/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/App.xaml b/GAssistant/App.xaml similarity index 72% rename from App.xaml rename to GAssistant/App.xaml index 553ae40..1a63008 100644 --- a/App.xaml +++ b/GAssistant/App.xaml @@ -1,8 +1,7 @@  + xmlns:local="clr-namespace:GoogleAssistantWindows"> diff --git a/GAssistant/App.xaml.cs b/GAssistant/App.xaml.cs new file mode 100644 index 0000000..aa7a362 --- /dev/null +++ b/GAssistant/App.xaml.cs @@ -0,0 +1,73 @@ +using Autofac; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Threading; + +namespace GoogleAssistantWindows +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + + public static IContainer Container { get; private set; } + + protected override void OnStartup(StartupEventArgs e) + { + Application.Current.DispatcherUnhandledException += OnUnhandledException; + + var builder = new ContainerBuilder(); + builder.RegisterType(); + builder.RegisterType(); + builder.RegisterType(); + + builder.RegisterType() + .SingleInstance(); + builder.RegisterType() + .SingleInstance(); + builder.RegisterType(); + + builder.RegisterType() + .OnActivating(settings => + { + settings.Instance.Load(); + }) + .SingleInstance(); + + Container = builder.Build(); + + MainWindow mainWindow = Container.Resolve(); + mainWindow.Show(); + } + + void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) + { + string typeName = GetTypeName(e.Exception); + if(typeName != null) + logger.Error("Unhandled Exception at \"{0}\": {1}", typeName, e.Exception.Message); + else + logger.Error("Unhandled Exception: {0}", e.Exception.Message); + } + + private string GetTypeName(Exception ex) + { + try + { + StackTrace stackTrace = new StackTrace(ex); + return stackTrace.GetFrame(0).GetMethod().DeclaringType.FullName; + } + catch + { + return null; + } + } + } +} diff --git a/Assistant.cs b/GAssistant/Assistant.cs similarity index 70% rename from Assistant.cs rename to GAssistant/Assistant.cs index 29bb9ea..2154f43 100644 --- a/Assistant.cs +++ b/GAssistant/Assistant.cs @@ -1,26 +1,35 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Google.Assistant.Embedded.V1Alpha1; +using Google.Assistant.Embedded.V1Alpha2; using Google.Protobuf; using Grpc.Core; using NAudio.Wave; +using static Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig.Types; namespace GoogleAssistantWindows { public class Assistant { + private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + public delegate void DebugOutputDelegate(string debug, bool consoleOnly = false); public event DebugOutputDelegate OnDebug; public delegate void AssistantWorkingDelegate(AssistantState state); public event AssistantWorkingDelegate OnAssistantStateChanged; + public delegate void AssistantDialogResult(string message); + public event AssistantDialogResult OnAssistantDialogResult; + + public delegate void AssistantSpeechResult(string message); + public event AssistantSpeechResult OnAssistantSpeechResult; + private Channel _channel; private EmbeddedAssistant.EmbeddedAssistantClient _assistant; - private IClientStreamWriter _requestStream; - private IAsyncStreamReader _responseStream; + private IClientStreamWriter _requestStream; + private IAsyncStreamReader _responseStream; // todo this doesn't seem to be needed anymore... private bool _writing; @@ -30,6 +39,8 @@ public class Assistant private readonly AudioOut _audioOut = new AudioOut(); + private readonly Settings settings; + // todo tidy this mess of flags up private bool _requestStreamAvailable = false; private bool _assistantResponseReceived = false; @@ -39,8 +50,10 @@ public class Assistant // If this documentation was a flow chart it would have been much better // https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha1#google.assistant.embedded.v1alpha1.EmbeddedAssistant - public Assistant() + public Assistant(Settings settings) { + this.settings = settings; + _audioOut.OnAudioPlaybackStateChanged += OnAudioPlaybackStateChanged; } @@ -59,11 +72,12 @@ public async void NewConversation() _followOn = false; _assistantResponseReceived = false; - AsyncDuplexStreamingCall converse = _assistant.Converse(); + AsyncDuplexStreamingCall assist = _assistant.Assist(); - _requestStream = converse.RequestStream; - _responseStream = converse.ResponseStream; + _requestStream = assist.RequestStream; + _responseStream = assist.ResponseStream; + logger.Debug("New Conversation - New Config Request"); OnDebug?.Invoke("New Conversation - New Config Request"); // Once this opening request is issued if its not followed by audio an error of 'code: 14, message: Service Unavaible.' comes back, really not helpful Google! @@ -81,17 +95,18 @@ public async void NewConversation() } catch (Exception ex) { + logger.Error(ex.Message); Console.WriteLine(ex.Message); OnDebug?.Invoke($"Error {ex.Message}"); StopRecording(); } } - private ConverseRequest CreateNewRequest() + private AssistRequest CreateNewRequest() { // initial request is the config this then gets followed by all out audio - var converseRequest = new ConverseRequest(); + var converseRequest = new AssistRequest(); var audioIn = new AudioInConfig() { @@ -106,8 +121,14 @@ private ConverseRequest CreateNewRequest() VolumePercentage = 75 }; - ConverseState state = new ConverseState() { ConversationState = ByteString.Empty }; - converseRequest.Config = new ConverseConfig() { AudioInConfig = audioIn, AudioOutConfig = audioOut, ConverseState = state }; + var screenOut = new ScreenOutConfig() + { + ScreenMode = ScreenMode.Playing + }; + + DialogStateIn state = new DialogStateIn() { ConversationState = ByteString.Empty, LanguageCode = this.settings.LanguageCode }; + DeviceConfig device = new DeviceConfig() { DeviceModelId = this.settings.DeviceModelId, DeviceId = this.settings.DeviceId }; + converseRequest.Config = new AssistConfig() { AudioInConfig = audioIn, AudioOutConfig = audioOut, DialogStateIn = state, DeviceConfig = device, ScreenOutConfig = screenOut }; return converseRequest; } @@ -116,6 +137,7 @@ private void StopRecording() { if (_waveIn != null) { + logger.Debug("Stop Recording"); OnDebug?.Invoke("Stop Recording"); _waveIn.StopRecording(); _waveIn.Dispose(); @@ -123,6 +145,7 @@ private void StopRecording() OnAssistantStateChanged?.Invoke(AssistantState.Processing); + logger.Debug("Send Request Complete"); OnDebug?.Invoke("Send Request Complete"); _requestStreamAvailable = false; _requestStream.CompleteAsync(); @@ -131,6 +154,7 @@ private void StopRecording() private void ProcessInAudio(object sender, WaveInEventArgs e) { + logger.Debug($"Process Audio {e.Buffer.Length} SendSpeech={_sendSpeech} Writing={_writing}"); OnDebug?.Invoke($"Process Audio {e.Buffer.Length} SendSpeech={_sendSpeech} Writing={_writing}", true); if (_sendSpeech) @@ -165,8 +189,9 @@ private async Task WriteAudioData(byte[] bytes) private async Task WriteAudioIn(byte[] buffer) { + logger.Debug("Write Audio " + buffer.Length); OnDebug?.Invoke("Write Audio " + buffer.Length, true); - var request = new ConverseRequest() {AudioIn = ByteString.CopyFrom(buffer)}; + var request = new AssistRequest() {AudioIn = ByteString.CopyFrom(buffer)}; await _requestStream.WriteAsync(request); } @@ -176,28 +201,43 @@ private async Task WaitForResponse() if (response) { // multiple response elements are received per response, each can contain one of the Result, AudioOut or EventType fields - ConverseResponse currentResponse = _responseStream.Current; + AssistResponse currentResponse = _responseStream.Current; // Debug output the whole response, useful for.. debugging. + logger.Debug(ResponseToOutput(currentResponse)); OnDebug?.Invoke(ResponseToOutput(currentResponse)); // EndOfUtterance, Assistant has recognised something so stop sending audio - if (currentResponse.EventType == ConverseResponse.Types.EventType.EndOfUtterance) + if (currentResponse.EventType == AssistResponse.Types.EventType.EndOfUtterance) ResetSendingAudio(false); if (currentResponse.AudioOut != null) _audioOut.AddBytesToPlay(currentResponse.AudioOut.AudioData.ToByteArray()); - if (currentResponse.Result != null) + if(currentResponse.ScreenOut != null) + { + + } + + if(currentResponse.SpeechResults.Count == 1 && currentResponse.SpeechResults[0].Stability == 1.0) + { + OnAssistantSpeechResult?.Invoke(currentResponse.SpeechResults[0].Transcript); + } + + if (currentResponse.DialogStateOut != null) { // if the assistant has recognised something, flag this so the failure notification isn't played - if (!String.IsNullOrEmpty(currentResponse.Result.SpokenRequestText)) + if (!String.IsNullOrEmpty(currentResponse.DialogStateOut.SupplementalDisplayText)) + { _assistantResponseReceived = true; - switch (currentResponse.Result.MicrophoneMode) + OnAssistantDialogResult?.Invoke(currentResponse.DialogStateOut.SupplementalDisplayText); + } + + switch (currentResponse.DialogStateOut.MicrophoneMode) { // this is the end of the current conversation - case ConverseResult.Types.MicrophoneMode.CloseMicrophone: + case DialogStateOut.Types.MicrophoneMode.CloseMicrophone: StopRecording(); // play failure notification if nothing recognised. @@ -207,7 +247,7 @@ private async Task WaitForResponse() OnAssistantStateChanged?.Invoke(AssistantState.Inactive); } break; - case ConverseResult.Types.MicrophoneMode.DialogFollowOn: + case DialogStateOut.Types.MicrophoneMode.DialogFollowOn: // stop recording as the follow on is in a whole new conversation, so may as well restart the same flow StopRecording(); _followOn = true; @@ -219,6 +259,7 @@ private async Task WaitForResponse() } else { + logger.Debug("Response End"); OnDebug?.Invoke("Response End"); // if we've received any audio... play it. _audioOut.Play(); @@ -257,15 +298,15 @@ public void Shutdown() } } - private string ResponseToOutput(ConverseResponse currentResponse) + private string ResponseToOutput(AssistResponse currentResponse) { if (currentResponse.AudioOut != null) return $"Response - AudioOut {currentResponse.AudioOut.AudioData.Length}"; - if (currentResponse.Error != null) - return $"Response - Error:{currentResponse.Error}"; - if (currentResponse.Result != null) - return $"Response - Result:{currentResponse.Result}"; - if (currentResponse.EventType != ConverseResponse.Types.EventType.Unspecified) + //if (currentResponse..Error != null) + // return $"Response - Error:{currentResponse.Error}"; + if (currentResponse.DialogStateOut != null) + return $"Response - Result:{currentResponse.DialogStateOut}"; + if (currentResponse.EventType != AssistResponse.Types.EventType.Unspecified) return $"Response - EventType:{currentResponse.EventType}"; return "Response Empty?"; diff --git a/AudioOut.cs b/GAssistant/AudioOut.cs similarity index 100% rename from AudioOut.cs rename to GAssistant/AudioOut.cs diff --git a/Const.cs b/GAssistant/Const.cs similarity index 88% rename from Const.cs rename to GAssistant/Const.cs index 883e8b0..affea3f 100644 --- a/Const.cs +++ b/GAssistant/Const.cs @@ -2,7 +2,7 @@ { public class Const { - public const string Folder = "GoogleAssistantWindows"; + public const string Folder = "GAssistant"; public const string AssistantEndpoint = "embeddedassistant.googleapis.com"; public const string AssistantScope = "https://www.googleapis.com/auth/assistant-sdk-prototype"; public static readonly string[] Scope = { "openid", AssistantScope }; diff --git a/GAssistant/DeviceRegistration.cs b/GAssistant/DeviceRegistration.cs new file mode 100644 index 0000000..318dcb3 --- /dev/null +++ b/GAssistant/DeviceRegistration.cs @@ -0,0 +1,109 @@ +using Google.Apis.Auth.OAuth2; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; + +namespace GoogleAssistantWindows +{ + public class DeviceRegistration + { + private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + + private const string deviceModelId = "gassistant_windows"; + private const string deviceInstanceId = "my_gassistant_windows"; + + public async Task RegisterDeviceModel(string projectId, UserCredential credential) + { + string url = string.Format("https://embeddedassistant.googleapis.com/v1alpha2/projects/{0}/deviceModels/", projectId); + + StringBuilder sb = new StringBuilder(); + StringWriter sw = new StringWriter(sb); + + using (JsonWriter writer = new JsonTextWriter(sw)) + { + writer.Formatting = Formatting.Indented; + + writer.WriteStartObject(); + writer.WritePropertyName("project_id"); + writer.WriteValue(projectId); + writer.WritePropertyName("device_model_id"); + writer.WriteValue(deviceModelId); + writer.WritePropertyName("manifest"); + writer.WriteStartObject(); + writer.WritePropertyName("manufacturer"); + writer.WriteValue("GAssistant Open Source"); + writer.WritePropertyName("product_name"); + writer.WriteValue("GAssistant"); + writer.WritePropertyName("device_description"); + writer.WriteValue("Open Source Google Assisant client for Windows."); + writer.WriteEndObject(); + writer.WritePropertyName("device_type"); + writer.WriteValue("action.devices.types.TV"); + writer.WriteEndObject(); + } + + using (HttpClient client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", credential.Token.AccessToken); + HttpResponseMessage response = await client.PostAsync(url, new StringContent(sb.ToString(), Encoding.UTF8, "application/json")); + + if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Accepted || response.StatusCode == HttpStatusCode.Conflict) + return deviceModelId; + else + { + string message = await response.Content.ReadAsStringAsync(); + logger.Error(message); + + throw new Exception("Failed to register the device model."); + } + } + } + + public async Task RegisterDeviceInstance(string projectId, UserCredential credential, string modelId) + { + string url = string.Format("https://embeddedassistant.googleapis.com/v1alpha2/projects/{0}/devices/", projectId); + + StringBuilder sb = new StringBuilder(); + StringWriter sw = new StringWriter(sb); + + using (JsonWriter writer = new JsonTextWriter(sw)) + { + writer.Formatting = Formatting.Indented; + + writer.WriteStartObject(); + writer.WritePropertyName("id"); + writer.WriteValue(deviceInstanceId); + writer.WritePropertyName("model_id"); + writer.WriteValue(modelId); + writer.WritePropertyName("nickname"); + writer.WriteValue("GAssistant"); + writer.WritePropertyName("client_type"); + writer.WriteValue("SDK_SERVICE"); + writer.WriteEndObject(); + } + + using (HttpClient client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", credential.Token.AccessToken); + HttpResponseMessage response = await client.PostAsync(url, new StringContent(sb.ToString(), Encoding.UTF8, "application/json")); + + if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Accepted || response.StatusCode == HttpStatusCode.Conflict) + return deviceInstanceId; + else + { + string message = await response.Content.ReadAsStringAsync(); + logger.Error(message); + + throw new Exception("Failed to register the device instance."); + } + } + } + } +} \ No newline at end of file diff --git a/GAssistant/DialogResult.cs b/GAssistant/DialogResult.cs new file mode 100644 index 0000000..dda737a --- /dev/null +++ b/GAssistant/DialogResult.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GoogleAssistantWindows +{ + class DialogResult + { + public DialogResultActor Actor { get; set; } + public string Message { get; set; } + } +} diff --git a/GAssistant/DialogResultActor.cs b/GAssistant/DialogResultActor.cs new file mode 100644 index 0000000..356ae01 --- /dev/null +++ b/GAssistant/DialogResultActor.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GoogleAssistantWindows +{ + enum DialogResultActor + { + GoogleAssistant, + User + } +} diff --git a/GAssistant/DialogResultDataTemplateSelector.cs b/GAssistant/DialogResultDataTemplateSelector.cs new file mode 100644 index 0000000..3cc98b4 --- /dev/null +++ b/GAssistant/DialogResultDataTemplateSelector.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace GoogleAssistantWindows +{ + public class DialogResultDataTemplateSelector : DataTemplateSelector + { + public override DataTemplate SelectTemplate(object item, DependencyObject container) + { + FrameworkElement element = container as FrameworkElement; + + if (element != null && item != null && item is DialogResult) + { + DialogResult dialogResult = item as DialogResult; + + if (dialogResult.Actor == DialogResultActor.GoogleAssistant) + return + element.FindResource("googleAssistantResultTemplate") as DataTemplate; + else + return + element.FindResource("userResultTemplate") as DataTemplate; + } + + return null; + } + } +} diff --git a/GAssistant/Generated/assistant/EmbeddedAssistant.cs b/GAssistant/Generated/assistant/EmbeddedAssistant.cs new file mode 100644 index 0000000..0b81271 --- /dev/null +++ b/GAssistant/Generated/assistant/EmbeddedAssistant.cs @@ -0,0 +1,3332 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/assistant/embedded/v1alpha2/embedded_assistant.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Assistant.Embedded.V1Alpha2 { + + /// Holder for reflection information generated from google/assistant/embedded/v1alpha2/embedded_assistant.proto + public static partial class EmbeddedAssistantReflection { + + #region Descriptor + /// File descriptor for google/assistant/embedded/v1alpha2/embedded_assistant.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static EmbeddedAssistantReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Cjtnb29nbGUvYXNzaXN0YW50L2VtYmVkZGVkL3YxYWxwaGEyL2VtYmVkZGVk", + "X2Fzc2lzdGFudC5wcm90bxIiZ29vZ2xlLmFzc2lzdGFudC5lbWJlZGRlZC52", + "MWFscGhhMhocZ29vZ2xlL2FwaS9hbm5vdGF0aW9ucy5wcm90bxoYZ29vZ2xl", + "L3R5cGUvbGF0bG5nLnByb3RvIm8KDUFzc2lzdFJlcXVlc3QSQgoGY29uZmln", + "GAEgASgLMjAuZ29vZ2xlLmFzc2lzdGFudC5lbWJlZGRlZC52MWFscGhhMi5B", + "c3Npc3RDb25maWdIABISCghhdWRpb19pbhgCIAEoDEgAQgYKBHR5cGUi1AQK", + "DkFzc2lzdFJlc3BvbnNlElAKCmV2ZW50X3R5cGUYASABKA4yPC5nb29nbGUu", + "YXNzaXN0YW50LmVtYmVkZGVkLnYxYWxwaGEyLkFzc2lzdFJlc3BvbnNlLkV2", + "ZW50VHlwZRI/CglhdWRpb19vdXQYAyABKAsyLC5nb29nbGUuYXNzaXN0YW50", + "LmVtYmVkZGVkLnYxYWxwaGEyLkF1ZGlvT3V0EkEKCnNjcmVlbl9vdXQYBCAB", + "KAsyLS5nb29nbGUuYXNzaXN0YW50LmVtYmVkZGVkLnYxYWxwaGEyLlNjcmVl", + "bk91dBJHCg1kZXZpY2VfYWN0aW9uGAYgASgLMjAuZ29vZ2xlLmFzc2lzdGFu", + "dC5lbWJlZGRlZC52MWFscGhhMi5EZXZpY2VBY3Rpb24SUwoOc3BlZWNoX3Jl", + "c3VsdHMYAiADKAsyOy5nb29nbGUuYXNzaXN0YW50LmVtYmVkZGVkLnYxYWxw", + "aGEyLlNwZWVjaFJlY29nbml0aW9uUmVzdWx0EkwKEGRpYWxvZ19zdGF0ZV9v", + "dXQYBSABKAsyMi5nb29nbGUuYXNzaXN0YW50LmVtYmVkZGVkLnYxYWxwaGEy", + "LkRpYWxvZ1N0YXRlT3V0EkEKCmRlYnVnX2luZm8YCCABKAsyLS5nb29nbGUu", + "YXNzaXN0YW50LmVtYmVkZGVkLnYxYWxwaGEyLkRlYnVnSW5mbyI9CglFdmVu", + "dFR5cGUSGgoWRVZFTlRfVFlQRV9VTlNQRUNJRklFRBAAEhQKEEVORF9PRl9V", + "VFRFUkFOQ0UQASIwCglEZWJ1Z0luZm8SIwobYW9nX2FnZW50X3RvX2Fzc2lz", + "dGFudF9qc29uGAEgASgJIvQDCgxBc3Npc3RDb25maWcSTAoPYXVkaW9faW5f", + "Y29uZmlnGAEgASgLMjEuZ29vZ2xlLmFzc2lzdGFudC5lbWJlZGRlZC52MWFs", + "cGhhMi5BdWRpb0luQ29uZmlnSAASFAoKdGV4dF9xdWVyeRgGIAEoCUgAEkwK", + "EGF1ZGlvX291dF9jb25maWcYAiABKAsyMi5nb29nbGUuYXNzaXN0YW50LmVt", + "YmVkZGVkLnYxYWxwaGEyLkF1ZGlvT3V0Q29uZmlnEk4KEXNjcmVlbl9vdXRf", + "Y29uZmlnGAggASgLMjMuZ29vZ2xlLmFzc2lzdGFudC5lbWJlZGRlZC52MWFs", + "cGhhMi5TY3JlZW5PdXRDb25maWcSSgoPZGlhbG9nX3N0YXRlX2luGAMgASgL", + "MjEuZ29vZ2xlLmFzc2lzdGFudC5lbWJlZGRlZC52MWFscGhhMi5EaWFsb2dT", + "dGF0ZUluEkcKDWRldmljZV9jb25maWcYBCABKAsyMC5nb29nbGUuYXNzaXN0", + "YW50LmVtYmVkZGVkLnYxYWxwaGEyLkRldmljZUNvbmZpZxJFCgxkZWJ1Z19j", + "b25maWcYBSABKAsyLy5nb29nbGUuYXNzaXN0YW50LmVtYmVkZGVkLnYxYWxw", + "aGEyLkRlYnVnQ29uZmlnQgYKBHR5cGUitgEKDUF1ZGlvSW5Db25maWcSTAoI", + "ZW5jb2RpbmcYASABKA4yOi5nb29nbGUuYXNzaXN0YW50LmVtYmVkZGVkLnYx", + "YWxwaGEyLkF1ZGlvSW5Db25maWcuRW5jb2RpbmcSGQoRc2FtcGxlX3JhdGVf", + "aGVydHoYAiABKAUiPAoIRW5jb2RpbmcSGAoURU5DT0RJTkdfVU5TUEVDSUZJ", + "RUQQABIMCghMSU5FQVIxNhABEggKBEZMQUMQAiLjAQoOQXVkaW9PdXRDb25m", + "aWcSTQoIZW5jb2RpbmcYASABKA4yOy5nb29nbGUuYXNzaXN0YW50LmVtYmVk", + "ZGVkLnYxYWxwaGEyLkF1ZGlvT3V0Q29uZmlnLkVuY29kaW5nEhkKEXNhbXBs", + "ZV9yYXRlX2hlcnR6GAIgASgFEhkKEXZvbHVtZV9wZXJjZW50YWdlGAMgASgF", + "IkwKCEVuY29kaW5nEhgKFEVOQ09ESU5HX1VOU1BFQ0lGSUVEEAASDAoITElO", + "RUFSMTYQARIHCgNNUDMQAhIPCgtPUFVTX0lOX09HRxADIqcBCg9TY3JlZW5P", + "dXRDb25maWcSUwoLc2NyZWVuX21vZGUYASABKA4yPi5nb29nbGUuYXNzaXN0", + "YW50LmVtYmVkZGVkLnYxYWxwaGEyLlNjcmVlbk91dENvbmZpZy5TY3JlZW5N", + "b2RlIj8KClNjcmVlbk1vZGUSGwoXU0NSRUVOX01PREVfVU5TUEVDSUZJRUQQ", + "ABIHCgNPRkYQARILCgdQTEFZSU5HEAMirAEKDURpYWxvZ1N0YXRlSW4SGgoS", + "Y29udmVyc2F0aW9uX3N0YXRlGAEgASgMEhUKDWxhbmd1YWdlX2NvZGUYAiAB", + "KAkSSwoPZGV2aWNlX2xvY2F0aW9uGAUgASgLMjIuZ29vZ2xlLmFzc2lzdGFu", + "dC5lbWJlZGRlZC52MWFscGhhMi5EZXZpY2VMb2NhdGlvbhIbChNpc19uZXdf", + "Y29udmVyc2F0aW9uGAcgASgIIjoKDERldmljZUNvbmZpZxIRCglkZXZpY2Vf", + "aWQYASABKAkSFwoPZGV2aWNlX21vZGVsX2lkGAMgASgJIh4KCEF1ZGlvT3V0", + "EhIKCmF1ZGlvX2RhdGEYASABKAwiiwEKCVNjcmVlbk91dBJECgZmb3JtYXQY", + "ASABKA4yNC5nb29nbGUuYXNzaXN0YW50LmVtYmVkZGVkLnYxYWxwaGEyLlNj", + "cmVlbk91dC5Gb3JtYXQSDAoEZGF0YRgCIAEoDCIqCgZGb3JtYXQSFgoSRk9S", + "TUFUX1VOU1BFQ0lGSUVEEAASCAoESFRNTBABIisKDERldmljZUFjdGlvbhIb", + "ChNkZXZpY2VfcmVxdWVzdF9qc29uGAEgASgJIkAKF1NwZWVjaFJlY29nbml0", + "aW9uUmVzdWx0EhIKCnRyYW5zY3JpcHQYASABKAkSEQoJc3RhYmlsaXR5GAIg", + "ASgCIqUCCg5EaWFsb2dTdGF0ZU91dBIhChlzdXBwbGVtZW50YWxfZGlzcGxh", + "eV90ZXh0GAEgASgJEhoKEmNvbnZlcnNhdGlvbl9zdGF0ZRgCIAEoDBJaCg9t", + "aWNyb3Bob25lX21vZGUYAyABKA4yQS5nb29nbGUuYXNzaXN0YW50LmVtYmVk", + "ZGVkLnYxYWxwaGEyLkRpYWxvZ1N0YXRlT3V0Lk1pY3JvcGhvbmVNb2RlEhkK", + "EXZvbHVtZV9wZXJjZW50YWdlGAQgASgFIl0KDk1pY3JvcGhvbmVNb2RlEh8K", + "G01JQ1JPUEhPTkVfTU9ERV9VTlNQRUNJRklFRBAAEhQKEENMT1NFX01JQ1JP", + "UEhPTkUQARIUChBESUFMT0dfRk9MTE9XX09OEAIiKAoLRGVidWdDb25maWcS", + "GQoRcmV0dXJuX2RlYnVnX2luZm8YBiABKAgiRAoORGV2aWNlTG9jYXRpb24S", + "KgoLY29vcmRpbmF0ZXMYASABKAsyEy5nb29nbGUudHlwZS5MYXRMbmdIAEIG", + "CgR0eXBlMogBChFFbWJlZGRlZEFzc2lzdGFudBJzCgZBc3Npc3QSMS5nb29n", + "bGUuYXNzaXN0YW50LmVtYmVkZGVkLnYxYWxwaGEyLkFzc2lzdFJlcXVlc3Qa", + "Mi5nb29nbGUuYXNzaXN0YW50LmVtYmVkZGVkLnYxYWxwaGEyLkFzc2lzdFJl", + "c3BvbnNlKAEwAUKPAQomY29tLmdvb2dsZS5hc3Npc3RhbnQuZW1iZWRkZWQu", + "djFhbHBoYTJCDkFzc2lzdGFudFByb3RvUAFaSmdvb2dsZS5nb2xhbmcub3Jn", + "L2dlbnByb3RvL2dvb2dsZWFwaXMvYXNzaXN0YW50L2VtYmVkZGVkL3YxYWxw", + "aGEyO2VtYmVkZGVkogIGQVNUU0RLYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Google.Api.AnnotationsReflection.Descriptor, global::Google.Type.LatlngReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AssistRequest), global::Google.Assistant.Embedded.V1Alpha2.AssistRequest.Parser, new[]{ "Config", "AudioIn" }, new[]{ "Type" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AssistResponse), global::Google.Assistant.Embedded.V1Alpha2.AssistResponse.Parser, new[]{ "EventType", "AudioOut", "ScreenOut", "DeviceAction", "SpeechResults", "DialogStateOut", "DebugInfo" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.AssistResponse.Types.EventType) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DebugInfo), global::Google.Assistant.Embedded.V1Alpha2.DebugInfo.Parser, new[]{ "AogAgentToAssistantJson" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AssistConfig), global::Google.Assistant.Embedded.V1Alpha2.AssistConfig.Parser, new[]{ "AudioInConfig", "TextQuery", "AudioOutConfig", "ScreenOutConfig", "DialogStateIn", "DeviceConfig", "DebugConfig" }, new[]{ "Type" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig), global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig.Parser, new[]{ "Encoding", "SampleRateHertz" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig.Types.Encoding) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig), global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig.Parser, new[]{ "Encoding", "SampleRateHertz", "VolumePercentage" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig.Types.Encoding) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig), global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig.Parser, new[]{ "ScreenMode" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig.Types.ScreenMode) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DialogStateIn), global::Google.Assistant.Embedded.V1Alpha2.DialogStateIn.Parser, new[]{ "ConversationState", "LanguageCode", "DeviceLocation", "IsNewConversation" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DeviceConfig), global::Google.Assistant.Embedded.V1Alpha2.DeviceConfig.Parser, new[]{ "DeviceId", "DeviceModelId" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioOut), global::Google.Assistant.Embedded.V1Alpha2.AudioOut.Parser, new[]{ "AudioData" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.ScreenOut), global::Google.Assistant.Embedded.V1Alpha2.ScreenOut.Parser, new[]{ "Format", "Data" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.ScreenOut.Types.Format) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DeviceAction), global::Google.Assistant.Embedded.V1Alpha2.DeviceAction.Parser, new[]{ "DeviceRequestJson" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.SpeechRecognitionResult), global::Google.Assistant.Embedded.V1Alpha2.SpeechRecognitionResult.Parser, new[]{ "Transcript", "Stability" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut), global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut.Parser, new[]{ "SupplementalDisplayText", "ConversationState", "MicrophoneMode", "VolumePercentage" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut.Types.MicrophoneMode) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DebugConfig), global::Google.Assistant.Embedded.V1Alpha2.DebugConfig.Parser, new[]{ "ReturnDebugInfo" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DeviceLocation), global::Google.Assistant.Embedded.V1Alpha2.DeviceLocation.Parser, new[]{ "Coordinates" }, new[]{ "Type" }, null, null) + })); + } + #endregion + + } + #region Messages + /// + /// The top-level message sent by the client. Clients must send at least two, and + /// typically numerous `AssistRequest` messages. The first message must + /// contain a `config` message and must not contain `audio_in` data. All + /// subsequent messages must contain `audio_in` data and must not contain a + /// `config` message. + /// + public sealed partial class AssistRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AssistRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistRequest(AssistRequest other) : this() { + switch (other.TypeCase) { + case TypeOneofCase.Config: + Config = other.Config.Clone(); + break; + case TypeOneofCase.AudioIn: + AudioIn = other.AudioIn; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistRequest Clone() { + return new AssistRequest(this); + } + + /// Field number for the "config" field. + public const int ConfigFieldNumber = 1; + /// + /// The `config` message provides information to the recognizer that + /// specifies how to process the request. + /// The first `AssistRequest` message must contain a `config` message. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.AssistConfig Config { + get { return typeCase_ == TypeOneofCase.Config ? (global::Google.Assistant.Embedded.V1Alpha2.AssistConfig) type_ : null; } + set { + type_ = value; + typeCase_ = value == null ? TypeOneofCase.None : TypeOneofCase.Config; + } + } + + /// Field number for the "audio_in" field. + public const int AudioInFieldNumber = 2; + /// + /// The audio data to be recognized. Sequential chunks of audio data are sent + /// in sequential `AssistRequest` messages. The first `AssistRequest` + /// message must not contain `audio_in` data and all subsequent + /// `AssistRequest` messages must contain `audio_in` data. The audio bytes + /// must be encoded as specified in `AudioInConfig`. + /// Audio must be sent at approximately real-time (16000 samples per second). + /// An error will be returned if audio is sent significantly faster or + /// slower. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString AudioIn { + get { return typeCase_ == TypeOneofCase.AudioIn ? (pb::ByteString) type_ : pb::ByteString.Empty; } + set { + type_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + typeCase_ = TypeOneofCase.AudioIn; + } + } + + private object type_; + /// Enum of possible cases for the "type" oneof. + public enum TypeOneofCase { + None = 0, + Config = 1, + AudioIn = 2, + } + private TypeOneofCase typeCase_ = TypeOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TypeOneofCase TypeCase { + get { return typeCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearType() { + typeCase_ = TypeOneofCase.None; + type_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as AssistRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(AssistRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Config, other.Config)) return false; + if (AudioIn != other.AudioIn) return false; + if (TypeCase != other.TypeCase) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (typeCase_ == TypeOneofCase.Config) hash ^= Config.GetHashCode(); + if (typeCase_ == TypeOneofCase.AudioIn) hash ^= AudioIn.GetHashCode(); + hash ^= (int) typeCase_; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (typeCase_ == TypeOneofCase.Config) { + output.WriteRawTag(10); + output.WriteMessage(Config); + } + if (typeCase_ == TypeOneofCase.AudioIn) { + output.WriteRawTag(18); + output.WriteBytes(AudioIn); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (typeCase_ == TypeOneofCase.Config) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Config); + } + if (typeCase_ == TypeOneofCase.AudioIn) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(AudioIn); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(AssistRequest other) { + if (other == null) { + return; + } + switch (other.TypeCase) { + case TypeOneofCase.Config: + if (Config == null) { + Config = new global::Google.Assistant.Embedded.V1Alpha2.AssistConfig(); + } + Config.MergeFrom(other.Config); + break; + case TypeOneofCase.AudioIn: + AudioIn = other.AudioIn; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + global::Google.Assistant.Embedded.V1Alpha2.AssistConfig subBuilder = new global::Google.Assistant.Embedded.V1Alpha2.AssistConfig(); + if (typeCase_ == TypeOneofCase.Config) { + subBuilder.MergeFrom(Config); + } + input.ReadMessage(subBuilder); + Config = subBuilder; + break; + } + case 18: { + AudioIn = input.ReadBytes(); + break; + } + } + } + } + + } + + /// + /// The top-level message received by the client. A series of one or more + /// `AssistResponse` messages are streamed back to the client. + /// + public sealed partial class AssistResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AssistResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistResponse(AssistResponse other) : this() { + eventType_ = other.eventType_; + AudioOut = other.audioOut_ != null ? other.AudioOut.Clone() : null; + ScreenOut = other.screenOut_ != null ? other.ScreenOut.Clone() : null; + DeviceAction = other.deviceAction_ != null ? other.DeviceAction.Clone() : null; + speechResults_ = other.speechResults_.Clone(); + DialogStateOut = other.dialogStateOut_ != null ? other.DialogStateOut.Clone() : null; + DebugInfo = other.debugInfo_ != null ? other.DebugInfo.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistResponse Clone() { + return new AssistResponse(this); + } + + /// Field number for the "event_type" field. + public const int EventTypeFieldNumber = 1; + private global::Google.Assistant.Embedded.V1Alpha2.AssistResponse.Types.EventType eventType_ = 0; + /// + /// *Output-only* Indicates the type of event. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.AssistResponse.Types.EventType EventType { + get { return eventType_; } + set { + eventType_ = value; + } + } + + /// Field number for the "audio_out" field. + public const int AudioOutFieldNumber = 3; + private global::Google.Assistant.Embedded.V1Alpha2.AudioOut audioOut_; + /// + /// *Output-only* The audio containing the Assistant's response to the query. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.AudioOut AudioOut { + get { return audioOut_; } + set { + audioOut_ = value; + } + } + + /// Field number for the "screen_out" field. + public const int ScreenOutFieldNumber = 4; + private global::Google.Assistant.Embedded.V1Alpha2.ScreenOut screenOut_; + /// + /// *Output-only* Contains the Assistant's visual response to the query. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.ScreenOut ScreenOut { + get { return screenOut_; } + set { + screenOut_ = value; + } + } + + /// Field number for the "device_action" field. + public const int DeviceActionFieldNumber = 6; + private global::Google.Assistant.Embedded.V1Alpha2.DeviceAction deviceAction_; + /// + /// *Output-only* Contains the action triggered by the query with the + /// appropriate payloads and semantic parsing. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.DeviceAction DeviceAction { + get { return deviceAction_; } + set { + deviceAction_ = value; + } + } + + /// Field number for the "speech_results" field. + public const int SpeechResultsFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_speechResults_codec + = pb::FieldCodec.ForMessage(18, global::Google.Assistant.Embedded.V1Alpha2.SpeechRecognitionResult.Parser); + private readonly pbc::RepeatedField speechResults_ = new pbc::RepeatedField(); + /// + /// *Output-only* This repeated list contains zero or more speech recognition + /// results that correspond to consecutive portions of the audio currently + /// being processed, starting with the portion corresponding to the earliest + /// audio (and most stable portion) to the portion corresponding to the most + /// recent audio. The strings can be concatenated to view the full + /// in-progress response. When the speech recognition completes, this list + /// will contain one item with `stability` of `1.0`. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField SpeechResults { + get { return speechResults_; } + } + + /// Field number for the "dialog_state_out" field. + public const int DialogStateOutFieldNumber = 5; + private global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut dialogStateOut_; + /// + /// *Output-only* Contains output related to the user's query. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut DialogStateOut { + get { return dialogStateOut_; } + set { + dialogStateOut_ = value; + } + } + + /// Field number for the "debug_info" field. + public const int DebugInfoFieldNumber = 8; + private global::Google.Assistant.Embedded.V1Alpha2.DebugInfo debugInfo_; + /// + /// *Output-only* Debugging info for developer. Only returned if request set + /// `return_debug_info` to true. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.DebugInfo DebugInfo { + get { return debugInfo_; } + set { + debugInfo_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as AssistResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(AssistResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (EventType != other.EventType) return false; + if (!object.Equals(AudioOut, other.AudioOut)) return false; + if (!object.Equals(ScreenOut, other.ScreenOut)) return false; + if (!object.Equals(DeviceAction, other.DeviceAction)) return false; + if(!speechResults_.Equals(other.speechResults_)) return false; + if (!object.Equals(DialogStateOut, other.DialogStateOut)) return false; + if (!object.Equals(DebugInfo, other.DebugInfo)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (EventType != 0) hash ^= EventType.GetHashCode(); + if (audioOut_ != null) hash ^= AudioOut.GetHashCode(); + if (screenOut_ != null) hash ^= ScreenOut.GetHashCode(); + if (deviceAction_ != null) hash ^= DeviceAction.GetHashCode(); + hash ^= speechResults_.GetHashCode(); + if (dialogStateOut_ != null) hash ^= DialogStateOut.GetHashCode(); + if (debugInfo_ != null) hash ^= DebugInfo.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (EventType != 0) { + output.WriteRawTag(8); + output.WriteEnum((int) EventType); + } + speechResults_.WriteTo(output, _repeated_speechResults_codec); + if (audioOut_ != null) { + output.WriteRawTag(26); + output.WriteMessage(AudioOut); + } + if (screenOut_ != null) { + output.WriteRawTag(34); + output.WriteMessage(ScreenOut); + } + if (dialogStateOut_ != null) { + output.WriteRawTag(42); + output.WriteMessage(DialogStateOut); + } + if (deviceAction_ != null) { + output.WriteRawTag(50); + output.WriteMessage(DeviceAction); + } + if (debugInfo_ != null) { + output.WriteRawTag(66); + output.WriteMessage(DebugInfo); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (EventType != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EventType); + } + if (audioOut_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(AudioOut); + } + if (screenOut_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ScreenOut); + } + if (deviceAction_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DeviceAction); + } + size += speechResults_.CalculateSize(_repeated_speechResults_codec); + if (dialogStateOut_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DialogStateOut); + } + if (debugInfo_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DebugInfo); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(AssistResponse other) { + if (other == null) { + return; + } + if (other.EventType != 0) { + EventType = other.EventType; + } + if (other.audioOut_ != null) { + if (audioOut_ == null) { + audioOut_ = new global::Google.Assistant.Embedded.V1Alpha2.AudioOut(); + } + AudioOut.MergeFrom(other.AudioOut); + } + if (other.screenOut_ != null) { + if (screenOut_ == null) { + screenOut_ = new global::Google.Assistant.Embedded.V1Alpha2.ScreenOut(); + } + ScreenOut.MergeFrom(other.ScreenOut); + } + if (other.deviceAction_ != null) { + if (deviceAction_ == null) { + deviceAction_ = new global::Google.Assistant.Embedded.V1Alpha2.DeviceAction(); + } + DeviceAction.MergeFrom(other.DeviceAction); + } + speechResults_.Add(other.speechResults_); + if (other.dialogStateOut_ != null) { + if (dialogStateOut_ == null) { + dialogStateOut_ = new global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut(); + } + DialogStateOut.MergeFrom(other.DialogStateOut); + } + if (other.debugInfo_ != null) { + if (debugInfo_ == null) { + debugInfo_ = new global::Google.Assistant.Embedded.V1Alpha2.DebugInfo(); + } + DebugInfo.MergeFrom(other.DebugInfo); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + eventType_ = (global::Google.Assistant.Embedded.V1Alpha2.AssistResponse.Types.EventType) input.ReadEnum(); + break; + } + case 18: { + speechResults_.AddEntriesFrom(input, _repeated_speechResults_codec); + break; + } + case 26: { + if (audioOut_ == null) { + audioOut_ = new global::Google.Assistant.Embedded.V1Alpha2.AudioOut(); + } + input.ReadMessage(audioOut_); + break; + } + case 34: { + if (screenOut_ == null) { + screenOut_ = new global::Google.Assistant.Embedded.V1Alpha2.ScreenOut(); + } + input.ReadMessage(screenOut_); + break; + } + case 42: { + if (dialogStateOut_ == null) { + dialogStateOut_ = new global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut(); + } + input.ReadMessage(dialogStateOut_); + break; + } + case 50: { + if (deviceAction_ == null) { + deviceAction_ = new global::Google.Assistant.Embedded.V1Alpha2.DeviceAction(); + } + input.ReadMessage(deviceAction_); + break; + } + case 66: { + if (debugInfo_ == null) { + debugInfo_ = new global::Google.Assistant.Embedded.V1Alpha2.DebugInfo(); + } + input.ReadMessage(debugInfo_); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the AssistResponse message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Indicates the type of event. + /// + public enum EventType { + /// + /// No event specified. + /// + [pbr::OriginalName("EVENT_TYPE_UNSPECIFIED")] Unspecified = 0, + /// + /// This event indicates that the server has detected the end of the user's + /// speech utterance and expects no additional speech. Therefore, the server + /// will not process additional audio (although it may subsequently return + /// additional results). The client should stop sending additional audio + /// data, half-close the gRPC connection, and wait for any additional results + /// until the server closes the gRPC connection. + /// + [pbr::OriginalName("END_OF_UTTERANCE")] EndOfUtterance = 1, + } + + } + #endregion + + } + + /// + /// Debug info for developer. Only returned if request set `return_debug_info` + /// to true. + /// + public sealed partial class DebugInfo : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DebugInfo()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugInfo() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugInfo(DebugInfo other) : this() { + aogAgentToAssistantJson_ = other.aogAgentToAssistantJson_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugInfo Clone() { + return new DebugInfo(this); + } + + /// Field number for the "aog_agent_to_assistant_json" field. + public const int AogAgentToAssistantJsonFieldNumber = 1; + private string aogAgentToAssistantJson_ = ""; + /// + /// The original JSON response from an Action-on-Google agent to Google server. + /// See + /// https://developers.google.com/actions/reference/rest/Shared.Types/AppResponse. + /// It will only be populated if the request maker owns the AoG project and the + /// AoG project is in preview mode. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string AogAgentToAssistantJson { + get { return aogAgentToAssistantJson_; } + set { + aogAgentToAssistantJson_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DebugInfo); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DebugInfo other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (AogAgentToAssistantJson != other.AogAgentToAssistantJson) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (AogAgentToAssistantJson.Length != 0) hash ^= AogAgentToAssistantJson.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (AogAgentToAssistantJson.Length != 0) { + output.WriteRawTag(10); + output.WriteString(AogAgentToAssistantJson); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (AogAgentToAssistantJson.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(AogAgentToAssistantJson); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DebugInfo other) { + if (other == null) { + return; + } + if (other.AogAgentToAssistantJson.Length != 0) { + AogAgentToAssistantJson = other.AogAgentToAssistantJson; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + AogAgentToAssistantJson = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// Specifies how to process the `AssistRequest` messages. + /// + public sealed partial class AssistConfig : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AssistConfig()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistConfig() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistConfig(AssistConfig other) : this() { + AudioOutConfig = other.audioOutConfig_ != null ? other.AudioOutConfig.Clone() : null; + ScreenOutConfig = other.screenOutConfig_ != null ? other.ScreenOutConfig.Clone() : null; + DialogStateIn = other.dialogStateIn_ != null ? other.DialogStateIn.Clone() : null; + DeviceConfig = other.deviceConfig_ != null ? other.DeviceConfig.Clone() : null; + DebugConfig = other.debugConfig_ != null ? other.DebugConfig.Clone() : null; + switch (other.TypeCase) { + case TypeOneofCase.AudioInConfig: + AudioInConfig = other.AudioInConfig.Clone(); + break; + case TypeOneofCase.TextQuery: + TextQuery = other.TextQuery; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AssistConfig Clone() { + return new AssistConfig(this); + } + + /// Field number for the "audio_in_config" field. + public const int AudioInConfigFieldNumber = 1; + /// + /// Specifies how to process the subsequent incoming audio. Required if + /// [AssistRequest.audio_in][google.assistant.embedded.v1alpha2.AssistRequest.audio_in] + /// bytes will be provided in subsequent requests. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig AudioInConfig { + get { return typeCase_ == TypeOneofCase.AudioInConfig ? (global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig) type_ : null; } + set { + type_ = value; + typeCase_ = value == null ? TypeOneofCase.None : TypeOneofCase.AudioInConfig; + } + } + + /// Field number for the "text_query" field. + public const int TextQueryFieldNumber = 6; + /// + /// The text input to be sent to the Assistant. This can be populated from a + /// text interface if audio input is not available. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string TextQuery { + get { return typeCase_ == TypeOneofCase.TextQuery ? (string) type_ : ""; } + set { + type_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + typeCase_ = TypeOneofCase.TextQuery; + } + } + + /// Field number for the "audio_out_config" field. + public const int AudioOutConfigFieldNumber = 2; + private global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig audioOutConfig_; + /// + /// *Required* Specifies how to format the audio that will be returned. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig AudioOutConfig { + get { return audioOutConfig_; } + set { + audioOutConfig_ = value; + } + } + + /// Field number for the "screen_out_config" field. + public const int ScreenOutConfigFieldNumber = 8; + private global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig screenOutConfig_; + /// + /// *Optional* Specifies the desired format to use when server returns a + /// visual screen response. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig ScreenOutConfig { + get { return screenOutConfig_; } + set { + screenOutConfig_ = value; + } + } + + /// Field number for the "dialog_state_in" field. + public const int DialogStateInFieldNumber = 3; + private global::Google.Assistant.Embedded.V1Alpha2.DialogStateIn dialogStateIn_; + /// + /// *Required* Represents the current dialog state. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.DialogStateIn DialogStateIn { + get { return dialogStateIn_; } + set { + dialogStateIn_ = value; + } + } + + /// Field number for the "device_config" field. + public const int DeviceConfigFieldNumber = 4; + private global::Google.Assistant.Embedded.V1Alpha2.DeviceConfig deviceConfig_; + /// + /// Device configuration that uniquely identifies a specific device. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.DeviceConfig DeviceConfig { + get { return deviceConfig_; } + set { + deviceConfig_ = value; + } + } + + /// Field number for the "debug_config" field. + public const int DebugConfigFieldNumber = 5; + private global::Google.Assistant.Embedded.V1Alpha2.DebugConfig debugConfig_; + /// + /// *Optional* Debugging parameters for the whole `Assist` RPC. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.DebugConfig DebugConfig { + get { return debugConfig_; } + set { + debugConfig_ = value; + } + } + + private object type_; + /// Enum of possible cases for the "type" oneof. + public enum TypeOneofCase { + None = 0, + AudioInConfig = 1, + TextQuery = 6, + } + private TypeOneofCase typeCase_ = TypeOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TypeOneofCase TypeCase { + get { return typeCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearType() { + typeCase_ = TypeOneofCase.None; + type_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as AssistConfig); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(AssistConfig other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(AudioInConfig, other.AudioInConfig)) return false; + if (TextQuery != other.TextQuery) return false; + if (!object.Equals(AudioOutConfig, other.AudioOutConfig)) return false; + if (!object.Equals(ScreenOutConfig, other.ScreenOutConfig)) return false; + if (!object.Equals(DialogStateIn, other.DialogStateIn)) return false; + if (!object.Equals(DeviceConfig, other.DeviceConfig)) return false; + if (!object.Equals(DebugConfig, other.DebugConfig)) return false; + if (TypeCase != other.TypeCase) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (typeCase_ == TypeOneofCase.AudioInConfig) hash ^= AudioInConfig.GetHashCode(); + if (typeCase_ == TypeOneofCase.TextQuery) hash ^= TextQuery.GetHashCode(); + if (audioOutConfig_ != null) hash ^= AudioOutConfig.GetHashCode(); + if (screenOutConfig_ != null) hash ^= ScreenOutConfig.GetHashCode(); + if (dialogStateIn_ != null) hash ^= DialogStateIn.GetHashCode(); + if (deviceConfig_ != null) hash ^= DeviceConfig.GetHashCode(); + if (debugConfig_ != null) hash ^= DebugConfig.GetHashCode(); + hash ^= (int) typeCase_; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (typeCase_ == TypeOneofCase.AudioInConfig) { + output.WriteRawTag(10); + output.WriteMessage(AudioInConfig); + } + if (audioOutConfig_ != null) { + output.WriteRawTag(18); + output.WriteMessage(AudioOutConfig); + } + if (dialogStateIn_ != null) { + output.WriteRawTag(26); + output.WriteMessage(DialogStateIn); + } + if (deviceConfig_ != null) { + output.WriteRawTag(34); + output.WriteMessage(DeviceConfig); + } + if (debugConfig_ != null) { + output.WriteRawTag(42); + output.WriteMessage(DebugConfig); + } + if (typeCase_ == TypeOneofCase.TextQuery) { + output.WriteRawTag(50); + output.WriteString(TextQuery); + } + if (screenOutConfig_ != null) { + output.WriteRawTag(66); + output.WriteMessage(ScreenOutConfig); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (typeCase_ == TypeOneofCase.AudioInConfig) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(AudioInConfig); + } + if (typeCase_ == TypeOneofCase.TextQuery) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TextQuery); + } + if (audioOutConfig_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(AudioOutConfig); + } + if (screenOutConfig_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ScreenOutConfig); + } + if (dialogStateIn_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DialogStateIn); + } + if (deviceConfig_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DeviceConfig); + } + if (debugConfig_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DebugConfig); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(AssistConfig other) { + if (other == null) { + return; + } + if (other.audioOutConfig_ != null) { + if (audioOutConfig_ == null) { + audioOutConfig_ = new global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig(); + } + AudioOutConfig.MergeFrom(other.AudioOutConfig); + } + if (other.screenOutConfig_ != null) { + if (screenOutConfig_ == null) { + screenOutConfig_ = new global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig(); + } + ScreenOutConfig.MergeFrom(other.ScreenOutConfig); + } + if (other.dialogStateIn_ != null) { + if (dialogStateIn_ == null) { + dialogStateIn_ = new global::Google.Assistant.Embedded.V1Alpha2.DialogStateIn(); + } + DialogStateIn.MergeFrom(other.DialogStateIn); + } + if (other.deviceConfig_ != null) { + if (deviceConfig_ == null) { + deviceConfig_ = new global::Google.Assistant.Embedded.V1Alpha2.DeviceConfig(); + } + DeviceConfig.MergeFrom(other.DeviceConfig); + } + if (other.debugConfig_ != null) { + if (debugConfig_ == null) { + debugConfig_ = new global::Google.Assistant.Embedded.V1Alpha2.DebugConfig(); + } + DebugConfig.MergeFrom(other.DebugConfig); + } + switch (other.TypeCase) { + case TypeOneofCase.AudioInConfig: + if (AudioInConfig == null) { + AudioInConfig = new global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig(); + } + AudioInConfig.MergeFrom(other.AudioInConfig); + break; + case TypeOneofCase.TextQuery: + TextQuery = other.TextQuery; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig subBuilder = new global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig(); + if (typeCase_ == TypeOneofCase.AudioInConfig) { + subBuilder.MergeFrom(AudioInConfig); + } + input.ReadMessage(subBuilder); + AudioInConfig = subBuilder; + break; + } + case 18: { + if (audioOutConfig_ == null) { + audioOutConfig_ = new global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig(); + } + input.ReadMessage(audioOutConfig_); + break; + } + case 26: { + if (dialogStateIn_ == null) { + dialogStateIn_ = new global::Google.Assistant.Embedded.V1Alpha2.DialogStateIn(); + } + input.ReadMessage(dialogStateIn_); + break; + } + case 34: { + if (deviceConfig_ == null) { + deviceConfig_ = new global::Google.Assistant.Embedded.V1Alpha2.DeviceConfig(); + } + input.ReadMessage(deviceConfig_); + break; + } + case 42: { + if (debugConfig_ == null) { + debugConfig_ = new global::Google.Assistant.Embedded.V1Alpha2.DebugConfig(); + } + input.ReadMessage(debugConfig_); + break; + } + case 50: { + TextQuery = input.ReadString(); + break; + } + case 66: { + if (screenOutConfig_ == null) { + screenOutConfig_ = new global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig(); + } + input.ReadMessage(screenOutConfig_); + break; + } + } + } + } + + } + + /// + /// Specifies how to process the `audio_in` data that will be provided in + /// subsequent requests. For recommended settings, see the Google Assistant SDK + /// [best + /// practices](https://developers.google.com/assistant/sdk/guides/service/python/best-practices/audio). + /// + public sealed partial class AudioInConfig : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AudioInConfig()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioInConfig() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioInConfig(AudioInConfig other) : this() { + encoding_ = other.encoding_; + sampleRateHertz_ = other.sampleRateHertz_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioInConfig Clone() { + return new AudioInConfig(this); + } + + /// Field number for the "encoding" field. + public const int EncodingFieldNumber = 1; + private global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig.Types.Encoding encoding_ = 0; + /// + /// *Required* Encoding of audio data sent in all `audio_in` messages. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig.Types.Encoding Encoding { + get { return encoding_; } + set { + encoding_ = value; + } + } + + /// Field number for the "sample_rate_hertz" field. + public const int SampleRateHertzFieldNumber = 2; + private int sampleRateHertz_; + /// + /// *Required* Sample rate (in Hertz) of the audio data sent in all `audio_in` + /// messages. Valid values are from 16000-24000, but 16000 is optimal. + /// For best results, set the sampling rate of the audio source to 16000 Hz. + /// If that's not possible, use the native sample rate of the audio source + /// (instead of re-sampling). + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int SampleRateHertz { + get { return sampleRateHertz_; } + set { + sampleRateHertz_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as AudioInConfig); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(AudioInConfig other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Encoding != other.Encoding) return false; + if (SampleRateHertz != other.SampleRateHertz) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Encoding != 0) hash ^= Encoding.GetHashCode(); + if (SampleRateHertz != 0) hash ^= SampleRateHertz.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Encoding != 0) { + output.WriteRawTag(8); + output.WriteEnum((int) Encoding); + } + if (SampleRateHertz != 0) { + output.WriteRawTag(16); + output.WriteInt32(SampleRateHertz); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Encoding != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Encoding); + } + if (SampleRateHertz != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(SampleRateHertz); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(AudioInConfig other) { + if (other == null) { + return; + } + if (other.Encoding != 0) { + Encoding = other.Encoding; + } + if (other.SampleRateHertz != 0) { + SampleRateHertz = other.SampleRateHertz; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + encoding_ = (global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig.Types.Encoding) input.ReadEnum(); + break; + } + case 16: { + SampleRateHertz = input.ReadInt32(); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the AudioInConfig message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Audio encoding of the data sent in the audio message. + /// Audio must be one-channel (mono). + /// + public enum Encoding { + /// + /// Not specified. Will return result [google.rpc.Code.INVALID_ARGUMENT][]. + /// + [pbr::OriginalName("ENCODING_UNSPECIFIED")] Unspecified = 0, + /// + /// Uncompressed 16-bit signed little-endian samples (Linear PCM). + /// This encoding includes no header, only the raw audio bytes. + /// + [pbr::OriginalName("LINEAR16")] Linear16 = 1, + /// + /// [`FLAC`](https://xiph.org/flac/documentation.html) (Free Lossless Audio + /// Codec) is the recommended encoding because it is + /// lossless--therefore recognition is not compromised--and + /// requires only about half the bandwidth of `LINEAR16`. This encoding + /// includes the `FLAC` stream header followed by audio data. It supports + /// 16-bit and 24-bit samples, however, not all fields in `STREAMINFO` are + /// supported. + /// + [pbr::OriginalName("FLAC")] Flac = 2, + } + + } + #endregion + + } + + /// + /// Specifies the desired format for the server to use when it returns + /// `audio_out` messages. + /// + public sealed partial class AudioOutConfig : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AudioOutConfig()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioOutConfig() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioOutConfig(AudioOutConfig other) : this() { + encoding_ = other.encoding_; + sampleRateHertz_ = other.sampleRateHertz_; + volumePercentage_ = other.volumePercentage_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioOutConfig Clone() { + return new AudioOutConfig(this); + } + + /// Field number for the "encoding" field. + public const int EncodingFieldNumber = 1; + private global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig.Types.Encoding encoding_ = 0; + /// + /// *Required* The encoding of audio data to be returned in all `audio_out` + /// messages. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig.Types.Encoding Encoding { + get { return encoding_; } + set { + encoding_ = value; + } + } + + /// Field number for the "sample_rate_hertz" field. + public const int SampleRateHertzFieldNumber = 2; + private int sampleRateHertz_; + /// + /// *Required* The sample rate in Hertz of the audio data returned in + /// `audio_out` messages. Valid values are: 16000-24000. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int SampleRateHertz { + get { return sampleRateHertz_; } + set { + sampleRateHertz_ = value; + } + } + + /// Field number for the "volume_percentage" field. + public const int VolumePercentageFieldNumber = 3; + private int volumePercentage_; + /// + /// *Required* Current volume setting of the device's audio output. + /// Valid values are 1 to 100 (corresponding to 1% to 100%). + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int VolumePercentage { + get { return volumePercentage_; } + set { + volumePercentage_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as AudioOutConfig); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(AudioOutConfig other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Encoding != other.Encoding) return false; + if (SampleRateHertz != other.SampleRateHertz) return false; + if (VolumePercentage != other.VolumePercentage) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Encoding != 0) hash ^= Encoding.GetHashCode(); + if (SampleRateHertz != 0) hash ^= SampleRateHertz.GetHashCode(); + if (VolumePercentage != 0) hash ^= VolumePercentage.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Encoding != 0) { + output.WriteRawTag(8); + output.WriteEnum((int) Encoding); + } + if (SampleRateHertz != 0) { + output.WriteRawTag(16); + output.WriteInt32(SampleRateHertz); + } + if (VolumePercentage != 0) { + output.WriteRawTag(24); + output.WriteInt32(VolumePercentage); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Encoding != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Encoding); + } + if (SampleRateHertz != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(SampleRateHertz); + } + if (VolumePercentage != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(VolumePercentage); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(AudioOutConfig other) { + if (other == null) { + return; + } + if (other.Encoding != 0) { + Encoding = other.Encoding; + } + if (other.SampleRateHertz != 0) { + SampleRateHertz = other.SampleRateHertz; + } + if (other.VolumePercentage != 0) { + VolumePercentage = other.VolumePercentage; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + encoding_ = (global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig.Types.Encoding) input.ReadEnum(); + break; + } + case 16: { + SampleRateHertz = input.ReadInt32(); + break; + } + case 24: { + VolumePercentage = input.ReadInt32(); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the AudioOutConfig message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Audio encoding of the data returned in the audio message. All encodings are + /// raw audio bytes with no header, except as indicated below. + /// + public enum Encoding { + /// + /// Not specified. Will return result [google.rpc.Code.INVALID_ARGUMENT][]. + /// + [pbr::OriginalName("ENCODING_UNSPECIFIED")] Unspecified = 0, + /// + /// Uncompressed 16-bit signed little-endian samples (Linear PCM). + /// + [pbr::OriginalName("LINEAR16")] Linear16 = 1, + /// + /// MP3 audio encoding. The sample rate is encoded in the payload. + /// + [pbr::OriginalName("MP3")] Mp3 = 2, + /// + /// Opus-encoded audio wrapped in an ogg container. The result will be a + /// file which can be played natively on Android and in some browsers (such + /// as Chrome). The quality of the encoding is considerably higher than MP3 + /// while using the same bitrate. The sample rate is encoded in the payload. + /// + [pbr::OriginalName("OPUS_IN_OGG")] OpusInOgg = 3, + } + + } + #endregion + + } + + /// + /// Specifies the desired format for the server to use when it returns + /// `screen_out` response. + /// + public sealed partial class ScreenOutConfig : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ScreenOutConfig()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ScreenOutConfig() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ScreenOutConfig(ScreenOutConfig other) : this() { + screenMode_ = other.screenMode_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ScreenOutConfig Clone() { + return new ScreenOutConfig(this); + } + + /// Field number for the "screen_mode" field. + public const int ScreenModeFieldNumber = 1; + private global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig.Types.ScreenMode screenMode_ = 0; + /// + /// Current visual screen-mode for the device while issuing the query. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig.Types.ScreenMode ScreenMode { + get { return screenMode_; } + set { + screenMode_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ScreenOutConfig); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ScreenOutConfig other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ScreenMode != other.ScreenMode) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ScreenMode != 0) hash ^= ScreenMode.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ScreenMode != 0) { + output.WriteRawTag(8); + output.WriteEnum((int) ScreenMode); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ScreenMode != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) ScreenMode); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ScreenOutConfig other) { + if (other == null) { + return; + } + if (other.ScreenMode != 0) { + ScreenMode = other.ScreenMode; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + screenMode_ = (global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig.Types.ScreenMode) input.ReadEnum(); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the ScreenOutConfig message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Possible modes for visual screen-output on the device. + /// + public enum ScreenMode { + /// + /// No video mode specified. + /// The Assistant may respond as if in `OFF` mode. + /// + [pbr::OriginalName("SCREEN_MODE_UNSPECIFIED")] Unspecified = 0, + /// + /// Screen is off (or has brightness or other settings set so low it is + /// not visible). The Assistant will typically not return a screen response + /// in this mode. + /// + [pbr::OriginalName("OFF")] Off = 1, + /// + /// The Assistant will typically return a partial-screen response in this + /// mode. + /// + [pbr::OriginalName("PLAYING")] Playing = 3, + } + + } + #endregion + + } + + /// + /// Provides information about the current dialog state. + /// + public sealed partial class DialogStateIn : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DialogStateIn()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[7]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DialogStateIn() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DialogStateIn(DialogStateIn other) : this() { + conversationState_ = other.conversationState_; + languageCode_ = other.languageCode_; + DeviceLocation = other.deviceLocation_ != null ? other.DeviceLocation.Clone() : null; + isNewConversation_ = other.isNewConversation_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DialogStateIn Clone() { + return new DialogStateIn(this); + } + + /// Field number for the "conversation_state" field. + public const int ConversationStateFieldNumber = 1; + private pb::ByteString conversationState_ = pb::ByteString.Empty; + /// + /// *Required* This field must always be set to the + /// [DialogStateOut.conversation_state][google.assistant.embedded.v1alpha2.DialogStateOut.conversation_state] + /// value that was returned in the prior `Assist` RPC. It should only be + /// omitted (field not set) if there was no prior `Assist` RPC because this is + /// the first `Assist` RPC made by this device after it was first setup and/or + /// a factory-default reset. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString ConversationState { + get { return conversationState_; } + set { + conversationState_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "language_code" field. + public const int LanguageCodeFieldNumber = 2; + private string languageCode_ = ""; + /// + /// *Required* Language of the request in + /// [IETF BCP 47 syntax](https://tools.ietf.org/html/bcp47) (for example, + /// "en-US"). See [Language + /// Support](https://developers.google.com/assistant/sdk/reference/rpc/languages) + /// for more information. If you have selected a language for this `device_id` + /// using the + /// [Settings](https://developers.google.com/assistant/sdk/reference/assistant-app/assistant-settings) + /// menu in your phone's Google Assistant app, that selection will override + /// this value. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string LanguageCode { + get { return languageCode_; } + set { + languageCode_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "device_location" field. + public const int DeviceLocationFieldNumber = 5; + private global::Google.Assistant.Embedded.V1Alpha2.DeviceLocation deviceLocation_; + /// + /// *Optional* Location of the device where the query originated. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.DeviceLocation DeviceLocation { + get { return deviceLocation_; } + set { + deviceLocation_ = value; + } + } + + /// Field number for the "is_new_conversation" field. + public const int IsNewConversationFieldNumber = 7; + private bool isNewConversation_; + /// + /// *Optional* If true, the server will treat the request as a new conversation + /// and not use state from the prior request. Set this field to true when the + /// conversation should be restarted, such as after a device reboot, or after a + /// significant lapse of time since the prior query. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool IsNewConversation { + get { return isNewConversation_; } + set { + isNewConversation_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DialogStateIn); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DialogStateIn other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ConversationState != other.ConversationState) return false; + if (LanguageCode != other.LanguageCode) return false; + if (!object.Equals(DeviceLocation, other.DeviceLocation)) return false; + if (IsNewConversation != other.IsNewConversation) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ConversationState.Length != 0) hash ^= ConversationState.GetHashCode(); + if (LanguageCode.Length != 0) hash ^= LanguageCode.GetHashCode(); + if (deviceLocation_ != null) hash ^= DeviceLocation.GetHashCode(); + if (IsNewConversation != false) hash ^= IsNewConversation.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ConversationState.Length != 0) { + output.WriteRawTag(10); + output.WriteBytes(ConversationState); + } + if (LanguageCode.Length != 0) { + output.WriteRawTag(18); + output.WriteString(LanguageCode); + } + if (deviceLocation_ != null) { + output.WriteRawTag(42); + output.WriteMessage(DeviceLocation); + } + if (IsNewConversation != false) { + output.WriteRawTag(56); + output.WriteBool(IsNewConversation); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ConversationState.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(ConversationState); + } + if (LanguageCode.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(LanguageCode); + } + if (deviceLocation_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DeviceLocation); + } + if (IsNewConversation != false) { + size += 1 + 1; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DialogStateIn other) { + if (other == null) { + return; + } + if (other.ConversationState.Length != 0) { + ConversationState = other.ConversationState; + } + if (other.LanguageCode.Length != 0) { + LanguageCode = other.LanguageCode; + } + if (other.deviceLocation_ != null) { + if (deviceLocation_ == null) { + deviceLocation_ = new global::Google.Assistant.Embedded.V1Alpha2.DeviceLocation(); + } + DeviceLocation.MergeFrom(other.DeviceLocation); + } + if (other.IsNewConversation != false) { + IsNewConversation = other.IsNewConversation; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + ConversationState = input.ReadBytes(); + break; + } + case 18: { + LanguageCode = input.ReadString(); + break; + } + case 42: { + if (deviceLocation_ == null) { + deviceLocation_ = new global::Google.Assistant.Embedded.V1Alpha2.DeviceLocation(); + } + input.ReadMessage(deviceLocation_); + break; + } + case 56: { + IsNewConversation = input.ReadBool(); + break; + } + } + } + } + + } + + /// + /// *Required* Fields that identify the device to the Assistant. + /// + /// See also: + /// + /// * [Register a Device - REST + /// API](https://developers.google.com/assistant/sdk/reference/device-registration/register-device-manual) + /// * [Device Model and Instance + /// Schemas](https://developers.google.com/assistant/sdk/reference/device-registration/model-and-instance-schemas) + /// * [Device + /// Proto](https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.devices.v1alpha2#device) + /// + public sealed partial class DeviceConfig : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeviceConfig()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[8]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceConfig() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceConfig(DeviceConfig other) : this() { + deviceId_ = other.deviceId_; + deviceModelId_ = other.deviceModelId_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceConfig Clone() { + return new DeviceConfig(this); + } + + /// Field number for the "device_id" field. + public const int DeviceIdFieldNumber = 1; + private string deviceId_ = ""; + /// + /// *Required* Unique identifier for the device. The id length must be 128 + /// characters or less. Example: DBCDW098234. This MUST match the device_id + /// returned from device registration. This device_id is used to match against + /// the user's registered devices to lookup the supported traits and + /// capabilities of this device. This information should not change across + /// device reboots. However, it should not be saved across + /// factory-default resets. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string DeviceId { + get { return deviceId_; } + set { + deviceId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "device_model_id" field. + public const int DeviceModelIdFieldNumber = 3; + private string deviceModelId_ = ""; + /// + /// *Required* Unique identifier for the device model. The combination of + /// device_model_id and device_id must have been previously associated through + /// device registration. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string DeviceModelId { + get { return deviceModelId_; } + set { + deviceModelId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DeviceConfig); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DeviceConfig other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (DeviceId != other.DeviceId) return false; + if (DeviceModelId != other.DeviceModelId) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (DeviceId.Length != 0) hash ^= DeviceId.GetHashCode(); + if (DeviceModelId.Length != 0) hash ^= DeviceModelId.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (DeviceId.Length != 0) { + output.WriteRawTag(10); + output.WriteString(DeviceId); + } + if (DeviceModelId.Length != 0) { + output.WriteRawTag(26); + output.WriteString(DeviceModelId); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (DeviceId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(DeviceId); + } + if (DeviceModelId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(DeviceModelId); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DeviceConfig other) { + if (other == null) { + return; + } + if (other.DeviceId.Length != 0) { + DeviceId = other.DeviceId; + } + if (other.DeviceModelId.Length != 0) { + DeviceModelId = other.DeviceModelId; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + DeviceId = input.ReadString(); + break; + } + case 26: { + DeviceModelId = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// The audio containing the Assistant's response to the query. Sequential chunks + /// of audio data are received in sequential `AssistResponse` messages. + /// + public sealed partial class AudioOut : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AudioOut()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[9]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioOut() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioOut(AudioOut other) : this() { + audioData_ = other.audioData_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AudioOut Clone() { + return new AudioOut(this); + } + + /// Field number for the "audio_data" field. + public const int AudioDataFieldNumber = 1; + private pb::ByteString audioData_ = pb::ByteString.Empty; + /// + /// *Output-only* The audio data containing the Assistant's response to the + /// query. Sequential chunks of audio data are received in sequential + /// `AssistResponse` messages. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString AudioData { + get { return audioData_; } + set { + audioData_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as AudioOut); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(AudioOut other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (AudioData != other.AudioData) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (AudioData.Length != 0) hash ^= AudioData.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (AudioData.Length != 0) { + output.WriteRawTag(10); + output.WriteBytes(AudioData); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (AudioData.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(AudioData); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(AudioOut other) { + if (other == null) { + return; + } + if (other.AudioData.Length != 0) { + AudioData = other.AudioData; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + AudioData = input.ReadBytes(); + break; + } + } + } + } + + } + + /// + /// The Assistant's visual output response to query. Enabled by + /// `screen_out_config`. + /// + public sealed partial class ScreenOut : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ScreenOut()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[10]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ScreenOut() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ScreenOut(ScreenOut other) : this() { + format_ = other.format_; + data_ = other.data_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ScreenOut Clone() { + return new ScreenOut(this); + } + + /// Field number for the "format" field. + public const int FormatFieldNumber = 1; + private global::Google.Assistant.Embedded.V1Alpha2.ScreenOut.Types.Format format_ = 0; + /// + /// *Output-only* The format of the provided screen data. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.ScreenOut.Types.Format Format { + get { return format_; } + set { + format_ = value; + } + } + + /// Field number for the "data" field. + public const int DataFieldNumber = 2; + private pb::ByteString data_ = pb::ByteString.Empty; + /// + /// *Output-only* The raw screen data to be displayed as the result of the + /// Assistant query. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString Data { + get { return data_; } + set { + data_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ScreenOut); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ScreenOut other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Format != other.Format) return false; + if (Data != other.Data) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Format != 0) hash ^= Format.GetHashCode(); + if (Data.Length != 0) hash ^= Data.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Format != 0) { + output.WriteRawTag(8); + output.WriteEnum((int) Format); + } + if (Data.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(Data); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Format != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Format); + } + if (Data.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Data); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ScreenOut other) { + if (other == null) { + return; + } + if (other.Format != 0) { + Format = other.Format; + } + if (other.Data.Length != 0) { + Data = other.Data; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + format_ = (global::Google.Assistant.Embedded.V1Alpha2.ScreenOut.Types.Format) input.ReadEnum(); + break; + } + case 18: { + Data = input.ReadBytes(); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the ScreenOut message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Possible formats of the screen data. + /// + public enum Format { + /// + /// No format specified. + /// + [pbr::OriginalName("FORMAT_UNSPECIFIED")] Unspecified = 0, + /// + /// Data will contain a fully-formed HTML5 layout encoded in UTF-8, e.g. + /// `<html><body><div>...</div></body></html>`. It is intended to be rendered + /// along with the audio response. Note that HTML5 doctype should be included + /// in the actual HTML data. + /// + [pbr::OriginalName("HTML")] Html = 1, + } + + } + #endregion + + } + + /// + /// The response returned to the device if the user has triggered a Device + /// Action. For example, a device which supports the query *Turn on the light* + /// would receive a `DeviceAction` with a JSON payload containing the semantics + /// of the request. + /// + public sealed partial class DeviceAction : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeviceAction()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[11]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceAction() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceAction(DeviceAction other) : this() { + deviceRequestJson_ = other.deviceRequestJson_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceAction Clone() { + return new DeviceAction(this); + } + + /// Field number for the "device_request_json" field. + public const int DeviceRequestJsonFieldNumber = 1; + private string deviceRequestJson_ = ""; + /// + /// JSON containing the device command response generated from the triggered + /// Device Action grammar. The format is given by the + /// `action.devices.EXECUTE` intent for a given + /// [trait](https://developers.google.com/assistant/sdk/reference/traits/). + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string DeviceRequestJson { + get { return deviceRequestJson_; } + set { + deviceRequestJson_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DeviceAction); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DeviceAction other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (DeviceRequestJson != other.DeviceRequestJson) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (DeviceRequestJson.Length != 0) hash ^= DeviceRequestJson.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (DeviceRequestJson.Length != 0) { + output.WriteRawTag(10); + output.WriteString(DeviceRequestJson); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (DeviceRequestJson.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(DeviceRequestJson); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DeviceAction other) { + if (other == null) { + return; + } + if (other.DeviceRequestJson.Length != 0) { + DeviceRequestJson = other.DeviceRequestJson; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + DeviceRequestJson = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// The estimated transcription of a phrase the user has spoken. This could be + /// a single segment or the full guess of the user's spoken query. + /// + public sealed partial class SpeechRecognitionResult : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SpeechRecognitionResult()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[12]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SpeechRecognitionResult() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SpeechRecognitionResult(SpeechRecognitionResult other) : this() { + transcript_ = other.transcript_; + stability_ = other.stability_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SpeechRecognitionResult Clone() { + return new SpeechRecognitionResult(this); + } + + /// Field number for the "transcript" field. + public const int TranscriptFieldNumber = 1; + private string transcript_ = ""; + /// + /// *Output-only* Transcript text representing the words that the user spoke. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Transcript { + get { return transcript_; } + set { + transcript_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "stability" field. + public const int StabilityFieldNumber = 2; + private float stability_; + /// + /// *Output-only* An estimate of the likelihood that the Assistant will not + /// change its guess about this result. Values range from 0.0 (completely + /// unstable) to 1.0 (completely stable and final). The default of 0.0 is a + /// sentinel value indicating `stability` was not set. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float Stability { + get { return stability_; } + set { + stability_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as SpeechRecognitionResult); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(SpeechRecognitionResult other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Transcript != other.Transcript) return false; + if (Stability != other.Stability) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Transcript.Length != 0) hash ^= Transcript.GetHashCode(); + if (Stability != 0F) hash ^= Stability.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Transcript.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Transcript); + } + if (Stability != 0F) { + output.WriteRawTag(21); + output.WriteFloat(Stability); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Transcript.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Transcript); + } + if (Stability != 0F) { + size += 1 + 4; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(SpeechRecognitionResult other) { + if (other == null) { + return; + } + if (other.Transcript.Length != 0) { + Transcript = other.Transcript; + } + if (other.Stability != 0F) { + Stability = other.Stability; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Transcript = input.ReadString(); + break; + } + case 21: { + Stability = input.ReadFloat(); + break; + } + } + } + } + + } + + /// + /// The dialog state resulting from the user's query. Multiple of these messages + /// may be received. + /// + public sealed partial class DialogStateOut : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DialogStateOut()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[13]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DialogStateOut() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DialogStateOut(DialogStateOut other) : this() { + supplementalDisplayText_ = other.supplementalDisplayText_; + conversationState_ = other.conversationState_; + microphoneMode_ = other.microphoneMode_; + volumePercentage_ = other.volumePercentage_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DialogStateOut Clone() { + return new DialogStateOut(this); + } + + /// Field number for the "supplemental_display_text" field. + public const int SupplementalDisplayTextFieldNumber = 1; + private string supplementalDisplayText_ = ""; + /// + /// *Output-only* Supplemental display text from the Assistant. This could be + /// the same as the speech spoken in `AssistResponse.audio_out` or it could + /// be some additional information which aids the user's understanding. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string SupplementalDisplayText { + get { return supplementalDisplayText_; } + set { + supplementalDisplayText_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "conversation_state" field. + public const int ConversationStateFieldNumber = 2; + private pb::ByteString conversationState_ = pb::ByteString.Empty; + /// + /// *Output-only* State information for the subsequent `Assist` RPC. This + /// value should be saved in the client and returned in the + /// [`DialogStateIn.conversation_state`](#dialogstatein) field with the next + /// `Assist` RPC. (The client does not need to interpret or otherwise use this + /// value.) This information should be saved across device reboots. However, + /// this value should be cleared (not saved in the client) during a + /// factory-default reset. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString ConversationState { + get { return conversationState_; } + set { + conversationState_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "microphone_mode" field. + public const int MicrophoneModeFieldNumber = 3; + private global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut.Types.MicrophoneMode microphoneMode_ = 0; + /// + /// *Output-only* Specifies the mode of the microphone after this `Assist` + /// RPC is processed. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut.Types.MicrophoneMode MicrophoneMode { + get { return microphoneMode_; } + set { + microphoneMode_ = value; + } + } + + /// Field number for the "volume_percentage" field. + public const int VolumePercentageFieldNumber = 4; + private int volumePercentage_; + /// + /// *Output-only* Updated volume level. The value will be 0 or omitted + /// (indicating no change) unless a voice command such as *Increase the volume* + /// or *Set volume level 4* was recognized, in which case the value will be + /// between 1 and 100 (corresponding to the new volume level of 1% to 100%). + /// Typically, a client should use this volume level when playing the + /// `audio_out` data, and retain this value as the current volume level and + /// supply it in the `AudioOutConfig` of the next `AssistRequest`. (Some + /// clients may also implement other ways to allow the current volume level to + /// be changed, for example, by providing a knob that the user can turn.) + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int VolumePercentage { + get { return volumePercentage_; } + set { + volumePercentage_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DialogStateOut); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DialogStateOut other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (SupplementalDisplayText != other.SupplementalDisplayText) return false; + if (ConversationState != other.ConversationState) return false; + if (MicrophoneMode != other.MicrophoneMode) return false; + if (VolumePercentage != other.VolumePercentage) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (SupplementalDisplayText.Length != 0) hash ^= SupplementalDisplayText.GetHashCode(); + if (ConversationState.Length != 0) hash ^= ConversationState.GetHashCode(); + if (MicrophoneMode != 0) hash ^= MicrophoneMode.GetHashCode(); + if (VolumePercentage != 0) hash ^= VolumePercentage.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (SupplementalDisplayText.Length != 0) { + output.WriteRawTag(10); + output.WriteString(SupplementalDisplayText); + } + if (ConversationState.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(ConversationState); + } + if (MicrophoneMode != 0) { + output.WriteRawTag(24); + output.WriteEnum((int) MicrophoneMode); + } + if (VolumePercentage != 0) { + output.WriteRawTag(32); + output.WriteInt32(VolumePercentage); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (SupplementalDisplayText.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SupplementalDisplayText); + } + if (ConversationState.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(ConversationState); + } + if (MicrophoneMode != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) MicrophoneMode); + } + if (VolumePercentage != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(VolumePercentage); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DialogStateOut other) { + if (other == null) { + return; + } + if (other.SupplementalDisplayText.Length != 0) { + SupplementalDisplayText = other.SupplementalDisplayText; + } + if (other.ConversationState.Length != 0) { + ConversationState = other.ConversationState; + } + if (other.MicrophoneMode != 0) { + MicrophoneMode = other.MicrophoneMode; + } + if (other.VolumePercentage != 0) { + VolumePercentage = other.VolumePercentage; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + SupplementalDisplayText = input.ReadString(); + break; + } + case 18: { + ConversationState = input.ReadBytes(); + break; + } + case 24: { + microphoneMode_ = (global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut.Types.MicrophoneMode) input.ReadEnum(); + break; + } + case 32: { + VolumePercentage = input.ReadInt32(); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the DialogStateOut message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Possible states of the microphone after a `Assist` RPC completes. + /// + public enum MicrophoneMode { + /// + /// No mode specified. + /// + [pbr::OriginalName("MICROPHONE_MODE_UNSPECIFIED")] Unspecified = 0, + /// + /// The service is not expecting a follow-on question from the user. + /// The microphone should remain off until the user re-activates it. + /// + [pbr::OriginalName("CLOSE_MICROPHONE")] CloseMicrophone = 1, + /// + /// The service is expecting a follow-on question from the user. The + /// microphone should be re-opened when the `AudioOut` playback completes + /// (by starting a new `Assist` RPC call to send the new audio). + /// + [pbr::OriginalName("DIALOG_FOLLOW_ON")] DialogFollowOn = 2, + } + + } + #endregion + + } + + /// + /// Debugging parameters for the current request. + /// + public sealed partial class DebugConfig : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DebugConfig()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[14]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugConfig() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugConfig(DebugConfig other) : this() { + returnDebugInfo_ = other.returnDebugInfo_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugConfig Clone() { + return new DebugConfig(this); + } + + /// Field number for the "return_debug_info" field. + public const int ReturnDebugInfoFieldNumber = 6; + private bool returnDebugInfo_; + /// + /// When this field is set to true, the `debug_info` field in `AssistResponse` + /// may be populated. However it will significantly increase latency of + /// responses. Do not set this field true in production code. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool ReturnDebugInfo { + get { return returnDebugInfo_; } + set { + returnDebugInfo_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DebugConfig); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DebugConfig other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ReturnDebugInfo != other.ReturnDebugInfo) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ReturnDebugInfo != false) hash ^= ReturnDebugInfo.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ReturnDebugInfo != false) { + output.WriteRawTag(48); + output.WriteBool(ReturnDebugInfo); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ReturnDebugInfo != false) { + size += 1 + 1; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DebugConfig other) { + if (other == null) { + return; + } + if (other.ReturnDebugInfo != false) { + ReturnDebugInfo = other.ReturnDebugInfo; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 48: { + ReturnDebugInfo = input.ReadBool(); + break; + } + } + } + } + + } + + /// + /// There are three sources of locations. They are used with this precedence: + /// + /// 1. This `DeviceLocation`, which is primarily used for mobile devices with + /// GPS . + /// 2. Location specified by the user during device setup; this is per-user, per + /// device. This location is used if `DeviceLocation` is not specified. + /// 3. Inferred location based on IP address. This is used only if neither of the + /// above are specified. + /// + public sealed partial class DeviceLocation : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeviceLocation()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.MessageTypes[15]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceLocation() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceLocation(DeviceLocation other) : this() { + switch (other.TypeCase) { + case TypeOneofCase.Coordinates: + Coordinates = other.Coordinates.Clone(); + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DeviceLocation Clone() { + return new DeviceLocation(this); + } + + /// Field number for the "coordinates" field. + public const int CoordinatesFieldNumber = 1; + /// + /// Latitude and longitude of device. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Type.LatLng Coordinates { + get { return typeCase_ == TypeOneofCase.Coordinates ? (global::Google.Type.LatLng) type_ : null; } + set { + type_ = value; + typeCase_ = value == null ? TypeOneofCase.None : TypeOneofCase.Coordinates; + } + } + + private object type_; + /// Enum of possible cases for the "type" oneof. + public enum TypeOneofCase { + None = 0, + Coordinates = 1, + } + private TypeOneofCase typeCase_ = TypeOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TypeOneofCase TypeCase { + get { return typeCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearType() { + typeCase_ = TypeOneofCase.None; + type_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DeviceLocation); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DeviceLocation other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Coordinates, other.Coordinates)) return false; + if (TypeCase != other.TypeCase) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (typeCase_ == TypeOneofCase.Coordinates) hash ^= Coordinates.GetHashCode(); + hash ^= (int) typeCase_; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (typeCase_ == TypeOneofCase.Coordinates) { + output.WriteRawTag(10); + output.WriteMessage(Coordinates); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (typeCase_ == TypeOneofCase.Coordinates) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Coordinates); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DeviceLocation other) { + if (other == null) { + return; + } + switch (other.TypeCase) { + case TypeOneofCase.Coordinates: + if (Coordinates == null) { + Coordinates = new global::Google.Type.LatLng(); + } + Coordinates.MergeFrom(other.Coordinates); + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + global::Google.Type.LatLng subBuilder = new global::Google.Type.LatLng(); + if (typeCase_ == TypeOneofCase.Coordinates) { + subBuilder.MergeFrom(Coordinates); + } + input.ReadMessage(subBuilder); + Coordinates = subBuilder; + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Generated/assistant/EmbeddedAssistantGrpc.cs b/GAssistant/Generated/assistant/EmbeddedAssistantGrpc.cs similarity index 56% rename from Generated/assistant/EmbeddedAssistantGrpc.cs rename to GAssistant/Generated/assistant/EmbeddedAssistantGrpc.cs index 381fa75..e303fe5 100644 --- a/Generated/assistant/EmbeddedAssistantGrpc.cs +++ b/GAssistant/Generated/assistant/EmbeddedAssistantGrpc.cs @@ -1,7 +1,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: googleapis/google/assistant/embedded/v1alpha1/embedded_assistant.proto +// source: google/assistant/embedded/v1alpha2/embedded_assistant.proto // Original file comments: -// Copyright 2017 Google Inc. +// Copyright 2018 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // +#pragma warning disable 1591 #region Designer generated code using System; @@ -22,81 +23,82 @@ using System.Threading.Tasks; using grpc = global::Grpc.Core; -namespace Google.Assistant.Embedded.V1Alpha1 { +namespace Google.Assistant.Embedded.V1Alpha2 { /// - /// Service that implements Google Assistant API. + /// Service that implements the Google Assistant API. /// public static partial class EmbeddedAssistant { - static readonly string __ServiceName = "google.assistant.embedded.v1alpha1.EmbeddedAssistant"; + static readonly string __ServiceName = "google.assistant.embedded.v1alpha2.EmbeddedAssistant"; - static readonly grpc::Marshaller __Marshaller_ConverseRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Google.Assistant.Embedded.V1Alpha1.ConverseRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_ConverseResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Google.Assistant.Embedded.V1Alpha1.ConverseResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_AssistRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Google.Assistant.Embedded.V1Alpha2.AssistRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_AssistResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Google.Assistant.Embedded.V1Alpha2.AssistResponse.Parser.ParseFrom); - static readonly grpc::Method __Method_Converse = new grpc::Method( + static readonly grpc::Method __Method_Assist = new grpc::Method( grpc::MethodType.DuplexStreaming, __ServiceName, - "Converse", - __Marshaller_ConverseRequest, - __Marshaller_ConverseResponse); + "Assist", + __Marshaller_AssistRequest, + __Marshaller_AssistResponse); /// Service descriptor public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor { - get { return global::Google.Assistant.Embedded.V1Alpha1.EmbeddedAssistantReflection.Descriptor.Services[0]; } + get { return global::Google.Assistant.Embedded.V1Alpha2.EmbeddedAssistantReflection.Descriptor.Services[0]; } } /// Base class for server-side implementations of EmbeddedAssistant public abstract partial class EmbeddedAssistantBase { /// - /// Initiates or continues a conversation with the embedded assistant service. + /// Initiates or continues a conversation with the embedded Assistant Service. /// Each call performs one round-trip, sending an audio request to the service /// and receiving the audio response. Uses bidirectional streaming to receive /// results, such as the `END_OF_UTTERANCE` event, while sending audio. /// /// A conversation is one or more gRPC connections, each consisting of several /// streamed requests and responses. - /// For example, the user says *Add to my shopping list* and the assistant + /// For example, the user says *Add to my shopping list* and the Assistant /// responds *What do you want to add?*. The sequence of streamed requests and /// responses in the first gRPC message could be: /// - /// * ConverseRequest.config - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseResponse.event_type.END_OF_UTTERANCE - /// * ConverseResponse.result.microphone_mode.DIALOG_FOLLOW_ON - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out + /// * AssistRequest.config + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistResponse.event_type.END_OF_UTTERANCE + /// * AssistResponse.speech_results.transcript "add to my shopping list" + /// * AssistResponse.dialog_state_out.microphone_mode.DIALOG_FOLLOW_ON + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out /// - /// The user then says *bagels* and the assistant responds + /// The user then says *bagels* and the Assistant responds /// *OK, I've added bagels to your shopping list*. This is sent as another gRPC - /// connection call to the `Converse` method, again with streamed requests and + /// connection call to the `Assist` method, again with streamed requests and /// responses, such as: /// - /// * ConverseRequest.config - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseResponse.event_type.END_OF_UTTERANCE - /// * ConverseResponse.result.microphone_mode.CLOSE_MICROPHONE - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out + /// * AssistRequest.config + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistResponse.event_type.END_OF_UTTERANCE + /// * AssistResponse.dialog_state_out.microphone_mode.CLOSE_MICROPHONE + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out /// /// Although the precise order of responses is not guaranteed, sequential - /// ConverseResponse.audio_out messages will always contain sequential portions + /// `AssistResponse.audio_out` messages will always contain sequential portions /// of audio. /// /// Used for reading requests from the client. /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task Converse(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) + public virtual global::System.Threading.Tasks.Task Assist(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } @@ -127,104 +129,106 @@ protected EmbeddedAssistantClient(ClientBaseConfiguration configuration) : base( } /// - /// Initiates or continues a conversation with the embedded assistant service. + /// Initiates or continues a conversation with the embedded Assistant Service. /// Each call performs one round-trip, sending an audio request to the service /// and receiving the audio response. Uses bidirectional streaming to receive /// results, such as the `END_OF_UTTERANCE` event, while sending audio. /// /// A conversation is one or more gRPC connections, each consisting of several /// streamed requests and responses. - /// For example, the user says *Add to my shopping list* and the assistant + /// For example, the user says *Add to my shopping list* and the Assistant /// responds *What do you want to add?*. The sequence of streamed requests and /// responses in the first gRPC message could be: /// - /// * ConverseRequest.config - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseResponse.event_type.END_OF_UTTERANCE - /// * ConverseResponse.result.microphone_mode.DIALOG_FOLLOW_ON - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out + /// * AssistRequest.config + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistResponse.event_type.END_OF_UTTERANCE + /// * AssistResponse.speech_results.transcript "add to my shopping list" + /// * AssistResponse.dialog_state_out.microphone_mode.DIALOG_FOLLOW_ON + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out /// - /// The user then says *bagels* and the assistant responds + /// The user then says *bagels* and the Assistant responds /// *OK, I've added bagels to your shopping list*. This is sent as another gRPC - /// connection call to the `Converse` method, again with streamed requests and + /// connection call to the `Assist` method, again with streamed requests and /// responses, such as: /// - /// * ConverseRequest.config - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseResponse.event_type.END_OF_UTTERANCE - /// * ConverseResponse.result.microphone_mode.CLOSE_MICROPHONE - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out + /// * AssistRequest.config + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistResponse.event_type.END_OF_UTTERANCE + /// * AssistResponse.dialog_state_out.microphone_mode.CLOSE_MICROPHONE + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out /// /// Although the precise order of responses is not guaranteed, sequential - /// ConverseResponse.audio_out messages will always contain sequential portions + /// `AssistResponse.audio_out` messages will always contain sequential portions /// of audio. /// /// The initial metadata to send with the call. This parameter is optional. /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual grpc::AsyncDuplexStreamingCall Converse(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncDuplexStreamingCall Assist(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return Converse(new grpc::CallOptions(headers, deadline, cancellationToken)); + return Assist(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// - /// Initiates or continues a conversation with the embedded assistant service. + /// Initiates or continues a conversation with the embedded Assistant Service. /// Each call performs one round-trip, sending an audio request to the service /// and receiving the audio response. Uses bidirectional streaming to receive /// results, such as the `END_OF_UTTERANCE` event, while sending audio. /// /// A conversation is one or more gRPC connections, each consisting of several /// streamed requests and responses. - /// For example, the user says *Add to my shopping list* and the assistant + /// For example, the user says *Add to my shopping list* and the Assistant /// responds *What do you want to add?*. The sequence of streamed requests and /// responses in the first gRPC message could be: /// - /// * ConverseRequest.config - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseResponse.event_type.END_OF_UTTERANCE - /// * ConverseResponse.result.microphone_mode.DIALOG_FOLLOW_ON - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out + /// * AssistRequest.config + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistResponse.event_type.END_OF_UTTERANCE + /// * AssistResponse.speech_results.transcript "add to my shopping list" + /// * AssistResponse.dialog_state_out.microphone_mode.DIALOG_FOLLOW_ON + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out /// - /// The user then says *bagels* and the assistant responds + /// The user then says *bagels* and the Assistant responds /// *OK, I've added bagels to your shopping list*. This is sent as another gRPC - /// connection call to the `Converse` method, again with streamed requests and + /// connection call to the `Assist` method, again with streamed requests and /// responses, such as: /// - /// * ConverseRequest.config - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseRequest.audio_in - /// * ConverseResponse.event_type.END_OF_UTTERANCE - /// * ConverseResponse.result.microphone_mode.CLOSE_MICROPHONE - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out - /// * ConverseResponse.audio_out + /// * AssistRequest.config + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistRequest.audio_in + /// * AssistResponse.event_type.END_OF_UTTERANCE + /// * AssistResponse.dialog_state_out.microphone_mode.CLOSE_MICROPHONE + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out + /// * AssistResponse.audio_out /// /// Although the precise order of responses is not guaranteed, sequential - /// ConverseResponse.audio_out messages will always contain sequential portions + /// `AssistResponse.audio_out` messages will always contain sequential portions /// of audio. /// /// The options for the call. /// The call object. - public virtual grpc::AsyncDuplexStreamingCall Converse(grpc::CallOptions options) + public virtual grpc::AsyncDuplexStreamingCall Assist(grpc::CallOptions options) { - return CallInvoker.AsyncDuplexStreamingCall(__Method_Converse, null, options); + return CallInvoker.AsyncDuplexStreamingCall(__Method_Assist, null, options); } /// Creates a new instance of client from given ClientBaseConfiguration. protected override EmbeddedAssistantClient NewInstance(ClientBaseConfiguration configuration) @@ -238,7 +242,7 @@ protected override EmbeddedAssistantClient NewInstance(ClientBaseConfiguration c public static grpc::ServerServiceDefinition BindService(EmbeddedAssistantBase serviceImpl) { return grpc::ServerServiceDefinition.CreateBuilder() - .AddMethod(__Method_Converse, serviceImpl.Converse).Build(); + .AddMethod(__Method_Assist, serviceImpl.Assist).Build(); } } diff --git a/Generated/googleapis/Annotations.cs b/GAssistant/Generated/googleapis/Annotations.cs similarity index 100% rename from Generated/googleapis/Annotations.cs rename to GAssistant/Generated/googleapis/Annotations.cs diff --git a/Generated/googleapis/Http.cs b/GAssistant/Generated/googleapis/Http.cs similarity index 56% rename from Generated/googleapis/Http.cs rename to GAssistant/Generated/googleapis/Http.cs index fe1e6d1..6914482 100644 --- a/Generated/googleapis/Http.cs +++ b/GAssistant/Generated/googleapis/Http.cs @@ -22,22 +22,24 @@ public static partial class HttpReflection { static HttpReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChVnb29nbGUvYXBpL2h0dHAucHJvdG8SCmdvb2dsZS5hcGkiKwoESHR0cBIj", - "CgVydWxlcxgBIAMoCzIULmdvb2dsZS5hcGkuSHR0cFJ1bGUi6gEKCEh0dHBS", - "dWxlEhAKCHNlbGVjdG9yGAEgASgJEg0KA2dldBgCIAEoCUgAEg0KA3B1dBgD", - "IAEoCUgAEg4KBHBvc3QYBCABKAlIABIQCgZkZWxldGUYBSABKAlIABIPCgVw", - "YXRjaBgGIAEoCUgAEi8KBmN1c3RvbRgIIAEoCzIdLmdvb2dsZS5hcGkuQ3Vz", - "dG9tSHR0cFBhdHRlcm5IABIMCgRib2R5GAcgASgJEjEKE2FkZGl0aW9uYWxf", - "YmluZGluZ3MYCyADKAsyFC5nb29nbGUuYXBpLkh0dHBSdWxlQgkKB3BhdHRl", - "cm4iLwoRQ3VzdG9tSHR0cFBhdHRlcm4SDAoEa2luZBgBIAEoCRIMCgRwYXRo", - "GAIgASgJQmoKDmNvbS5nb29nbGUuYXBpQglIdHRwUHJvdG9QAVpBZ29vZ2xl", - "LmdvbGFuZy5vcmcvZ2VucHJvdG8vZ29vZ2xlYXBpcy9hcGkvYW5ub3RhdGlv", - "bnM7YW5ub3RhdGlvbnP4AQGiAgRHQVBJYgZwcm90bzM=")); + "ChVnb29nbGUvYXBpL2h0dHAucHJvdG8SCmdvb2dsZS5hcGkiVAoESHR0cBIj", + "CgVydWxlcxgBIAMoCzIULmdvb2dsZS5hcGkuSHR0cFJ1bGUSJwofZnVsbHlf", + "ZGVjb2RlX3Jlc2VydmVkX2V4cGFuc2lvbhgCIAEoCCKBAgoISHR0cFJ1bGUS", + "EAoIc2VsZWN0b3IYASABKAkSDQoDZ2V0GAIgASgJSAASDQoDcHV0GAMgASgJ", + "SAASDgoEcG9zdBgEIAEoCUgAEhAKBmRlbGV0ZRgFIAEoCUgAEg8KBXBhdGNo", + "GAYgASgJSAASLwoGY3VzdG9tGAggASgLMh0uZ29vZ2xlLmFwaS5DdXN0b21I", + "dHRwUGF0dGVybkgAEgwKBGJvZHkYByABKAkSFQoNcmVzcG9uc2VfYm9keRgM", + "IAEoCRIxChNhZGRpdGlvbmFsX2JpbmRpbmdzGAsgAygLMhQuZ29vZ2xlLmFw", + "aS5IdHRwUnVsZUIJCgdwYXR0ZXJuIi8KEUN1c3RvbUh0dHBQYXR0ZXJuEgwK", + "BGtpbmQYASABKAkSDAoEcGF0aBgCIAEoCUJqCg5jb20uZ29vZ2xlLmFwaUIJ", + "SHR0cFByb3RvUAFaQWdvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL2dvb2ds", + "ZWFwaXMvYXBpL2Fubm90YXRpb25zO2Fubm90YXRpb25z+AEBogIER0FQSWIG", + "cHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Api.Http), global::Google.Api.Http.Parser, new[]{ "Rules" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Api.HttpRule), global::Google.Api.HttpRule.Parser, new[]{ "Selector", "Get", "Put", "Post", "Delete", "Patch", "Custom", "Body", "AdditionalBindings" }, new[]{ "Pattern" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Api.Http), global::Google.Api.Http.Parser, new[]{ "Rules", "FullyDecodeReservedExpansion" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Api.HttpRule), global::Google.Api.HttpRule.Parser, new[]{ "Selector", "Get", "Put", "Post", "Delete", "Patch", "Custom", "Body", "ResponseBody", "AdditionalBindings" }, new[]{ "Pattern" }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Api.CustomHttpPattern), global::Google.Api.CustomHttpPattern.Parser, new[]{ "Kind", "Path" }, null, null, null) })); } @@ -46,9 +48,9 @@ static HttpReflection() { } #region Messages /// - /// Defines the HTTP configuration for a service. It contains a list of - /// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method - /// to one or more HTTP REST API methods. + /// Defines the HTTP configuration for an API service. It contains a list of + /// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + /// to one or more HTTP REST API methods. /// public sealed partial class Http : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Http()); @@ -75,6 +77,7 @@ public Http() { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Http(Http other) : this() { rules_ = other.rules_.Clone(); + fullyDecodeReservedExpansion_ = other.fullyDecodeReservedExpansion_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -88,15 +91,34 @@ public Http Clone() { = pb::FieldCodec.ForMessage(10, global::Google.Api.HttpRule.Parser); private readonly pbc::RepeatedField rules_ = new pbc::RepeatedField(); /// - /// A list of HTTP configuration rules that apply to individual API methods. + /// A list of HTTP configuration rules that apply to individual API methods. /// - /// **NOTE:** All service configuration rules follow "last one wins" order. + /// **NOTE:** All service configuration rules follow "last one wins" order. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Rules { get { return rules_; } } + /// Field number for the "fully_decode_reserved_expansion" field. + public const int FullyDecodeReservedExpansionFieldNumber = 2; + private bool fullyDecodeReservedExpansion_; + /// + /// When set to true, URL path parmeters will be fully URI-decoded except in + /// cases of single segment matches in reserved expansion, where "%2F" will be + /// left encoded. + /// + /// The default behavior is to not decode RFC 6570 reserved characters in multi + /// segment matches. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool FullyDecodeReservedExpansion { + get { return fullyDecodeReservedExpansion_; } + set { + fullyDecodeReservedExpansion_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Http); @@ -111,6 +133,7 @@ public bool Equals(Http other) { return true; } if(!rules_.Equals(other.rules_)) return false; + if (FullyDecodeReservedExpansion != other.FullyDecodeReservedExpansion) return false; return true; } @@ -118,6 +141,7 @@ public bool Equals(Http other) { public override int GetHashCode() { int hash = 1; hash ^= rules_.GetHashCode(); + if (FullyDecodeReservedExpansion != false) hash ^= FullyDecodeReservedExpansion.GetHashCode(); return hash; } @@ -129,12 +153,19 @@ public override string ToString() { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { rules_.WriteTo(output, _repeated_rules_codec); + if (FullyDecodeReservedExpansion != false) { + output.WriteRawTag(16); + output.WriteBool(FullyDecodeReservedExpansion); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += rules_.CalculateSize(_repeated_rules_codec); + if (FullyDecodeReservedExpansion != false) { + size += 1 + 1; + } return size; } @@ -144,6 +175,9 @@ public void MergeFrom(Http other) { return; } rules_.Add(other.rules_); + if (other.FullyDecodeReservedExpansion != false) { + FullyDecodeReservedExpansion = other.FullyDecodeReservedExpansion; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -158,6 +192,10 @@ public void MergeFrom(pb::CodedInputStream input) { rules_.AddEntriesFrom(input, _repeated_rules_codec); break; } + case 16: { + FullyDecodeReservedExpansion = input.ReadBool(); + break; + } } } } @@ -165,205 +203,277 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// `HttpRule` defines the mapping of an RPC method to one or more HTTP - /// REST APIs. The mapping determines what portions of the request - /// message are populated from the path, query parameters, or body of - /// the HTTP request. The mapping is typically specified as an - /// `google.api.http` annotation, see "google/api/annotations.proto" - /// for details. - /// - /// The mapping consists of a field specifying the path template and - /// method kind. The path template can refer to fields in the request - /// message, as in the example below which describes a REST GET - /// operation on a resource collection of messages: - /// - /// service Messaging { - /// rpc GetMessage(GetMessageRequest) returns (Message) { - /// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; - /// } - /// } - /// message GetMessageRequest { - /// message SubMessage { - /// string subfield = 1; - /// } - /// string message_id = 1; // mapped to the URL - /// SubMessage sub = 2; // `sub.subfield` is url-mapped - /// } - /// message Message { - /// string text = 1; // content of the resource - /// } - /// - /// The same http annotation can alternatively be expressed inside the - /// `GRPC API Configuration` YAML file. - /// - /// http: - /// rules: - /// - selector: <proto_package_name>.Messaging.GetMessage - /// get: /v1/messages/{message_id}/{sub.subfield} - /// - /// This definition enables an automatic, bidrectional mapping of HTTP - /// JSON to RPC. Example: - /// - /// HTTP | RPC - /// -----|----- - /// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` - /// - /// In general, not only fields but also field paths can be referenced - /// from a path pattern. Fields mapped to the path pattern cannot be - /// repeated and must have a primitive (non-message) type. - /// - /// Any fields in the request message which are not bound by the path - /// pattern automatically become (optional) HTTP query - /// parameters. Assume the following definition of the request message: - /// - /// message GetMessageRequest { - /// message SubMessage { - /// string subfield = 1; - /// } - /// string message_id = 1; // mapped to the URL - /// int64 revision = 2; // becomes a parameter - /// SubMessage sub = 3; // `sub.subfield` becomes a parameter - /// } - /// - /// This enables a HTTP JSON to RPC mapping as below: - /// - /// HTTP | RPC - /// -----|----- - /// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` - /// - /// Note that fields which are mapped to HTTP parameters must have a - /// primitive type or a repeated primitive type. Message types are not - /// allowed. In the case of a repeated type, the parameter can be - /// repeated in the URL, as in `...?param=A&param=B`. - /// - /// For HTTP method kinds which allow a request body, the `body` field - /// specifies the mapping. Consider a REST update method on the - /// message resource collection: - /// - /// service Messaging { - /// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { - /// option (google.api.http) = { - /// put: "/v1/messages/{message_id}" - /// body: "message" - /// }; - /// } - /// } - /// message UpdateMessageRequest { - /// string message_id = 1; // mapped to the URL - /// Message message = 2; // mapped to the body - /// } - /// - /// The following HTTP JSON to RPC mapping is enabled, where the - /// representation of the JSON in the request body is determined by - /// protos JSON encoding: - /// - /// HTTP | RPC - /// -----|----- - /// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` - /// - /// The special name `*` can be used in the body mapping to define that - /// every field not bound by the path template should be mapped to the - /// request body. This enables the following alternative definition of - /// the update method: - /// - /// service Messaging { - /// rpc UpdateMessage(Message) returns (Message) { - /// option (google.api.http) = { - /// put: "/v1/messages/{message_id}" - /// body: "*" - /// }; - /// } - /// } - /// message Message { - /// string message_id = 1; - /// string text = 2; - /// } - /// - /// The following HTTP JSON to RPC mapping is enabled: - /// - /// HTTP | RPC - /// -----|----- - /// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` - /// - /// Note that when using `*` in the body mapping, it is not possible to - /// have HTTP parameters, as all fields not bound by the path end in - /// the body. This makes this option more rarely used in practice of - /// defining REST APIs. The common usage of `*` is in custom methods - /// which don't use the URL at all for transferring data. - /// - /// It is possible to define multiple HTTP methods for one RPC by using - /// the `additional_bindings` option. Example: - /// - /// service Messaging { - /// rpc GetMessage(GetMessageRequest) returns (Message) { - /// option (google.api.http) = { - /// get: "/v1/messages/{message_id}" - /// additional_bindings { - /// get: "/v1/users/{user_id}/messages/{message_id}" - /// } - /// }; - /// } - /// } - /// message GetMessageRequest { - /// string message_id = 1; - /// string user_id = 2; - /// } - /// - /// This enables the following two alternative HTTP JSON to RPC - /// mappings: - /// - /// HTTP | RPC - /// -----|----- - /// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` - /// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` - /// - /// # Rules for HTTP mapping - /// - /// The rules for mapping HTTP path, query parameters, and body fields - /// to the request message are as follows: - /// - /// 1. The `body` field specifies either `*` or a field path, or is - /// omitted. If omitted, it assumes there is no HTTP body. - /// 2. Leaf fields (recursive expansion of nested messages in the - /// request) can be classified into three types: - /// (a) Matched in the URL template. - /// (b) Covered by body (if body is `*`, everything except (a) fields; - /// else everything under the body field) - /// (c) All other fields. - /// 3. URL query parameters found in the HTTP request are mapped to (c) fields. - /// 4. Any body sent with an HTTP request can contain only (b) fields. - /// - /// The syntax of the path template is as follows: - /// - /// Template = "/" Segments [ Verb ] ; - /// Segments = Segment { "/" Segment } ; - /// Segment = "*" | "**" | LITERAL | Variable ; - /// Variable = "{" FieldPath [ "=" Segments ] "}" ; - /// FieldPath = IDENT { "." IDENT } ; - /// Verb = ":" LITERAL ; - /// - /// The syntax `*` matches a single path segment. It follows the semantics of - /// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String - /// Expansion. - /// - /// The syntax `**` matches zero or more path segments. It follows the semantics - /// of [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.3 Reserved - /// Expansion. NOTE: it must be the last segment in the path except the Verb. - /// - /// The syntax `LITERAL` matches literal text in the URL path. - /// - /// The syntax `Variable` matches the entire path as specified by its template; - /// this nested template must not contain further variables. If a variable - /// matches a single path segment, its template may be omitted, e.g. `{var}` - /// is equivalent to `{var=*}`. - /// - /// NOTE: the field paths in variables and in the `body` must not refer to - /// repeated fields or map fields. - /// - /// Use CustomHttpPattern to specify any HTTP method that is not included in the - /// `pattern` field, such as HEAD, or "*" to leave the HTTP method unspecified for - /// a given URL path rule. The wild-card rule is useful for services that provide - /// content to Web (HTML) clients. + /// # gRPC Transcoding + /// + /// gRPC Transcoding is a feature for mapping between a gRPC method and one or + /// more HTTP REST endpoints. It allows developers to build a single API service + /// that supports both gRPC APIs and REST APIs. Many systems, including [Google + /// APIs](https://github.com/googleapis/googleapis), + /// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC + /// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), + /// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature + /// and use it for large scale production services. + /// + /// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies + /// how different portions of the gRPC request message are mapped to the URL + /// path, URL query parameters, and HTTP request body. It also controls how the + /// gRPC response message is mapped to the HTTP response body. `HttpRule` is + /// typically specified as an `google.api.http` annotation on the gRPC method. + /// + /// Each mapping specifies a URL path template and an HTTP method. The path + /// template may refer to one or more fields in the gRPC request message, as long + /// as each field is a non-repeated field with a primitive (non-message) type. + /// The path template controls how fields of the request message are mapped to + /// the URL path. + /// + /// Example: + /// + /// service Messaging { + /// rpc GetMessage(GetMessageRequest) returns (Message) { + /// option (google.api.http) = { + /// get: "/v1/{name=messages/*}" + /// }; + /// } + /// } + /// message GetMessageRequest { + /// string name = 1; // Mapped to URL path. + /// } + /// message Message { + /// string text = 1; // The resource content. + /// } + /// + /// This enables an HTTP REST to gRPC mapping as below: + /// + /// HTTP | gRPC + /// -----|----- + /// `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")` + /// + /// Any fields in the request message which are not bound by the path template + /// automatically become HTTP query parameters if there is no HTTP request body. + /// For example: + /// + /// service Messaging { + /// rpc GetMessage(GetMessageRequest) returns (Message) { + /// option (google.api.http) = { + /// get:"/v1/messages/{message_id}" + /// }; + /// } + /// } + /// message GetMessageRequest { + /// message SubMessage { + /// string subfield = 1; + /// } + /// string message_id = 1; // Mapped to URL path. + /// int64 revision = 2; // Mapped to URL query parameter `revision`. + /// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. + /// } + /// + /// This enables a HTTP JSON to RPC mapping as below: + /// + /// HTTP | gRPC + /// -----|----- + /// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | + /// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: + /// "foo"))` + /// + /// Note that fields which are mapped to URL query parameters must have a + /// primitive type or a repeated primitive type or a non-repeated message type. + /// In the case of a repeated type, the parameter can be repeated in the URL + /// as `...?param=A&param=B`. In the case of a message type, each field of the + /// message is mapped to a separate parameter, such as + /// `...?foo.a=A&foo.b=B&foo.c=C`. + /// + /// For HTTP methods that allow a request body, the `body` field + /// specifies the mapping. Consider a REST update method on the + /// message resource collection: + /// + /// service Messaging { + /// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + /// option (google.api.http) = { + /// patch: "/v1/messages/{message_id}" + /// body: "message" + /// }; + /// } + /// } + /// message UpdateMessageRequest { + /// string message_id = 1; // mapped to the URL + /// Message message = 2; // mapped to the body + /// } + /// + /// The following HTTP JSON to RPC mapping is enabled, where the + /// representation of the JSON in the request body is determined by + /// protos JSON encoding: + /// + /// HTTP | gRPC + /// -----|----- + /// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: + /// "123456" message { text: "Hi!" })` + /// + /// The special name `*` can be used in the body mapping to define that + /// every field not bound by the path template should be mapped to the + /// request body. This enables the following alternative definition of + /// the update method: + /// + /// service Messaging { + /// rpc UpdateMessage(Message) returns (Message) { + /// option (google.api.http) = { + /// patch: "/v1/messages/{message_id}" + /// body: "*" + /// }; + /// } + /// } + /// message Message { + /// string message_id = 1; + /// string text = 2; + /// } + /// + /// The following HTTP JSON to RPC mapping is enabled: + /// + /// HTTP | gRPC + /// -----|----- + /// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: + /// "123456" text: "Hi!")` + /// + /// Note that when using `*` in the body mapping, it is not possible to + /// have HTTP parameters, as all fields not bound by the path end in + /// the body. This makes this option more rarely used in practice when + /// defining REST APIs. The common usage of `*` is in custom methods + /// which don't use the URL at all for transferring data. + /// + /// It is possible to define multiple HTTP methods for one RPC by using + /// the `additional_bindings` option. Example: + /// + /// service Messaging { + /// rpc GetMessage(GetMessageRequest) returns (Message) { + /// option (google.api.http) = { + /// get: "/v1/messages/{message_id}" + /// additional_bindings { + /// get: "/v1/users/{user_id}/messages/{message_id}" + /// } + /// }; + /// } + /// } + /// message GetMessageRequest { + /// string message_id = 1; + /// string user_id = 2; + /// } + /// + /// This enables the following two alternative HTTP JSON to RPC mappings: + /// + /// HTTP | gRPC + /// -----|----- + /// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + /// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: + /// "123456")` + /// + /// ## Rules for HTTP mapping + /// + /// 1. Leaf request fields (recursive expansion nested messages in the request + /// message) are classified into three categories: + /// - Fields referred by the path template. They are passed via the URL path. + /// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They + /// are passed via the HTTP + /// request body. + /// - All other fields are passed via the URL query parameters, and the + /// parameter name is the field path in the request message. A repeated + /// field can be represented as multiple query parameters under the same + /// name. + /// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL + /// query parameter, all fields + /// are passed via URL path and HTTP request body. + /// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP + /// request body, all + /// fields are passed via URL path and URL query parameters. + /// + /// ### Path template syntax + /// + /// Template = "/" Segments [ Verb ] ; + /// Segments = Segment { "/" Segment } ; + /// Segment = "*" | "**" | LITERAL | Variable ; + /// Variable = "{" FieldPath [ "=" Segments ] "}" ; + /// FieldPath = IDENT { "." IDENT } ; + /// Verb = ":" LITERAL ; + /// + /// The syntax `*` matches a single URL path segment. The syntax `**` matches + /// zero or more URL path segments, which must be the last part of the URL path + /// except the `Verb`. + /// + /// The syntax `Variable` matches part of the URL path as specified by its + /// template. A variable template must not contain other variables. If a variable + /// matches a single path segment, its template may be omitted, e.g. `{var}` + /// is equivalent to `{var=*}`. + /// + /// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` + /// contains any reserved character, such characters should be percent-encoded + /// before the matching. + /// + /// If a variable contains exactly one path segment, such as `"{var}"` or + /// `"{var=*}"`, when such a variable is expanded into a URL path on the client + /// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The + /// server side does the reverse decoding. Such variables show up in the + /// [Discovery + /// Document](https://developers.google.com/discovery/v1/reference/apis) as + /// `{var}`. + /// + /// If a variable contains multiple path segments, such as `"{var=foo/*}"` + /// or `"{var=**}"`, when such a variable is expanded into a URL path on the + /// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. + /// The server side does the reverse decoding, except "%2F" and "%2f" are left + /// unchanged. Such variables show up in the + /// [Discovery + /// Document](https://developers.google.com/discovery/v1/reference/apis) as + /// `{+var}`. + /// + /// ## Using gRPC API Service Configuration + /// + /// gRPC API Service Configuration (service config) is a configuration language + /// for configuring a gRPC service to become a user-facing product. The + /// service config is simply the YAML representation of the `google.api.Service` + /// proto message. + /// + /// As an alternative to annotating your proto file, you can configure gRPC + /// transcoding in your service config YAML files. You do this by specifying a + /// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same + /// effect as the proto annotation. This can be particularly useful if you + /// have a proto that is reused in multiple services. Note that any transcoding + /// specified in the service config will override any matching transcoding + /// configuration in the proto. + /// + /// Example: + /// + /// http: + /// rules: + /// # Selects a gRPC method and applies HttpRule to it. + /// - selector: example.v1.Messaging.GetMessage + /// get: /v1/messages/{message_id}/{sub.subfield} + /// + /// ## Special notes + /// + /// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the + /// proto to JSON conversion must follow the [proto3 + /// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). + /// + /// While the single segment variable follows the semantics of + /// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String + /// Expansion, the multi segment variable **does not** follow RFC 6570 Section + /// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion + /// does not expand special characters like `?` and `#`, which would lead + /// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding + /// for multi segment variables. + /// + /// The path variables **must not** refer to any repeated or mapped field, + /// because client libraries are not capable of handling such variable expansion. + /// + /// The path variables **must not** capture the leading "/" character. The reason + /// is that the most common use case "{var}" does not capture the leading "/" + /// character. For consistency, all path variables must share the same behavior. + /// + /// Repeated message fields must not be mapped to URL query parameters, because + /// no client library can support such complicated mapping. + /// + /// If an API needs to use a JSON array for request or response body, it can map + /// the request or response body to a repeated field. However, some gRPC + /// Transcoding implementations may not support this feature. /// public sealed partial class HttpRule : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HttpRule()); @@ -391,6 +501,7 @@ public HttpRule() { public HttpRule(HttpRule other) : this() { selector_ = other.selector_; body_ = other.body_; + responseBody_ = other.responseBody_; additionalBindings_ = other.additionalBindings_.Clone(); switch (other.PatternCase) { case PatternOneofCase.Get: @@ -424,9 +535,10 @@ public HttpRule Clone() { public const int SelectorFieldNumber = 1; private string selector_ = ""; /// - /// Selects methods to which this rule applies. + /// Selects a method to which this rule applies. /// - /// Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + /// Refer to [selector][google.api.DocumentationRule.selector] for syntax + /// details. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Selector { @@ -439,7 +551,8 @@ public string Selector { /// Field number for the "get" field. public const int GetFieldNumber = 2; /// - /// Used for listing and getting information about resources. + /// Maps to HTTP GET. Used for listing and getting information about + /// resources. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Get { @@ -453,7 +566,7 @@ public string Get { /// Field number for the "put" field. public const int PutFieldNumber = 3; /// - /// Used for updating a resource. + /// Maps to HTTP PUT. Used for replacing a resource. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Put { @@ -467,7 +580,7 @@ public string Put { /// Field number for the "post" field. public const int PostFieldNumber = 4; /// - /// Used for creating a resource. + /// Maps to HTTP POST. Used for creating a resource or performing an action. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Post { @@ -481,7 +594,7 @@ public string Post { /// Field number for the "delete" field. public const int DeleteFieldNumber = 5; /// - /// Used for deleting a resource. + /// Maps to HTTP DELETE. Used for deleting a resource. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Delete { @@ -495,7 +608,7 @@ public string Delete { /// Field number for the "patch" field. public const int PatchFieldNumber = 6; /// - /// Used for updating a resource. + /// Maps to HTTP PATCH. Used for updating a resource. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Patch { @@ -509,7 +622,10 @@ public string Patch { /// Field number for the "custom" field. public const int CustomFieldNumber = 8; /// - /// Custom pattern is used for defining custom verbs. + /// The custom pattern is used for specifying an HTTP method that is not + /// included in the `pattern` field, such as HEAD, or "*" to leave the + /// HTTP method unspecified for this rule. The wild-card rule is useful + /// for services that provide content to Web (HTML) clients. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Api.CustomHttpPattern Custom { @@ -524,10 +640,12 @@ public string Patch { public const int BodyFieldNumber = 7; private string body_ = ""; /// - /// The name of the request field whose value is mapped to the HTTP body, or - /// `*` for mapping all fields not captured by the path pattern to the HTTP - /// body. NOTE: the referred field must not be a repeated field and must be - /// present at the top-level of request message type. + /// The name of the request field whose value is mapped to the HTTP request + /// body, or `*` for mapping all request fields not captured by the path + /// pattern to the HTTP body, or omitted for not having any HTTP request body. + /// + /// NOTE: the referred field must be present at the top-level of the request + /// message type. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Body { @@ -537,15 +655,34 @@ public string Body { } } + /// Field number for the "response_body" field. + public const int ResponseBodyFieldNumber = 12; + private string responseBody_ = ""; + /// + /// Optional. The name of the response field whose value is mapped to the HTTP + /// response body. When omitted, the entire response message will be used + /// as the HTTP response body. + /// + /// NOTE: The referred field must be present at the top-level of the response + /// message type. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ResponseBody { + get { return responseBody_; } + set { + responseBody_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// Field number for the "additional_bindings" field. public const int AdditionalBindingsFieldNumber = 11; private static readonly pb::FieldCodec _repeated_additionalBindings_codec = pb::FieldCodec.ForMessage(90, global::Google.Api.HttpRule.Parser); private readonly pbc::RepeatedField additionalBindings_ = new pbc::RepeatedField(); /// - /// Additional HTTP bindings for the selector. Nested bindings must - /// not contain an `additional_bindings` field themselves (that is, - /// the nesting may only be one level deep). + /// Additional HTTP bindings for the selector. Nested bindings must + /// not contain an `additional_bindings` field themselves (that is, + /// the nesting may only be one level deep). /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField AdditionalBindings { @@ -596,6 +733,7 @@ public bool Equals(HttpRule other) { if (Patch != other.Patch) return false; if (!object.Equals(Custom, other.Custom)) return false; if (Body != other.Body) return false; + if (ResponseBody != other.ResponseBody) return false; if(!additionalBindings_.Equals(other.additionalBindings_)) return false; if (PatternCase != other.PatternCase) return false; return true; @@ -612,6 +750,7 @@ public override int GetHashCode() { if (patternCase_ == PatternOneofCase.Patch) hash ^= Patch.GetHashCode(); if (patternCase_ == PatternOneofCase.Custom) hash ^= Custom.GetHashCode(); if (Body.Length != 0) hash ^= Body.GetHashCode(); + if (ResponseBody.Length != 0) hash ^= ResponseBody.GetHashCode(); hash ^= additionalBindings_.GetHashCode(); hash ^= (int) patternCase_; return hash; @@ -657,6 +796,10 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteMessage(Custom); } additionalBindings_.WriteTo(output, _repeated_additionalBindings_codec); + if (ResponseBody.Length != 0) { + output.WriteRawTag(98); + output.WriteString(ResponseBody); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -686,6 +829,9 @@ public int CalculateSize() { if (Body.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Body); } + if (ResponseBody.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ResponseBody); + } size += additionalBindings_.CalculateSize(_repeated_additionalBindings_codec); return size; } @@ -701,6 +847,9 @@ public void MergeFrom(HttpRule other) { if (other.Body.Length != 0) { Body = other.Body; } + if (other.ResponseBody.Length != 0) { + ResponseBody = other.ResponseBody; + } additionalBindings_.Add(other.additionalBindings_); switch (other.PatternCase) { case PatternOneofCase.Get: @@ -719,7 +868,10 @@ public void MergeFrom(HttpRule other) { Patch = other.Patch; break; case PatternOneofCase.Custom: - Custom = other.Custom; + if (Custom == null) { + Custom = new global::Google.Api.CustomHttpPattern(); + } + Custom.MergeFrom(other.Custom); break; } @@ -774,6 +926,10 @@ public void MergeFrom(pb::CodedInputStream input) { additionalBindings_.AddEntriesFrom(input, _repeated_additionalBindings_codec); break; } + case 98: { + ResponseBody = input.ReadString(); + break; + } } } } @@ -781,7 +937,7 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// A custom pattern is used for defining custom HTTP verb. + /// A custom pattern is used for defining custom HTTP verb. /// public sealed partial class CustomHttpPattern : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomHttpPattern()); @@ -820,7 +976,7 @@ public CustomHttpPattern Clone() { public const int KindFieldNumber = 1; private string kind_ = ""; /// - /// The name of this custom HTTP verb. + /// The name of this custom HTTP verb. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Kind { @@ -834,7 +990,7 @@ public string Kind { public const int PathFieldNumber = 2; private string path_ = ""; /// - /// The path matched by this custom verb. + /// The path matched by this custom verb. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Path { diff --git a/GAssistant/Generated/googleapis/Latlng.cs b/GAssistant/Generated/googleapis/Latlng.cs new file mode 100644 index 0000000..bca6276 --- /dev/null +++ b/GAssistant/Generated/googleapis/Latlng.cs @@ -0,0 +1,236 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/latlng.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Type { + + /// Holder for reflection information generated from google/type/latlng.proto + public static partial class LatlngReflection { + + #region Descriptor + /// File descriptor for google/type/latlng.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static LatlngReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chhnb29nbGUvdHlwZS9sYXRsbmcucHJvdG8SC2dvb2dsZS50eXBlIi0KBkxh", + "dExuZxIQCghsYXRpdHVkZRgBIAEoARIRCglsb25naXR1ZGUYAiABKAFCYAoP", + "Y29tLmdvb2dsZS50eXBlQgtMYXRMbmdQcm90b1ABWjhnb29nbGUuZ29sYW5n", + "Lm9yZy9nZW5wcm90by9nb29nbGVhcGlzL3R5cGUvbGF0bG5nO2xhdGxuZ6IC", + "A0dUUGIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Type.LatLng), global::Google.Type.LatLng.Parser, new[]{ "Latitude", "Longitude" }, null, null, null) + })); + } + #endregion + + } + #region Messages + /// + /// An object representing a latitude/longitude pair. This is expressed as a pair + /// of doubles representing degrees latitude and degrees longitude. Unless + /// specified otherwise, this must conform to the + /// <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84 + /// standard</a>. Values must be within normalized ranges. + /// + /// Example of normalization code in Python: + /// + /// def NormalizeLongitude(longitude): + /// """Wraps decimal degrees longitude to [-180.0, 180.0].""" + /// q, r = divmod(longitude, 360.0) + /// if r > 180.0 or (r == 180.0 and q <= -1.0): + /// return r - 360.0 + /// return r + /// + /// def NormalizeLatLng(latitude, longitude): + /// """Wraps decimal degrees latitude and longitude to + /// [-90.0, 90.0] and [-180.0, 180.0], respectively.""" + /// r = latitude % 360.0 + /// if r <= 90.0: + /// return r, NormalizeLongitude(longitude) + /// elif r >= 270.0: + /// return r - 360, NormalizeLongitude(longitude) + /// else: + /// return 180 - r, NormalizeLongitude(longitude + 180.0) + /// + /// assert 180.0 == NormalizeLongitude(180.0) + /// assert -180.0 == NormalizeLongitude(-180.0) + /// assert -179.0 == NormalizeLongitude(181.0) + /// assert (0.0, 0.0) == NormalizeLatLng(360.0, 0.0) + /// assert (0.0, 0.0) == NormalizeLatLng(-360.0, 0.0) + /// assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0) + /// assert (-85.0, -170.0) == NormalizeLatLng(-95.0, 10.0) + /// assert (90.0, 10.0) == NormalizeLatLng(90.0, 10.0) + /// assert (-90.0, -10.0) == NormalizeLatLng(-90.0, -10.0) + /// assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0) + /// assert (0.0, -170.0) == NormalizeLatLng(180.0, 10.0) + /// assert (-90.0, 10.0) == NormalizeLatLng(270.0, 10.0) + /// assert (90.0, 10.0) == NormalizeLatLng(-270.0, 10.0) + /// + public sealed partial class LatLng : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new LatLng()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Type.LatlngReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public LatLng() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public LatLng(LatLng other) : this() { + latitude_ = other.latitude_; + longitude_ = other.longitude_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public LatLng Clone() { + return new LatLng(this); + } + + /// Field number for the "latitude" field. + public const int LatitudeFieldNumber = 1; + private double latitude_; + /// + /// The latitude in degrees. It must be in the range [-90.0, +90.0]. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Latitude { + get { return latitude_; } + set { + latitude_ = value; + } + } + + /// Field number for the "longitude" field. + public const int LongitudeFieldNumber = 2; + private double longitude_; + /// + /// The longitude in degrees. It must be in the range [-180.0, +180.0]. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Longitude { + get { return longitude_; } + set { + longitude_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as LatLng); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(LatLng other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Latitude != other.Latitude) return false; + if (Longitude != other.Longitude) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Latitude != 0D) hash ^= Latitude.GetHashCode(); + if (Longitude != 0D) hash ^= Longitude.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Latitude != 0D) { + output.WriteRawTag(9); + output.WriteDouble(Latitude); + } + if (Longitude != 0D) { + output.WriteRawTag(17); + output.WriteDouble(Longitude); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Latitude != 0D) { + size += 1 + 8; + } + if (Longitude != 0D) { + size += 1 + 8; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(LatLng other) { + if (other == null) { + return; + } + if (other.Latitude != 0D) { + Latitude = other.Latitude; + } + if (other.Longitude != 0D) { + Longitude = other.Longitude; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 9: { + Latitude = input.ReadDouble(); + break; + } + case 17: { + Longitude = input.ReadDouble(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Generated/googleapis/Status.cs b/GAssistant/Generated/googleapis/Status.cs similarity index 69% rename from Generated/googleapis/Status.cs rename to GAssistant/Generated/googleapis/Status.cs index 68270ff..472328d 100644 --- a/Generated/googleapis/Status.cs +++ b/GAssistant/Generated/googleapis/Status.cs @@ -39,58 +39,59 @@ static StatusReflection() { } #region Messages /// - /// The `Status` type defines a logical error model that is suitable for different - /// programming environments, including REST APIs and RPC APIs. It is used by - /// [gRPC](https://github.com/grpc). The error model is designed to be: + /// The `Status` type defines a logical error model that is suitable for + /// different programming environments, including REST APIs and RPC APIs. It is + /// used by [gRPC](https://github.com/grpc). The error model is designed to be: /// - /// - Simple to use and understand for most users - /// - Flexible enough to meet unexpected needs + /// - Simple to use and understand for most users + /// - Flexible enough to meet unexpected needs /// - /// # Overview + /// # Overview /// - /// The `Status` message contains three pieces of data: error code, error message, - /// and error details. The error code should be an enum value of - /// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The - /// error message should be a developer-facing English message that helps - /// developers *understand* and *resolve* the error. If a localized user-facing - /// error message is needed, put the localized message in the error details or - /// localize it in the client. The optional error details may contain arbitrary - /// information about the error. There is a predefined set of error detail types - /// in the package `google.rpc` which can be used for common error conditions. + /// The `Status` message contains three pieces of data: error code, error + /// message, and error details. The error code should be an enum value of + /// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes + /// if needed. The error message should be a developer-facing English message + /// that helps developers *understand* and *resolve* the error. If a localized + /// user-facing error message is needed, put the localized message in the error + /// details or localize it in the client. The optional error details may contain + /// arbitrary information about the error. There is a predefined set of error + /// detail types in the package `google.rpc` that can be used for common error + /// conditions. /// - /// # Language mapping + /// # Language mapping /// - /// The `Status` message is the logical representation of the error model, but it - /// is not necessarily the actual wire format. When the `Status` message is - /// exposed in different client libraries and different wire protocols, it can be - /// mapped differently. For example, it will likely be mapped to some exceptions - /// in Java, but more likely mapped to some error codes in C. + /// The `Status` message is the logical representation of the error model, but it + /// is not necessarily the actual wire format. When the `Status` message is + /// exposed in different client libraries and different wire protocols, it can be + /// mapped differently. For example, it will likely be mapped to some exceptions + /// in Java, but more likely mapped to some error codes in C. /// - /// # Other uses + /// # Other uses /// - /// The error model and the `Status` message can be used in a variety of - /// environments, either with or without APIs, to provide a - /// consistent developer experience across different environments. + /// The error model and the `Status` message can be used in a variety of + /// environments, either with or without APIs, to provide a + /// consistent developer experience across different environments. /// - /// Example uses of this error model include: + /// Example uses of this error model include: /// - /// - Partial errors. If a service needs to return partial errors to the client, - /// it may embed the `Status` in the normal response to indicate the partial - /// errors. + /// - Partial errors. If a service needs to return partial errors to the client, + /// it may embed the `Status` in the normal response to indicate the partial + /// errors. /// - /// - Workflow errors. A typical workflow has multiple steps. Each step may - /// have a `Status` message for error reporting purpose. + /// - Workflow errors. A typical workflow has multiple steps. Each step may + /// have a `Status` message for error reporting. /// - /// - Batch operations. If a client uses batch request and batch response, the - /// `Status` message should be used directly inside batch response, one for - /// each error sub-response. + /// - Batch operations. If a client uses batch request and batch response, the + /// `Status` message should be used directly inside batch response, one for + /// each error sub-response. /// - /// - Asynchronous operations. If an API call embeds asynchronous operation - /// results in its response, the status of those operations should be - /// represented directly using the `Status` message. + /// - Asynchronous operations. If an API call embeds asynchronous operation + /// results in its response, the status of those operations should be + /// represented directly using the `Status` message. /// - /// - Logging. If some API errors are stored in logs, the message `Status` could - /// be used directly after any stripping needed for security/privacy reasons. + /// - Logging. If some API errors are stored in logs, the message `Status` could + /// be used directly after any stripping needed for security/privacy reasons. /// public sealed partial class Status : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Status()); @@ -130,7 +131,8 @@ public Status Clone() { public const int CodeFieldNumber = 1; private int code_; /// - /// The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. + /// The status code, which should be an enum value of + /// [google.rpc.Code][google.rpc.Code]. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Code { @@ -144,9 +146,10 @@ public int Code { public const int MessageFieldNumber = 2; private string message_ = ""; /// - /// A developer-facing error message, which should be in English. Any - /// user-facing error message should be localized and sent in the - /// [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. + /// A developer-facing error message, which should be in English. Any + /// user-facing error message should be localized and sent in the + /// [google.rpc.Status.details][google.rpc.Status.details] field, or localized + /// by the client. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { @@ -162,8 +165,8 @@ public string Message { = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Any.Parser); private readonly pbc::RepeatedField details_ = new pbc::RepeatedField(); /// - /// A list of messages that carry the error details. There will be a - /// common set of message types for APIs to use. + /// A list of messages that carry the error details. There is a common set of + /// message types for APIs to use. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Details { diff --git a/GAssistant/GettingStarted.md b/GAssistant/GettingStarted.md new file mode 100644 index 0000000..314a5e8 --- /dev/null +++ b/GAssistant/GettingStarted.md @@ -0,0 +1,27 @@ +# Welcome to GAssistant +Due to limitations with a free Google Developer Account for the Google Assistant API its not possible for me to use a single developer account for all GAssistant installations. Because of this, every user of GAssistant must create its own Google Developer Account and use this within his client. + +This guide will explain you how to do the necessary and configure GAssistant. In this guide, I assume that you already have a Google Account. If this is not the case, you can create one using the following link: https://accounts.google.com/SignUp + +## Create/Enable a Google Developer Account for the Google Assistant API +1. In order to create a Google Developer Key, you need to go the Google Actions Console: https://console.actions.google.com/ +2. Click on Add/Import Project +3. Create a new project (you can choose the name; I choose GAssistant) +4. Enable the Google Assistant API on the project you created in the Cloud Platform Console: https://console.developers.google.com/apis/library + 1. Search for "Assistant" + 2. "Enable" of Google Assistant API +5. Configure the OAuth Consent screen for the project you created (most fields are optional and not needed) in the Cloud Platform Console: https://console.developers.google.com/apis/credentials/consent + +More information can also be found at: https://developers.google.com/assistant/sdk/guides/service/python/embed/config-dev-project-and-account + +## Register a new Device Model +1. Use the Registration UI in the Actions Console and click on Register Model for the project that you created in the previous step +2. Fill in all fields. Ensure that you select "" as Device Type. You will need the Device Model id for the GAssistant Settings +3. Download the credentials JSON file, you will need this for the GAssistant Settings + +More information can also be found at: https://developers.google.com/assistant/sdk/guides/service/python/embed/register-device + +## Register a new Device Instance +You can create a new Device Instance using the Actions Console. But in case you don't explicitly create one, GAssistant will register a device instance for you. + +## Configure GAssistant diff --git a/GoogleAccountControl.xaml b/GAssistant/GoogleAccountControl.xaml similarity index 100% rename from GoogleAccountControl.xaml rename to GAssistant/GoogleAccountControl.xaml diff --git a/GoogleAccountControl.xaml.cs b/GAssistant/GoogleAccountControl.xaml.cs similarity index 95% rename from GoogleAccountControl.xaml.cs rename to GAssistant/GoogleAccountControl.xaml.cs index b1e6123..ac4c696 100644 --- a/GoogleAccountControl.xaml.cs +++ b/GAssistant/GoogleAccountControl.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Autofac; +using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -16,7 +17,7 @@ public partial class GoogleAccountControl : UserControl public GoogleAccountControl() { InitializeComponent(); - _userManager = UserManager.Instance; + _userManager = App.Container.Resolve(); _userManager.OnUserUpdate += OnUserUpdate; } diff --git a/GoogleAssistantWindows.csproj b/GAssistant/GoogleAssistantWindows.csproj similarity index 66% rename from GoogleAssistantWindows.csproj rename to GAssistant/GoogleAssistantWindows.csproj index dcfaef8..d5a4477 100644 --- a/GoogleAssistantWindows.csproj +++ b/GAssistant/GoogleAssistantWindows.csproj @@ -8,7 +8,7 @@ WinExe GoogleAssistantWindows GoogleAssistantWindows - v4.5.2 + v4.6.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -42,49 +42,69 @@ mic.ico + + ..\packages\Autofac.4.8.1\lib\net45\Autofac.dll + - packages\Google.Apis.1.25.0\lib\net45\Google.Apis.dll + ..\packages\Google.Apis.1.25.0\lib\net45\Google.Apis.dll - packages\Google.Apis.Auth.1.25.0\lib\net45\Google.Apis.Auth.dll + ..\packages\Google.Apis.Auth.1.25.0\lib\net45\Google.Apis.Auth.dll - packages\Google.Apis.Auth.1.25.0\lib\net45\Google.Apis.Auth.PlatformServices.dll + ..\packages\Google.Apis.Auth.1.25.0\lib\net45\Google.Apis.Auth.PlatformServices.dll - packages\Google.Apis.Core.1.25.0\lib\net45\Google.Apis.Core.dll + ..\packages\Google.Apis.Core.1.25.0\lib\net45\Google.Apis.Core.dll - packages\Google.Apis.Oauth2.v2.1.25.0.672\lib\net45\Google.Apis.Oauth2.v2.dll + ..\packages\Google.Apis.Oauth2.v2.1.25.0.672\lib\net45\Google.Apis.Oauth2.v2.dll - packages\Google.Apis.1.25.0\lib\net45\Google.Apis.PlatformServices.dll + ..\packages\Google.Apis.1.25.0\lib\net45\Google.Apis.PlatformServices.dll - packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll + ..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll - packages\Grpc.Auth.1.3.0\lib\net45\Grpc.Auth.dll + ..\packages\Grpc.Auth.1.3.0\lib\net45\Grpc.Auth.dll - packages\Grpc.Core.1.3.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.3.0\lib\net45\Grpc.Core.dll + + + ..\packages\Markdig.0.15.5\lib\net40\Markdig.dll + + + ..\packages\Markdig.Wpf.0.2.6\lib\net452\Markdig.Wpf.dll + + + ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.0.1\lib\net45\Microsoft.Xaml.Behaviors.dll - packages\NAudio.1.8.0\lib\net35\NAudio.dll + ..\packages\NAudio.1.8.0\lib\net35\NAudio.dll - packages\NAudio.Lame.1.0.4\lib\net20\NAudio.Lame.dll + ..\packages\NAudio.Lame.1.0.4\lib\net20\NAudio.Lame.dll - packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll + + + ..\packages\NLog.4.5.11\lib\net45\NLog.dll + - packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll + ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll + + + + @@ -98,7 +118,7 @@ - packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll + ..\packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll @@ -109,12 +129,25 @@ + + + + + GoogleAccountControl.xaml + + + SettingsWindow.xaml + + + + WelcomeWindow.xaml + Designer MSBuild:Compile @@ -136,6 +169,14 @@ MainWindow.xaml Code + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + @@ -155,9 +196,7 @@ ResXFileCodeGenerator Resources.Designer.cs - - Always - + Always @@ -167,6 +206,12 @@ Always + + Always + + + Always + SettingsSingleFileGenerator @@ -183,11 +228,11 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/KeyboardHook.cs b/GAssistant/KeyboardHook.cs similarity index 100% rename from KeyboardHook.cs rename to GAssistant/KeyboardHook.cs diff --git a/GAssistant/MainWindow.xaml b/GAssistant/MainWindow.xaml new file mode 100644 index 0000000..747330d --- /dev/null +++ b/GAssistant/MainWindow.xaml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GAssistant/MainWindow.xaml.cs b/GAssistant/MainWindow.xaml.cs new file mode 100644 index 0000000..d665848 --- /dev/null +++ b/GAssistant/MainWindow.xaml.cs @@ -0,0 +1,224 @@ +using Autofac; +using System; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Reflection; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Forms; +using System.Windows.Media; + +namespace GoogleAssistantWindows +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + private const int NormalHeight = 368; + private const int DebugHeight = 618; + + private readonly UserManager _userManager; + private readonly Assistant _assistant; + private readonly Settings settings; + private readonly DeviceRegistration deviceRegistration; + + private readonly KeyboardHook _hook; + + private readonly NotifyIcon _notifyIcon; + + private readonly AudioOut _audioOut; + + private AssistantState _assistantState = AssistantState.Inactive; + + private ObservableCollection dialogResults; + + public MainWindow(Assistant assistant, UserManager userManager, Settings settings, DeviceRegistration deviceRegistration) + { + InitializeComponent(); + + _audioOut = new AudioOut(); + + _hook = new KeyboardHook(); + _hook.KeyDown += OnHookKeyDown; + void OnHookKeyDown(object sender, HookEventArgs e) + { + // Global keyboard hook for Ctrl+Alt+G to start listening. + if (e.Control && e.Alt && e.Key == Keys.G) + StartListening(); + } + + // When minimized it will hide in the tray. but the global keyboard hook should still work + _notifyIcon = new NotifyIcon(); + _notifyIcon.Icon = ReadIcon("mic.ico"); + _notifyIcon.Text = Title; + _notifyIcon.DoubleClick += + delegate + { + _notifyIcon.Visible = false; + Show(); + WindowState = WindowState.Normal; + }; + + this._assistant = assistant; + this._assistant.OnAssistantStateChanged += OnAssistantStateChanged; + this._assistant.OnAssistantDialogResult += OnAssistantDialogResult; + this._assistant.OnAssistantSpeechResult += OnAssistantSpeechResult; + + this._userManager = userManager; + this._userManager.OnUserUpdate += OnUserUpdate; + + this.deviceRegistration = deviceRegistration; + + this.settings = settings; + + dialogResults = new ObservableCollection(); + DialogBox.ItemsSource = dialogResults; + } + + protected override void OnStateChanged(EventArgs e) + { + if (WindowState == WindowState.Minimized) + { + _notifyIcon.Visible = true; + Hide(); + } + base.OnStateChanged(e); + } + + private void OnAssistantSpeechResult(string message) + { + dialogResults.Add(new DialogResult() { Actor = DialogResultActor.User, Message = message }); + } + + private void OnAssistantDialogResult(string message) + { + dialogResults.Add(new DialogResult() { Actor = DialogResultActor.GoogleAssistant, Message = message }); + } + + private void OnAssistantStateChanged(AssistantState state) + { + _assistantState = state; + UpdateButtonText(state); + } + + private void UpdateButtonText(AssistantState state) + { + if (ButtonRecord.Dispatcher.CheckAccess()) + { + switch(state) + { + case AssistantState.Listening: + ButtonRecordIcon.Text = "\xF12E"; + ButtonRecordText.Text = state.ToString(); + break; + case AssistantState.Processing: + ButtonRecordIcon.Text = "\xE9F5"; + ButtonRecordText.Text = state.ToString(); + break; + case AssistantState.Speaking: + ButtonRecordIcon.Text = "\xF5B0"; + ButtonRecordText.Text = state.ToString(); + break; + case AssistantState.Inactive: + ButtonRecordIcon.Text = "\xE720"; + ButtonRecordText.Text = "Press"; + break; + } + } + else + ButtonRecord.Dispatcher.BeginInvoke(new Action(() => UpdateButtonText(state))); + } + + private async void OnUserUpdate(UserManager.GoogleUserData userData) + { + ButtonRecord.IsEnabled = false; + _assistant.Shutdown(); + if (userData != null) + { + _assistant.InitAssistantForUser(_userManager.GetChannelCredential()); + ButtonRecord.IsEnabled = true; + } + + if(string.IsNullOrEmpty(settings.DeviceModelId)) + { + string deviceModelId = await deviceRegistration.RegisterDeviceModel(settings.ProjectId, _userManager.Credential); + string deviceId = await deviceRegistration.RegisterDeviceInstance(settings.ProjectId, _userManager.Credential, deviceModelId); + + settings.DeviceModelId = deviceModelId; + settings.DeviceId = deviceId; + } + + if (string.IsNullOrEmpty(settings.DeviceId)) + { + string deviceId = await deviceRegistration.RegisterDeviceInstance(settings.ProjectId, _userManager.Credential, settings.DeviceModelId); + settings.DeviceId = deviceId; + } + + settings.Save(); + } + + private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) + { + if (Utils.HasTokenFile()) + _userManager.GetOrRefreshCredential(); // we don't need to wait for this UserManager will throw an event on loaded. + + if (settings.ShowWelcome) + { + WelcomeWindow dialog = App.Container.Resolve(); + dialog.Owner = this; + dialog.ShowDialog(); + } + } + + private void ButtonRecord_OnClick(object sender, RoutedEventArgs e) + { + StartListening(); + } + + private void StartListening() + { + if (_assistant.IsInitialised() && _assistantState == AssistantState.Inactive) + { + _assistant.NewConversation(); + _audioOut.PlayNotification(); + } + } + + private void DebugButton_OnClick(object sender, RoutedEventArgs e) + { + Height = (Height == NormalHeight ? DebugHeight : NormalHeight); + } + + private void OnProjectWebsiteClick(object sender, RoutedEventArgs e) + { + Process.Start("https://github.com/pieterderycke/GoogleAssistantWindows"); + } + + private void OnSettingsClick(object sender, RoutedEventArgs e) + { + SettingsWindow dialog = App.Container.Resolve(); + dialog.Owner = this; + dialog.ShowDialog(); + } + + private void OnLogFileClick(object sender, RoutedEventArgs e) + { + Process.Start(Utils.GetDataStoreFolder() + "log.txt"); + } + + private Icon ReadIcon(string fileName) + { + var assembly = Assembly.GetExecutingAssembly(); + var resourceName = "GoogleAssistantWindows." + fileName; + + using (Stream stream = assembly.GetManifestResourceStream(resourceName)) + { + return new System.Drawing.Icon(stream); + } + } + } +} diff --git a/GAssistant/NLog.config b/GAssistant/NLog.config new file mode 100644 index 0000000..0e265d2 --- /dev/null +++ b/GAssistant/NLog.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/GAssistant/Properties/AssemblyInfo.cs similarity index 100% rename from Properties/AssemblyInfo.cs rename to GAssistant/Properties/AssemblyInfo.cs diff --git a/Properties/Resources.Designer.cs b/GAssistant/Properties/Resources.Designer.cs similarity index 97% rename from Properties/Resources.Designer.cs rename to GAssistant/Properties/Resources.Designer.cs index 9f5bbe0..2e5ba2c 100644 --- a/Properties/Resources.Designer.cs +++ b/GAssistant/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace GoogleAssistantWindows.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/Properties/Resources.resx b/GAssistant/Properties/Resources.resx similarity index 100% rename from Properties/Resources.resx rename to GAssistant/Properties/Resources.resx diff --git a/Properties/Settings.Designer.cs b/GAssistant/Properties/Settings.Designer.cs similarity index 97% rename from Properties/Settings.Designer.cs rename to GAssistant/Properties/Settings.Designer.cs index 9ac8c99..e365f65 100644 --- a/Properties/Settings.Designer.cs +++ b/GAssistant/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace GoogleAssistantWindows.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Properties/Settings.settings b/GAssistant/Properties/Settings.settings similarity index 100% rename from Properties/Settings.settings rename to GAssistant/Properties/Settings.settings diff --git a/GAssistant/RegisterDevice.ps1 b/GAssistant/RegisterDevice.ps1 new file mode 100644 index 0000000..5f2a003 --- /dev/null +++ b/GAssistant/RegisterDevice.ps1 @@ -0,0 +1,11 @@ +google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype --headless --save --client-secrets Secrets\client_id.json + +googlesamples-assistant-devicetool --client-secrets Secrets\client_id.json register-model --model "assistanttest-187121-mymodel" --type LIGHT --manufacturer "Pieter De Rycke" --product-name "Assistant Test" + +googlesamples-assistant-devicetool --client-secrets Secrets\client_id.json register-device --device "mylaptop" --model "assistanttest-187121-mymodel" --nickname "My Laptop" --client-type SERVICE + +googlesamples-assistant-devicetool --client-secrets Secrets\client_id.json list --model +googlesamples-assistant-devicetool --client-secrets Secrets\client_id.json list --device + +#googlesamples-assistant-devicetool --client-secrets Secrets\client_id.json delete --device "mylaptop" +#googlesamples-assistant-devicetool --client-secrets Secrets\client_id.json delete --model "assistanttest-187121-mymodel" \ No newline at end of file diff --git a/Resources/Google_SignIn.png b/GAssistant/Resources/Google_SignIn.png similarity index 100% rename from Resources/Google_SignIn.png rename to GAssistant/Resources/Google_SignIn.png diff --git a/Resources/negative.wav b/GAssistant/Resources/negative.wav similarity index 100% rename from Resources/negative.wav rename to GAssistant/Resources/negative.wav diff --git a/Resources/positive.wav b/GAssistant/Resources/positive.wav similarity index 100% rename from Resources/positive.wav rename to GAssistant/Resources/positive.wav diff --git a/Secrets/MISSING.md b/GAssistant/Secrets/MISSING.md similarity index 100% rename from Secrets/MISSING.md rename to GAssistant/Secrets/MISSING.md diff --git a/GAssistant/Secrets/client_id.json b/GAssistant/Secrets/client_id.json new file mode 100644 index 0000000..f8e3fee --- /dev/null +++ b/GAssistant/Secrets/client_id.json @@ -0,0 +1 @@ +{"installed":{"client_id":"720180500142-l9cko65i5oputb3437d3ialii939du53.apps.googleusercontent.com","project_id":"assistanttest-187121","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"ped7Qv21XSqdPMloN8h1uH_g","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}} \ No newline at end of file diff --git a/GAssistant/Settings.cs b/GAssistant/Settings.cs new file mode 100644 index 0000000..f48146f --- /dev/null +++ b/GAssistant/Settings.cs @@ -0,0 +1,107 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GoogleAssistantWindows +{ + public class Settings + { + private const string SettingsFilename = @"settings.json"; + private const string ClientIdFilename = @"client_id.json"; + + public delegate void ClientIdChangedDelegate(); + public event ClientIdChangedDelegate OnClientIdChanged; + + private string clientId; + + public string ClientId { + get + { + return clientId; + } + set + { + if(!string.Equals(clientId, value)) + { + clientId = value; + OnClientIdChanged?.Invoke(); + } + } + } + + public string DeviceModelId { get; set; } + public string DeviceId { get; set; } + public string LanguageCode { get; set; } + public bool ShowWelcome { get; set; } + + public string ProjectId + { + get + { + try + { + JObject json = JObject.Parse(ClientId); + return (string)json.SelectToken("installed").SelectToken("project_id"); + } + catch (Exception) + { + return null; + } + } + } + + public void Load() + { + if(File.Exists(Utils.GetDataStoreFolder() + ClientIdFilename)) + ClientId = File.ReadAllText(Utils.GetDataStoreFolder() + ClientIdFilename); + + string fileName = Utils.GetDataStoreFolder() + SettingsFilename; + + if (File.Exists(fileName)) + { + using (TextReader reader = File.OpenText(fileName)) + { + JObject json = JObject.Load(new JsonTextReader(reader)); + DeviceModelId = (string)json.SelectToken("device_model_id"); + DeviceId = (string)json.SelectToken("device_id"); + LanguageCode = (string)json.SelectToken("language_code"); + ShowWelcome = (json.SelectToken("show_welcome") != null) ? (bool)json.SelectToken("show_welcome") : true; + } + } + else + { + ShowWelcome = true; + LanguageCode = "en-US"; + } + } + + public void Save() + { + using (TextWriter textWriter = File.CreateText(Utils.GetDataStoreFolder() + SettingsFilename)) + { + using (JsonWriter writer = new JsonTextWriter(textWriter)) + { + writer.Formatting = Formatting.Indented; + + writer.WriteStartObject(); + writer.WritePropertyName("device_model_id"); + writer.WriteValue(DeviceModelId); + writer.WritePropertyName("device_id"); + writer.WriteValue(DeviceId); + writer.WritePropertyName("language_code"); + writer.WriteValue(LanguageCode); + writer.WritePropertyName("show_welcome"); + writer.WriteValue(ShowWelcome); + writer.WriteEndObject(); + } + } + + File.WriteAllText(Utils.GetDataStoreFolder() + ClientIdFilename, ClientId); + } + } +} diff --git a/GAssistant/SettingsWindow.xaml b/GAssistant/SettingsWindow.xaml new file mode 100644 index 0000000..009e230 --- /dev/null +++ b/GAssistant/SettingsWindow.xaml @@ -0,0 +1,27 @@ + + + + +