| 39 | } |
| 40 | |
| 41 | func (c *Client) ApiVersions( |
| 42 | ctx context.Context, |
| 43 | req *ApiVersionsRequest, |
| 44 | ) (*ApiVersionsResponse, error) { |
| 45 | apiReq := &apiversions.Request{} |
| 46 | protoResp, err := c.roundTrip( |
| 47 | ctx, |
| 48 | req.Addr, |
| 49 | apiReq, |
| 50 | ) |
| 51 | if err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | apiResp := protoResp.(*apiversions.Response) |
| 55 | |
| 56 | resp := &ApiVersionsResponse{ |
| 57 | Error: makeError(apiResp.ErrorCode, ""), |
| 58 | } |
| 59 | for _, apiKey := range apiResp.ApiKeys { |
| 60 | resp.ApiKeys = append( |
| 61 | resp.ApiKeys, |
| 62 | ApiVersionsResponseApiKey{ |
| 63 | ApiKey: int(apiKey.ApiKey), |
| 64 | ApiName: protocol.ApiKey(apiKey.ApiKey).String(), |
| 65 | MinVersion: int(apiKey.MinVersion), |
| 66 | MaxVersion: int(apiKey.MaxVersion), |
| 67 | }, |
| 68 | ) |
| 69 | } |
| 70 | |
| 71 | return resp, err |
| 72 | } |