If true will successfully store an unparseable resource name into the UnparsedResource
property; otherwise will throw an ArgumentException if an unparseable resource name is
specified.
If true will successfully store an unparseable resource name into the UnparsedResource
property; otherwise will throw an ArgumentException if an unparseable resource name is
specified.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003ePolicyName\u003c/code\u003e class in the Security Command Center v2 API represents a resource name for a policy and implements \u003ccode\u003eIResourceName\u003c/code\u003e and \u003ccode\u003eIEquatable<PolicyName>\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can construct a \u003ccode\u003ePolicyName\u003c/code\u003e using the \u003ccode\u003ePolicyName(string, string)\u003c/code\u003e constructor, providing an organization ID and a constraint name ID, or use the static methods \u003ccode\u003eFromFolderConstraintName\u003c/code\u003e, \u003ccode\u003eFromOrganizationConstraintName\u003c/code\u003e, or \u003ccode\u003eFromProjectConstraintName\u003c/code\u003e which create \u003ccode\u003ePolicyName\u003c/code\u003e with specific patterns.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ePolicyName\u003c/code\u003e class supports different resource name patterns: \u003ccode\u003eorganizations/{organization}/policies/{constraint_name}\u003c/code\u003e, \u003ccode\u003efolders/{folder}/policies/{constraint_name}\u003c/code\u003e, and \u003ccode\u003eprojects/{project}/policies/{constraint_name}\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eParse\u003c/code\u003e and \u003ccode\u003eTryParse\u003c/code\u003e methods are provided to convert a string representation of a resource name into a \u003ccode\u003ePolicyName\u003c/code\u003e instance, with options to allow or disallow unparseable resource names.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ePolicyName\u003c/code\u003e provides properties such as \u003ccode\u003eOrganizationId\u003c/code\u003e, \u003ccode\u003eFolderId\u003c/code\u003e, \u003ccode\u003eProjectId\u003c/code\u003e, and \u003ccode\u003eConstraintNameId\u003c/code\u003e, which can be \u003ccode\u003enull\u003c/code\u003e depending on the contained resource name, and also contains an \u003ccode\u003eUnparsedResource\u003c/code\u003e to handle non-standard formats.\u003c/p\u003e\n"]]],[],null,["# Security Command Center v2 API - Class PolicyName (1.2.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.0 (latest)](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/1.1.0/Google.Cloud.SecurityCenter.V2.PolicyName)\n- [1.0.0](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/1.0.0/Google.Cloud.SecurityCenter.V2.PolicyName) \n\n public sealed class PolicyName : IResourceName, IEquatable\u003cPolicyName\u003e\n\nReference documentation and code samples for the Security Command Center v2 API class PolicyName.\n\nResource name for the `Policy` resource. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e PolicyName \n\nImplements\n----------\n\n[IResourceName](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.IResourceName.html), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) \n\nInherited Members\n-----------------\n\n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)\n\nNamespace\n---------\n\n[Google.Cloud.SecurityCenter.V2](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2)\n\nAssembly\n--------\n\nGoogle.Cloud.SecurityCenter.V2.dll\n\nConstructors\n------------\n\n### PolicyName(string, string)\n\n public PolicyName(string organizationId, string constraintNameId)\n\nConstructs a new instance of a [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) class from the component parts of pattern\n`organizations/{organization}/policies/{constraint_name}`\n\nProperties\n----------\n\n### ConstraintNameId\n\n public string ConstraintNameId { get; }\n\nThe `ConstraintName` ID. May be `null`, depending on which resource name is contained by this\ninstance.\n\n### FolderId\n\n public string FolderId { get; }\n\nThe `Folder` ID. May be `null`, depending on which resource name is contained by this instance.\n\n### IsKnownPattern\n\n public bool IsKnownPattern { get; }\n\nWhether this instance contains a resource name with a known pattern.\n\n### OrganizationId\n\n public string OrganizationId { get; }\n\nThe `Organization` ID. May be `null`, depending on which resource name is contained by this\ninstance.\n\n### ProjectId\n\n public string ProjectId { get; }\n\nThe `Project` ID. May be `null`, depending on which resource name is contained by this instance.\n\n### Type\n\n public PolicyName.ResourceNameType Type { get; }\n\nThe [PolicyName.ResourceNameType](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName.ResourceNameType) of the contained resource name.\n\n### UnparsedResource\n\n public UnparsedResourceName UnparsedResource { get; }\n\nThe contained [UnparsedResourceName](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.UnparsedResourceName.html). Only non-`null` if this instance contains an\nunparsed resource name.\n\nMethods\n-------\n\n### Format(string, string)\n\n public static string Format(string organizationId, string constraintNameId)\n\nFormats the IDs into the string representation of this [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) with pattern\n`organizations/{organization}/policies/{constraint_name}`.\n\n### FormatFolderConstraintName(string, string)\n\n public static string FormatFolderConstraintName(string folderId, string constraintNameId)\n\nFormats the IDs into the string representation of this [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) with pattern\n`folders/{folder}/policies/{constraint_name}`.\n\n### FormatOrganizationConstraintName(string, string)\n\n public static string FormatOrganizationConstraintName(string organizationId, string constraintNameId)\n\nFormats the IDs into the string representation of this [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) with pattern\n`organizations/{organization}/policies/{constraint_name}`.\n\n### FormatProjectConstraintName(string, string)\n\n public static string FormatProjectConstraintName(string projectId, string constraintNameId)\n\nFormats the IDs into the string representation of this [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) with pattern\n`projects/{project}/policies/{constraint_name}`.\n\n### FromFolderConstraintName(string, string)\n\n public static PolicyName FromFolderConstraintName(string folderId, string constraintNameId)\n\nCreates a [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) with the pattern `folders/{folder}/policies/{constraint_name}`.\n\n### FromOrganizationConstraintName(string, string)\n\n public static PolicyName FromOrganizationConstraintName(string organizationId, string constraintNameId)\n\nCreates a [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) with the pattern\n`organizations/{organization}/policies/{constraint_name}`.\n\n### FromProjectConstraintName(string, string)\n\n public static PolicyName FromProjectConstraintName(string projectId, string constraintNameId)\n\nCreates a [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) with the pattern `projects/{project}/policies/{constraint_name}`.\n\n### FromUnparsed(UnparsedResourceName)\n\n public static PolicyName FromUnparsed(UnparsedResourceName unparsedResourceName)\n\nCreates a [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) containing an unparsed resource name.\n\n### GetHashCode()\n\n public override int GetHashCode()\n\nReturns a hash code for this resource name.\n\n**Overrides** \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)\n\n### Parse(string)\n\n public static PolicyName Parse(string policyName)\n\nParses the given resource name string into a new [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) instance.\n\n**Remarks** \nTo parse successfully, the resource name must be formatted as one of the following:\n\n- `organizations/{organization}/policies/{constraint_name}`\n- `folders/{folder}/policies/{constraint_name}`\n- `projects/{project}/policies/{constraint_name}`\n\n\u003cbr /\u003e\n\n### Parse(string, bool)\n\n public static PolicyName Parse(string policyName, bool allowUnparsed)\n\nParses the given resource name string into a new [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) instance; optionally allowing an\nunparseable resource name.\n\n**Remarks** \nTo parse successfully, the resource name must be formatted as one of the following:\n\n- `organizations/{organization}/policies/{constraint_name}`\n- `folders/{folder}/policies/{constraint_name}`\n- `projects/{project}/policies/{constraint_name}`\n\nOr may be in any format if `allowUnparsed` is `true`.\n\n\u003cbr /\u003e\n\n### ToString()\n\n public override string ToString()\n\nThe string representation of the resource name.\n\n**Overrides** \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\n### TryParse(string, out PolicyName)\n\n public static bool TryParse(string policyName, out PolicyName result)\n\nTries to parse the given resource name string into a new [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) instance.\n\n**Remarks** \nTo parse successfully, the resource name must be formatted as one of the following:\n\n- `organizations/{organization}/policies/{constraint_name}`\n- `folders/{folder}/policies/{constraint_name}`\n- `projects/{project}/policies/{constraint_name}`\n\n\u003cbr /\u003e\n\n### TryParse(string, bool, out PolicyName)\n\n public static bool TryParse(string policyName, bool allowUnparsed, out PolicyName result)\n\nTries to parse the given resource name string into a new [PolicyName](/dotnet/docs/reference/Google.Cloud.SecurityCenter.V2/latest/Google.Cloud.SecurityCenter.V2.PolicyName) instance; optionally\nallowing an unparseable resource name.\n\n**Remarks** \nTo parse successfully, the resource name must be formatted as one of the following:\n\n- `organizations/{organization}/policies/{constraint_name}`\n- `folders/{folder}/policies/{constraint_name}`\n- `projects/{project}/policies/{constraint_name}`\n\nOr may be in any format if `allowUnparsed` is `true`.\n\n\u003cbr /\u003e\n\nOperators\n---------\n\n### operator ==(PolicyName, PolicyName)\n\n public static bool operator ==(PolicyName a, PolicyName b)\n\nDetermines whether two specified resource names have the same value.\n\n### operator !=(PolicyName, PolicyName)\n\n public static bool operator !=(PolicyName a, PolicyName b)\n\nDetermines whether two specified resource names have different values."]]