package kms

//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

import (
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)

// ListClientKeys invokes the kms.ListClientKeys API synchronously
func (client *Client) ListClientKeys(request *ListClientKeysRequest) (response *ListClientKeysResponse, err error) {
	response = CreateListClientKeysResponse()
	err = client.DoAction(request, response)
	return
}

// ListClientKeysWithChan invokes the kms.ListClientKeys API asynchronously
func (client *Client) ListClientKeysWithChan(request *ListClientKeysRequest) (<-chan *ListClientKeysResponse, <-chan error) {
	responseChan := make(chan *ListClientKeysResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.ListClientKeys(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// ListClientKeysWithCallback invokes the kms.ListClientKeys API asynchronously
func (client *Client) ListClientKeysWithCallback(request *ListClientKeysRequest, callback func(response *ListClientKeysResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *ListClientKeysResponse
		var err error
		defer close(result)
		response, err = client.ListClientKeys(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// ListClientKeysRequest is the request struct for api ListClientKeys
type ListClientKeysRequest struct {
	*requests.RpcRequest
	AapName string `position:"Query" name:"AapName"`
}

// ListClientKeysResponse is the response struct for api ListClientKeys
type ListClientKeysResponse struct {
	*responses.BaseResponse
	RequestId  string      `json:"RequestId" xml:"RequestId"`
	ClientKeys []ClientKey `json:"ClientKeys" xml:"ClientKeys"`
}

// CreateListClientKeysRequest creates a request to invoke ListClientKeys API
func CreateListClientKeysRequest() (request *ListClientKeysRequest) {
	request = &ListClientKeysRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("Kms", "2016-01-20", "ListClientKeys", "kms", "openAPI")
	request.Method = requests.GET
	return
}

// CreateListClientKeysResponse creates a response to parse from ListClientKeys response
func CreateListClientKeysResponse() (response *ListClientKeysResponse) {
	response = &ListClientKeysResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
