# ApiMethod

com.google.api.server.spi.config

## Annotation Type ApiMethod

-

  *** ** * ** ***

  <br />

  ```
  @Retention(value=RUNTIME)
   @Target(value=METHOD)
  public @interface ApiMethod
  ```
  Annotation for API method configuration.
-
  -

    ### Optional Element Summary

    | Modifier and Type | Optional Element and Description |
    |---|---|
    | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/AnnotationBoolean.html` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#apiKeyRequired--` Whether or not an API key is required. |
    | `java.lang.String[]` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#audiences--` Audience for IdTokens. |
    | `java.lang.Class<? extends https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/Authenticator.html>[]` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#authenticators--` Custom authenticators used for authentication for this method. |
    | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/AuthLevel.html` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#authLevel--` Set frontend auth level. |
    | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethodCacheControl.html` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#cacheControl--` Deprecated. ApiMethodCacheControl is deprecated and will be removed in a future version of Cloud Endpoints. |
    | `java.lang.String[]` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#clientIds--` Client IDs allowed to call this method. |
    | `java.lang.String` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#description--` Description of this API method. |
    | `java.lang.String` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#httpMethod--` The HTTP method to use to access this method. |
    | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/AnnotationBoolean.html` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#ignored--` Whether or not API method should be ignored. |
    | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiIssuerAudience.html[]` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#issuerAudiences--` Audiences for individual issuers. |
    | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMetricCost.html[]` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#metricCosts--` A list of metric costs associated with this method. |
    | `java.lang.String` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#name--` The name for this method in the .api file. |
    | `java.lang.String` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#path--` The URI path to use to access this method. |
    | `java.lang.Class<? extends PeerAuthenticator>[]` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#peerAuthenticators--` Custom peer authenticators used to verify peer for this method. |
    | `java.lang.String[]` | `https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethod.html#scopes--` OAuth 2 scopes, one of which is required for calling this method. |
    [Optional Elements]

-
  -

    ### Element Detail


    -

      #### name

      ```
      public abstract java.lang.String name
      ```
      The name for this method in the .api file. This will automatically be prefixed with `"<apiname>."` to create a unique name for the method. If not set the method name will be derived from the Java method name.

      Default:
      :   ""

  <!-- -->

  -

    -

      #### description

      ```
      public abstract java.lang.String description
      ```
      Description of this API method. This will be exposed in the discovery service to describe your API method, and may also be used to generate documentation.

      Default:
      :   ""

  <!-- -->

  -

    -

      #### path

      ```
      public abstract java.lang.String path
      ```
      The URI path to use to access this method. If not set a default will be created based on the Java method name.

      Default:
      :   ""

  <!-- -->

  -

    -

      #### httpMethod

      ```
      public abstract java.lang.String httpMethod
      ```
      The HTTP method to use to access this method. If not set a default will be chosen based on the name of the method.

      Default:
      :   ""

  <!-- -->

  -

    -

      #### cacheControl

      ```
      @Deprecated
      public abstract ApiMethodCacheControl cacheControl
      ```
      Deprecated. ApiMethodCacheControl is deprecated and will be removed in a future version of Cloud Endpoints. Cache-Control header settings for this method. See [`ApiMethodCacheControl`](https://docs.cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiMethodCacheControl.html "annotation in com.google.api.server.spi.config") for details.

      Default:
      :   @com.google.api.server.spi.config.ApiMethodCacheControl

  <!-- -->

  -

    -

      #### authLevel

      ```
      public abstract AuthLevel authLevel
      ```
      Set frontend auth level.

      Default:
      :   com.google.api.server.spi.config.AuthLevel.UNSPECIFIED

  <!-- -->

  -

    -

      #### scopes

      ```
      public abstract java.lang.String[] scopes
      ```
      OAuth 2 scopes, one of which is required for calling this method.

      Default:
      :   "_UNSPECIFIED_LIST_STRING_VALUE"

  <!-- -->

  -

    -

      #### audiences

      ```
      public abstract java.lang.String[] audiences
      ```
      Audience for IdTokens.

      Default:
      :   "_UNSPECIFIED_LIST_STRING_VALUE"

  <!-- -->

  -

    -

      #### issuerAudiences

      ```
      public abstract ApiIssuerAudience[] issuerAudiences
      ```
      Audiences for individual issuers. This is only meant to be used with EspAuthenticator in endpoints-framework-auth.

      Default:
      :   @com.google.api.server.spi.config.ApiIssuerAudience(name="_UNSPECIFIED_LIST_STRING_VALUE", audiences="_UNSPECIFIED_LIST_STRING_VALUE")

  <!-- -->

  -

    -

      #### clientIds

      ```
      public abstract java.lang.String[] clientIds
      ```
      Client IDs allowed to call this method.

      Default:
      :   "_UNSPECIFIED_LIST_STRING_VALUE"

  <!-- -->

  -

    -

      #### authenticators

      ```
      public abstract java.lang.Class<? extends Authenticator>[] authenticators
      ```
      Custom authenticators used for authentication for this method.

      Default:
      :   com.google.api.server.spi.config.Authenticator.class

  <!-- -->

  -

    -

      #### peerAuthenticators

      ```
      public abstract java.lang.Class<? extends PeerAuthenticator>[] peerAuthenticators
      ```
      Custom peer authenticators used to verify peer for this method.

      Default:
      :   \<error\>

  <!-- -->

  -

    -

      #### ignored

      ```
      public abstract AnnotationBoolean ignored
      ```
      Whether or not API method should be ignored.

      Default:
      :   com.google.api.server.spi.config.AnnotationBoolean.UNSPECIFIED

  <!-- -->

  -

    -

      #### apiKeyRequired

      ```
      public abstract AnnotationBoolean apiKeyRequired
      ```
      Whether or not an API key is required. This is used to output a Swagger specification and has no effect unless used with endpoints-management-control-appengine.

      Default:
      :   com.google.api.server.spi.config.AnnotationBoolean.UNSPECIFIED

  <!-- -->

  -

    -

      #### metricCosts

      ```
      public abstract ApiMetricCost[] metricCosts
      ```
      A list of metric costs associated with this method.

      Default:
      :   {}