package biz_ipdb

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

// FindIpInfo invokes the biz_ipdb.FindIpInfo API synchronously
func (client *Client) FindIpInfo(request *FindIpInfoRequest) (response *FindIpInfoResponse, err error) {
	response = CreateFindIpInfoResponse()
	err = client.DoAction(request, response)
	return
}

// FindIpInfoWithChan invokes the biz_ipdb.FindIpInfo API asynchronously
func (client *Client) FindIpInfoWithChan(request *FindIpInfoRequest) (<-chan *FindIpInfoResponse, <-chan error) {
	responseChan := make(chan *FindIpInfoResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.FindIpInfo(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// FindIpInfoWithCallback invokes the biz_ipdb.FindIpInfo API asynchronously
func (client *Client) FindIpInfoWithCallback(request *FindIpInfoRequest, callback func(response *FindIpInfoResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *FindIpInfoResponse
		var err error
		defer close(result)
		response, err = client.FindIpInfo(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// FindIpInfoRequest is the request struct for api FindIpInfo
type FindIpInfoRequest struct {
	*requests.RpcRequest
	Ip string `position:"Query" name:"Ip"`
}

// FindIpInfoResponse is the response struct for api FindIpInfo
type FindIpInfoResponse struct {
	*responses.BaseResponse
	Pod          string `json:"Pod" xml:"Pod"`
	HighIp       string `json:"HighIp" xml:"HighIp"`
	Cluster      string `json:"Cluster" xml:"Cluster"`
	Gateway      string `json:"Gateway" xml:"Gateway"`
	SysOwner     string `json:"SysOwner" xml:"SysOwner"`
	LowIp        string `json:"LowIp" xml:"LowIp"`
	Vlan         string `json:"Vlan" xml:"Vlan"`
	RegionId     string `json:"RegionId" xml:"RegionId"`
	IpType       string `json:"IpType" xml:"IpType"`
	Value        string `json:"Value" xml:"Value"`
	RequestId    string `json:"RequestId" xml:"RequestId"`
	IpPublic     bool   `json:"IpPublic" xml:"IpPublic"`
	BizLine      string `json:"BizLine" xml:"BizLine"`
	HighIpNumber int64  `json:"HighIpNumber" xml:"HighIpNumber"`
	LocationId   string `json:"LocationId" xml:"LocationId"`
	LowIpNumber  int64  `json:"LowIpNumber" xml:"LowIpNumber"`
}

// CreateFindIpInfoRequest creates a request to invoke FindIpInfo API
func CreateFindIpInfoRequest() (request *FindIpInfoRequest) {
	request = &FindIpInfoRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("Biz-ipdb", "2016-08-08", "FindIpInfo", "", "")
	request.Method = requests.POST
	return
}

// CreateFindIpInfoResponse creates a response to parse from FindIpInfo response
func CreateFindIpInfoResponse() (response *FindIpInfoResponse) {
	response = &FindIpInfoResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
