package tag

//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"
)

// ListSupportResourceTypes invokes the tag.ListSupportResourceTypes API synchronously
func (client *Client) ListSupportResourceTypes(request *ListSupportResourceTypesRequest) (response *ListSupportResourceTypesResponse, err error) {
	response = CreateListSupportResourceTypesResponse()
	err = client.DoAction(request, response)
	return
}

// ListSupportResourceTypesWithChan invokes the tag.ListSupportResourceTypes API asynchronously
func (client *Client) ListSupportResourceTypesWithChan(request *ListSupportResourceTypesRequest) (<-chan *ListSupportResourceTypesResponse, <-chan error) {
	responseChan := make(chan *ListSupportResourceTypesResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.ListSupportResourceTypes(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// ListSupportResourceTypesWithCallback invokes the tag.ListSupportResourceTypes API asynchronously
func (client *Client) ListSupportResourceTypesWithCallback(request *ListSupportResourceTypesRequest, callback func(response *ListSupportResourceTypesResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *ListSupportResourceTypesResponse
		var err error
		defer close(result)
		response, err = client.ListSupportResourceTypes(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// ListSupportResourceTypesRequest is the request struct for api ListSupportResourceTypes
type ListSupportResourceTypesRequest struct {
	*requests.RpcRequest
	ProductCode          string           `position:"Query" name:"ProductCode"`
	SupportCode          string           `position:"Query" name:"SupportCode"`
	NextToken            string           `position:"Query" name:"NextToken"`
	ResourceOwnerAccount string           `position:"Query" name:"ResourceOwnerAccount"`
	OwnerAccount         string           `position:"Query" name:"OwnerAccount"`
	ResourceTye          string           `position:"Query" name:"ResourceTye"`
	OwnerId              requests.Integer `position:"Query" name:"OwnerId"`
	MaxResult            requests.Integer `position:"Query" name:"MaxResult"`
	ShowItems            requests.Boolean `position:"Query" name:"ShowItems"`
}

// ListSupportResourceTypesResponse is the response struct for api ListSupportResourceTypes
type ListSupportResourceTypesResponse struct {
	*responses.BaseResponse
	NextToken            string                `json:"NextToken" xml:"NextToken"`
	RequestId            string                `json:"RequestId" xml:"RequestId"`
	SupportResourceTypes []SupportResourceType `json:"SupportResourceTypes" xml:"SupportResourceTypes"`
}

// CreateListSupportResourceTypesRequest creates a request to invoke ListSupportResourceTypes API
func CreateListSupportResourceTypesRequest() (request *ListSupportResourceTypesRequest) {
	request = &ListSupportResourceTypesRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("Tag", "2018-08-28", "ListSupportResourceTypes", "tag", "openAPI")
	request.Method = requests.POST
	return
}

// CreateListSupportResourceTypesResponse creates a response to parse from ListSupportResourceTypes response
func CreateListSupportResourceTypesResponse() (response *ListSupportResourceTypesResponse) {
	response = &ListSupportResourceTypesResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
