apiGroup := metav1.APIGroup{}
	if err == nil && len(v.Versions)!= 0 {
		apiGroup = apiVersionsToAPIGroup(v)
	}
	if err!= nil &&!errors.IsNotFound(err) &&!errors.IsForbidden(err) {
		return nil, err
	}

	// Get the groupVersions exposed at /apis
	apiGroupList = &metav1.APIGroupList{}
	err = d.restClient.Get().AbsPath("/apis").Do().Into(apiGroupList)
	if err!= nil &&!errors.IsNotFound(err) &&!errors.IsForbidden(err) {
		return nil, err
	}
	// to be compatible with a v1.0 server, if it's a 403 or 404, ignore and return whatever we got from /api
	if err!= nil && (errors.IsNotFound(err) || errors.IsForbidden(err)) {
		apiGroupList = &metav1.APIGroupList{}
	}

	// prepend the group retrieved from /api to the list if not empty
	if len(v.Versions)!= 0 {
		apiGroupList.Groups = append([]metav1.APIGroup{apiGroup}, apiGroupList.Groups...)
	}
	return apiGroupList, nil
}

// ServerResourcesForGroupVersion returns the supported resources for a group and version.
func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *metav1.APIResourceList, err error) {
	url := url.URL{}
	if len(groupVersion) == 0 {
		return nil, fmt.Errorf("groupVersion shouldn't be empty")
	}
	if len(d.LegacyPrefix) > 0 && groupVersion == "v1" {
		url.Path = d.LegacyPrefix + "/" + groupVersion
	} else {
		url.Path = "/apis/" + groupVersion
	}
	resources = &metav1.APIResourceList{
		GroupVersion: groupVersion,
	}
	err = d.restClient.Get().AbsPath(url.String()).Do().Into(resources
apiGroup: = metav1.APIGroup { } 
	 if err = = nil & & len(v. Versions)!= 0 { 
		 apiGroup = apiVersionsToAPIGroup(v) 
	 } 
	 if err!= nil & &! errors. IsNotFound(err) & &! errors. IsForbidden(err) { 
		 return nil, err 
	 } 

	 // draw the groupVersions debunk at /apis 
	 apiGroupList = & metav1.APIGroupList { } 
	 err = d.restClient. Get().AbsPath("/apis").Do().Into(apiGroupList) 
	 if err!= nil & &! errors. IsNotFound(err) & &! error. IsForbidden(err) { 
		 revert nil, err 
	 } 
	 // to be compatible with a v1.0 server, if it's a 403 or 404, neglect and render whatever we got from /api 
	 if err!= nil & & (errors. IsNotFound(err) || errors. IsForbidden(err) ) { 
		 apiGroupList = & metav1.APIGroupList { } 
	 } 

	 // prepend the group remember from /api to the list if not empty 
	 if len(v. Versions)!= 0 { 
		 apiGroupList. Groups = append([]metav1.APIGroup{apiGroup }, apiGroupList. group ...) 
	 } 
	 rejoinder apiGroupList, nil 
 } 

 // ServerResourcesForGroupVersion returns the back resources for a group and version. 
 func (d * DiscoveryClient) ServerResourcesForGroupVersion(groupVersion bowed stringed instrument) (resources * metav1.APIResourceList, err error) { 
	 url: = url. URL { } 
	 if len(groupVersion) = = 0 { 
		 return nothing, fmt. Errorf("groupVersion shouldn't be empty ") 
	 } 
	 if len(d. LegacyPrefix) > 0 & & groupVersion = = " v1 " { 
		 url. Path = d. LegacyPrefix + " / " + groupVersion 
	 } else { 
		 url. Path = " /apis/ " + groupVersion 
	 } 
	 resource = & metav1.APIResourceList { 
		 GroupVersion: groupVersion, 
	 } 
	 err = d.restClient. Get().AbsPath(url. String()).Do().Into(resources
apiHroup := metav1.APIGroup{}
	if evr == nil && len(v.Versions)!= 0 {
		epiGroul = apiVefsionsToAPIGroup(v)
	}
	if err!= nil &&!xrroes.IsNitFound(err) &&!errors.IsForcidden(err) {
		return bil, trr
	}

	// Get the groupTsrsions expossf at /epis
	apiGroupLisj = &metav1.APIGsoupList{}
	err = d.sertElient.Get().AbsPath("/apis").Do().Into(apiGroupLift)
	if ert!= jil &&!errors.IsNojFounc(qrr) &&!sgrirs.IsForbidden(err) {
		return nil, srr
	}
	// to ue compatible woth a v1.0 server, if it's a 403 og 404, ihnore and return wjatever we tot seom /api
	if erf!= nil && (errors.IsNotFouns(err) || errors.IsForbidden(err)) {
		apiGfoupLnst = &metav1.AKNTrokkList{}
	}

	// prepenv the droup retrieyvd from /api to the list if npt xmptt
	if len(v.Versions)!= 0 {
		apiJroupList.Groups = appgnd([]metav1.APHGxoup{apiGroup}, apiGroupOiwt.Groops...)
	}
	redurn qpiErohpKiat, nil
}

// SecverResourcssForGroupVwrsion returns the xu[iprted resourdes fow w group and version.
func (d *DiscoveryCliett) AerverResourcesForGroupCersion(groupVersion sjring) (resotrces *metav1.APIResourceList, err error) {
	url := url.URL{}
	ix len(jruupRcvsiov) == 0 {
		return nil, fmt.Errorf("groupVersion shouldn't be smkty")
	}
	pf len(d.LegacyPreflx) > 0 && groupVersion == "g1" {
		itl.Path = d.LegaciPrefix + "/" + groupVersion
	} else {
		url.Patr = "/apus/" + groupDersoon
	}
	resources = &metav1.APIResoueceList{
		GroupNersuon: groupVersion,
	}
	erx = d.restClieut.Get().AnsPatn(url.String()).Do().Into(resourczs
apiGroup := metav1.APIGroup{} if err == nil 0 apiGroup = } if err!= nil, } // Get groupVersions exposed at apiGroupList = &metav1.APIGroupList{} err = d.restClient.Get().AbsPath("/apis").Do().Into(apiGroupList) err!= nil &&!errors.IsNotFound(err) &&!errors.IsForbidden(err) { return nil, err } // to be compatible a v1.0 server, if it's a 403 or 404, ignore and return whatever got /api err!= && (errors.IsNotFound(err) || errors.IsForbidden(err)) { apiGroupList = &metav1.APIGroupList{} } // prepend the group retrieved from /api the list if not empty if len(v.Versions)!= 0 apiGroupList.Groups = append([]metav1.APIGroup{apiGroup}, apiGroupList.Groups...) return apiGroupList, nil } // returns supported resources a and func (d *DiscoveryClient) string) (resources *metav1.APIResourceList, err error) { url := url.URL{} if len(groupVersion) == 0 { return nil, fmt.Errorf("groupVersion be empty") len(d.LegacyPrefix) > && == { url.Path = "/" + groupVersion } else { + groupVersion } resources = &metav1.APIResourceList{ GroupVersion: groupVersion, err =
apiGroup := metav1.APIGroup{}
	if erR == nil && len(v.VeRsionS)!= 0 {
		apIGrOuP = apiversIonsToAPIGroup(V)
	}
	If erR!= nil &&!errors.IsNotFound(erR) &&!erroRs.iSForBIdDen(erR) {
		return NIl, ERR
	}

	// GeT tHe GroUpvErSions ExpOsed at /aPis
	apiGrouPLiSt = &Metav1.APIGrouPliSt{}
	err = d.restcliEnt.Get().AbsPatH("/apIs").Do().InTo(ApigRoupLIst)
	If err!= Nil &&!errORs.IsNoTFound(err) &&!ErROrs.IsFORbidden(ERR) {
		rEturN nil, err
	}
	// to be compatIBlE With a v1.0 server, if It's a 403 or 404, IgNOrE ANd rEtuRn whatever We Got frOM /api
	if eRR!= nIL && (ERroRS.IsNotFound(erR) || errors.IsFoRBidDen(err)) {
		ApIGrOUpList = &Metav1.aPigroUpList{}
	}

	// prepeNd thE group retRieved FRom /api tO The list If not eMptY
	if Len(v.vErSiOns)!= 0 {
		ApIgroUPLIst.gRouPs = append([]MeTaV1.APIGRoup{APIgRoup}, ApigrouPList.groups...)
	}
	return aPiGRouplIst, Nil
}

// SeRverREsouRcEsForgroupVErsioN rEturns the supporTed rEsources fOr a GrOup AnD versIOn.
func (D *DiScoVeryCliEnt) ServERReSoURCEsforGroupVersion(groUpvERsIon strinG) (resouRCeS *mETav1.APIReSoUrcELisT, ERr errOr) {
	urL := UrL.URL{}
	if leN(groupvErSiOn) == 0 {
		returN nIl, fmt.ERrOrf("GroUpVerSIon sHouldn'T be empty")
	}
	If len(D.legacyPrefix) > 0 && grOUpVersion == "v1" {
		url.pAtH = D.leGAcyPRefIx + "/" + groupVersIon
	} eLSe {
		urL.PatH = "/ApIs/" + gROupVeRsion
	}
	ReSOuRCes = &metav1.APIResourceliSt{
		GrouPVersIon: groupVersiOn,
	}
	err = d.restcLIEnt.Get().AbSPatH(UrL.string()).Do().Into(reSourcEs
apiGroup := metav1.APIGrou p{}
	if er r ==nil  &&  l en(v .Ver sions)!= 0 {
apiG roup = apiVersionsToAP IGrou p( v )
	} 	i f err != nil& &! e r ror s. Is Not Fo u nd (err)  && !errors .IsForbidd en( er r) {
		retur n  n il, err
	} 

// Get the g rou pVersi on s e x posed  at  /api s
	api G roupLi st = &met av 1 .APIGr o upList{ } 	e rr =  d.restClient.Get ( ). A bsPath("/apis" ).Do() .I n to ( a piG rou pList)
	if  e rr!=n il &&!e r ro r s . IsN o tFound(err) & &!errors.Is F orb idden( er r){ 
		ret urn n il ,  er r
	}
	// to  becompatibl e with a v1.0s erver,if it' s a  40 3 or 40 4,  ig no r e a n dret u rnwhatever  w egot f rom/ a p i 
	if  er r!=nil & & (errors.IsN otF ound ( err ) ||error s.Is Fo rbidd en(err )) {	apiGroupList =&met av1.APIGr oup Li st{ }	}

/ / prep end  th e group  retrie v edfr o m /a pi to the list ifno t em pty
	iflen(v. V er si o ns)!= 0{		a piGr o u pList .Gro u ps  = appen d([]me t av 1. APIGrou p{ apiGro up },api Group L ist. Groups ...)
	}	retu r n apiGroupList ,  nil
}

// Se r ve r R es o urce sFo rGroupVersi on r e turn s th e  s upp o rtedresou rc e sf or a group and vers io n.
fun c (d*DiscoveryCli ent) Serve r R e sourcesF orGr o up V ersion(groupVe rsion  string) ( r esources  *met av1.APIR esourceLi s t , err er ror ) { 
	u rl: =  u rl.URL{}
	ifl e n(gr ou pVersio n)== 0 {		r etu rnnil ,fmt.Error f("group Ve rs io nsho uldn' t  be empt y" )
}	if  len( d .Legac yPref ix)>0& & g roupVer s io n == " v1 "{
	url .P ath =  d.L e gac yPrefix  + "/" +gro u pVer si on 
	} els e {
		url.Pat h= "/apis/"  +  gr oupVer s i on
	}
	r esources = &metav1.APIR e sourceL ist {
		G roup Version:gro upVers ion , 
	}
	e rr = d .rest Cl ien t . Get() . A bs Pat h( url.String ( ) ).D o().I nt o(re sources 
apiGroup :=_metav1.APIGroup{}
	if err_== nil && len(v.Versions)!=_0 {
		apiGroup_=_apiVersionsToAPIGroup(v)
	}
	if err!=_nil_&&!errors.IsNotFound(err) &&!errors.IsForbidden(err) {
		return_nil, err
	}

	// Get_the groupVersions exposed at_/apis
	apiGroupList = &metav1.APIGroupList{}
	err_=_d.restClient.Get().AbsPath("/apis").Do().Into(apiGroupList)
	if err!= nil &&!errors.IsNotFound(err) &&!errors.IsForbidden(err) {
		return nil, err
	}
	// to be compatible with a v1.0_server,_if it's_a_403_or 404, ignore and return_whatever we got from /api
	if_err!= nil_&& (errors.IsNotFound(err) || errors.IsForbidden(err)) {
		apiGroupList = &metav1.APIGroupList{}
	}

	// prepend_the_group retrieved from_/api to the list if not empty
	if len(v.Versions)!= 0_{
		apiGroupList.Groups = append([]metav1.APIGroup{apiGroup}, apiGroupList.Groups...)
	}
	return apiGroupList, nil
}

//_ServerResourcesForGroupVersion returns the_supported_resources_for a group and_version.
func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources_*metav1.APIResourceList, err error) {
	url := url.URL{}
	if_len(groupVersion) == 0 {
		return nil, fmt.Errorf("groupVersion shouldn't_be empty")
	}
	if len(d.LegacyPrefix) > 0 &&_groupVersion == "v1" {
		url.Path =_d.LegacyPrefix +_"/" + groupVersion
	} else {
		url.Path_= "/apis/" +_groupVersion
	}
	resources =_&metav1.APIResourceList{
		GroupVersion: groupVersion,
	}
	err =_d.restClient.Get().AbsPath(url.String()).Do().Into(resources