/*
Copyright 2022 The Knative Authors

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 injection-gen. DO NOT EDIT.

package client

import (
	context "context"
	json "encoding/json"
	errors "errors"
	fmt "fmt"

	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	runtime "k8s.io/apimachinery/pkg/runtime"
	schema "k8s.io/apimachinery/pkg/runtime/schema"
	types "k8s.io/apimachinery/pkg/types"
	watch "k8s.io/apimachinery/pkg/watch"
	discovery "k8s.io/client-go/discovery"
	dynamic "k8s.io/client-go/dynamic"
	rest "k8s.io/client-go/rest"
	injection "knative.dev/pkg/injection"
	dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
	logging "knative.dev/pkg/logging"
	v1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1"
	servingv1 "knative.dev/serving/pkg/apis/serving/v1"
	servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1"
	v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1"
	versioned "knative.dev/serving/pkg/client/clientset/versioned"
	typedautoscalingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1"
	typedservingv1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1"
	typedservingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1"
	typedservingv1beta1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1"
)

func init() {
	injection.Default.RegisterClient(withClientFromConfig)
	injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} {
		return Get(ctx)
	})
	injection.Dynamic.RegisterDynamicClient(withClientFromDynamic)
}

// Key is used as the key for associating information with a context.Context.
type Key struct{}

func withClientFromConfig(ctx context.Context, cfg *rest.Config) context.Context {
	return context.WithValue(ctx, Key{}, versioned.NewForConfigOrDie(cfg))
}

func withClientFromDynamic(ctx context.Context) context.Context {
	return context.WithValue(ctx, Key{}, &wrapClient{dyn: dynamicclient.Get(ctx)})
}

// Get extracts the versioned.Interface client from the context.
func Get(ctx context.Context) versioned.Interface {
	untyped := ctx.Value(Key{})
	if untyped == nil {
		if injection.GetConfig(ctx) == nil {
			logging.FromContext(ctx).Panic(
				"Unable to fetch knative.dev/serving/pkg/client/clientset/versioned.Interface from context. This context is not the application context (which is typically given to constructors via sharedmain).")
		} else {
			logging.FromContext(ctx).Panic(
				"Unable to fetch knative.dev/serving/pkg/client/clientset/versioned.Interface from context.")
		}
	}
	return untyped.(versioned.Interface)
}

type wrapClient struct {
	dyn dynamic.Interface
}

var _ versioned.Interface = (*wrapClient)(nil)

func (w *wrapClient) Discovery() discovery.DiscoveryInterface {
	panic("Discovery called on dynamic client!")
}

func convert(from interface{}, to runtime.Object) error {
	bs, err := json.Marshal(from)
	if err != nil {
		return fmt.Errorf("Marshal() = %w", err)
	}
	if err := json.Unmarshal(bs, to); err != nil {
		return fmt.Errorf("Unmarshal() = %w", err)
	}
	return nil
}

// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client
func (w *wrapClient) AutoscalingV1alpha1() typedautoscalingv1alpha1.AutoscalingV1alpha1Interface {
	return &wrapAutoscalingV1alpha1{
		dyn: w.dyn,
	}
}

type wrapAutoscalingV1alpha1 struct {
	dyn dynamic.Interface
}

func (w *wrapAutoscalingV1alpha1) RESTClient() rest.Interface {
	panic("RESTClient called on dynamic client!")
}

func (w *wrapAutoscalingV1alpha1) Metrics(namespace string) typedautoscalingv1alpha1.MetricInterface {
	return &wrapAutoscalingV1alpha1MetricImpl{
		dyn: w.dyn.Resource(schema.GroupVersionResource{
			Group:    "autoscaling.internal.knative.dev",
			Version:  "v1alpha1",
			Resource: "metrics",
		}),

		namespace: namespace,
	}
}

type wrapAutoscalingV1alpha1MetricImpl struct {
	dyn dynamic.NamespaceableResourceInterface

	namespace string
}

var _ typedautoscalingv1alpha1.MetricInterface = (*wrapAutoscalingV1alpha1MetricImpl)(nil)

func (w *wrapAutoscalingV1alpha1MetricImpl) Create(ctx context.Context, in *v1alpha1.Metric, opts v1.CreateOptions) (*v1alpha1.Metric, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "autoscaling.internal.knative.dev",
		Version: "v1alpha1",
		Kind:    "Metric",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.Metric{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1MetricImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts)
}

func (w *wrapAutoscalingV1alpha1MetricImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts)
}

func (w *wrapAutoscalingV1alpha1MetricImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Metric, error) {
	uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.Metric{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1MetricImpl) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.MetricList, error) {
	uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.MetricList{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1MetricImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Metric, err error) {
	uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.Metric{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1MetricImpl) Update(ctx context.Context, in *v1alpha1.Metric, opts v1.UpdateOptions) (*v1alpha1.Metric, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "autoscaling.internal.knative.dev",
		Version: "v1alpha1",
		Kind:    "Metric",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.Metric{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1MetricImpl) UpdateStatus(ctx context.Context, in *v1alpha1.Metric, opts v1.UpdateOptions) (*v1alpha1.Metric, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "autoscaling.internal.knative.dev",
		Version: "v1alpha1",
		Kind:    "Metric",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.Metric{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1MetricImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return nil, errors.New("NYI: Watch")
}

func (w *wrapAutoscalingV1alpha1) PodAutoscalers(namespace string) typedautoscalingv1alpha1.PodAutoscalerInterface {
	return &wrapAutoscalingV1alpha1PodAutoscalerImpl{
		dyn: w.dyn.Resource(schema.GroupVersionResource{
			Group:    "autoscaling.internal.knative.dev",
			Version:  "v1alpha1",
			Resource: "podautoscalers",
		}),

		namespace: namespace,
	}
}

type wrapAutoscalingV1alpha1PodAutoscalerImpl struct {
	dyn dynamic.NamespaceableResourceInterface

	namespace string
}

var _ typedautoscalingv1alpha1.PodAutoscalerInterface = (*wrapAutoscalingV1alpha1PodAutoscalerImpl)(nil)

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) Create(ctx context.Context, in *v1alpha1.PodAutoscaler, opts v1.CreateOptions) (*v1alpha1.PodAutoscaler, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "autoscaling.internal.knative.dev",
		Version: "v1alpha1",
		Kind:    "PodAutoscaler",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.PodAutoscaler{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts)
}

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts)
}

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.PodAutoscaler, error) {
	uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.PodAutoscaler{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PodAutoscalerList, error) {
	uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.PodAutoscalerList{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) {
	uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.PodAutoscaler{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) Update(ctx context.Context, in *v1alpha1.PodAutoscaler, opts v1.UpdateOptions) (*v1alpha1.PodAutoscaler, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "autoscaling.internal.knative.dev",
		Version: "v1alpha1",
		Kind:    "PodAutoscaler",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.PodAutoscaler{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) UpdateStatus(ctx context.Context, in *v1alpha1.PodAutoscaler, opts v1.UpdateOptions) (*v1alpha1.PodAutoscaler, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "autoscaling.internal.knative.dev",
		Version: "v1alpha1",
		Kind:    "PodAutoscaler",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1alpha1.PodAutoscaler{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapAutoscalingV1alpha1PodAutoscalerImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return nil, errors.New("NYI: Watch")
}

// ServingV1 retrieves the ServingV1Client
func (w *wrapClient) ServingV1() typedservingv1.ServingV1Interface {
	return &wrapServingV1{
		dyn: w.dyn,
	}
}

type wrapServingV1 struct {
	dyn dynamic.Interface
}

func (w *wrapServingV1) RESTClient() rest.Interface {
	panic("RESTClient called on dynamic client!")
}

func (w *wrapServingV1) Configurations(namespace string) typedservingv1.ConfigurationInterface {
	return &wrapServingV1ConfigurationImpl{
		dyn: w.dyn.Resource(schema.GroupVersionResource{
			Group:    "serving.knative.dev",
			Version:  "v1",
			Resource: "configurations",
		}),

		namespace: namespace,
	}
}

type wrapServingV1ConfigurationImpl struct {
	dyn dynamic.NamespaceableResourceInterface

	namespace string
}

var _ typedservingv1.ConfigurationInterface = (*wrapServingV1ConfigurationImpl)(nil)

func (w *wrapServingV1ConfigurationImpl) Create(ctx context.Context, in *servingv1.Configuration, opts v1.CreateOptions) (*servingv1.Configuration, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Configuration",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Configuration{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ConfigurationImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts)
}

func (w *wrapServingV1ConfigurationImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts)
}

func (w *wrapServingV1ConfigurationImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*servingv1.Configuration, error) {
	uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Configuration{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ConfigurationImpl) List(ctx context.Context, opts v1.ListOptions) (*servingv1.ConfigurationList, error) {
	uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.ConfigurationList{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ConfigurationImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *servingv1.Configuration, err error) {
	uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Configuration{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ConfigurationImpl) Update(ctx context.Context, in *servingv1.Configuration, opts v1.UpdateOptions) (*servingv1.Configuration, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Configuration",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Configuration{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ConfigurationImpl) UpdateStatus(ctx context.Context, in *servingv1.Configuration, opts v1.UpdateOptions) (*servingv1.Configuration, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Configuration",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Configuration{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ConfigurationImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return nil, errors.New("NYI: Watch")
}

func (w *wrapServingV1) Revisions(namespace string) typedservingv1.RevisionInterface {
	return &wrapServingV1RevisionImpl{
		dyn: w.dyn.Resource(schema.GroupVersionResource{
			Group:    "serving.knative.dev",
			Version:  "v1",
			Resource: "revisions",
		}),

		namespace: namespace,
	}
}

type wrapServingV1RevisionImpl struct {
	dyn dynamic.NamespaceableResourceInterface

	namespace string
}

var _ typedservingv1.RevisionInterface = (*wrapServingV1RevisionImpl)(nil)

func (w *wrapServingV1RevisionImpl) Create(ctx context.Context, in *servingv1.Revision, opts v1.CreateOptions) (*servingv1.Revision, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Revision",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Revision{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RevisionImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts)
}

func (w *wrapServingV1RevisionImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts)
}

func (w *wrapServingV1RevisionImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*servingv1.Revision, error) {
	uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Revision{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RevisionImpl) List(ctx context.Context, opts v1.ListOptions) (*servingv1.RevisionList, error) {
	uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.RevisionList{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RevisionImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *servingv1.Revision, err error) {
	uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Revision{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RevisionImpl) Update(ctx context.Context, in *servingv1.Revision, opts v1.UpdateOptions) (*servingv1.Revision, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Revision",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Revision{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RevisionImpl) UpdateStatus(ctx context.Context, in *servingv1.Revision, opts v1.UpdateOptions) (*servingv1.Revision, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Revision",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Revision{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RevisionImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return nil, errors.New("NYI: Watch")
}

func (w *wrapServingV1) Routes(namespace string) typedservingv1.RouteInterface {
	return &wrapServingV1RouteImpl{
		dyn: w.dyn.Resource(schema.GroupVersionResource{
			Group:    "serving.knative.dev",
			Version:  "v1",
			Resource: "routes",
		}),

		namespace: namespace,
	}
}

type wrapServingV1RouteImpl struct {
	dyn dynamic.NamespaceableResourceInterface

	namespace string
}

var _ typedservingv1.RouteInterface = (*wrapServingV1RouteImpl)(nil)

func (w *wrapServingV1RouteImpl) Create(ctx context.Context, in *servingv1.Route, opts v1.CreateOptions) (*servingv1.Route, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Route",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Route{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RouteImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts)
}

func (w *wrapServingV1RouteImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts)
}

func (w *wrapServingV1RouteImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*servingv1.Route, error) {
	uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Route{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RouteImpl) List(ctx context.Context, opts v1.ListOptions) (*servingv1.RouteList, error) {
	uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.RouteList{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RouteImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *servingv1.Route, err error) {
	uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Route{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RouteImpl) Update(ctx context.Context, in *servingv1.Route, opts v1.UpdateOptions) (*servingv1.Route, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Route",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Route{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RouteImpl) UpdateStatus(ctx context.Context, in *servingv1.Route, opts v1.UpdateOptions) (*servingv1.Route, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Route",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Route{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1RouteImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return nil, errors.New("NYI: Watch")
}

func (w *wrapServingV1) Services(namespace string) typedservingv1.ServiceInterface {
	return &wrapServingV1ServiceImpl{
		dyn: w.dyn.Resource(schema.GroupVersionResource{
			Group:    "serving.knative.dev",
			Version:  "v1",
			Resource: "services",
		}),

		namespace: namespace,
	}
}

type wrapServingV1ServiceImpl struct {
	dyn dynamic.NamespaceableResourceInterface

	namespace string
}

var _ typedservingv1.ServiceInterface = (*wrapServingV1ServiceImpl)(nil)

func (w *wrapServingV1ServiceImpl) Create(ctx context.Context, in *servingv1.Service, opts v1.CreateOptions) (*servingv1.Service, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Service",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Service{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ServiceImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts)
}

func (w *wrapServingV1ServiceImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts)
}

func (w *wrapServingV1ServiceImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*servingv1.Service, error) {
	uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Service{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ServiceImpl) List(ctx context.Context, opts v1.ListOptions) (*servingv1.ServiceList, error) {
	uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.ServiceList{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ServiceImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *servingv1.Service, err error) {
	uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Service{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ServiceImpl) Update(ctx context.Context, in *servingv1.Service, opts v1.UpdateOptions) (*servingv1.Service, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Service",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Service{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ServiceImpl) UpdateStatus(ctx context.Context, in *servingv1.Service, opts v1.UpdateOptions) (*servingv1.Service, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1",
		Kind:    "Service",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1.Service{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1ServiceImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return nil, errors.New("NYI: Watch")
}

// ServingV1beta1 retrieves the ServingV1beta1Client
func (w *wrapClient) ServingV1beta1() typedservingv1beta1.ServingV1beta1Interface {
	return &wrapServingV1beta1{
		dyn: w.dyn,
	}
}

type wrapServingV1beta1 struct {
	dyn dynamic.Interface
}

func (w *wrapServingV1beta1) RESTClient() rest.Interface {
	panic("RESTClient called on dynamic client!")
}

func (w *wrapServingV1beta1) DomainMappings(namespace string) typedservingv1beta1.DomainMappingInterface {
	return &wrapServingV1beta1DomainMappingImpl{
		dyn: w.dyn.Resource(schema.GroupVersionResource{
			Group:    "serving.knative.dev",
			Version:  "v1beta1",
			Resource: "domainmappings",
		}),

		namespace: namespace,
	}
}

type wrapServingV1beta1DomainMappingImpl struct {
	dyn dynamic.NamespaceableResourceInterface

	namespace string
}

var _ typedservingv1beta1.DomainMappingInterface = (*wrapServingV1beta1DomainMappingImpl)(nil)

func (w *wrapServingV1beta1DomainMappingImpl) Create(ctx context.Context, in *v1beta1.DomainMapping, opts v1.CreateOptions) (*v1beta1.DomainMapping, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1beta1",
		Kind:    "DomainMapping",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1beta1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1beta1DomainMappingImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts)
}

func (w *wrapServingV1beta1DomainMappingImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts)
}

func (w *wrapServingV1beta1DomainMappingImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.DomainMapping, error) {
	uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts)
	if err != nil {
		return nil, err
	}
	out := &v1beta1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1beta1DomainMappingImpl) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.DomainMappingList, error) {
	uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts)
	if err != nil {
		return nil, err
	}
	out := &v1beta1.DomainMappingList{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1beta1DomainMappingImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.DomainMapping, err error) {
	uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts)
	if err != nil {
		return nil, err
	}
	out := &v1beta1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1beta1DomainMappingImpl) Update(ctx context.Context, in *v1beta1.DomainMapping, opts v1.UpdateOptions) (*v1beta1.DomainMapping, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1beta1",
		Kind:    "DomainMapping",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1beta1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1beta1DomainMappingImpl) UpdateStatus(ctx context.Context, in *v1beta1.DomainMapping, opts v1.UpdateOptions) (*v1beta1.DomainMapping, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1beta1",
		Kind:    "DomainMapping",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &v1beta1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1beta1DomainMappingImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return nil, errors.New("NYI: Watch")
}

// ServingV1alpha1 retrieves the ServingV1alpha1Client
func (w *wrapClient) ServingV1alpha1() typedservingv1alpha1.ServingV1alpha1Interface {
	return &wrapServingV1alpha1{
		dyn: w.dyn,
	}
}

type wrapServingV1alpha1 struct {
	dyn dynamic.Interface
}

func (w *wrapServingV1alpha1) RESTClient() rest.Interface {
	panic("RESTClient called on dynamic client!")
}

func (w *wrapServingV1alpha1) DomainMappings(namespace string) typedservingv1alpha1.DomainMappingInterface {
	return &wrapServingV1alpha1DomainMappingImpl{
		dyn: w.dyn.Resource(schema.GroupVersionResource{
			Group:    "serving.knative.dev",
			Version:  "v1alpha1",
			Resource: "domainmappings",
		}),

		namespace: namespace,
	}
}

type wrapServingV1alpha1DomainMappingImpl struct {
	dyn dynamic.NamespaceableResourceInterface

	namespace string
}

var _ typedservingv1alpha1.DomainMappingInterface = (*wrapServingV1alpha1DomainMappingImpl)(nil)

func (w *wrapServingV1alpha1DomainMappingImpl) Create(ctx context.Context, in *servingv1alpha1.DomainMapping, opts v1.CreateOptions) (*servingv1alpha1.DomainMapping, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1alpha1",
		Kind:    "DomainMapping",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1alpha1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1alpha1DomainMappingImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts)
}

func (w *wrapServingV1alpha1DomainMappingImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts)
}

func (w *wrapServingV1alpha1DomainMappingImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*servingv1alpha1.DomainMapping, error) {
	uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1alpha1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1alpha1DomainMappingImpl) List(ctx context.Context, opts v1.ListOptions) (*servingv1alpha1.DomainMappingList, error) {
	uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1alpha1.DomainMappingList{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1alpha1DomainMappingImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *servingv1alpha1.DomainMapping, err error) {
	uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1alpha1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1alpha1DomainMappingImpl) Update(ctx context.Context, in *servingv1alpha1.DomainMapping, opts v1.UpdateOptions) (*servingv1alpha1.DomainMapping, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1alpha1",
		Kind:    "DomainMapping",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1alpha1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1alpha1DomainMappingImpl) UpdateStatus(ctx context.Context, in *servingv1alpha1.DomainMapping, opts v1.UpdateOptions) (*servingv1alpha1.DomainMapping, error) {
	in.SetGroupVersionKind(schema.GroupVersionKind{
		Group:   "serving.knative.dev",
		Version: "v1alpha1",
		Kind:    "DomainMapping",
	})
	uo := &unstructured.Unstructured{}
	if err := convert(in, uo); err != nil {
		return nil, err
	}
	uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts)
	if err != nil {
		return nil, err
	}
	out := &servingv1alpha1.DomainMapping{}
	if err := convert(uo, out); err != nil {
		return nil, err
	}
	return out, nil
}

func (w *wrapServingV1alpha1DomainMappingImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return nil, errors.New("NYI: Watch")
}
