/* * Copyright 2012 Splunk, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"): you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ namespace Splunk { /// /// The EntityMetadata class provides access to the metadata properties /// of a corresponding entity. Use Entity.getMetadata to obtain an /// instance of this class. /// public class EntityMetadata { /// /// The entity /// private Entity entity; /// /// Initializes a new instance of the /// class. /// /// The entity public EntityMetadata(Entity entity) { this.entity = entity; } /// /// Gets a value indicating whether this entity's permission can be /// changed. /// public bool CanChangePermissions { get { return this.GetEaiAcl().GetBoolean("can_change_perms", false); } } /// /// Gets a value indicating whether this resource can be shared via an /// app. /// public bool CanShareApp { get { return this.GetEaiAcl().GetBoolean("can_share_app", false); } } /// /// Gets a value indicating whether the resource can be shared globally. /// public bool CanShareGlobal { get { return this.GetEaiAcl().GetBoolean("can_share_global", false); } } /// /// Gets a value indicating whether the resource can be shared to a /// specific user. /// public bool CanShareUser { get { return this.GetEaiAcl().GetBoolean("can_share_user", false); } } /// /// Gets a value indicating whether his entity can be modified. /// public bool CanWrite { get { return this.GetEaiAcl().GetBoolean("can_write", false); } } /// /// Gets the app context of this resource. /// public string App { get { return this.GetEaiAcl().GetString("app", "system"); } } /// /// Gets the username of the resource owner. /// public string Owner { get { return this.GetEaiAcl().GetString("owner"); } } /// /// Gets this entity's permissions, which represent an /// allowable inclusive action:list-of-roles map. /// public Record Permissions { get { return (Record)this.GetEaiAcl().GetValue("perms", null); } } /// /// Gets how this resource is shared (app, global, and/or user). /// public string Sharing { get { return this.GetEaiAcl().GetString("sharing"); } } /// /// Gets a value indicating whether this entity can be modified. /// public bool IsModifiable { get { return this.GetEaiAcl().GetBoolean("modifiable", false); } } /// /// Returns a record containing all of the metadata information /// for this resource. /// /// The metadata record public Record GetEaiAcl() { return (Record)this.entity.Validate().Get("eai:acl"); } } }