Skip to content

Commit

Permalink
feat: Add the resource definition of a STT recognizer
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 537079193

Source-Link: googleapis/googleapis@b933446

Source-Link: googleapis/googleapis-gen@086270d
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuQ29udGFjdENlbnRlckluc2lnaHRzLlYxLy5Pd2xCb3QueWFtbCIsImgiOiIwODYyNzBkMWJlNTA1ZDIwYWJhN2JiMjgzYTA0YmYxMDA4OWRiZDM4In0=
  • Loading branch information
gcf-owl-bot[bot] authored and hemanshv committed Jun 2, 2023
1 parent 8c86af6 commit 2f4ff72
Show file tree
Hide file tree
Showing 2 changed files with 243 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public static partial class ResourcesReflection {
"ZWN0b3IuU3VtbWFyaXphdGlvbkNvbmZpZy5TdW1tYXJpemF0aW9uTW9kZWxI",
"ACJNChJTdW1tYXJpemF0aW9uTW9kZWwSIwofU1VNTUFSSVpBVElPTl9NT0RF",
"TF9VTlNQRUNJRklFRBAAEhIKDkJBU0VMSU5FX01PREVMEAFCDgoMbW9kZWxf",
"c291cmNlQvkECiljb20uZ29vZ2xlLmNsb3VkLmNvbnRhY3RjZW50ZXJpbnNp",
"c291cmNlQuAFCiljb20uZ29vZ2xlLmNsb3VkLmNvbnRhY3RjZW50ZXJpbnNp",
"Z2h0cy52MUIOUmVzb3VyY2VzUHJvdG9QAVpfY2xvdWQuZ29vZ2xlLmNvbS9n",
"by9jb250YWN0Y2VudGVyaW5zaWdodHMvYXBpdjEvY29udGFjdGNlbnRlcmlu",
"c2lnaHRzcGI7Y29udGFjdGNlbnRlcmluc2lnaHRzcGKqAiVHb29nbGUuQ2xv",
Expand All @@ -381,7 +381,9 @@ public static partial class ResourcesReflection {
"cnNhdGlvbnMve2NvbnZlcnNhdGlvbn0vcGFydGljaXBhbnRzL3twYXJ0aWNp",
"cGFudH0SX3Byb2plY3RzL3twcm9qZWN0fS9sb2NhdGlvbnMve2xvY2F0aW9u",
"fS9jb252ZXJzYXRpb25zL3tjb252ZXJzYXRpb259L3BhcnRpY2lwYW50cy97",
"cGFydGljaXBhbnR9YgZwcm90bzM="));
"cGFydGljaXBhbnR96kFkCiBzcGVlY2guZ29vZ2xlYXBpcy5jb20vUmVjb2du",
"aXplchJAcHJvamVjdHMve3Byb2plY3R9L2xvY2F0aW9ucy97bG9jYXRpb259",
"L3JlY29nbml6ZXJzL3tyZWNvZ25pemVyfWIGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Api.FieldBehaviorReflection.Descriptor, global::Google.Api.ResourceReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,245 @@ public override string ToString()
public static bool operator !=(ParticipantName a, ParticipantName b) => !(a == b);
}

/// <summary>Resource name for the <c>Recognizer</c> resource.</summary>
public sealed partial class RecognizerName : gax::IResourceName, sys::IEquatable<RecognizerName>
{
/// <summary>The possible contents of <see cref="RecognizerName"/>.</summary>
public enum ResourceNameType
{
/// <summary>An unparsed resource name.</summary>
Unparsed = 0,

/// <summary>
/// A resource name with pattern <c>projects/{project}/locations/{location}/recognizers/{recognizer}</c>.
/// </summary>
ProjectLocationRecognizer = 1,
}

private static gax::PathTemplate s_projectLocationRecognizer = new gax::PathTemplate("projects/{project}/locations/{location}/recognizers/{recognizer}");

/// <summary>Creates a <see cref="RecognizerName"/> containing an unparsed resource name.</summary>
/// <param name="unparsedResourceName">The unparsed resource name. Must not be <c>null</c>.</param>
/// <returns>
/// A new instance of <see cref="RecognizerName"/> containing the provided
/// <paramref name="unparsedResourceName"/>.
/// </returns>
public static RecognizerName FromUnparsed(gax::UnparsedResourceName unparsedResourceName) =>
new RecognizerName(ResourceNameType.Unparsed, gax::GaxPreconditions.CheckNotNull(unparsedResourceName, nameof(unparsedResourceName)));

/// <summary>
/// Creates a <see cref="RecognizerName"/> with the pattern
/// <c>projects/{project}/locations/{location}/recognizers/{recognizer}</c>.
/// </summary>
/// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
/// <param name="locationId">The <c>Location</c> ID. Must not be <c>null</c> or empty.</param>
/// <param name="recognizerId">The <c>Recognizer</c> ID. Must not be <c>null</c> or empty.</param>
/// <returns>A new instance of <see cref="RecognizerName"/> constructed from the provided ids.</returns>
public static RecognizerName FromProjectLocationRecognizer(string projectId, string locationId, string recognizerId) =>
new RecognizerName(ResourceNameType.ProjectLocationRecognizer, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), locationId: gax::GaxPreconditions.CheckNotNullOrEmpty(locationId, nameof(locationId)), recognizerId: gax::GaxPreconditions.CheckNotNullOrEmpty(recognizerId, nameof(recognizerId)));

