Categories
Check and create categories within an existing catalog
Feature
Use these functions when you want to create categories within an existing catalog?
# Returns true/false whether or not the specified category exists in the specified catalog. def category_exists?(catalog_name, category_name) category = Kinetic::RequestAPI::Category.find(catalog_name, category_name) !category.nil? end # Creates a new category in the specified catalog. def create_category(catalog_name, category_name, description=nil, status='Active', sort_order=nil) # Note that this will raise an exception if the catalog does not exist. catalog = Kinetic::RequestAPI::Catalog.find(catalog_name) # Create a new category instance. category = Kinetic::RequestAPI::Category.new({ 'Category' => category_name, 'ServiceCatalog' => catalog_name, 'Status' => status, 'CategoryDescription' => description, 'SortOrder' => sort_order }) # Set the catalog id field. Note that this option cannot be set via the constructor. category.fields['CatalogInstanceID'] = catalog.category_fields['instanceId'] # Save the new category. category.write end Example of category_exists? category_exists?('ACME IT', 'Hardware') Examples of create_category create_category('ACME IT', 'Hardware') create_category('ACME IT', 'Hardware', 'description of catalog', 'Active', '2')
When to use this feature?
Use this feature when you want to add additional categories (and possibly templates) to an existing catalog. Normally with KURL - categories are only created at catalog create time. These functions allow you to add a category after a catalog exists.