/*
* 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
{
///
/// Represents the collection of configuration collections.
///
public class ConfCollection : ResourceCollection>
{
///
/// Initializes a new instance of the
/// class.
///
/// The connected service
public ConfCollection(Service service)
: base(service, "properties", typeof(EntityCollection))
{
}
///
/// Initializes a new instance of the
/// class.
///
/// The connected service
/// The arguments
public ConfCollection(Service service, Args args)
: base(service, "properties", args, typeof(EntityCollection))
{
}
///
/// Creates a new stanza in the current configuration file.
///
/// The stanza name
/// The stanza
public EntityCollection Create(string name)
{
return this.Create(name, (Args)null);
}
///
/// Creates a new stanza in the current configuration file with
/// attributes.
///
/// The stanza name
/// The arguments
/// The stanza
public EntityCollection Create(string name, Args args)
{
args = Args.Create(args);
args.Add("__conf", name);
this.Service.Post(this.Path, args);
this.Invalidate();
return this.Get(name);
}
///
/// Returns the endpoint path for this configuration stanza.
///
/// The Atom entry
/// The item path
protected override string ItemPath(AtomEntry entry)
{
return string.Format("configs/conf-{0}", entry.Title);
}
}
}