/// <summary>
/// Formats the IDs into the string representation of this <see cref="RecognizerName"/> with pattern
/// <c>projects/{project}/locations/{location}/recognizers/{recognizer}</c>.
/// </summary>
/// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
/// <param name="locationId">The <c>Location</c> ID. Must not be <c>null</c> or empty.</param>
/// <param name="recognizerId">The <c>Recognizer</c> ID. Must not be <c>null</c> or empty.</param>
/// <returns>
/// The string representation of this <see cref="RecognizerName"/> with pattern
/// <c>projects/{project}/locations/{location}/recognizers/{recognizer}</c>.
/// </returns>
public static string Format(string projectId, string locationId, string recognizerId) =>
FormatProjectLocationRecognizer(projectId, locationId, recognizerId);

/// <summary>
/// Formats the IDs into the string representation of this <see cref="RecognizerName"/> with pattern
/// <c>projects/{project}/locations/{location}/recognizers/{recognizer}</c>.
/// </summary>
/// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
/// <param name="locationId">The <c>Location</c> ID. Must not be <c>null</c> or empty.</param>
/// <param name="recognizerId">The <c>Recognizer</c> ID. Must not be <c>null</c> or empty.</param>
/// <returns>
/// The string representation of this <see cref="RecognizerName"/> with pattern
/// <c>projects/{project}/locations/{location}/recognizers/{recognizer}</c>.
/// </returns>
public static string FormatProjectLocationRecognizer(string projectId, string locationId, string recognizerId) =>
s_projectLocationRecognizer.Expand(gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), gax::GaxPreconditions.CheckNotNullOrEmpty(locationId, nameof(locationId)), gax::GaxPreconditions.CheckNotNullOrEmpty(recognizerId, nameof(recognizerId)));

/// <summary>Parses the given resource name string into a new <see cref="RecognizerName"/> instance.</summary>
/// <remarks>
/// To parse successfully, the resource name must be formatted as one of the following:
/// <list type="bullet">
/// <item>
/// <description><c>projects/{project}/locations/{location}/recognizers/{recognizer}</c></description>
/// </item>
/// </list>
/// </remarks>
/// <param name="recognizerName">The resource name in string form. Must not be <c>null</c>.</param>
/// <returns>The parsed <see cref="RecognizerName"/> if successful.</returns>
public static RecognizerName Parse(string recognizerName) => Parse(recognizerName, false);

/// <summary>
/// Parses the given resource name string into a new <see cref="RecognizerName"/> instance; optionally allowing
/// an unparseable resource name.
/// </summary>
/// <remarks>
/// To parse successfully, the resource name must be formatted as one of the following:
/// <list type="bullet">
/// <item>
/// <description><c>projects/{project}/locations/{location}/recognizers/{recognizer}</c></description>
/// </item>
/// </list>
/// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
/// </remarks>
/// <param name="recognizerName">The resource name in string form. Must not be <c>null</c>.</param>
/// <param name="allowUnparsed">
/// If <c>true</c> will successfully store an unparseable resource name into the <see cref="UnparsedResource"/>
/// property; otherwise will throw an <see cref="sys::ArgumentException"/> if an unparseable resource name is
/// specified.
/// </param>
/// <returns>The parsed <see cref="RecognizerName"/> if successful.</returns>
public static RecognizerName Parse(string recognizerName, bool allowUnparsed) =>
TryParse(recognizerName, allowUnparsed, out RecognizerName result) ? result : throw new sys::ArgumentException("The given resource-name matches no pattern.");

/// <summary>
/// Tries to parse the given resource name string into a new <see cref="RecognizerName"/> instance.
/// </summary>
/// <remarks>
/// To parse successfully, the resource name must be formatted as one of the following:
/// <list type="bullet">
/// <item>
/// <description><c>projects/{project}/locations/{location}/recognizers/{recognizer}</c></description>
/// </item>
/// </list>
/// </remarks>
/// <param name="recognizerName">The resource name in string form. Must not be <c>null</c>.</param>
/// <param name="result">
/// When this method returns, the parsed <see cref="RecognizerName"/>, or <c>null</c> if parsing failed.
/// </param>
/// <returns><c>true</c> if the name was parsed successfully; <c>false</c> otherwise.</returns>
public static bool TryParse(string recognizerName, out RecognizerName result) =>
TryParse(recognizerName, false, out result);

