# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.

module Azure::CDN::Mgmt::V2020_09_01
  #
  # Cdn Management Client
  #
  class LogAnalytics
    include MsRestAzure

    #
    # Creates and initializes a new instance of the LogAnalytics class.
    # @param client service class for accessing basic functionality.
    #
    def initialize(client)
      @client = client
    end

    # @return [CdnManagementClient] reference to the CdnManagementClient
    attr_reader :client

    #
    # Get log report for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param granularity [Enum] Possible values include: 'PT5M', 'PT1H', 'P1D'
    # @param group_by [Array<Enum>]
    # @param continents [Array<String>]
    # @param country_or_regions [Array<String>]
    # @param custom_domains [Array<String>]
    # @param protocols [Array<String>]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MetricsResponse] operation results.
    #
    def get_log_analytics_metrics(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, group_by:nil, continents:nil, country_or_regions:nil, custom_domains:nil, protocols:nil, custom_headers:nil)
      response = get_log_analytics_metrics_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, group_by:group_by, continents:continents, country_or_regions:country_or_regions, custom_domains:custom_domains, protocols:protocols, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Get log report for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param granularity [Enum] Possible values include: 'PT5M', 'PT1H', 'P1D'
    # @param group_by [Array<Enum>]
    # @param continents [Array<String>]
    # @param country_or_regions [Array<String>]
    # @param custom_domains [Array<String>]
    # @param protocols [Array<String>]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def get_log_analytics_metrics_with_http_info(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, group_by:nil, continents:nil, country_or_regions:nil, custom_domains:nil, protocols:nil, custom_headers:nil)
      get_log_analytics_metrics_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, group_by:group_by, continents:continents, country_or_regions:country_or_regions, custom_domains:custom_domains, protocols:protocols, custom_headers:custom_headers).value!
    end

    #
    # Get log report for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param granularity [Enum] Possible values include: 'PT5M', 'PT1H', 'P1D'
    # @param group_by [Array<Enum>]
    # @param continents [Array<String>]
    # @param country_or_regions [Array<String>]
    # @param custom_domains [Array<String>]
    # @param protocols [Array<String>]
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def get_log_analytics_metrics_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, group_by:nil, continents:nil, country_or_regions:nil, custom_domains:nil, protocols:nil, custom_headers:nil)
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, 'profile_name is nil' if profile_name.nil?
      fail ArgumentError, 'metrics is nil' if metrics.nil?
      fail ArgumentError, 'date_time_begin is nil' if date_time_begin.nil?
      fail ArgumentError, 'date_time_end is nil' if date_time_end.nil?
      fail ArgumentError, 'granularity is nil' if granularity.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsMetrics'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'profileName' => profile_name},
          query_params: {'api-version' => @client.api_version,'metrics' => metrics.nil? ? nil : metrics.join(','),'dateTimeBegin' => date_time_begin,'dateTimeEnd' => date_time_end,'granularity' => granularity,'groupBy' => group_by.nil? ? nil : group_by.join(','),'continents' => continents.nil? ? nil : continents.join(','),'countryOrRegions' => country_or_regions.nil? ? nil : country_or_regions.join(','),'customDomains' => custom_domains.nil? ? nil : custom_domains.join(','),'protocols' => protocols.nil? ? nil : protocols.join(',')},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::CDN::Mgmt::V2020_09_01::Models::MetricsResponse.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Get log analytics ranking report for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param rankings [Array<Enum>]
    # @param metrics [Array<Enum>]
    # @param max_ranking [Float]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param custom_domains [Array<String>]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [RankingsResponse] operation results.
    #
    def get_log_analytics_rankings(resource_group_name, profile_name, rankings, metrics, max_ranking, date_time_begin, date_time_end, custom_domains:nil, custom_headers:nil)
      response = get_log_analytics_rankings_async(resource_group_name, profile_name, rankings, metrics, max_ranking, date_time_begin, date_time_end, custom_domains:custom_domains, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Get log analytics ranking report for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param rankings [Array<Enum>]
    # @param metrics [Array<Enum>]
    # @param max_ranking [Float]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param custom_domains [Array<String>]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def get_log_analytics_rankings_with_http_info(resource_group_name, profile_name, rankings, metrics, max_ranking, date_time_begin, date_time_end, custom_domains:nil, custom_headers:nil)
      get_log_analytics_rankings_async(resource_group_name, profile_name, rankings, metrics, max_ranking, date_time_begin, date_time_end, custom_domains:custom_domains, custom_headers:custom_headers).value!
    end

    #
    # Get log analytics ranking report for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param rankings [Array<Enum>]
    # @param metrics [Array<Enum>]
    # @param max_ranking [Float]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param custom_domains [Array<String>]
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def get_log_analytics_rankings_async(resource_group_name, profile_name, rankings, metrics, max_ranking, date_time_begin, date_time_end, custom_domains:nil, custom_headers:nil)
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, 'profile_name is nil' if profile_name.nil?
      fail ArgumentError, 'rankings is nil' if rankings.nil?
      fail ArgumentError, 'metrics is nil' if metrics.nil?
      fail ArgumentError, 'max_ranking is nil' if max_ranking.nil?
      fail ArgumentError, 'date_time_begin is nil' if date_time_begin.nil?
      fail ArgumentError, 'date_time_end is nil' if date_time_end.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsRankings'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'profileName' => profile_name},
          query_params: {'api-version' => @client.api_version,'rankings' => rankings.nil? ? nil : rankings.join(','),'metrics' => metrics.nil? ? nil : metrics.join(','),'maxRanking' => max_ranking,'dateTimeBegin' => date_time_begin,'dateTimeEnd' => date_time_end,'customDomains' => custom_domains.nil? ? nil : custom_domains.join(',')},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::CDN::Mgmt::V2020_09_01::Models::RankingsResponse.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Get all available location names for AFD log analytics report.
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [ContinentsResponse] operation results.
    #
    def get_log_analytics_locations(resource_group_name, profile_name, custom_headers:nil)
      response = get_log_analytics_locations_async(resource_group_name, profile_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Get all available location names for AFD log analytics report.
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def get_log_analytics_locations_with_http_info(resource_group_name, profile_name, custom_headers:nil)
      get_log_analytics_locations_async(resource_group_name, profile_name, custom_headers:custom_headers).value!
    end

    #
    # Get all available location names for AFD log analytics report.
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def get_log_analytics_locations_async(resource_group_name, profile_name, custom_headers:nil)
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, 'profile_name is nil' if profile_name.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsLocations'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'profileName' => profile_name},
          query_params: {'api-version' => @client.api_version},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::CDN::Mgmt::V2020_09_01::Models::ContinentsResponse.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Get all endpoints and custom domains available for AFD log report
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [ResourcesResponse] operation results.
    #
    def get_log_analytics_resources(resource_group_name, profile_name, custom_headers:nil)
      response = get_log_analytics_resources_async(resource_group_name, profile_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Get all endpoints and custom domains available for AFD log report
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def get_log_analytics_resources_with_http_info(resource_group_name, profile_name, custom_headers:nil)
      get_log_analytics_resources_async(resource_group_name, profile_name, custom_headers:custom_headers).value!
    end

    #
    # Get all endpoints and custom domains available for AFD log report
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def get_log_analytics_resources_async(resource_group_name, profile_name, custom_headers:nil)
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, 'profile_name is nil' if profile_name.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsResources'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'profileName' => profile_name},
          query_params: {'api-version' => @client.api_version},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::CDN::Mgmt::V2020_09_01::Models::ResourcesResponse.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Get Waf related log analytics report for AFD profile.
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param granularity [Enum] Possible values include: 'PT5M', 'PT1H', 'P1D'
    # @param actions [Array<Enum>]
    # @param group_by [Array<Enum>]
    # @param rule_types [Array<Enum>]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [WafMetricsResponse] operation results.
    #
    def get_waf_log_analytics_metrics(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, actions:nil, group_by:nil, rule_types:nil, custom_headers:nil)
      response = get_waf_log_analytics_metrics_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, actions:actions, group_by:group_by, rule_types:rule_types, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Get Waf related log analytics report for AFD profile.
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param granularity [Enum] Possible values include: 'PT5M', 'PT1H', 'P1D'
    # @param actions [Array<Enum>]
    # @param group_by [Array<Enum>]
    # @param rule_types [Array<Enum>]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def get_waf_log_analytics_metrics_with_http_info(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, actions:nil, group_by:nil, rule_types:nil, custom_headers:nil)
      get_waf_log_analytics_metrics_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, actions:actions, group_by:group_by, rule_types:rule_types, custom_headers:custom_headers).value!
    end

    #
    # Get Waf related log analytics report for AFD profile.
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param granularity [Enum] Possible values include: 'PT5M', 'PT1H', 'P1D'
    # @param actions [Array<Enum>]
    # @param group_by [Array<Enum>]
    # @param rule_types [Array<Enum>]
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def get_waf_log_analytics_metrics_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, granularity, actions:nil, group_by:nil, rule_types:nil, custom_headers:nil)
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, 'profile_name is nil' if profile_name.nil?
      fail ArgumentError, 'metrics is nil' if metrics.nil?
      fail ArgumentError, 'date_time_begin is nil' if date_time_begin.nil?
      fail ArgumentError, 'date_time_end is nil' if date_time_end.nil?
      fail ArgumentError, 'granularity is nil' if granularity.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsMetrics'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'profileName' => profile_name},
          query_params: {'api-version' => @client.api_version,'metrics' => metrics.nil? ? nil : metrics.join(','),'dateTimeBegin' => date_time_begin,'dateTimeEnd' => date_time_end,'granularity' => granularity,'actions' => actions.nil? ? nil : actions.join(','),'groupBy' => group_by.nil? ? nil : group_by.join(','),'ruleTypes' => rule_types.nil? ? nil : rule_types.join(',')},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::CDN::Mgmt::V2020_09_01::Models::WafMetricsResponse.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Get WAF log analytics charts for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param max_ranking [Float]
    # @param rankings [Array<Enum>]
    # @param actions [Array<Enum>]
    # @param rule_types [Array<Enum>]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [WafRankingsResponse] operation results.
    #
    def get_waf_log_analytics_rankings(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, max_ranking, rankings, actions:nil, rule_types:nil, custom_headers:nil)
      response = get_waf_log_analytics_rankings_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, max_ranking, rankings, actions:actions, rule_types:rule_types, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Get WAF log analytics charts for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param max_ranking [Float]
    # @param rankings [Array<Enum>]
    # @param actions [Array<Enum>]
    # @param rule_types [Array<Enum>]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def get_waf_log_analytics_rankings_with_http_info(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, max_ranking, rankings, actions:nil, rule_types:nil, custom_headers:nil)
      get_waf_log_analytics_rankings_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, max_ranking, rankings, actions:actions, rule_types:rule_types, custom_headers:custom_headers).value!
    end

    #
    # Get WAF log analytics charts for AFD profile
    #
    # @param resource_group_name [String] Name of the Resource group within the
    # Azure subscription.
    # @param profile_name [String] Name of the CDN profile which is unique within
    # the resource group.
    # @param metrics [Array<Enum>]
    # @param date_time_begin [DateTime]
    # @param date_time_end [DateTime]
    # @param max_ranking [Float]
    # @param rankings [Array<Enum>]
    # @param actions [Array<Enum>]
    # @param rule_types [Array<Enum>]
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def get_waf_log_analytics_rankings_async(resource_group_name, profile_name, metrics, date_time_begin, date_time_end, max_ranking, rankings, actions:nil, rule_types:nil, custom_headers:nil)
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, 'profile_name is nil' if profile_name.nil?
      fail ArgumentError, 'metrics is nil' if metrics.nil?
      fail ArgumentError, 'date_time_begin is nil' if date_time_begin.nil?
      fail ArgumentError, 'date_time_end is nil' if date_time_end.nil?
      fail ArgumentError, 'max_ranking is nil' if max_ranking.nil?
      fail ArgumentError, 'rankings is nil' if rankings.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsRankings'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'profileName' => profile_name},
          query_params: {'api-version' => @client.api_version,'metrics' => metrics.nil? ? nil : metrics.join(','),'dateTimeBegin' => date_time_begin,'dateTimeEnd' => date_time_end,'maxRanking' => max_ranking,'rankings' => rankings.nil? ? nil : rankings.join(','),'actions' => actions.nil? ? nil : actions.join(','),'ruleTypes' => rule_types.nil? ? nil : rule_types.join(',')},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::CDN::Mgmt::V2020_09_01::Models::WafRankingsResponse.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

  end
end
