/// <summary> /// Parses the given instance resource name in string form into a new /// <see cref="InstanceName"/> instance. /// </summary> /// <param name="instanceName">The instance 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) { GaxPreconditions.CheckNotNull(instanceName, nameof(instanceName)); TemplatedResourceName resourceName = s_template.ParseName(instanceName); return(new InstanceName(resourceName[0], resourceName[1])); }
public void NonRoundtripCornerCase() { var template = new PathTemplate("**"); var name = template.ParseName("//service/"); Assert.Equal("//service", name.ToString()); }
/// <summary> /// Parses the given topic resource name in string form into a new /// <see cref="TopicName"/> instance. /// </summary> /// <param name="topicName">The topic resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="TopicName"/> if successful.</returns> public static TopicName Parse(string topicName) { GaxPreconditions.CheckNotNull(topicName, nameof(topicName)); TemplatedResourceName resourceName = s_template.ParseName(topicName); return(new TopicName(resourceName[0], resourceName[1])); }
/// <summary> /// Parses the given uptime_check_config resource name in string form into a new /// <see cref="UptimeCheckConfigName"/> instance. /// </summary> /// <param name="uptimeCheckConfigName">The uptime_check_config resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="UptimeCheckConfigName"/> if successful.</returns> public static UptimeCheckConfigName Parse(string uptimeCheckConfigName) { GaxPreconditions.CheckNotNull(uptimeCheckConfigName, nameof(uptimeCheckConfigName)); TemplatedResourceName resourceName = s_template.ParseName(uptimeCheckConfigName); return(new UptimeCheckConfigName(resourceName[0], resourceName[1])); }
/// <summary> /// Parses the given subscription resource name in string form into a new /// <see cref="SubscriptionName"/> instance. /// </summary> /// <param name="subscriptionName">The subscription resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="SubscriptionName"/> if successful.</returns> public static SubscriptionName Parse(string subscriptionName) { GaxPreconditions.CheckNotNull(subscriptionName, nameof(subscriptionName)); TemplatedResourceName resourceName = s_template.ParseName(subscriptionName); return(new SubscriptionName(resourceName[0], resourceName[1])); }
/// <summary> /// Parses the given monitored_resource_descriptor resource name in string form into a new /// <see cref="MonitoredResourceDescriptorName"/> instance. /// </summary> /// <param name="monitoredResourceDescriptorName">The monitored_resource_descriptor resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="MonitoredResourceDescriptorName"/> if successful.</returns> public static MonitoredResourceDescriptorName Parse(string monitoredResourceDescriptorName) { GaxPreconditions.CheckNotNull(monitoredResourceDescriptorName, nameof(monitoredResourceDescriptorName)); TemplatedResourceName resourceName = s_template.ParseName(monitoredResourceDescriptorName); return(new MonitoredResourceDescriptorName(resourceName[0], resourceName[1])); }
/// <summary> /// Parses the given group resource name in string form into a new /// <see cref="GroupName"/> instance. /// </summary> /// <param name="groupName">The group resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="GroupName"/> if successful.</returns> public static GroupName Parse(string groupName) { GaxPreconditions.CheckNotNull(groupName, nameof(groupName)); TemplatedResourceName resourceName = s_template.ParseName(groupName); return(new GroupName(resourceName[0], resourceName[1])); }
/// <summary> /// Parses the given project resource name in string form into a new /// <see cref="ProjectName"/> instance. /// </summary> /// <param name="projectName">The project resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="ProjectName"/> if successful.</returns> public static ProjectName Parse(string projectName) { GaxPreconditions.CheckNotNull(projectName, nameof(projectName)); TemplatedResourceName resourceName = s_template.ParseName(projectName); return(new ProjectName(resourceName[0])); }
/// <summary> /// Parses the given snapshot resource name in string form into a new /// <see cref="SnapshotName"/> instance. /// </summary> /// <param name="snapshotName">The snapshot resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="SnapshotName"/> if successful.</returns> public static SnapshotName Parse(string snapshotName) { GaxPreconditions.CheckNotNull(snapshotName, nameof(snapshotName)); TemplatedResourceName resourceName = s_template.ParseName(snapshotName); return(new SnapshotName(resourceName[0], resourceName[1], resourceName[2], resourceName[3])); }
/// <summary> /// Parses the given user resource name in string form into a new /// <see cref="UserName"/> instance. /// </summary> /// <param name="userName">The user resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="UserName"/> if successful.</returns> public static UserName Parse(string userName) { GaxPreconditions.CheckNotNull(userName, nameof(userName)); TemplatedResourceName resourceName = s_template.ParseName(userName); return(new UserName(resourceName[0])); }
/// <summary> /// Parses the given database resource name in string form into a new /// <see cref="DatabaseName"/> instance. /// </summary> /// <param name="databaseName">The database resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="DatabaseName"/> if successful.</returns> public static DatabaseName Parse(string databaseName) { GaxPreconditions.CheckNotNull(databaseName, nameof(databaseName)); TemplatedResourceName resourceName = s_template.ParseName(databaseName); return(new DatabaseName(resourceName[0], resourceName[1], resourceName[2])); }
/// <summary> /// Parses the given billing account resource name in string form into a new /// <see cref="BillingAccountName"/> instance. /// </summary> /// <param name="BillingAccountName">The billing account resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="BillingAccountName"/> if successful.</returns> public static BillingAccountName Parse(string BillingAccountName) { GaxPreconditions.CheckNotNull(BillingAccountName, nameof(BillingAccountName)); TemplatedResourceName resourceName = s_template.ParseName(BillingAccountName); return(new BillingAccountName(resourceName[0])); }
/// <summary> /// Parses the given fingerprint resource name in string form into a new /// <see cref="FingerprintName"/> instance. /// </summary> /// <param name="fingerprintName">The fingerprint resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="FingerprintName"/> if successful.</returns> public static FingerprintName Parse(string fingerprintName) { GaxPreconditions.CheckNotNull(fingerprintName, nameof(fingerprintName)); TemplatedResourceName resourceName = s_template.ParseName(fingerprintName); return(new FingerprintName(resourceName[0], resourceName[1])); }
/// <summary> /// Parses the given any_path resource name in string form into a new /// <see cref="AnyPathName"/> instance. /// </summary> /// <param name="anyPathName">The any_path resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="AnyPathName"/> if successful.</returns> public static AnyPathName Parse(string anyPathName) { GaxPreconditions.CheckNotNull(anyPathName, nameof(anyPathName)); TemplatedResourceName resourceName = s_template.ParseName(anyPathName); return(new AnyPathName(resourceName[0], resourceName[1], resourceName[2], resourceName[3])); }
/// <summary> /// Parses the given document_root resource name in string form into a new /// <see cref="DocumentRootName"/> instance. /// </summary> /// <param name="documentRootName">The document_root resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="DocumentRootName"/> if successful.</returns> public static DocumentRootName Parse(string documentRootName) { GaxPreconditions.CheckNotNull(documentRootName, nameof(documentRootName)); TemplatedResourceName resourceName = s_template.ParseName(documentRootName); return(new DocumentRootName(resourceName[0], resourceName[1])); }
/// <summary> /// Parses the given organization resource name in string form into a new /// <see cref="OrganizationName"/> instance. /// </summary> /// <param name="organizationName">The organization resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="OrganizationName"/> if successful.</returns> public static OrganizationName Parse(string organizationName) { GaxPreconditions.CheckNotNull(organizationName, nameof(organizationName)); TemplatedResourceName resourceName = s_template.ParseName(organizationName); return(new OrganizationName(resourceName[0])); }
/// <summary> /// Parses the given cluster resource name in string form into a new /// <see cref="ClusterName"/> instance. /// </summary> /// <param name="clusterName">The cluster resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="ClusterName"/> if successful.</returns> public static ClusterName Parse(string clusterName) { GaxPreconditions.CheckNotNull(clusterName, nameof(clusterName)); TemplatedResourceName resourceName = s_template.ParseName(clusterName); return(new ClusterName(resourceName[0], resourceName[1], resourceName[2])); }
/// <summary> /// Parses the given location resource name in string form into a new /// <see cref="LocationName"/> instance. /// </summary> /// <param name="locationName">The location resource name in string form. Must not be <c>null</c>.</param> /// <returns>The parsed <see cref="LocationName"/> if successful.</returns> public static LocationName Parse(string locationName) { GaxPreconditions.CheckNotNull(locationName, nameof(locationName)); TemplatedResourceName resourceName = s_template.ParseName(locationName); return(new LocationName(resourceName[0], resourceName[1])); }
public void ParseName_Invalid(string templateText, string name) { var template = new PathTemplate(templateText); Assert.Throws<FormatException>(() => template.ParseName(name)); ResourceName result; Assert.False(template.TryParseName(name, out result)); Assert.Null(result); }
public void ParseName_Invalid(string templateText, string name) { var template = new PathTemplate(templateText); Assert.Throws <FormatException>(() => template.ParseName(name)); TemplatedResourceName result; Assert.False(template.TryParseName(name, out result)); Assert.Null(result); }
public void ParseName_Valid(string templateText, string name, string[] expectedResourceIds, string expectedServiceName) { var template = new PathTemplate(templateText); var resourceName = template.ParseName(name); for (int i = 0; i < expectedResourceIds.Length; i++) { Assert.Equal(resourceName[i], expectedResourceIds[i]); } Assert.Equal(expectedServiceName, resourceName.ServiceName); // Should round-trip... Assert.Equal(name, resourceName.ToString()); // And TryParse... ResourceName result; Assert.True(template.TryParseName(name, out result)); Assert.NotNull(result); }
public void ParseName_Valid(string templateText, string name, string[] expectedResourceIds, string expectedServiceName) { var template = new PathTemplate(templateText); var resourceName = template.ParseName(name); for (int i = 0; i < expectedResourceIds.Length; i++) { Assert.Equal(resourceName[i], expectedResourceIds[i]); } Assert.Equal(expectedServiceName, resourceName.ServiceName); // Should round-trip... Assert.Equal(name, resourceName.ToString()); // And TryParse... TemplatedResourceName result; Assert.True(template.TryParseName(name, out result)); Assert.NotNull(result); }