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

module MobileCenterApi
  #
  # Microsoft Visual Studio Mobile Center API
  #
  class Crashes

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

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

    #
    # Gets a list of application versions
    #
    # Gets a list of application versions
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Array] operation results.
    #
    def get_app_versions(owner_name, app_name, custom_headers = nil)
      response = get_app_versions_async(owner_name, app_name, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets a list of application versions
    #
    # Gets a list of application versions
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_app_versions_with_http_info(owner_name, app_name, custom_headers = nil)
      get_app_versions_async(owner_name, app_name, custom_headers).value!
    end

    #
    # Gets a list of application versions
    #
    # Gets a list of application versions
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @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_app_versions_async(owner_name, app_name, custom_headers = nil)
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/versions'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'owner_name' => owner_name,'app_name' => app_name},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = {
              required: false,
              serialized_name: 'parsed_response',
              type: {
                name: 'Sequence',
                element: {
                    required: false,
                    serialized_name: 'AppVersionElementType',
                    type: {
                      name: 'Composite',
                      class_name: 'AppVersion'
                    }
                }
              }
            }
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets whether the application has any crashes
    #
    # Gets whether the application has any crashes
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [AppCrashesInfo] operation results.
    #
    def get_crash_info(owner_name, app_name, custom_headers = nil)
      response = get_crash_info_async(owner_name, app_name, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets whether the application has any crashes
    #
    # Gets whether the application has any crashes
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_info_with_http_info(owner_name, app_name, custom_headers = nil)
      get_crash_info_async(owner_name, app_name, custom_headers).value!
    end

    #
    # Gets whether the application has any crashes
    #
    # Gets whether the application has any crashes
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @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_crash_info_async(owner_name, app_name, custom_headers = nil)
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crashes_info'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'owner_name' => owner_name,'app_name' => app_name},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = MobileCenterApi::Models::AppCrashesInfo.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets url to download attachment
    #
    # @param crash_id [String] id of a specific error
    # @param attachment_id [String] attachment id
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [String] operation results.
    #
    def get_crash_attachment_url(crash_id, attachment_id, owner_name, app_name, custom_headers = nil)
      response = get_crash_attachment_url_async(crash_id, attachment_id, owner_name, app_name, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets url to download attachment
    #
    # @param crash_id [String] id of a specific error
    # @param attachment_id [String] attachment id
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_attachment_url_with_http_info(crash_id, attachment_id, owner_name, app_name, custom_headers = nil)
      get_crash_attachment_url_async(crash_id, attachment_id, owner_name, app_name, custom_headers).value!
    end

    #
    # Gets url to download attachment
    #
    # @param crash_id [String] id of a specific error
    # @param attachment_id [String] attachment id
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @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_crash_attachment_url_async(crash_id, attachment_id, owner_name, app_name, custom_headers = nil)
      fail ArgumentError, 'crash_id is nil' if crash_id.nil?
      fail ArgumentError, 'attachment_id is nil' if attachment_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crashes/{crash_id}/attachments/{attachment_id}/url'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_id' => crash_id,'attachment_id' => attachment_id,'owner_name' => owner_name,'app_name' => app_name},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = {
              required: false,
              serialized_name: 'parsed_response',
              type: {
                name: 'String'
              }
            }
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets content of the text attachment
    #
    # @param crash_id [String] id of a specific error
    # @param attachment_id [String] attachment id
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [String] operation results.
    #
    def get_crash_text_attachment_content(crash_id, attachment_id, owner_name, app_name, custom_headers = nil)
      response = get_crash_text_attachment_content_async(crash_id, attachment_id, owner_name, app_name, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets content of the text attachment
    #
    # @param crash_id [String] id of a specific error
    # @param attachment_id [String] attachment id
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_text_attachment_content_with_http_info(crash_id, attachment_id, owner_name, app_name, custom_headers = nil)
      get_crash_text_attachment_content_async(crash_id, attachment_id, owner_name, app_name, custom_headers).value!
    end

    #
    # Gets content of the text attachment
    #
    # @param crash_id [String] id of a specific error
    # @param attachment_id [String] attachment id
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @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_crash_text_attachment_content_async(crash_id, attachment_id, owner_name, app_name, custom_headers = nil)
      fail ArgumentError, 'crash_id is nil' if crash_id.nil?
      fail ArgumentError, 'attachment_id is nil' if attachment_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crashes/{crash_id}/attachments/{attachment_id}/text'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_id' => crash_id,'attachment_id' => attachment_id,'owner_name' => owner_name,'app_name' => app_name},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = {
              required: false,
              serialized_name: 'parsed_response',
              type: {
                name: 'String'
              }
            }
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets all attachments for a specific error
    #
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Array] operation results.
    #
    def get_crash_attachments(crash_id, owner_name, app_name, custom_headers = nil)
      response = get_crash_attachments_async(crash_id, owner_name, app_name, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets all attachments for a specific error
    #
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_attachments_with_http_info(crash_id, owner_name, app_name, custom_headers = nil)
      get_crash_attachments_async(crash_id, owner_name, app_name, custom_headers).value!
    end

    #
    # Gets all attachments for a specific error
    #
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @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_crash_attachments_async(crash_id, owner_name, app_name, custom_headers = nil)
      fail ArgumentError, 'crash_id is nil' if crash_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crashes/{crash_id}/attachments'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_id' => crash_id,'owner_name' => owner_name,'app_name' => app_name},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = {
              required: false,
              serialized_name: 'parsed_response',
              type: {
                name: 'Sequence',
                element: {
                    required: false,
                    serialized_name: 'CrashAttachmentElementType',
                    type: {
                      name: 'Composite',
                      class_name: 'CrashAttachment'
                    }
                }
              }
            }
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets a stacktrace for a specific error
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param grouping_only [Boolean] true if the stacktrace should be only the
    # relevant thread / exception. Default is false
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Stacktrace] operation results.
    #
    def get_group_stacktrace(crash_group_id, owner_name, app_name, grouping_only = false, custom_headers = nil)
      response = get_group_stacktrace_async(crash_group_id, owner_name, app_name, grouping_only, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets a stacktrace for a specific error
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param grouping_only [Boolean] true if the stacktrace should be only the
    # relevant thread / exception. Default is false
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_group_stacktrace_with_http_info(crash_group_id, owner_name, app_name, grouping_only = false, custom_headers = nil)
      get_group_stacktrace_async(crash_group_id, owner_name, app_name, grouping_only, custom_headers).value!
    end

    #
    # Gets a stacktrace for a specific error
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param grouping_only [Boolean] true if the stacktrace should be only the
    # relevant thread / exception. Default is false
    # @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_group_stacktrace_async(crash_group_id, owner_name, app_name, grouping_only = false, custom_headers = nil)
      fail ArgumentError, 'crash_group_id is nil' if crash_group_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}/stacktrace'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_group_id' => crash_group_id,'owner_name' => owner_name,'app_name' => app_name},
          query_params: {'grouping_only' => grouping_only},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = MobileCenterApi::Models::Stacktrace.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets a stacktrace for a specific error
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param grouping_only [Boolean] true if the stacktrace should be only the
    # relevant thread / exception. Default is false
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Stacktrace] operation results.
    #
    def get_error_stacktrace(crash_group_id, crash_id, owner_name, app_name, grouping_only = false, custom_headers = nil)
      response = get_error_stacktrace_async(crash_group_id, crash_id, owner_name, app_name, grouping_only, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets a stacktrace for a specific error
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param grouping_only [Boolean] true if the stacktrace should be only the
    # relevant thread / exception. Default is false
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_error_stacktrace_with_http_info(crash_group_id, crash_id, owner_name, app_name, grouping_only = false, custom_headers = nil)
      get_error_stacktrace_async(crash_group_id, crash_id, owner_name, app_name, grouping_only, custom_headers).value!
    end

    #
    # Gets a stacktrace for a specific error
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param grouping_only [Boolean] true if the stacktrace should be only the
    # relevant thread / exception. Default is false
    # @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_error_stacktrace_async(crash_group_id, crash_id, owner_name, app_name, grouping_only = false, custom_headers = nil)
      fail ArgumentError, 'crash_group_id is nil' if crash_group_id.nil?
      fail ArgumentError, 'crash_id is nil' if crash_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}/crashes/{crash_id}/stacktrace'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_group_id' => crash_group_id,'crash_id' => crash_id,'owner_name' => owner_name,'app_name' => app_name},
          query_params: {'grouping_only' => grouping_only},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = MobileCenterApi::Models::Stacktrace.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets the URL to download json of a specific crash
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CrashRawUrl] operation results.
    #
    def get_crash_raw_url(crash_group_id, crash_id, owner_name, app_name, custom_headers = nil)
      response = get_crash_raw_url_async(crash_group_id, crash_id, owner_name, app_name, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets the URL to download json of a specific crash
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_raw_url_with_http_info(crash_group_id, crash_id, owner_name, app_name, custom_headers = nil)
      get_crash_raw_url_async(crash_group_id, crash_id, owner_name, app_name, custom_headers).value!
    end

    #
    # Gets the URL to download json of a specific crash
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @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_crash_raw_url_async(crash_group_id, crash_id, owner_name, app_name, custom_headers = nil)
      fail ArgumentError, 'crash_group_id is nil' if crash_group_id.nil?
      fail ArgumentError, 'crash_id is nil' if crash_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}/crashes/{crash_id}/raw_url'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_group_id' => crash_group_id,'crash_id' => crash_id,'owner_name' => owner_name,'app_name' => app_name},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = MobileCenterApi::Models::CrashRawUrl.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets a specific error for an app
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param include_report [Boolean] true if the error should include the raw
    # error report. Default is false
    # @param include_log [Boolean] true if the error should include the custom log
    # report. Default is false
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Crash] operation results.
    #
    def get_crash(crash_group_id, crash_id, owner_name, app_name, include_report = false, include_log = false, custom_headers = nil)
      response = get_crash_async(crash_group_id, crash_id, owner_name, app_name, include_report, include_log, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets a specific error for an app
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param include_report [Boolean] true if the error should include the raw
    # error report. Default is false
    # @param include_log [Boolean] true if the error should include the custom log
    # report. Default is false
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_with_http_info(crash_group_id, crash_id, owner_name, app_name, include_report = false, include_log = false, custom_headers = nil)
      get_crash_async(crash_group_id, crash_id, owner_name, app_name, include_report, include_log, custom_headers).value!
    end

    #
    # Gets a specific error for an app
    #
    # @param crash_group_id [String] id of a specific group
    # @param crash_id [String] id of a specific error
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param include_report [Boolean] true if the error should include the raw
    # error report. Default is false
    # @param include_log [Boolean] true if the error should include the custom log
    # report. Default is false
    # @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_crash_async(crash_group_id, crash_id, owner_name, app_name, include_report = false, include_log = false, custom_headers = nil)
      fail ArgumentError, 'crash_group_id is nil' if crash_group_id.nil?
      fail ArgumentError, 'crash_id is nil' if crash_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}/crashes/{crash_id}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_group_id' => crash_group_id,'crash_id' => crash_id,'owner_name' => owner_name,'app_name' => app_name},
          query_params: {'include_report' => include_report,'include_log' => include_log},
          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 == 201
          error_model = JSON.load(response_content)
          fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
        end

        # Deserialize Response
        if status_code == 201
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = MobileCenterApi::Models::Crash.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets all crashes of the app
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param include_report [Boolean] true if the error should include the raw
    # error report. Default is false
    # @param include_log [Boolean] true if the error should include the custom log
    # report. Default is false
    # @param date_from [DateTime]
    # @param date_to [DateTime]
    # @param app_version [String] version
    # @param error_type [Enum] Possible values include: 'CrashingErrors',
    # 'HandledErrors'
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Array] operation results.
    #
    def get_crashes(crash_group_id, owner_name, app_name, include_report = false, include_log = false, date_from = nil, date_to = nil, app_version = nil, error_type = nil, custom_headers = nil)
      response = get_crashes_async(crash_group_id, owner_name, app_name, include_report, include_log, date_from, date_to, app_version, error_type, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets all crashes of the app
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param include_report [Boolean] true if the error should include the raw
    # error report. Default is false
    # @param include_log [Boolean] true if the error should include the custom log
    # report. Default is false
    # @param date_from [DateTime]
    # @param date_to [DateTime]
    # @param app_version [String] version
    # @param error_type [Enum] Possible values include: 'CrashingErrors',
    # 'HandledErrors'
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crashes_with_http_info(crash_group_id, owner_name, app_name, include_report = false, include_log = false, date_from = nil, date_to = nil, app_version = nil, error_type = nil, custom_headers = nil)
      get_crashes_async(crash_group_id, owner_name, app_name, include_report, include_log, date_from, date_to, app_version, error_type, custom_headers).value!
    end

    #
    # Gets all crashes of the app
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param include_report [Boolean] true if the error should include the raw
    # error report. Default is false
    # @param include_log [Boolean] true if the error should include the custom log
    # report. Default is false
    # @param date_from [DateTime]
    # @param date_to [DateTime]
    # @param app_version [String] version
    # @param error_type [Enum] Possible values include: 'CrashingErrors',
    # 'HandledErrors'
    # @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_crashes_async(crash_group_id, owner_name, app_name, include_report = false, include_log = false, date_from = nil, date_to = nil, app_version = nil, error_type = nil, custom_headers = nil)
      fail ArgumentError, 'crash_group_id is nil' if crash_group_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}/crashes'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_group_id' => crash_group_id,'owner_name' => owner_name,'app_name' => app_name},
          query_params: {'include_report' => include_report,'include_log' => include_log,'date_from' => date_from,'date_to' => date_to,'app_version' => app_version,'error_type' => error_type},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = {
              required: false,
              serialized_name: 'parsed_response',
              type: {
                name: 'Sequence',
                element: {
                    required: false,
                    serialized_name: 'CrashElementType',
                    type: {
                      name: 'Composite',
                      class_name: 'Crash'
                    }
                }
              }
            }
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets a specific group
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CrashGroup] operation results.
    #
    def get_crash_group(crash_group_id, owner_name, app_name, custom_headers = nil)
      response = get_crash_group_async(crash_group_id, owner_name, app_name, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets a specific group
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_group_with_http_info(crash_group_id, owner_name, app_name, custom_headers = nil)
      get_crash_group_async(crash_group_id, owner_name, app_name, custom_headers).value!
    end

    #
    # Gets a specific group
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @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_crash_group_async(crash_group_id, owner_name, app_name, custom_headers = nil)
      fail ArgumentError, 'crash_group_id is nil' if crash_group_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_group_id' => crash_group_id,'owner_name' => owner_name,'app_name' => app_name},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = MobileCenterApi::Models::CrashGroup.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Updates a group
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param status
    # @param annotation [String]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CrashGroup] operation results.
    #
    def patch_crash_group(crash_group_id, owner_name, app_name, status = nil, annotation = nil, custom_headers = nil)
      response = patch_crash_group_async(crash_group_id, owner_name, app_name, status, annotation, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Updates a group
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param status
    # @param annotation [String]
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def patch_crash_group_with_http_info(crash_group_id, owner_name, app_name, status = nil, annotation = nil, custom_headers = nil)
      patch_crash_group_async(crash_group_id, owner_name, app_name, status, annotation, custom_headers).value!
    end

    #
    # Updates a group
    #
    # @param crash_group_id [String] id of a specific group
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param status
    # @param annotation [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 patch_crash_group_async(crash_group_id, owner_name, app_name, status = nil, annotation = nil, custom_headers = nil)
      fail ArgumentError, 'crash_group_id is nil' if crash_group_id.nil?
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?

      group = CrashGroupChange.new
      unless status.nil? && annotation.nil?
        group.status = status
        group.annotation = annotation
      end

      request_headers = {}

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

      # Serialize Request
      request_mapper = MobileCenterApi::Models::CrashGroupChange.mapper()
      request_content = @client.serialize(request_mapper,  group, 'group')
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'crash_group_id' => crash_group_id,'owner_name' => owner_name,'app_name' => app_name},
          body: request_content,
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:patch, 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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = MobileCenterApi::Models::CrashGroup.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # Gets a list of crashes
    #
    # Gets a list of crashes
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param last_occurrence_from [DateTime] Earliest date when the last time a
    # crash occured in a error group
    # @param last_occurrence_to [DateTime] Latest date when the last time a crash
    # occured in a error group
    # @param app_version [String] version
    # @param group_type [Enum] Possible values include: 'GroupType1', 'GroupType2'
    # @param group_status [Enum] Possible values include: 'open', 'closed',
    # 'ignored'
    # @param group_text_search [String] A freetext search that matches in error,
    # error types, error stack_traces and error user
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Array] operation results.
    #
    def get_crash_groups(owner_name, app_name, last_occurrence_from = nil, last_occurrence_to = nil, app_version = nil, group_type = nil, group_status = nil, group_text_search = nil, custom_headers = nil)
      response = get_crash_groups_async(owner_name, app_name, last_occurrence_from, last_occurrence_to, app_version, group_type, group_status, group_text_search, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets a list of crashes
    #
    # Gets a list of crashes
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param last_occurrence_from [DateTime] Earliest date when the last time a
    # crash occured in a error group
    # @param last_occurrence_to [DateTime] Latest date when the last time a crash
    # occured in a error group
    # @param app_version [String] version
    # @param group_type [Enum] Possible values include: 'GroupType1', 'GroupType2'
    # @param group_status [Enum] Possible values include: 'open', 'closed',
    # 'ignored'
    # @param group_text_search [String] A freetext search that matches in error,
    # error types, error stack_traces and error user
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_groups_with_http_info(owner_name, app_name, last_occurrence_from = nil, last_occurrence_to = nil, app_version = nil, group_type = nil, group_status = nil, group_text_search = nil, custom_headers = nil)
      get_crash_groups_async(owner_name, app_name, last_occurrence_from, last_occurrence_to, app_version, group_type, group_status, group_text_search, custom_headers).value!
    end

    #
    # Gets a list of crashes
    #
    # Gets a list of crashes
    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param last_occurrence_from [DateTime] Earliest date when the last time a
    # crash occured in a error group
    # @param last_occurrence_to [DateTime] Latest date when the last time a crash
    # occured in a error group
    # @param app_version [String] version
    # @param group_type [Enum] Possible values include: 'GroupType1', 'GroupType2'
    # @param group_status [Enum] Possible values include: 'open', 'closed',
    # 'ignored'
    # @param group_text_search [String] A freetext search that matches in error,
    # error types, error stack_traces and error user
    # @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_crash_groups_async(owner_name, app_name, last_occurrence_from = nil, last_occurrence_to = nil, app_version = nil, group_type = nil, group_status = nil, group_text_search = nil, custom_headers = nil)
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_groups'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'owner_name' => owner_name,'app_name' => app_name},
          query_params: {'last_occurrence_from' => last_occurrence_from,'last_occurrence_to' => last_occurrence_to,'app_version' => app_version,'group_type' => group_type,'group_status' => group_status,'group_text_search' => group_text_search},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = {
              required: false,
              serialized_name: 'parsed_response',
              type: {
                name: 'Sequence',
                element: {
                    required: false,
                    serialized_name: 'CrashGroupElementType',
                    type: {
                      name: 'Composite',
                      class_name: 'CrashGroup'
                    }
                }
              }
            }
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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

    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CrashGroupCounts] operation results.
    #
    def get_crash_group_counts(owner_name, app_name, custom_headers = nil)
      response = get_crash_group_counts_async(owner_name, app_name, custom_headers).value!
      response.body unless response.nil?
    end

    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRest::HttpOperationResponse] HTTP response information.
    #
    def get_crash_group_counts_with_http_info(owner_name, app_name, custom_headers = nil)
      get_crash_group_counts_async(owner_name, app_name, custom_headers).value!
    end

    #
    # @param owner_name [String] The name of the owner
    # @param app_name [String] The name of the application
    # @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_crash_group_counts_async(owner_name, app_name, custom_headers = nil)
      fail ArgumentError, 'owner_name is nil' if owner_name.nil?
      fail ArgumentError, 'app_name is nil' if app_name.nil?


      request_headers = {}
      path_template = 'v0.1/apps/{owner_name}/{app_name}/crash_group_counts'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'owner_name' => owner_name,'app_name' => app_name},
          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

        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = MobileCenterApi::Models::CrashGroupCounts.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
          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
