/*
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is
 * regenerated.
 */

'use strict';

const models = require('./index');

/**
 * External OAuth authorization server settings.
 *
 * @extends models['Resource']
 */
class AuthorizationServerContract extends models['Resource'] {
  /**
   * Create a AuthorizationServerContract.
   * @property {string} [description] Description of the authorization server.
   * Can contain HTML formatting tags.
   * @property {array} [authorizationMethods] HTTP verbs supported by the
   * authorization endpoint. GET must be always present. POST is optional.
   * @property {array} [clientAuthenticationMethod] Method of authentication
   * supported by the token endpoint of this authorization server. Possible
   * values are Basic and/or Body. When Body is specified, client credentials
   * and other parameters are passed within the request body in the
   * application/x-www-form-urlencoded format.
   * @property {array} [tokenBodyParameters] Additional parameters required by
   * the token endpoint of this authorization server represented as an array of
   * JSON objects with name and value string properties, i.e. {"name" : "name
   * value", "value": "a value"}.
   * @property {string} [tokenEndpoint] OAuth token endpoint. Contains absolute
   * URI to entity being referenced.
   * @property {boolean} [supportState] If true, authorization server will
   * include state parameter from the authorization request to its response.
   * Client may use state parameter to raise protocol security.
   * @property {string} [defaultScope] Access token scope that is going to be
   * requested by default. Can be overridden at the API level. Should be
   * provided in the form of a string containing space-delimited values.
   * @property {array} [bearerTokenSendingMethods] Specifies the mechanism by
   * which access token is passed to the API.
   * @property {string} [resourceOwnerUsername] Can be optionally specified
   * when resource owner password grant type is supported by this authorization
   * server. Default resource owner username.
   * @property {string} [resourceOwnerPassword] Can be optionally specified
   * when resource owner password grant type is supported by this authorization
   * server. Default resource owner password.
   * @property {string} displayName User-friendly authorization server name.
   * @property {string} clientRegistrationEndpoint Optional reference to a page
   * where client or app registration for this authorization server is
   * performed. Contains absolute URL to entity being referenced.
   * @property {string} authorizationEndpoint OAuth authorization endpoint. See
   * http://tools.ietf.org/html/rfc6749#section-3.2.
   * @property {array} grantTypes Form of an authorization grant, which the
   * client uses to request the access token.
   * @property {string} clientId Client or app id registered with this
   * authorization server.
   * @property {string} [clientSecret] Client or app secret registered with
   * this authorization server. This property will not be filled on 'GET'
   * operations! Use '/listSecrets' POST request to get the value.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of AuthorizationServerContract
   *
   * @returns {object} metadata of AuthorizationServerContract
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'AuthorizationServerContract',
      type: {
        name: 'Composite',
        className: 'AuthorizationServerContract',
        modelProperties: {
          id: {
            required: false,
            readOnly: true,
            serializedName: 'id',
            type: {
              name: 'String'
            }
          },
          name: {
            required: false,
            readOnly: true,
            serializedName: 'name',
            type: {
              name: 'String'
            }
          },
          type: {
            required: false,
            readOnly: true,
            serializedName: 'type',
            type: {
              name: 'String'
            }
          },
          description: {
            required: false,
            serializedName: 'properties.description',
            type: {
              name: 'String'
            }
          },
          authorizationMethods: {
            required: false,
            serializedName: 'properties.authorizationMethods',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'AuthorizationMethodElementType',
                  type: {
                    name: 'Enum',
                    allowedValues: [ 'HEAD', 'OPTIONS', 'TRACE', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE' ]
                  }
              }
            }
          },
          clientAuthenticationMethod: {
            required: false,
            serializedName: 'properties.clientAuthenticationMethod',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ClientAuthenticationMethodElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          tokenBodyParameters: {
            required: false,
            serializedName: 'properties.tokenBodyParameters',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'TokenBodyParameterContractElementType',
                  type: {
                    name: 'Composite',
                    className: 'TokenBodyParameterContract'
                  }
              }
            }
          },
          tokenEndpoint: {
            required: false,
            serializedName: 'properties.tokenEndpoint',
            type: {
              name: 'String'
            }
          },
          supportState: {
            required: false,
            serializedName: 'properties.supportState',
            type: {
              name: 'Boolean'
            }
          },
          defaultScope: {
            required: false,
            serializedName: 'properties.defaultScope',
            type: {
              name: 'String'
            }
          },
          bearerTokenSendingMethods: {
            required: false,
            serializedName: 'properties.bearerTokenSendingMethods',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'BearerTokenSendingMethodElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          resourceOwnerUsername: {
            required: false,
            serializedName: 'properties.resourceOwnerUsername',
            type: {
              name: 'String'
            }
          },
          resourceOwnerPassword: {
            required: false,
            serializedName: 'properties.resourceOwnerPassword',
            type: {
              name: 'String'
            }
          },
          displayName: {
            required: true,
            serializedName: 'properties.displayName',
            constraints: {
              MaxLength: 50,
              MinLength: 1
            },
            type: {
              name: 'String'
            }
          },
          clientRegistrationEndpoint: {
            required: true,
            serializedName: 'properties.clientRegistrationEndpoint',
            type: {
              name: 'String'
            }
          },
          authorizationEndpoint: {
            required: true,
            serializedName: 'properties.authorizationEndpoint',
            type: {
              name: 'String'
            }
          },
          grantTypes: {
            required: true,
            serializedName: 'properties.grantTypes',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'GrantTypeElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          clientId: {
            required: true,
            serializedName: 'properties.clientId',
            type: {
              name: 'String'
            }
          },
          clientSecret: {
            required: false,
            serializedName: 'properties.clientSecret',
            type: {
              name: 'String'
            }
          }
        }
      }
    };
  }
}

module.exports = AuthorizationServerContract;
