public sealed class OSPolicy.Types.Resource : IMessage<OSPolicy.Types.Resource>, IEquatable<OSPolicy.Types.Resource>, IDeepCloneable<OSPolicy.Types.Resource>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud OS Config v1 API class OSPolicy.Types.Resource.
An OS policy resource is used to define the desired state configuration
and provides a specific functionality like installing/removing packages,
executing a script etc.
The system ensures that resources are always in their desired state by
taking necessary actions if they have drifted from their desired state.
[[["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-12 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eOSPolicy.Types.Resource\u003c/code\u003e class is 2.4.0, with several previous versions available, from 2.3.0 down to 1.3.0, accessible in the documentation.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOSPolicy.Types.Resource\u003c/code\u003e is a class within the Google Cloud OS Config v1 API, defining the desired state configuration for resources, including managing packages and executing scripts.\u003c/p\u003e\n"],["\u003cp\u003eThis class ensures that system resources maintain their desired state, automatically taking corrective actions if deviations occur, and it inherits from object while implementing several interfaces such as IMessage, IEquatable, IDeepCloneable and IBufferMessage.\u003c/p\u003e\n"],["\u003cp\u003eThe class contains properties such as Exec, File, Id, Pkg, and Repository, which allow for detailed configuration, including executing scripts, handling files, defining package resources, and managing package repository resources.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eId\u003c/code\u003e property of a \u003ccode\u003eResource\u003c/code\u003e has constraints, including it must only contain lowercase letters, numbers and hyphens, it must start and end with a letter or number, be between 1-63 characters, and be unique within the OS policy.\u003c/p\u003e\n"]]],[],null,["# Google Cloud OS Config v1 API - Class OSPolicy.Types.Resource (2.5.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.5.0 (latest)](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/2.4.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/2.3.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/2.2.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [2.1.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/2.1.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [2.0.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/2.0.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [1.8.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/1.8.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [1.7.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/1.7.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [1.6.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/1.6.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [1.5.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/1.5.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [1.4.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/1.4.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource)\n- [1.3.0](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/1.3.0/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource) \n\n public sealed class OSPolicy.Types.Resource : IMessage\u003cOSPolicy.Types.Resource\u003e, IEquatable\u003cOSPolicy.Types.Resource\u003e, IDeepCloneable\u003cOSPolicy.Types.Resource\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud OS Config v1 API class OSPolicy.Types.Resource.\n\nAn OS policy resource is used to define the desired state configuration\nand provides a specific functionality like installing/removing packages,\nexecuting a script etc.\n\nThe system ensures that resources are always in their desired state by\ntaking necessary actions if they have drifted from their desired state. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e OSPolicy.Types.Resource \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[OSPolicy](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy)[Types](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy.Types)[Resource](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[OSPolicy](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy)[Types](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy.Types)[Resource](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[OSPolicy](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy)[Types](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy.Types)[Resource](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1.OSPolicy.Types.Resource), [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.OsConfig.V1](/dotnet/docs/reference/Google.Cloud.OsConfig.V1/latest/Google.Cloud.OsConfig.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.OsConfig.V1.dll\n\nConstructors\n------------\n\n### Resource()\n\n public Resource()\n\n### Resource(Resource)\n\n public Resource(OSPolicy.Types.Resource other)\n\nProperties\n----------\n\n### Exec\n\n public OSPolicy.Types.Resource.Types.ExecResource Exec { get; set; }\n\nExec resource\n\n### File\n\n public OSPolicy.Types.Resource.Types.FileResource File { get; set; }\n\nFile resource\n\n### Id\n\n public string Id { get; set; }\n\nRequired. The id of the resource with the following restrictions:\n\n- Must contain only lowercase letters, numbers, and hyphens.\n- Must start with a letter.\n- Must be between 1-63 characters.\n- Must end with a number or a letter.\n- Must be unique within the OS policy.\n\n### Pkg\n\n public OSPolicy.Types.Resource.Types.PackageResource Pkg { get; set; }\n\nPackage resource\n\n### Repository\n\n public OSPolicy.Types.Resource.Types.RepositoryResource Repository { get; set; }\n\nPackage repository resource\n\n### ResourceTypeCase\n\n public OSPolicy.Types.Resource.ResourceTypeOneofCase ResourceTypeCase { get; }"]]