// Code generated by protoc-gen-go-flipt-sdk. DO NOT EDIT.

package http

import (
	context "context"
	meta "go.flipt.io/flipt/rpc/flipt/meta"
	httpbody "google.golang.org/genproto/googleapis/api/httpbody"
	grpc "google.golang.org/grpc"
	emptypb "google.golang.org/protobuf/types/known/emptypb"
	io "io"
	http "net/http"
	url "net/url"
)

type MetadataServiceClient struct {
	client *http.Client
	addr   string
}

func (x *MetadataServiceClient) GetConfiguration(ctx context.Context, v *emptypb.Empty, _ ...grpc.CallOption) (*httpbody.HttpBody, error) {
	var body io.Reader
	var values url.Values
	req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+"/meta/config", body)
	if err != nil {
		return nil, err
	}
	req.URL.RawQuery = values.Encode()
	resp, err := x.client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	var output httpbody.HttpBody
	respData, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	if err := checkResponse(resp, respData); err != nil {
		return nil, err
	}
	output.ContentType = resp.Header.Get("Content-Type")
	output.Data = respData
	return &output, nil
}

func (x *MetadataServiceClient) GetInfo(ctx context.Context, v *emptypb.Empty, _ ...grpc.CallOption) (*httpbody.HttpBody, error) {
	var body io.Reader
	var values url.Values
	req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+"/meta/info", body)
	if err != nil {
		return nil, err
	}
	req.URL.RawQuery = values.Encode()
	resp, err := x.client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	var output httpbody.HttpBody
	respData, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	if err := checkResponse(resp, respData); err != nil {
		return nil, err
	}
	output.ContentType = resp.Header.Get("Content-Type")
	output.Data = respData
	return &output, nil
}

func (t Transport) MetaClient() meta.MetadataServiceClient {
	return &MetadataServiceClient{client: t.client, addr: t.addr}
}
