text:
using gax = Google.Api.Gax;
using gagr = Google.Api.Gax.ResourceNames;
using gcnv = Google.Cloud.NetworkConnectivity.V1Alpha1;
using sys = System;

namespace Google.Cloud.NetworkConnectivity.V1Alpha1
{
    /// Resource name for the <c>Hub</c> resource.
    public sealed partial class HubName : gax::IResourceName, sys::IEquatable<HubName>
    {
        /// The possible contents of <see cref="HubName"/>.
        public enum ResourceNameType
        {
            /// An unparsed resource name.
            Unparsed = 0,

            /// A resource name with pattern <c>projects/{project}/locations/global/hubs/{hub}</c>.
            ProjectHub = 1,
        }

        private static gax::PathTemplate s_projectHub = new gax::PathTemplate("projects/{project}/locations/global/hubs/{hub}");

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

        ///
        /// Creates a <see cref="HubName"/> with the pattern <c>projects/{project}/locations/global/hubs/{hub}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="hubId">The <c>Hub</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>A new instance of <see cref="HubName"/> constructed from the provided ids.</returns>
        public static HubName FromProjectHub(string projectId, string hubId) =>
            new HubName(ResourceNameType.ProjectHub, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), hubId: gax::GaxPreconditions.CheckNotNullOrEmpty(hubId, nameof(hubId)));

        ///
        /// Formats the IDs into the string representation of this <see cref="HubName"/> with pattern
        /// <c>projects/{project}/locations/global/hubs/{hub}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="hubId">The <c>Hub</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="HubName"/> with pattern
        /// <c>projects/{project}/locations/global/hubs/{hub}</c>.
        /// </returns>
        public static string Format(string projectId, string hubId) => FormatProjectHub(projectId, hubId);