/// <summary>
/// Tries to parse the given resource name string into a new <see cref="RecognizerName"/> instance; optionally
/// allowing an unparseable resource name.
/// </summary>
/// <remarks>
/// To parse successfully, the resource name must be formatted as one of the following:
/// <list type="bullet">
/// <item>
/// <description><c>projects/{project}/locations/{location}/recognizers/{recognizer}</c></description>
/// </item>
/// </list>
/// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
/// </remarks>
/// <param name="recognizerName">The resource name in string form. Must not be <c>null</c>.</param>
/// <param name="allowUnparsed">
/// If <c>true</c> will successfully store an unparseable resource name into the <see cref="UnparsedResource"/>
/// property; otherwise will throw an <see cref="sys::ArgumentException"/> if an unparseable resource name is
/// specified.
/// </param>
/// <param name="result">
/// When this method returns, the parsed <see cref="RecognizerName"/>, or <c>null</c> if parsing failed.
/// </param>
/// <returns><c>true</c> if the name was parsed successfully; <c>false</c> otherwise.</returns>
public static bool TryParse(string recognizerName, bool allowUnparsed, out RecognizerName result)
{
gax::GaxPreconditions.CheckNotNull(recognizerName, nameof(recognizerName));
gax::TemplatedResourceName resourceName;
if (s_projectLocationRecognizer.TryParseName(recognizerName, out resourceName))
{
result = FromProjectLocationRecognizer(resourceName[0], resourceName[1], resourceName[2]);
return true;
}
if (allowUnparsed)
{
if (gax::UnparsedResourceName.TryParse(recognizerName, out gax::UnparsedResourceName unparsedResourceName))
{
result = FromUnparsed(unparsedResourceName);
return true;
}
}
result = null;
return false;
}

private RecognizerName(ResourceNameType type, gax::UnparsedResourceName unparsedResourceName = null, string locationId = null, string projectId = null, string recognizerId = null)
{
Type = type;
UnparsedResource = unparsedResourceName;
LocationId = locationId;
ProjectId = projectId;
RecognizerId = recognizerId;
}

/// <summary>
/// Constructs a new instance of a <see cref="RecognizerName"/> class from the component parts of pattern
/// <c>projects/{project}/locations/{location}/recognizers/{recognizer}</c>
/// </summary>
/// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
/// <param name="locationId">The <c>Location</c> ID. Must not be <c>null</c> or empty.</param>
/// <param name="recognizerId">The <c>Recognizer</c> ID. Must not be <c>null</c> or empty.</param>
public RecognizerName(string projectId, string locationId, string recognizerId) : this(ResourceNameType.ProjectLocationRecognizer, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), locationId: gax::GaxPreconditions.CheckNotNullOrEmpty(locationId, nameof(locationId)), recognizerId: gax::GaxPreconditions.CheckNotNullOrEmpty(recognizerId, nameof(recognizerId)))
{
}

/// <summary>The <see cref="ResourceNameType"/> of the contained resource name.</summary>
public ResourceNameType Type { get; }

/// <summary>
/// The contained <see cref="gax::UnparsedResourceName"/>. Only non-<c>null</c> if this instance contains an
/// unparsed resource name.
/// </summary>
public gax::UnparsedResourceName UnparsedResource { get; }

/// <summary>
/// The <c>Location</c> ID. Will not be <c>null</c>, unless this instance contains an unparsed resource name.
/// </summary>
public string LocationId { get; }

/// <summary>
/// The <c>Project</c> ID. Will not be <c>null</c>, unless this instance contains an unparsed resource name.
/// </summary>
public string ProjectId { get; }

/// <summary>
/// The <c>Recognizer</c> ID. Will not be <c>null</c>, unless this instance contains an unparsed resource name.
/// </summary>
public string RecognizerId { get; }

/// <summary>Whether this instance contains a resource name with a known pattern.</summary>
public bool IsKnownPattern => Type != ResourceNameType.Unparsed;

/// <summary>The string representation of the resource name.</summary>
/// <returns>The string representation of the resource name.</returns>
public override string ToString()
{
switch (Type)
{
case ResourceNameType.Unparsed: return UnparsedResource.ToString();
case ResourceNameType.ProjectLocationRecognizer: return s_projectLocationRecognizer.Expand(ProjectId, LocationId, RecognizerId);
default: throw new sys::InvalidOperationException("Unrecognized resource-type.");
}
}

/// <summary>Returns a hash code for this resource name.</summary>
public override int GetHashCode() => ToString().GetHashCode();

/// <inheritdoc/>
public override bool Equals(object obj) => Equals(obj as RecognizerName);

/// <inheritdoc/>
public bool Equals(RecognizerName other) => ToString() == other?.ToString();

/// <inheritdoc/>
public static bool operator ==(RecognizerName a, RecognizerName b) => ReferenceEquals(a, b) || (a?.Equals(b) ?? false);

/// <inheritdoc/>
public static bool operator !=(RecognizerName a, RecognizerName b) => !(a == b);
}

public partial class Conversation
{
/// <summary>
Expand Down

0 comments on commit 2f4ff72

Please sign in to comment.