public sealed class Rule : IMessage<Rule>, IEquatable<Rule>, IDeepCloneable<Rule>, IBufferMessage, IMessage
Reference documentation and code samples for the Artifact Registry v1 API class Rule.
A rule defines the deny or allow action of the operation it applies to and
the conditions required for the rule to apply. You can set one rule for an
entire repository and one rule for each package within.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eRule\u003c/code\u003e class in the Artifact Registry v1 API defines the action (allow or deny) and conditions for operations on repositories and packages.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of the \u003ccode\u003eRule\u003c/code\u003e class is 2.9.0, with several previous versions available, spanning from 1.0.0 to 2.8.0.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eRule\u003c/code\u003e can apply to an entire repository or to a specific package, with the \u003ccode\u003ePackageId\u003c/code\u003e property determining the scope.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eRule\u003c/code\u003e has a \u003ccode\u003eName\u003c/code\u003e, representing its resource name, which can be viewed through the \u003ccode\u003eRuleName\u003c/code\u003e property.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRule\u003c/code\u003e objects have properties to configure the action (\u003ccode\u003eAction\u003c/code\u003e), operation (\u003ccode\u003eOperation\u003c/code\u003e), and the conditions (\u003ccode\u003eCondition\u003c/code\u003e) under which the rule applies, as well as constructors to create new rules.\u003c/p\u003e\n"]]],[],null,["# Artifact Registry v1 API - Class Rule (2.10.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.10.0 (latest)](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/latest/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.9.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.9.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.8.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.8.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.7.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.7.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.6.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.6.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.5.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.4.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.3.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.2.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.1.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.1.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [2.0.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/2.0.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/1.1.0/Google.Cloud.ArtifactRegistry.V1.Rule)\n- [1.0.0](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/1.0.0/Google.Cloud.ArtifactRegistry.V1.Rule) \n\n public sealed class Rule : IMessage\u003cRule\u003e, IEquatable\u003cRule\u003e, IDeepCloneable\u003cRule\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Artifact Registry v1 API class Rule.\n\nA rule defines the deny or allow action of the operation it applies to and\nthe conditions required for the rule to apply. You can set one rule for an\nentire repository and one rule for each package within. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e Rule \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[Rule](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/latest/Google.Cloud.ArtifactRegistry.V1.Rule), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[Rule](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/latest/Google.Cloud.ArtifactRegistry.V1.Rule), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[Rule](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/latest/Google.Cloud.ArtifactRegistry.V1.Rule), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.ArtifactRegistry.V1](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/latest/Google.Cloud.ArtifactRegistry.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.ArtifactRegistry.V1.dll\n\nConstructors\n------------\n\n### Rule()\n\n public Rule()\n\n### Rule(Rule)\n\n public Rule(Rule other)\n\nProperties\n----------\n\n### Action\n\n public Rule.Types.Action Action { get; set; }\n\nThe action this rule takes.\n\n### Condition\n\n public Expr Condition { get; set; }\n\nOptional. A CEL expression for conditions that must be met in order for the\nrule to apply. If not provided, the rule matches all objects.\n\n### Name\n\n public string Name { get; set; }\n\nThe name of the rule, for example:\n`projects/p1/locations/us-central1/repositories/repo1/rules/rule1`.\n\n### Operation\n\n public Rule.Types.Operation Operation { get; set; }\n\n### PackageId\n\n public string PackageId { get; set; }\n\nThe package ID the rule applies to.\nIf empty, this rule applies to all packages inside the repository.\n\n### RuleName\n\n public RuleName RuleName { get; set; }\n\n[RuleName](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/latest/Google.Cloud.ArtifactRegistry.V1.RuleName)-typed view over the [Name](/dotnet/docs/reference/Google.Cloud.ArtifactRegistry.V1/latest/Google.Cloud.ArtifactRegistry.V1.Rule#Google_Cloud_ArtifactRegistry_V1_Rule_Name) resource name property."]]