operations

in build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/rbs/async_client_class.rb [47:113]


        def operations
          shapes = @api['shapes']
          @api['operations'].map do |name, body|
            next unless async_operation?(body)



            method_name = Underscore.underscore(name)
            indent = ' ' * (12 + method_name.length)
            input_shape_name = body.dig('input', 'shape')
            arguments = nil
            include_required = false
            if input_shape_name
              input_shape = shapes[input_shape_name]
              options =
                if AwsSdkCodeGenerator::Helper.operation_bidirectional_eventstreaming?(body, @api)
                  { bidirectional_eventstreaming: true }
                else
                  {}
                end

              builder = AwsSdkCodeGenerator::RBS::KeywordArgumentBuilder.new(
                api: @api,
                shape: input_shape,
                newline: true,
                options: options
              )
              arguments = builder.format(indent: indent)
              include_required = input_shape['required']&.empty?&.!
            end
            block = ' ?{ (*untyped) -> void }' if AwsSdkCodeGenerator::Helper.operation_streaming?(body, @api)
            if (output_shape_name = body.dig('output', 'shape'))
              output_shape = shapes[output_shape_name]
              data = AwsSdkCodeGenerator::RBS.to_type(body.fetch('output'), @api)
              interface = "_#{name}ResponseSuccess"
            else
              output_shape = nil
              data = '::Aws::EmptyStructure'
              interface = '::Seahorse::Client::_ResponseSuccess[::Aws::EmptyStructure]'
            end
            returns_members = output_shape&.[]('members')&.inject([]) do |a, (member_name, member_ref)|
              member_name_underscore = Underscore.underscore(member_name)
              next a if SKIP_MEMBERS.include?(member_name_underscore)

              a << {
                method_name: member_name_underscore,
                returns: AwsSdkCodeGenerator::RBS.to_type(member_ref, @api)
              }
            end

            {
              method_name: method_name,
              signature: AwsSdkCodeGenerator::RBS::MethodSignature.new(
                method_name: method_name,
                overloads: [
                  "(#{arguments})#{block} -> #{interface}",
                  "(#{include_required ? '' : '?'}Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options)#{block} -> #{interface}",
                ]
              ).signature,
              interface: interface,
              data: data,
              returns_members: returns_members,
              empty_structure: output_shape.nil?
            }
          end.compact
        end