/*
 * Copyright 2017 Netflix, 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.
 */

package com.netflix.spinnaker.clouddriver.cache;

import com.netflix.spinnaker.clouddriver.core.provider.agent.Namespace;

import java.util.Map;

public interface KeyParser {

  /**
   * Returns the parsed property name for the specified <code>cache</code> that represents the "name" of the item being
   * parsed.
   *
   * For example,
   *
   * Given the AWS key <code>serverGroups:mycluster-stack-detail:some-account:some-region:myservergroup-stack-detail-v000</code>,
   * we might store the server group name (the last part of the key) under a different property than <code>name</code>,
   * e.g., <code>serverGroup</code>, in which case the mapping of {@link Namespace#SERVER_GROUPS#ns} ->
   * "serverGroup" would be needed.
   *
   * @param cache the name of the cache (key type) being parsed
   *
   * @return the mapping of the key name to the actual key property name for the specified <code>cache</code> or
   * <code>null</code> if no mapping exists or is required (e.g., if the parsed key already contains a <code>name</code>
   * property and it maps correctly).
   */
  default String getNameMapping(String cache) {
    return null;
  }

  /**
   * Indicates which provider this particular parser handles
   * @return the cloud provider ID
   */
  String getCloudProvider();

  /**
   * Parses the supplied key to an arbitrary Map of attributes
   * @param key the full key
   * @return a Map of the key attributes
   */
  Map<String, String> parseKey(String key);

  /**
   * indicates whether this parser can parse the supplied type
   * @param type the entity type, typically corresponding to a value in the implementing class's Namespace
   * @return true if it can parse this type
   */
  Boolean canParse(String type);
}

@@ -1251,15 +1251,8 @@
  of 
-%7B@link 
 Name
@@ -1256,17 +1256,17 @@
 amespace
-#
+.
 SERVER_G
@@ -1274,20 +1274,14 @@
 OUPS
-#ns%7D -%3E%0A   *
+.ns to
  %22se
@@ -1290,16 +1290,21 @@
 erGroup%22
+%0A   *
  would b

fix javadocs to unbreak travis (#1830)