// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-2019 Datadog, Inc.

// Code generated by client-gen. DO NOT EDIT.

package v1alpha1

import (
	v1alpha1 "github.com/DataDog/datadog-operator/pkg/apis/datadoghq/v1alpha1"
	"github.com/DataDog/datadog-operator/pkg/generated/clientset/versioned/scheme"
	rest "k8s.io/client-go/rest"
)

type DatadoghqV1alpha1Interface interface {
	RESTClient() rest.Interface
	DatadogAgentsGetter
	DatadogMetricsGetter
}

// DatadoghqV1alpha1Client is used to interact with features provided by the datadoghq.com group.
type DatadoghqV1alpha1Client struct {
	restClient rest.Interface
}

func (c *DatadoghqV1alpha1Client) DatadogAgents(namespace string) DatadogAgentInterface {
	return newDatadogAgents(c, namespace)
}

func (c *DatadoghqV1alpha1Client) DatadogMetrics(namespace string) DatadogMetricInterface {
	return newDatadogMetrics(c, namespace)
}

// NewForConfig creates a new DatadoghqV1alpha1Client for the given config.
func NewForConfig(c *rest.Config) (*DatadoghqV1alpha1Client, error) {
	config := *c
	if err := setConfigDefaults(&config); err != nil {
		return nil, err
	}
	client, err := rest.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &DatadoghqV1alpha1Client{client}, nil
}

// NewForConfigOrDie creates a new DatadoghqV1alpha1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *DatadoghqV1alpha1Client {
	client, err := NewForConfig(c)
	if err != nil {
		panic(err)
	}
	return client
}

// New creates a new DatadoghqV1alpha1Client for the given RESTClient.
func New(c rest.Interface) *DatadoghqV1alpha1Client {
	return &DatadoghqV1alpha1Client{c}
}

func setConfigDefaults(config *rest.Config) error {
	gv := v1alpha1.SchemeGroupVersion
	config.GroupVersion = &gv
	config.APIPath = "/apis"
	config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()

	if config.UserAgent == "" {
		config.UserAgent = rest.DefaultKubernetesUserAgent()
	}

	return nil
}

// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *DatadoghqV1alpha1Client) RESTClient() rest.Interface {
	if c == nil {
		return nil
	}
	return c.restClient
}