        ///
        /// Formats the IDs into the string representation of this <see cref="HubName"/> with pattern
        /// <c>projects/{project}/locations/global/hubs/{hub}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="hubId">The <c>Hub</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="HubName"/> with pattern
        /// <c>projects/{project}/locations/global/hubs/{hub}</c>.
        /// </returns>
        public static string FormatProjectHub(string projectId, string hubId) =>
            s_projectHub.Expand(gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), gax::GaxPreconditions.CheckNotNullOrEmpty(hubId, nameof(hubId)));

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

        ///
        /// Parses the given resource name string into a new <see cref="HubName"/> instance; optionally allowing an
        /// unparseable resource name.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/locations/global/hubs/{hub}</c></description></item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="hubName">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="HubName"/> if successful.</returns>
        public static HubName Parse(string hubName, bool allowUnparsed) =>
            TryParse(hubName, allowUnparsed, out HubName result) ? result : throw new sys::ArgumentException("The given resource-name matches no pattern.");

        /// Tries to parse the given resource name string into a new <see cref="HubName"/> instance.
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/locations/global/hubs/{hub}</c></description></item>
        /// </list>
        /// </remarks>
        /// <param name="hubName">The resource name in string form. Must not be <c>null</c>.</param>
        /// <param name="result">
        /// When this method returns, the parsed <see cref="HubName"/>, 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 hubName, out HubName result) => TryParse(hubName, false, out result);

        ///
        /// Tries to parse the given resource name string into a new <see cref="HubName"/> instance; optionally allowing
        /// an unparseable resource name.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/locations/global/hubs/{hub}</c></description></item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="hubName">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="HubName"/>, 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 hubName, bool allowUnparsed, out HubName result)
        {
            gax::GaxPreconditions.CheckNotNull(hubName, nameof(hubName));
            gax::TemplatedResourceName resourceName;
            if (s_projectHub.TryParseName(hubName, out resourceName))
            {
                result = FromProjectHub(resourceName[0], resourceName[1]);
                return true;
            }
            if (allowUnparsed)
            {
                if (gax::UnparsedResourceName.TryParse(hubName, out gax::UnparsedResourceName unparsedResourceName))
                {
                    result = FromUnparsed(unparsedResourceName);
                    return true;
                }
            }
            result = null;
            return false;
        }

        private HubName(ResourceNameType type, gax::UnparsedResourceName unparsedResourceName = null, string hubId = null, string projectId = null)
        {
            Type = type;
            UnparsedResource = unparsedResourceName;
            HubId = hubId;
            ProjectId = projectId;
        }

        ///
        /// Constructs a new instance of a <see cref="HubName"/> class from the component parts of pattern
        /// <c>projects/{project}/locations/global/hubs/{hub}</c>
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="hubId">The <c>Hub</c> ID. Must not be <c>null</c> or empty.</param>
        public HubName(string projectId, string hubId) : this(ResourceNameType.ProjectHub, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), hubId: gax::GaxPreconditions.CheckNotNullOrEmpty(hubId, nameof(hubId)))
        {
        }

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

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

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

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

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

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

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

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

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

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

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

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

            ///
            /// A resource name with pattern <c>projects/{project}/locations/{location}/spokes/{spoke}</c>.
            ///
            ProjectLocationSpoke = 1,
        }

        private static gax::PathTemplate s_projectLocationSpoke = new gax::PathTemplate("projects/{project}/locations/{location}/spokes/{spoke}");

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

        ///
        /// Creates a <see cref="SpokeName"/> with the pattern <c>projects/{project}/locations/{location}/spokes/{spoke}</c>
        /// .
        ///
        /// <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="spokeId">The <c>Spoke</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>A new instance of <see cref="SpokeName"/> constructed from the provided ids.</returns>
        public static SpokeName FromProjectLocationSpoke(string projectId, string locationId, string spokeId) =>
            new SpokeName(ResourceNameType.ProjectLocationSpoke, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), locationId: gax::GaxPreconditions.CheckNotNullOrEmpty(locationId, nameof(locationId)), spokeId: gax::GaxPreconditions.CheckNotNullOrEmpty(spokeId, nameof(spokeId)));

        ///
        /// Formats the IDs into the string representation of this <see cref="SpokeName"/> with pattern
        /// <c>projects/{project}/locations/{location}/spokes/{spoke}</c>.
        ///
        /// <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="spokeId">The <c>Spoke</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="SpokeName"/> with pattern
        /// <c>projects/{project}/locations/{location}/spokes/{spoke}</c>.
        /// </returns>
        public static string Format(string projectId, string locationId, string spokeId) =>
            FormatProjectLocationSpoke(projectId, locationId, spokeId);

        ///
        /// Formats the IDs into the string representation of this <see cref="SpokeName"/> with pattern
        /// <c>projects/{project}/locations/{location}/spokes/{spoke}</c>.
        ///
        /// <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="spokeId">The <c>Spoke</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="SpokeName"/> with pattern
        /// <c>projects/{project}/locations/{location}/spokes/{spoke}</c>.
        /// </returns>
        public static string FormatProjectLocationSpoke(string projectId, string locationId, string spokeId) =>
            s_projectLocationSpoke.Expand(gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), gax::GaxPreconditions.CheckNotNullOrEmpty(locationId, nameof(locationId)), gax::GaxPreconditions.CheckNotNullOrEmpty(spokeId, nameof(spokeId)));

        /// Parses the given resource name string into a new <see cref="SpokeName"/> instance.
        /// <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}/spokes/{spoke}</c></description></item>
        /// </list>
        /// </remarks>
        /// <param name="spokeName">The resource name in string form. Must not be <c>null</c>.</param>
        /// <returns>The parsed <see cref="SpokeName"/> if successful.</returns>
        public static SpokeName Parse(string spokeName) => Parse(spokeName, false);

        ///
        /// Parses the given resource name string into a new <see cref="SpokeName"/> instance; optionally allowing an
        /// unparseable resource name.
        ///
        /// <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}/spokes/{spoke}</c></description></item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="spokeName">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="SpokeName"/> if successful.</returns>
        public static SpokeName Parse(string spokeName, bool allowUnparsed) =>
            TryParse(spokeName, allowUnparsed, out SpokeName result) ? result : throw new sys::ArgumentException("The given resource-name matches no pattern.");

        ///
        /// Tries to parse the given resource name string into a new <see cref="SpokeName"/> instance.
        ///
        /// <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}/spokes/{spoke}</c></description></item>
        /// </list>
        /// </remarks>
        /// <param name="spokeName">The resource name in string form. Must not be <c>null</c>.</param>
        /// <param name="result">
        /// When this method returns, the parsed <see cref="SpokeName"/>, 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 spokeName, out SpokeName result) => TryParse(spokeName, false, out result);

        ///
        /// Tries to parse the given resource name string into a new <see cref="SpokeName"/> instance; optionally
        /// allowing an unparseable resource name.
        ///
        /// <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}/spokes/{spoke}</c></description></item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="spokeName">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="SpokeName"/>, 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 spokeName, bool allowUnparsed, out SpokeName result)
        {
            gax::GaxPreconditions.CheckNotNull(spokeName, nameof(spokeName));
            gax::TemplatedResourceName resourceName;
            if (s_projectLocationSpoke.TryParseName(spokeName, out resourceName))
            {
                result = FromProjectLocationSpoke(resourceName[0], resourceName[1], resourceName[2]);
                return true;
            }
            if (allowUnparsed)
            {
                if (gax::UnparsedResourceName.TryParse(spokeName, out gax::UnparsedResourceName unparsedResourceName))
                {
                    result = FromUnparsed(unparsedResourceName);
                    return true;
                }
            }
            result = null;
            return false;
        }

        private SpokeName(ResourceNameType type, gax::UnparsedResourceName unparsedResourceName = null, string locationId = null, string projectId = null, string spokeId = null)
        {
            Type = type;
            UnparsedResource = unparsedResourceName;
            LocationId = locationId;
            ProjectId = projectId;
            SpokeId = spokeId;
        }

        ///
        /// Constructs a new instance of a <see cref="SpokeName"/> class from the component parts of pattern
        /// <c>projects/{project}/locations/{location}/spokes/{spoke}</c>
        ///
        /// <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="spokeId">The <c>Spoke</c> ID. Must not be <c>null</c> or empty.</param>
        public SpokeName(string projectId, string locationId, string spokeId) : this(ResourceNameType.ProjectLocationSpoke, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), locationId: gax::GaxPreconditions.CheckNotNullOrEmpty(locationId, nameof(locationId)), spokeId: gax::GaxPreconditions.CheckNotNullOrEmpty(spokeId, nameof(spokeId)))
        {
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

            ///
            /// A resource name with pattern <c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c>.
            ///
            ProjectRegionResource = 1,
        }

        private static gax::PathTemplate s_projectRegionResource = new gax::PathTemplate("projects/{project}/regions/{region}/vpnTunnels/{resource_id}");

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

        ///
        /// Creates a <see cref="VpnTunnelName"/> with the pattern
        /// <c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="regionId">The <c>Region</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="resourceId">The <c>Resource</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>A new instance of <see cref="VpnTunnelName"/> constructed from the provided ids.</returns>
        public static VpnTunnelName FromProjectRegionResource(string projectId, string regionId, string resourceId) =>
            new VpnTunnelName(ResourceNameType.ProjectRegionResource, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), regionId: gax::GaxPreconditions.CheckNotNullOrEmpty(regionId, nameof(regionId)), resourceId: gax::GaxPreconditions.CheckNotNullOrEmpty(resourceId, nameof(resourceId)));

        ///
        /// Formats the IDs into the string representation of this <see cref="VpnTunnelName"/> with pattern
        /// <c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="regionId">The <c>Region</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="resourceId">The <c>Resource</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="VpnTunnelName"/> with pattern
        /// <c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c>.
        /// </returns>
        public static string Format(string projectId, string regionId, string resourceId) =>
            FormatProjectRegionResource(projectId, regionId, resourceId);

        ///
        /// Formats the IDs into the string representation of this <see cref="VpnTunnelName"/> with pattern
        /// <c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="regionId">The <c>Region</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="resourceId">The <c>Resource</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="VpnTunnelName"/> with pattern
        /// <c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c>.
        /// </returns>
        public static string FormatProjectRegionResource(string projectId, string regionId, string resourceId) =>
            s_projectRegionResource.Expand(gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), gax::GaxPreconditions.CheckNotNullOrEmpty(regionId, nameof(regionId)), gax::GaxPreconditions.CheckNotNullOrEmpty(resourceId, nameof(resourceId)));

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

        ///
        /// Parses the given resource name string into a new <see cref="VpnTunnelName"/> instance; optionally allowing
        /// an unparseable resource name.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c></description></item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="vpnTunnelName">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="VpnTunnelName"/> if successful.</returns>
        public static VpnTunnelName Parse(string vpnTunnelName, bool allowUnparsed) =>
            TryParse(vpnTunnelName, allowUnparsed, out VpnTunnelName result) ? result : throw new sys::ArgumentException("The given resource-name matches no pattern.");

        ///
        /// Tries to parse the given resource name string into a new <see cref="VpnTunnelName"/> instance.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c></description></item>
        /// </list>
        /// </remarks>
        /// <param name="vpnTunnelName">The resource name in string form. Must not be <c>null</c>.</param>
        /// <param name="result">
        /// When this method returns, the parsed <see cref="VpnTunnelName"/>, 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 vpnTunnelName, out VpnTunnelName result) => TryParse(vpnTunnelName, false, out result);

        ///
        /// Tries to parse the given resource name string into a new <see cref="VpnTunnelName"/> instance; optionally
        /// allowing an unparseable resource name.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c></description></item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="vpnTunnelName">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="VpnTunnelName"/>, 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 vpnTunnelName, bool allowUnparsed, out VpnTunnelName result)
        {
            gax::GaxPreconditions.CheckNotNull(vpnTunnelName, nameof(vpnTunnelName));
            gax::TemplatedResourceName resourceName;
            if (s_projectRegionResource.TryParseName(vpnTunnelName, out resourceName))
            {
                result = FromProjectRegionResource(resourceName[0], resourceName[1], resourceName[2]);
                return true;
            }
            if (allowUnparsed)
            {
                if (gax::UnparsedResourceName.TryParse(vpnTunnelName, out gax::UnparsedResourceName unparsedResourceName))
                {
                    result = FromUnparsed(unparsedResourceName);
                    return true;
                }
            }
            result = null;
            return false;
        }

        private VpnTunnelName(ResourceNameType type, gax::UnparsedResourceName unparsedResourceName = null, string projectId = null, string regionId = null, string resourceId = null)
        {
            Type = type;
            UnparsedResource = unparsedResourceName;
            ProjectId = projectId;
            RegionId = regionId;
            ResourceId = resourceId;
        }

        ///
        /// Constructs a new instance of a <see cref="VpnTunnelName"/> class from the component parts of pattern
        /// <c>projects/{project}/regions/{region}/vpnTunnels/{resource_id}</c>
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="regionId">The <c>Region</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="resourceId">The <c>Resource</c> ID. Must not be <c>null</c> or empty.</param>
        public VpnTunnelName(string projectId, string regionId, string resourceId) : this(ResourceNameType.ProjectRegionResource, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), regionId: gax::GaxPreconditions.CheckNotNullOrEmpty(regionId, nameof(regionId)), resourceId: gax::GaxPreconditions.CheckNotNullOrEmpty(resourceId, nameof(resourceId)))
        {
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

            ///
            /// A resource name with pattern
            /// <c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c>.
            ///
            ProjectRegionResource = 1,
        }

        private static gax::PathTemplate s_projectRegionResource = new gax::PathTemplate("projects/{project}/regions/{region}/interconnectAttachments/{resource_id}");

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

        ///
        /// Creates a <see cref="InterconnectAttachmentName"/> with the pattern
        /// <c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="regionId">The <c>Region</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="resourceId">The <c>Resource</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// A new instance of <see cref="InterconnectAttachmentName"/> constructed from the provided ids.
        /// </returns>
        public static InterconnectAttachmentName FromProjectRegionResource(string projectId, string regionId, string resourceId) =>
            new InterconnectAttachmentName(ResourceNameType.ProjectRegionResource, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), regionId: gax::GaxPreconditions.CheckNotNullOrEmpty(regionId, nameof(regionId)), resourceId: gax::GaxPreconditions.CheckNotNullOrEmpty(resourceId, nameof(resourceId)));

        ///
        /// Formats the IDs into the string representation of this <see cref="InterconnectAttachmentName"/> with pattern
        /// <c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="regionId">The <c>Region</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="resourceId">The <c>Resource</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="InterconnectAttachmentName"/> with pattern
        /// <c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c>.
        /// </returns>
        public static string Format(string projectId, string regionId, string resourceId) =>
            FormatProjectRegionResource(projectId, regionId, resourceId);

        ///
        /// Formats the IDs into the string representation of this <see cref="InterconnectAttachmentName"/> with pattern
        /// <c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="regionId">The <c>Region</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="resourceId">The <c>Resource</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="InterconnectAttachmentName"/> with pattern
        /// <c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c>.
        /// </returns>
        public static string FormatProjectRegionResource(string projectId, string regionId, string resourceId) =>
            s_projectRegionResource.Expand(gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), gax::GaxPreconditions.CheckNotNullOrEmpty(regionId, nameof(regionId)), gax::GaxPreconditions.CheckNotNullOrEmpty(resourceId, nameof(resourceId)));

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

        ///
        /// Parses the given resource name string into a new <see cref="InterconnectAttachmentName"/> instance;
        /// optionally allowing an unparseable resource name.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item>
        /// <description><c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c></description>
        /// </item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="interconnectAttachmentName">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="InterconnectAttachmentName"/> if successful.</returns>
        public static InterconnectAttachmentName Parse(string interconnectAttachmentName, bool allowUnparsed) =>
            TryParse(interconnectAttachmentName, allowUnparsed, out InterconnectAttachmentName result) ? result : throw new sys::ArgumentException("The given resource-name matches no pattern.");

        ///
        /// Tries to parse the given resource name string into a new <see cref="InterconnectAttachmentName"/> instance.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item>
        /// <description><c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c></description>
        /// </item>
        /// </list>
        /// </remarks>
        /// <param name="interconnectAttachmentName">The resource name in string form. Must not be <c>null</c>.</param>
        /// <param name="result">
        /// When this method returns, the parsed <see cref="InterconnectAttachmentName"/>, 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 interconnectAttachmentName, out InterconnectAttachmentName result) =>
            TryParse(interconnectAttachmentName, false, out result);

        ///
        /// Tries to parse the given resource name string into a new <see cref="InterconnectAttachmentName"/> instance;
        /// optionally allowing an unparseable resource name.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item>
        /// <description><c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c></description>
        /// </item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="interconnectAttachmentName">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="InterconnectAttachmentName"/>, 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 interconnectAttachmentName, bool allowUnparsed, out InterconnectAttachmentName result)
        {
            gax::GaxPreconditions.CheckNotNull(interconnectAttachmentName, nameof(interconnectAttachmentName));
            gax::TemplatedResourceName resourceName;
            if (s_projectRegionResource.TryParseName(interconnectAttachmentName, out resourceName))
            {
                result = FromProjectRegionResource(resourceName[0], resourceName[1], resourceName[2]);
                return true;
            }
            if (allowUnparsed)
            {
                if (gax::UnparsedResourceName.TryParse(interconnectAttachmentName, out gax::UnparsedResourceName unparsedResourceName))
                {
                    result = FromUnparsed(unparsedResourceName);
                    return true;
                }
            }
            result = null;
            return false;
        }

        private InterconnectAttachmentName(ResourceNameType type, gax::UnparsedResourceName unparsedResourceName = null, string projectId = null, string regionId = null, string resourceId = null)
        {
            Type = type;
            UnparsedResource = unparsedResourceName;
            ProjectId = projectId;
            RegionId = regionId;
            ResourceId = resourceId;
        }

        ///
        /// Constructs a new instance of a <see cref="InterconnectAttachmentName"/> class from the component parts of
        /// pattern <c>projects/{project}/regions/{region}/interconnectAttachments/{resource_id}</c>
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="regionId">The <c>Region</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="resourceId">The <c>Resource</c> ID. Must not be <c>null</c> or empty.</param>
        public InterconnectAttachmentName(string projectId, string regionId, string resourceId) : this(ResourceNameType.ProjectRegionResource, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), regionId: gax::GaxPreconditions.CheckNotNullOrEmpty(regionId, nameof(regionId)), resourceId: gax::GaxPreconditions.CheckNotNullOrEmpty(resourceId, nameof(resourceId)))
        {
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

            ///
            /// A resource name with pattern <c>projects/{project}/zones/{zone}/instances/{instance}</c>.
            ///
            ProjectZoneInstance = 1,
        }

        private static gax::PathTemplate s_projectZoneInstance = new gax::PathTemplate("projects/{project}/zones/{zone}/instances/{instance}");

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

        ///
        /// Creates a <see cref="InstanceName"/> with the pattern
        /// <c>projects/{project}/zones/{zone}/instances/{instance}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="zoneId">The <c>Zone</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="instanceId">The <c>Instance</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>A new instance of <see cref="InstanceName"/> constructed from the provided ids.</returns>
        public static InstanceName FromProjectZoneInstance(string projectId, string zoneId, string instanceId) =>
            new InstanceName(ResourceNameType.ProjectZoneInstance, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), zoneId: gax::GaxPreconditions.CheckNotNullOrEmpty(zoneId, nameof(zoneId)), instanceId: gax::GaxPreconditions.CheckNotNullOrEmpty(instanceId, nameof(instanceId)));

        ///
        /// Formats the IDs into the string representation of this <see cref="InstanceName"/> with pattern
        /// <c>projects/{project}/zones/{zone}/instances/{instance}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="zoneId">The <c>Zone</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="instanceId">The <c>Instance</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="InstanceName"/> with pattern
        /// <c>projects/{project}/zones/{zone}/instances/{instance}</c>.
        /// </returns>
        public static string Format(string projectId, string zoneId, string instanceId) =>
            FormatProjectZoneInstance(projectId, zoneId, instanceId);

        ///
        /// Formats the IDs into the string representation of this <see cref="InstanceName"/> with pattern
        /// <c>projects/{project}/zones/{zone}/instances/{instance}</c>.
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="zoneId">The <c>Zone</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="instanceId">The <c>Instance</c> ID. Must not be <c>null</c> or empty.</param>
        /// <returns>
        /// The string representation of this <see cref="InstanceName"/> with pattern
        /// <c>projects/{project}/zones/{zone}/instances/{instance}</c>.
        /// </returns>
        public static string FormatProjectZoneInstance(string projectId, string zoneId, string instanceId) =>
            s_projectZoneInstance.Expand(gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), gax::GaxPreconditions.CheckNotNullOrEmpty(zoneId, nameof(zoneId)), gax::GaxPreconditions.CheckNotNullOrEmpty(instanceId, nameof(instanceId)));

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

        ///
        /// Parses the given resource name string into a new <see cref="InstanceName"/> instance; optionally allowing an
        /// unparseable resource name.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/zones/{zone}/instances/{instance}</c></description></item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="instanceName">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="InstanceName"/> if successful.</returns>
        public static InstanceName Parse(string instanceName, bool allowUnparsed) =>
            TryParse(instanceName, allowUnparsed, out InstanceName result) ? result : throw new sys::ArgumentException("The given resource-name matches no pattern.");

        ///
        /// Tries to parse the given resource name string into a new <see cref="InstanceName"/> instance.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/zones/{zone}/instances/{instance}</c></description></item>
        /// </list>
        /// </remarks>
        /// <param name="instanceName">The resource name in string form. Must not be <c>null</c>.</param>
        /// <param name="result">
        /// When this method returns, the parsed <see cref="InstanceName"/>, 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 instanceName, out InstanceName result) => TryParse(instanceName, false, out result);

        ///
        /// Tries to parse the given resource name string into a new <see cref="InstanceName"/> instance; optionally
        /// allowing an unparseable resource name.
        ///
        /// <remarks>
        /// To parse successfully, the resource name must be formatted as one of the following:
        /// <list type="bullet">
        /// <item><description><c>projects/{project}/zones/{zone}/instances/{instance}</c></description></item>
        /// </list>
        /// Or may be in any format if <paramref name="allowUnparsed"/> is <c>true</c>.
        /// </remarks>
        /// <param name="instanceName">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="InstanceName"/>, 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 instanceName, bool allowUnparsed, out InstanceName result)
        {
            gax::GaxPreconditions.CheckNotNull(instanceName, nameof(instanceName));
            gax::TemplatedResourceName resourceName;
            if (s_projectZoneInstance.TryParseName(instanceName, out resourceName))
            {
                result = FromProjectZoneInstance(resourceName[0], resourceName[1], resourceName[2]);
                return true;
            }
            if (allowUnparsed)
            {
                if (gax::UnparsedResourceName.TryParse(instanceName, out gax::UnparsedResourceName unparsedResourceName))
                {
                    result = FromUnparsed(unparsedResourceName);
                    return true;
                }
            }
            result = null;
            return false;
        }

        private InstanceName(ResourceNameType type, gax::UnparsedResourceName unparsedResourceName = null, string instanceId = null, string projectId = null, string zoneId = null)
        {
            Type = type;
            UnparsedResource = unparsedResourceName;
            InstanceId = instanceId;
            ProjectId = projectId;
            ZoneId = zoneId;
        }

        ///
        /// Constructs a new instance of a <see cref="InstanceName"/> class from the component parts of pattern
        /// <c>projects/{project}/zones/{zone}/instances/{instance}</c>
        ///
        /// <param name="projectId">The <c>Project</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="zoneId">The <c>Zone</c> ID. Must not be <c>null</c> or empty.</param>
        /// <param name="instanceId">The <c>Instance</c> ID. Must not be <c>null</c> or empty.</param>
        public InstanceName(string projectId, string zoneId, string instanceId) : this(ResourceNameType.ProjectZoneInstance, projectId: gax::GaxPreconditions.CheckNotNullOrEmpty(projectId, nameof(projectId)), zoneId: gax::GaxPreconditions.CheckNotNullOrEmpty(zoneId, nameof(zoneId)), instanceId: gax::GaxPreconditions.CheckNotNullOrEmpty(instanceId, nameof(instanceId)))
        {
        }

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

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

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

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

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

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

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

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

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

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

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

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

    public partial class Hub
    {
        ///
        /// <see cref="gcnv::HubName"/>-typed view over the <see cref="Name"/> resource name property.
        ///
        public gcnv::HubName HubName
        {
            get => string.IsNullOrEmpty(Name) ? null : gcnv::HubName.Parse(Name, allowUnparsed: true);
            set => Name = value?.ToString() ?? "";
        }

        /// <see cref="SpokeName"/>-typed view over the <see cref="Spokes"/> resource name property.
        public gax::ResourceNameList<SpokeName> SpokesAsSpokeNames
        {
            get => new gax::ResourceNameList<SpokeName>(Spokes, s => string.IsNullOrEmpty(s) ? null : SpokeName.Parse(s, allowUnparsed: true));
        }
    }

    public partial class Spoke
    {
        ///
        /// <see cref="gcnv::SpokeName"/>-typed view over the <see cref="Name"/> resource name property.
        ///
        public gcnv::SpokeName SpokeName
        {
            get => string.IsNullOrEmpty(Name) ? null : gcnv::SpokeName.Parse(Name, allowUnparsed: true);
            set => Name = value?.ToString() ?? "";
        }

        /// <see cref="HubName"/>-typed view over the <see cref="Hub"/> resource name property.
        public HubName HubAsHubName
        {
            get => string.IsNullOrEmpty(Hub) ? null : HubName.Parse(Hub, allowUnparsed: true);
            set => Hub = value?.ToString() ?? "";
        }

        ///
        /// <see cref="VpnTunnelName"/>-typed view over the <see cref="LinkedVpnTunnels"/> resource name property.
        ///
        public gax::ResourceNameList<VpnTunnelName> LinkedVpnTunnelsAsVpnTunnelNames
        {
            get => new gax::ResourceNameList<VpnTunnelName>(LinkedVpnTunnels, s => string.IsNullOrEmpty(s) ? null : VpnTunnelName.Parse(s, allowUnparsed: true));
        }

        ///
        /// <see cref="InterconnectAttachmentName"/>-typed view over the <see cref="LinkedInterconnectAttachments"/>
        /// resource name property.
        ///
        public gax::ResourceNameList<InterconnectAttachmentName> LinkedInterconnectAttachmentsAsInterconnectAttachmentNames
        {
            get => new gax::ResourceNameList<InterconnectAttachmentName>(LinkedInterconnectAttachments, s => string.IsNullOrEmpty(s) ? null : InterconnectAttachmentName.Parse(s, allowUnparsed: true));
        }
    }

    public partial class ListHubsRequest
    {
        ///
        /// <see cref="gagr::LocationName"/>-typed view over the <see cref="Parent"/> resource name property.
        ///
        public gagr::LocationName ParentAsLocationName
        {
            get => string.IsNullOrEmpty(Parent) ? null : gagr::LocationName.Parse(Parent, allowUnparsed: true);
            set => Parent = value?.ToString() ?? "";
        }
    }

    public partial class GetHubRequest
    {
        ///
        /// <see cref="gcnv::HubName"/>-typed view over the <see cref="Name"/> resource name property.
        ///
        public gcnv::HubName HubName
        {
            get => string.IsNullOrEmpty(Name) ? null : gcnv::HubName.Parse(Name, allowUnparsed: true);
            set => Name = value?.ToString() ?? "";
        }
    }

    public partial class CreateHubRequest
    {
        ///
        /// <see cref="gagr::LocationName"/>-typed view over the <see cref="Parent"/> resource name property.
        ///
        public gagr::LocationName ParentAsLocationName
        {
            get => string.IsNullOrEmpty(Parent) ? null : gagr::LocationName.Parse(Parent, allowUnparsed: true);
            set => Parent = value?.ToString() ?? "";
        }
    }

    public partial class DeleteHubRequest
    {
        ///
        /// <see cref="gcnv::HubName"/>-typed view over the <see cref="Name"/> resource name property.
        ///
        public gcnv::HubName HubName
        {
            get => string.IsNullOrEmpty(Name) ? null : gcnv::HubName.Parse(Name, allowUnparsed: true);
            set => Name = value?.ToString() ?? "";
        }
    }

    public partial class ListSpokesRequest
    {
        ///
        /// <see cref="gagr::LocationName"/>-typed view over the <see cref="Parent"/> resource name property.
        ///
        public gagr::LocationName ParentAsLocationName
        {
            get => string.IsNullOrEmpty(Parent) ? null : gagr::LocationName.Parse(Parent, allowUnparsed: true);
            set => Parent = value?.ToString() ?? "";
        }
    }

    public partial class GetSpokeRequest
    {
        ///
        /// <see cref="gcnv::SpokeName"/>-typed view over the <see cref="Name"/> resource name property.
        ///
        public gcnv::SpokeName SpokeName
        {
            get => string.IsNullOrEmpty(Name) ? null : gcnv::SpokeName.Parse(Name, allowUnparsed: true);
            set => Name = value?.ToString() ?? "";
        }
    }

    public partial class CreateSpokeRequest
    {
        ///
        /// <see cref="gagr::LocationName"/>-typed view over the <see cref="Parent"/> resource name property.
        ///
        public gagr::LocationName ParentAsLocationName
        {
            get => string.IsNullOrEmpty(Parent) ? null : gagr::LocationName.Parse(Parent, allowUnparsed: true);
            set => Parent = value?.ToString() ?? "";
        }
    }

    public partial class DeleteSpokeRequest
    {
        ///
        /// <see cref="gcnv::SpokeName"/>-typed view over the <see cref="Name"/> resource name property.
        ///
        public gcnv::SpokeName SpokeName
        {
            get => string.IsNullOrEmpty(Name) ? null : gcnv::SpokeName.Parse(Name, allowUnparsed: true);
            set => Name = value?.ToString() ?? "";
        }
    }

    public partial class RouterApplianceInstance
    {
        ///
        /// <see cref="InstanceName"/>-typed view over the <see cref="VirtualMachine"/> resource name property.
        ///
        public InstanceName VirtualMachineAsInstanceName
        {
            get => string.IsNullOrEmpty(VirtualMachine) ? null : InstanceName.Parse(VirtualMachine, allowUnparsed: true);
            set => VirtualMachine = value?.ToString() ?? "";
        }
    }
}