github.com/jfrog/jfrog-cli-core@v1.12.1/artifactory/commands/repository/repository.go (about)

     1  package repository
     2  
     3  import (
     4  	"encoding/json"
     5  	"errors"
     6  	"strconv"
     7  	"strings"
     8  
     9  	"github.com/jfrog/jfrog-cli-core/artifactory/commands/utils"
    10  	rtUtils "github.com/jfrog/jfrog-cli-core/artifactory/utils"
    11  	"github.com/jfrog/jfrog-cli-core/utils/config"
    12  	"github.com/jfrog/jfrog-client-go/artifactory"
    13  	"github.com/jfrog/jfrog-client-go/artifactory/services"
    14  	"github.com/jfrog/jfrog-client-go/utils/errorutils"
    15  )
    16  
    17  type RepoCommand struct {
    18  	serverDetails *config.ServerDetails
    19  	templatePath  string
    20  	vars          string
    21  }
    22  
    23  func (rc *RepoCommand) Vars() string {
    24  	return rc.vars
    25  }
    26  
    27  func (rc *RepoCommand) TemplatePath() string {
    28  	return rc.templatePath
    29  }
    30  
    31  func (rc *RepoCommand) PerformRepoCmd(isUpdate bool) (err error) {
    32  	repoConfigMap, err := utils.ConvertTemplateToMap(rc)
    33  	if err != nil {
    34  		return err
    35  	}
    36  	// All the values in the template are strings
    37  	// Go over the the confMap and write the values with the correct type using the writersMap
    38  	for key, value := range repoConfigMap {
    39  		if err = utils.ValidateMapEntry(key, value, writersMap); err != nil {
    40  			return
    41  		}
    42  		writersMap[key](&repoConfigMap, key, value.(string))
    43  	}
    44  	// Write a JSON with the correct values
    45  	content, err := json.Marshal(repoConfigMap)
    46  
    47  	servicesManager, err := rtUtils.CreateServiceManager(rc.serverDetails, -1, false)
    48  	if err != nil {
    49  		return err
    50  	}
    51  	// Rclass and packgeType are mandatory keys in our templates
    52  	// Using their values we'll pick the suitable handler from one of the handler maps to create/update a repository
    53  	switch repoConfigMap[Rclass] {
    54  	case Local:
    55  		err = localRepoHandlers[repoConfigMap[PackageType].(string)](servicesManager, content, isUpdate)
    56  	case Remote:
    57  		err = remoteRepoHandlers[repoConfigMap[PackageType].(string)](servicesManager, content, isUpdate)
    58  	case Virtual:
    59  		err = virtualRepoHandlers[repoConfigMap[PackageType].(string)](servicesManager, content, isUpdate)
    60  	default:
    61  		return errorutils.CheckError(errors.New("unsupported rclass"))
    62  	}
    63  	return err
    64  }
    65  
    66  var writersMap = map[string]utils.AnswerWriter{
    67  	Key:                               utils.WriteStringAnswer,
    68  	Rclass:                            utils.WriteStringAnswer,
    69  	PackageType:                       utils.WriteStringAnswer,
    70  	MandatoryUrl:                      utils.WriteStringAnswer,
    71  	Url:                               utils.WriteStringAnswer,
    72  	Description:                       utils.WriteStringAnswer,
    73  	Notes:                             utils.WriteStringAnswer,
    74  	IncludePatterns:                   utils.WriteStringAnswer,
    75  	ExcludePatterns:                   utils.WriteStringAnswer,
    76  	RepoLayoutRef:                     utils.WriteStringAnswer,
    77  	HandleReleases:                    utils.WriteBoolAnswer,
    78  	HandleSnapshots:                   utils.WriteBoolAnswer,
    79  	MaxUniqueSnapshots:                utils.WriteIntAnswer,
    80  	SuppressPomConsistencyChecks:      utils.WriteBoolAnswer,
    81  	BlackedOut:                        utils.WriteBoolAnswer,
    82  	DownloadRedirect:                  utils.WriteBoolAnswer,
    83  	BlockPushingSchema1:               utils.WriteBoolAnswer,
    84  	DebianTrivialLayout:               utils.WriteBoolAnswer,
    85  	ExternalDependenciesEnabled:       utils.WriteBoolAnswer,
    86  	ExternalDependenciesPatterns:      utils.WriteStringArrayAnswer,
    87  	ChecksumPolicyType:                utils.WriteStringAnswer,
    88  	MaxUniqueTags:                     utils.WriteIntAnswer,
    89  	SnapshotVersionBehavior:           utils.WriteStringAnswer,
    90  	XrayIndex:                         utils.WriteBoolAnswer,
    91  	PropertySets:                      utils.WriteStringArrayAnswer,
    92  	ArchiveBrowsingEnabled:            utils.WriteBoolAnswer,
    93  	CalculateYumMetadata:              utils.WriteBoolAnswer,
    94  	YumRootDepth:                      utils.WriteIntAnswer,
    95  	DockerApiVersion:                  utils.WriteStringAnswer,
    96  	EnableFileListsIndexing:           utils.WriteBoolAnswer,
    97  	OptionalIndexCompressionFormats:   utils.WriteStringAnswer,
    98  	Username:                          utils.WriteStringAnswer,
    99  	Password:                          utils.WriteStringAnswer,
   100  	Proxy:                             utils.WriteStringAnswer,
   101  	RemoteRepoChecksumPolicyType:      utils.WriteStringAnswer,
   102  	HardFail:                          utils.WriteBoolAnswer,
   103  	Offline:                           utils.WriteBoolAnswer,
   104  	StoreArtifactsLocally:             utils.WriteBoolAnswer,
   105  	SocketTimeoutMillis:               utils.WriteIntAnswer,
   106  	LocalAddress:                      utils.WriteStringAnswer,
   107  	RetrievalCachePeriodSecs:          utils.WriteIntAnswer,
   108  	FailedRetrievalCachePeriodSecs:    utils.WriteIntAnswer,
   109  	MissedRetrievalCachePeriodSecs:    utils.WriteIntAnswer,
   110  	UnusedArtifactsCleanupEnabled:     utils.WriteBoolAnswer,
   111  	UnusedArtifactsCleanupPeriodHours: utils.WriteIntAnswer,
   112  	AssumedOfflinePeriodSecs:          utils.WriteIntAnswer,
   113  	FetchJarsEagerly:                  utils.WriteBoolAnswer,
   114  	FetchSourcesEagerly:               utils.WriteBoolAnswer,
   115  	ShareConfiguration:                utils.WriteBoolAnswer,
   116  	SynchronizeProperties:             utils.WriteBoolAnswer,
   117  	BlockMismatchingMimeTypes:         utils.WriteBoolAnswer,
   118  	AllowAnyHostAuth:                  utils.WriteBoolAnswer,
   119  	EnableCookieManagement:            utils.WriteBoolAnswer,
   120  	BowerRegistryUrl:                  utils.WriteStringAnswer,
   121  	ComposerRegistryUrl:               utils.WriteStringAnswer,
   122  	PyPIRegistryUrl:                   utils.WriteStringAnswer,
   123  	VcsType:                           utils.WriteStringAnswer,
   124  	VcsGitProvider:                    utils.WriteStringAnswer,
   125  	VcsGitDownloadUrl:                 utils.WriteStringAnswer,
   126  	BypassHeadRequests:                utils.WriteBoolAnswer,
   127  	ClientTlsCertificate:              utils.WriteStringAnswer,
   128  	FeedContextPath:                   utils.WriteStringAnswer,
   129  	DownloadContextPath:               utils.WriteStringAnswer,
   130  	V3FeedUrl:                         utils.WriteStringAnswer,
   131  	ContentSynchronisation:            writeContentSynchronisation,
   132  	ListRemoteFolderItems:             utils.WriteBoolAnswer,
   133  	RejectInvalidJars:                 utils.WriteBoolAnswer,
   134  	PodsSpecsRepoUrl:                  utils.WriteStringAnswer,
   135  	EnableTokenAuthentication:         utils.WriteBoolAnswer,
   136  	Repositories:                      utils.WriteStringArrayAnswer,
   137  	ArtifactoryRequestsCanRetrieveRemoteArtifacts: utils.WriteBoolAnswer,
   138  	KeyPair:                              utils.WriteStringAnswer,
   139  	PomRepositoryReferencesCleanupPolicy: utils.WriteStringAnswer,
   140  	DefaultDeploymentRepo:                utils.WriteStringAnswer,
   141  	ForceMavenAuthentication:             utils.WriteBoolAnswer,
   142  	ExternalDependenciesRemoteRepo:       utils.WriteStringAnswer,
   143  }
   144  
   145  func writeContentSynchronisation(resultMap *map[string]interface{}, key, value string) error {
   146  	answerArray := strings.Split(value, ",")
   147  	if len(answerArray) != 4 {
   148  		return errors.New("invalid value for Content Synchronisation")
   149  	}
   150  	var cs services.ContentSynchronisation
   151  	cs.Enabled, _ = strconv.ParseBool(answerArray[0])
   152  	cs.Statistics.Enabled, _ = strconv.ParseBool(answerArray[1])
   153  	cs.Properties.Enabled, _ = strconv.ParseBool(answerArray[2])
   154  	cs.Source.OriginAbsenceDetection, _ = strconv.ParseBool(answerArray[3])
   155  
   156  	(*resultMap)[key] = cs
   157  	return nil
   158  
   159  }
   160  
   161  // repoHandler is a function that gets serviceManager, JSON configuration content and a flag indicates is the operation in an update operation
   162  // Each handler unmarshal the JSOn content into the jfrog-client's unique rclass-pkgType param struct, and run the operation service
   163  type repoHandler func(artifactory.ArtifactoryServicesManager, []byte, bool) error
   164  
   165  var localRepoHandlers = map[string]repoHandler{
   166  	Maven:     localMavenHandler,
   167  	Gradle:    localGradleHandler,
   168  	Ivy:       localIvyHandles,
   169  	Sbt:       localSbtHandler,
   170  	Helm:      localHelmHandler,
   171  	Cocoapods: localCocoapodsHandler,
   172  	Opkg:      localOpkgHandler,
   173  	Rpm:       localRpmHandler,
   174  	Nuget:     localNugetHandler,
   175  	Cran:      localCranHandler,
   176  	Gems:      localGemsHandler,
   177  	Npm:       localNpmHandler,
   178  	Bower:     localBowerHandler,
   179  	Debian:    localDebianHandler,
   180  	Composer:  localComposerHandler,
   181  	Pypi:      localPypiHandler,
   182  	Docker:    localDockerHandler,
   183  	Vagrant:   localVagrantHandler,
   184  	Gitlfs:    localGitlfsHandler,
   185  	Go:        localGoHandler,
   186  	Yum:       localYumHandler,
   187  	Conan:     localConanHandler,
   188  	Chef:      localChefHandler,
   189  	Puppet:    localPuppetHandler,
   190  	Generic:   localGenericHandler,
   191  }
   192  
   193  func localMavenHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   194  	params := services.NewMavenLocalRepositoryParams()
   195  	err := json.Unmarshal(jsonConfig, &params)
   196  	if errorutils.CheckError(err) != nil {
   197  		return err
   198  	}
   199  	if isUpdate {
   200  		err = servicesManager.UpdateLocalRepository().Maven(params)
   201  	} else {
   202  		err = servicesManager.CreateLocalRepository().Maven(params)
   203  	}
   204  	return err
   205  }
   206  
   207  func localGradleHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   208  	params := services.NewGradleLocalRepositoryParams()
   209  	err := json.Unmarshal(jsonConfig, &params)
   210  	if errorutils.CheckError(err) != nil {
   211  		return err
   212  	}
   213  	if isUpdate {
   214  		err = servicesManager.UpdateLocalRepository().Gradle(params)
   215  	} else {
   216  		err = servicesManager.CreateLocalRepository().Gradle(params)
   217  	}
   218  	return err
   219  }
   220  
   221  func localIvyHandles(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   222  	params := services.NewIvyLocalRepositoryParams()
   223  	err := json.Unmarshal(jsonConfig, &params)
   224  	if errorutils.CheckError(err) != nil {
   225  		return err
   226  	}
   227  	if isUpdate {
   228  		err = servicesManager.UpdateLocalRepository().Ivy(params)
   229  	} else {
   230  		err = servicesManager.CreateLocalRepository().Ivy(params)
   231  	}
   232  	return err
   233  }
   234  
   235  func localSbtHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   236  	params := services.NewSbtLocalRepositoryParams()
   237  	err := json.Unmarshal(jsonConfig, &params)
   238  	if errorutils.CheckError(err) != nil {
   239  		return err
   240  	}
   241  	if isUpdate {
   242  		err = servicesManager.UpdateLocalRepository().Sbt(params)
   243  	} else {
   244  		err = servicesManager.CreateLocalRepository().Sbt(params)
   245  	}
   246  	return err
   247  }
   248  
   249  func localHelmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   250  	params := services.NewHelmLocalRepositoryParams()
   251  	err := json.Unmarshal(jsonConfig, &params)
   252  	if errorutils.CheckError(err) != nil {
   253  		return err
   254  	}
   255  	if isUpdate {
   256  		err = servicesManager.UpdateLocalRepository().Helm(params)
   257  	} else {
   258  		err = servicesManager.CreateLocalRepository().Helm(params)
   259  	}
   260  	return err
   261  }
   262  
   263  func localCocoapodsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   264  	params := services.NewCocoapodsLocalRepositoryParams()
   265  	err := json.Unmarshal(jsonConfig, &params)
   266  	if errorutils.CheckError(err) != nil {
   267  		return err
   268  	}
   269  	if isUpdate {
   270  		err = servicesManager.UpdateLocalRepository().Cocoapods(params)
   271  	} else {
   272  		err = servicesManager.CreateLocalRepository().Cocoapods(params)
   273  	}
   274  	return err
   275  }
   276  
   277  func localOpkgHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   278  	params := services.NewOpkgLocalRepositoryParams()
   279  	err := json.Unmarshal(jsonConfig, &params)
   280  	if errorutils.CheckError(err) != nil {
   281  		return err
   282  	}
   283  	if isUpdate {
   284  		err = servicesManager.UpdateLocalRepository().Opkg(params)
   285  	} else {
   286  		err = servicesManager.CreateLocalRepository().Opkg(params)
   287  	}
   288  	return err
   289  }
   290  
   291  func localRpmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   292  	params := services.NewRpmLocalRepositoryParams()
   293  	err := json.Unmarshal(jsonConfig, &params)
   294  	if errorutils.CheckError(err) != nil {
   295  		return err
   296  	}
   297  	if isUpdate {
   298  		err = servicesManager.UpdateLocalRepository().Rpm(params)
   299  	} else {
   300  		err = servicesManager.CreateLocalRepository().Rpm(params)
   301  	}
   302  	return err
   303  }
   304  
   305  func localNugetHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   306  	params := services.NewNugetLocalRepositoryParams()
   307  	err := json.Unmarshal(jsonConfig, &params)
   308  	if errorutils.CheckError(err) != nil {
   309  		return err
   310  	}
   311  	if isUpdate {
   312  		err = servicesManager.UpdateLocalRepository().Nuget(params)
   313  	} else {
   314  		err = servicesManager.CreateLocalRepository().Nuget(params)
   315  	}
   316  	return err
   317  }
   318  
   319  func localCranHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   320  	params := services.NewCranLocalRepositoryParams()
   321  	err := json.Unmarshal(jsonConfig, &params)
   322  	if errorutils.CheckError(err) != nil {
   323  		return err
   324  	}
   325  	if isUpdate {
   326  		err = servicesManager.UpdateLocalRepository().Cran(params)
   327  	} else {
   328  		err = servicesManager.CreateLocalRepository().Cran(params)
   329  	}
   330  	return err
   331  }
   332  
   333  func localGemsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   334  	params := services.NewGemsLocalRepositoryParams()
   335  	err := json.Unmarshal(jsonConfig, &params)
   336  	if errorutils.CheckError(err) != nil {
   337  		return err
   338  	}
   339  	if isUpdate {
   340  		err = servicesManager.UpdateLocalRepository().Gems(params)
   341  	} else {
   342  		err = servicesManager.CreateLocalRepository().Gems(params)
   343  	}
   344  	return err
   345  }
   346  
   347  func localNpmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   348  	params := services.NewNpmLocalRepositoryParams()
   349  	err := json.Unmarshal(jsonConfig, &params)
   350  	if errorutils.CheckError(err) != nil {
   351  		return err
   352  	}
   353  	if isUpdate {
   354  		err = servicesManager.UpdateLocalRepository().Npm(params)
   355  	} else {
   356  		err = servicesManager.CreateLocalRepository().Npm(params)
   357  	}
   358  	return err
   359  }
   360  
   361  func localBowerHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   362  	params := services.NewBowerLocalRepositoryParams()
   363  	err := json.Unmarshal(jsonConfig, &params)
   364  	if errorutils.CheckError(err) != nil {
   365  		return err
   366  	}
   367  	if isUpdate {
   368  		err = servicesManager.UpdateLocalRepository().Bower(params)
   369  	} else {
   370  		err = servicesManager.CreateLocalRepository().Bower(params)
   371  	}
   372  	return err
   373  }
   374  
   375  func localDebianHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   376  	params := services.NewDebianLocalRepositoryParams()
   377  	err := json.Unmarshal(jsonConfig, &params)
   378  	if errorutils.CheckError(err) != nil {
   379  		return err
   380  	}
   381  	if isUpdate {
   382  		err = servicesManager.UpdateLocalRepository().Debian(params)
   383  	} else {
   384  		err = servicesManager.CreateLocalRepository().Debian(params)
   385  	}
   386  	return err
   387  }
   388  
   389  func localComposerHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   390  	params := services.NewComposerLocalRepositoryParams()
   391  	err := json.Unmarshal(jsonConfig, &params)
   392  	if errorutils.CheckError(err) != nil {
   393  		return err
   394  	}
   395  	if isUpdate {
   396  		err = servicesManager.UpdateLocalRepository().Composer(params)
   397  	} else {
   398  		err = servicesManager.CreateLocalRepository().Composer(params)
   399  	}
   400  	return err
   401  }
   402  
   403  func localPypiHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   404  	params := services.NewPypiLocalRepositoryParams()
   405  	err := json.Unmarshal(jsonConfig, &params)
   406  	if errorutils.CheckError(err) != nil {
   407  		return err
   408  	}
   409  	if isUpdate {
   410  		err = servicesManager.UpdateLocalRepository().Pypi(params)
   411  	} else {
   412  		err = servicesManager.CreateLocalRepository().Pypi(params)
   413  	}
   414  	return err
   415  }
   416  
   417  func localDockerHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   418  	params := services.NewDockerLocalRepositoryParams()
   419  	err := json.Unmarshal(jsonConfig, &params)
   420  	if errorutils.CheckError(err) != nil {
   421  		return err
   422  	}
   423  	if isUpdate {
   424  		err = servicesManager.UpdateLocalRepository().Docker(params)
   425  	} else {
   426  		err = servicesManager.CreateLocalRepository().Docker(params)
   427  	}
   428  	return err
   429  }
   430  
   431  func localVagrantHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   432  	params := services.NewVagrantLocalRepositoryParams()
   433  	err := json.Unmarshal(jsonConfig, &params)
   434  	if errorutils.CheckError(err) != nil {
   435  		return err
   436  	}
   437  	if isUpdate {
   438  		err = servicesManager.UpdateLocalRepository().Vagrant(params)
   439  	} else {
   440  		err = servicesManager.CreateLocalRepository().Vagrant(params)
   441  	}
   442  	return err
   443  }
   444  
   445  func localGitlfsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   446  	params := services.NewGitlfsLocalRepositoryParams()
   447  	err := json.Unmarshal(jsonConfig, &params)
   448  	if errorutils.CheckError(err) != nil {
   449  		return err
   450  	}
   451  	if isUpdate {
   452  		err = servicesManager.UpdateLocalRepository().Gitlfs(params)
   453  	} else {
   454  		err = servicesManager.CreateLocalRepository().Gitlfs(params)
   455  	}
   456  	return err
   457  }
   458  
   459  func localGoHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   460  	params := services.NewGoLocalRepositoryParams()
   461  	err := json.Unmarshal(jsonConfig, &params)
   462  	if errorutils.CheckError(err) != nil {
   463  		return err
   464  	}
   465  	if isUpdate {
   466  		err = servicesManager.UpdateLocalRepository().Go(params)
   467  	} else {
   468  		err = servicesManager.CreateLocalRepository().Go(params)
   469  	}
   470  	return err
   471  }
   472  
   473  func localYumHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   474  	params := services.NewYumLocalRepositoryParams()
   475  	err := json.Unmarshal(jsonConfig, &params)
   476  	if errorutils.CheckError(err) != nil {
   477  		return err
   478  	}
   479  	if isUpdate {
   480  		err = servicesManager.UpdateLocalRepository().Yum(params)
   481  	} else {
   482  		err = servicesManager.CreateLocalRepository().Yum(params)
   483  	}
   484  	return err
   485  }
   486  
   487  func localConanHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   488  	params := services.NewConanLocalRepositoryParams()
   489  	err := json.Unmarshal(jsonConfig, &params)
   490  	if errorutils.CheckError(err) != nil {
   491  		return err
   492  	}
   493  	if isUpdate {
   494  		err = servicesManager.UpdateLocalRepository().Conan(params)
   495  	} else {
   496  		err = servicesManager.CreateLocalRepository().Conan(params)
   497  	}
   498  	return err
   499  }
   500  
   501  func localChefHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   502  	params := services.NewChefLocalRepositoryParams()
   503  	err := json.Unmarshal(jsonConfig, &params)
   504  	if errorutils.CheckError(err) != nil {
   505  		return err
   506  	}
   507  	if isUpdate {
   508  		err = servicesManager.UpdateLocalRepository().Chef(params)
   509  	} else {
   510  		err = servicesManager.CreateLocalRepository().Chef(params)
   511  	}
   512  	return err
   513  }
   514  
   515  func localPuppetHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   516  	params := services.NewPuppetLocalRepositoryParams()
   517  	err := json.Unmarshal(jsonConfig, &params)
   518  	if errorutils.CheckError(err) != nil {
   519  		return err
   520  	}
   521  	if isUpdate {
   522  		err = servicesManager.UpdateLocalRepository().Puppet(params)
   523  	} else {
   524  		err = servicesManager.CreateLocalRepository().Puppet(params)
   525  	}
   526  	return err
   527  }
   528  
   529  func localGenericHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   530  	params := services.NewGenericLocalRepositoryParams()
   531  	err := json.Unmarshal(jsonConfig, &params)
   532  	if errorutils.CheckError(err) != nil {
   533  		return err
   534  	}
   535  
   536  	if isUpdate {
   537  		err = servicesManager.UpdateLocalRepository().Generic(params)
   538  	} else {
   539  		err = servicesManager.CreateLocalRepository().Generic(params)
   540  	}
   541  	return err
   542  }
   543  
   544  var remoteRepoHandlers = map[string]repoHandler{
   545  	Maven:     remoteMavenHandler,
   546  	Gradle:    remoteGradleHandler,
   547  	Ivy:       remoteIvyHandler,
   548  	Sbt:       remoteSbtHandler,
   549  	Helm:      remoteHelmHandler,
   550  	Cocoapods: remoteCocoapodsHandler,
   551  	Opkg:      remoteOpkgHandler,
   552  	Rpm:       remoteRpmHandler,
   553  	Nuget:     remoteNugetHandler,
   554  	Cran:      remoteCranHandler,
   555  	Gems:      remoteGemsHandler,
   556  	Npm:       remoteNpmHandler,
   557  	Bower:     remoteBowerHandler,
   558  	Debian:    remoteDebianHandler,
   559  	Composer:  remoteComposerHandler,
   560  	Pypi:      remotelPypiHandler,
   561  	Docker:    remoteDockerHandler,
   562  	Gitlfs:    remoteGitlfsHandler,
   563  	Go:        remoteGoHandler,
   564  	Yum:       remoteYumHandler,
   565  	Conan:     remoteConanHandler,
   566  	Chef:      remoteChefHandler,
   567  	Puppet:    remotePuppetHandler,
   568  	Conda:     remoteCondaHandler,
   569  	P2:        remoteP2Handler,
   570  	Vcs:       remoteVcsHandler,
   571  	Generic:   remoteGenericHandler,
   572  }
   573  
   574  func remoteMavenHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   575  	params := services.NewMavenRemoteRepositoryParams()
   576  	err := json.Unmarshal(jsonConfig, &params)
   577  	if errorutils.CheckError(err) != nil {
   578  		return err
   579  	}
   580  	if isUpdate {
   581  		err = servicesManager.UpdateRemoteRepository().Maven(params)
   582  	} else {
   583  		err = servicesManager.CreateRemoteRepository().Maven(params)
   584  	}
   585  	return err
   586  }
   587  
   588  func remoteGradleHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   589  	params := services.NewGradleRemoteRepositoryParams()
   590  	err := json.Unmarshal(jsonConfig, &params)
   591  	if errorutils.CheckError(err) != nil {
   592  		return err
   593  	}
   594  	if isUpdate {
   595  		err = servicesManager.UpdateRemoteRepository().Gradle(params)
   596  	} else {
   597  		err = servicesManager.CreateRemoteRepository().Gradle(params)
   598  	}
   599  	return err
   600  }
   601  
   602  func remoteIvyHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   603  	params := services.NewIvyRemoteRepositoryParams()
   604  	err := json.Unmarshal(jsonConfig, &params)
   605  	if errorutils.CheckError(err) != nil {
   606  		return err
   607  	}
   608  	if isUpdate {
   609  		err = servicesManager.UpdateRemoteRepository().Ivy(params)
   610  	} else {
   611  		err = servicesManager.CreateRemoteRepository().Ivy(params)
   612  	}
   613  	return err
   614  }
   615  
   616  func remoteSbtHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   617  	params := services.NewSbtRemoteRepositoryParams()
   618  	err := json.Unmarshal(jsonConfig, &params)
   619  	if errorutils.CheckError(err) != nil {
   620  		return err
   621  	}
   622  	if isUpdate {
   623  		err = servicesManager.UpdateRemoteRepository().Sbt(params)
   624  	} else {
   625  		err = servicesManager.CreateRemoteRepository().Sbt(params)
   626  	}
   627  	return err
   628  }
   629  
   630  func remoteHelmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   631  	params := services.NewHelmRemoteRepositoryParams()
   632  	err := json.Unmarshal(jsonConfig, &params)
   633  	if errorutils.CheckError(err) != nil {
   634  		return err
   635  	}
   636  	if isUpdate {
   637  		err = servicesManager.UpdateRemoteRepository().Helm(params)
   638  	} else {
   639  		err = servicesManager.CreateRemoteRepository().Helm(params)
   640  	}
   641  	return err
   642  }
   643  
   644  func remoteCocoapodsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   645  	params := services.NewCocoapodsRemoteRepositoryParams()
   646  	err := json.Unmarshal(jsonConfig, &params)
   647  	if errorutils.CheckError(err) != nil {
   648  		return err
   649  	}
   650  	if isUpdate {
   651  		err = servicesManager.UpdateRemoteRepository().Cocoapods(params)
   652  	} else {
   653  		err = servicesManager.CreateRemoteRepository().Cocoapods(params)
   654  	}
   655  	return err
   656  }
   657  
   658  func remoteOpkgHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   659  	params := services.NewOpkgRemoteRepositoryParams()
   660  	err := json.Unmarshal(jsonConfig, &params)
   661  	if errorutils.CheckError(err) != nil {
   662  		return err
   663  	}
   664  	if isUpdate {
   665  		err = servicesManager.UpdateRemoteRepository().Opkg(params)
   666  	} else {
   667  		err = servicesManager.CreateRemoteRepository().Opkg(params)
   668  	}
   669  	return err
   670  }
   671  
   672  func remoteRpmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   673  	params := services.NewRpmRemoteRepositoryParams()
   674  	err := json.Unmarshal(jsonConfig, &params)
   675  	if errorutils.CheckError(err) != nil {
   676  		return err
   677  	}
   678  	if isUpdate {
   679  		err = servicesManager.UpdateRemoteRepository().Rpm(params)
   680  	} else {
   681  		err = servicesManager.CreateRemoteRepository().Rpm(params)
   682  	}
   683  	return err
   684  }
   685  
   686  func remoteNugetHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   687  	params := services.NewNugetRemoteRepositoryParams()
   688  	err := json.Unmarshal(jsonConfig, &params)
   689  	if errorutils.CheckError(err) != nil {
   690  		return err
   691  	}
   692  	if isUpdate {
   693  		err = servicesManager.UpdateRemoteRepository().Nuget(params)
   694  	} else {
   695  		err = servicesManager.CreateRemoteRepository().Nuget(params)
   696  	}
   697  	return err
   698  }
   699  
   700  func remoteCranHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   701  	params := services.NewCranRemoteRepositoryParams()
   702  	err := json.Unmarshal(jsonConfig, &params)
   703  	if errorutils.CheckError(err) != nil {
   704  		return err
   705  	}
   706  	if isUpdate {
   707  		err = servicesManager.UpdateRemoteRepository().Cran(params)
   708  	} else {
   709  		err = servicesManager.CreateRemoteRepository().Cran(params)
   710  	}
   711  	return err
   712  }
   713  
   714  func remoteGemsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   715  	params := services.NewGemsRemoteRepositoryParams()
   716  	err := json.Unmarshal(jsonConfig, &params)
   717  	if errorutils.CheckError(err) != nil {
   718  		return err
   719  	}
   720  	if isUpdate {
   721  		err = servicesManager.UpdateRemoteRepository().Gems(params)
   722  	} else {
   723  		err = servicesManager.CreateRemoteRepository().Gems(params)
   724  	}
   725  	return err
   726  }
   727  
   728  func remoteNpmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   729  	params := services.NewNpmRemoteRepositoryParams()
   730  	err := json.Unmarshal(jsonConfig, &params)
   731  	if errorutils.CheckError(err) != nil {
   732  		return err
   733  	}
   734  	if isUpdate {
   735  		err = servicesManager.UpdateRemoteRepository().Npm(params)
   736  	} else {
   737  		err = servicesManager.CreateRemoteRepository().Npm(params)
   738  	}
   739  	return err
   740  }
   741  
   742  func remoteBowerHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   743  	params := services.NewBowerRemoteRepositoryParams()
   744  	err := json.Unmarshal(jsonConfig, &params)
   745  	if errorutils.CheckError(err) != nil {
   746  		return err
   747  	}
   748  	if isUpdate {
   749  		err = servicesManager.UpdateRemoteRepository().Bower(params)
   750  	} else {
   751  		err = servicesManager.CreateRemoteRepository().Bower(params)
   752  	}
   753  	return err
   754  }
   755  
   756  func remoteDebianHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   757  	params := services.NewDebianRemoteRepositoryParams()
   758  	err := json.Unmarshal(jsonConfig, &params)
   759  	if errorutils.CheckError(err) != nil {
   760  		return err
   761  	}
   762  	if isUpdate {
   763  		err = servicesManager.UpdateRemoteRepository().Debian(params)
   764  	} else {
   765  		err = servicesManager.CreateRemoteRepository().Debian(params)
   766  	}
   767  	return err
   768  }
   769  
   770  func remoteComposerHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   771  	params := services.NewComposerRemoteRepositoryParams()
   772  	err := json.Unmarshal(jsonConfig, &params)
   773  	if errorutils.CheckError(err) != nil {
   774  		return err
   775  	}
   776  	if isUpdate {
   777  		err = servicesManager.UpdateRemoteRepository().Composer(params)
   778  	} else {
   779  		err = servicesManager.CreateRemoteRepository().Composer(params)
   780  	}
   781  	return err
   782  }
   783  
   784  func remotelPypiHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   785  	params := services.NewPypiRemoteRepositoryParams()
   786  	err := json.Unmarshal(jsonConfig, &params)
   787  	if errorutils.CheckError(err) != nil {
   788  		return err
   789  	}
   790  	if isUpdate {
   791  		err = servicesManager.UpdateRemoteRepository().Pypi(params)
   792  	} else {
   793  		err = servicesManager.CreateRemoteRepository().Pypi(params)
   794  	}
   795  	return err
   796  }
   797  
   798  func remoteDockerHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   799  	params := services.NewDockerRemoteRepositoryParams()
   800  	err := json.Unmarshal(jsonConfig, &params)
   801  	if errorutils.CheckError(err) != nil {
   802  		return err
   803  	}
   804  	if isUpdate {
   805  		err = servicesManager.UpdateRemoteRepository().Docker(params)
   806  	} else {
   807  		err = servicesManager.CreateRemoteRepository().Docker(params)
   808  	}
   809  	return err
   810  }
   811  
   812  func remoteGitlfsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   813  	params := services.NewGitlfsRemoteRepositoryParams()
   814  	err := json.Unmarshal(jsonConfig, &params)
   815  	if errorutils.CheckError(err) != nil {
   816  		return err
   817  	}
   818  	if isUpdate {
   819  		err = servicesManager.UpdateRemoteRepository().Gitlfs(params)
   820  	} else {
   821  		err = servicesManager.CreateRemoteRepository().Gitlfs(params)
   822  	}
   823  	return err
   824  }
   825  
   826  func remoteGoHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   827  	params := services.NewGoRemoteRepositoryParams()
   828  	err := json.Unmarshal(jsonConfig, &params)
   829  	if errorutils.CheckError(err) != nil {
   830  		return err
   831  	}
   832  	if isUpdate {
   833  		err = servicesManager.UpdateRemoteRepository().Go(params)
   834  	} else {
   835  		err = servicesManager.CreateRemoteRepository().Go(params)
   836  	}
   837  	return err
   838  }
   839  
   840  func remoteConanHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   841  	params := services.NewConanRemoteRepositoryParams()
   842  	err := json.Unmarshal(jsonConfig, &params)
   843  	if errorutils.CheckError(err) != nil {
   844  		return err
   845  	}
   846  	if isUpdate {
   847  		err = servicesManager.UpdateRemoteRepository().Conan(params)
   848  	} else {
   849  		err = servicesManager.CreateRemoteRepository().Conan(params)
   850  	}
   851  	return err
   852  }
   853  
   854  func remoteChefHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   855  	params := services.NewChefRemoteRepositoryParams()
   856  	err := json.Unmarshal(jsonConfig, &params)
   857  	if errorutils.CheckError(err) != nil {
   858  		return err
   859  	}
   860  	if isUpdate {
   861  		err = servicesManager.UpdateRemoteRepository().Chef(params)
   862  	} else {
   863  		err = servicesManager.CreateRemoteRepository().Chef(params)
   864  	}
   865  	return err
   866  }
   867  
   868  func remotePuppetHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   869  	params := services.NewPuppetRemoteRepositoryParams()
   870  	err := json.Unmarshal(jsonConfig, &params)
   871  	if errorutils.CheckError(err) != nil {
   872  		return err
   873  	}
   874  	if isUpdate {
   875  		err = servicesManager.UpdateRemoteRepository().Puppet(params)
   876  	} else {
   877  		err = servicesManager.CreateRemoteRepository().Puppet(params)
   878  	}
   879  	return err
   880  }
   881  
   882  func remoteVcsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   883  	params := services.NewVcsRemoteRepositoryParams()
   884  	err := json.Unmarshal(jsonConfig, &params)
   885  	if errorutils.CheckError(err) != nil {
   886  		return err
   887  	}
   888  	if isUpdate {
   889  		err = servicesManager.UpdateRemoteRepository().Vcs(params)
   890  	} else {
   891  		err = servicesManager.CreateRemoteRepository().Vcs(params)
   892  	}
   893  	return err
   894  }
   895  
   896  func remoteP2Handler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   897  	params := services.NewP2RemoteRepositoryParams()
   898  	err := json.Unmarshal(jsonConfig, &params)
   899  	if errorutils.CheckError(err) != nil {
   900  		return err
   901  	}
   902  	if isUpdate {
   903  		err = servicesManager.UpdateRemoteRepository().P2(params)
   904  	} else {
   905  		err = servicesManager.CreateRemoteRepository().P2(params)
   906  	}
   907  	return err
   908  }
   909  
   910  func remoteCondaHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   911  	params := services.NewCondaRemoteRepositoryParams()
   912  	err := json.Unmarshal(jsonConfig, &params)
   913  	if errorutils.CheckError(err) != nil {
   914  		return err
   915  	}
   916  	if isUpdate {
   917  		err = servicesManager.UpdateRemoteRepository().Conda(params)
   918  	} else {
   919  		err = servicesManager.CreateRemoteRepository().Conda(params)
   920  	}
   921  	return err
   922  }
   923  
   924  func remoteYumHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   925  	params := services.NewYumRemoteRepositoryParams()
   926  	err := json.Unmarshal(jsonConfig, &params)
   927  	if errorutils.CheckError(err) != nil {
   928  		return err
   929  	}
   930  	if isUpdate {
   931  		err = servicesManager.UpdateRemoteRepository().Yum(params)
   932  	} else {
   933  		err = servicesManager.CreateRemoteRepository().Yum(params)
   934  	}
   935  	return err
   936  }
   937  
   938  func remoteGenericHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   939  	params := services.NewGenericRemoteRepositoryParams()
   940  	err := json.Unmarshal(jsonConfig, &params)
   941  	if errorutils.CheckError(err) != nil {
   942  		return err
   943  	}
   944  	if isUpdate {
   945  		err = servicesManager.UpdateRemoteRepository().Generic(params)
   946  	} else {
   947  		err = servicesManager.CreateRemoteRepository().Generic(params)
   948  	}
   949  	return err
   950  }
   951  
   952  var virtualRepoHandlers = map[string]repoHandler{
   953  	Maven:   virtualMavenHandler,
   954  	Gradle:  virtualGradleHandler,
   955  	Ivy:     virtualIvyHandler,
   956  	Sbt:     virtualSbtHandler,
   957  	Helm:    virtualHelmHandler,
   958  	Rpm:     virtualRpmHandler,
   959  	Nuget:   virtualNugetHandler,
   960  	Cran:    virtualCranHandler,
   961  	Gems:    virtualGemsHandler,
   962  	Npm:     virtualNpmHandler,
   963  	Bower:   virtualBowerHandler,
   964  	Debian:  virtualDebianHandler,
   965  	Pypi:    virtualPypiHandler,
   966  	Docker:  virtualDockerHandler,
   967  	Gitlfs:  virtualGitlfsHandler,
   968  	Go:      virtualGoHandler,
   969  	Yum:     virtualYumHandler,
   970  	Conan:   virtualConanHandler,
   971  	Chef:    virtualChefHandler,
   972  	Puppet:  virtualPuppetHandler,
   973  	Conda:   virtualCondaHandler,
   974  	P2:      virtualP2Handler,
   975  	Generic: virtualGenericHandler,
   976  }
   977  
   978  func virtualMavenHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   979  	params := services.NewMavenVirtualRepositoryParams()
   980  	err := json.Unmarshal(jsonConfig, &params)
   981  	if errorutils.CheckError(err) != nil {
   982  		return err
   983  	}
   984  	if isUpdate {
   985  		err = servicesManager.UpdateVirtualRepository().Maven(params)
   986  	} else {
   987  		err = servicesManager.CreateVirtualRepository().Maven(params)
   988  	}
   989  	return err
   990  }
   991  
   992  func virtualGradleHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
   993  	params := services.NewGradleVirtualRepositoryParams()
   994  	err := json.Unmarshal(jsonConfig, &params)
   995  	if errorutils.CheckError(err) != nil {
   996  		return err
   997  	}
   998  	if isUpdate {
   999  		err = servicesManager.UpdateVirtualRepository().Gradle(params)
  1000  	} else {
  1001  		err = servicesManager.CreateVirtualRepository().Gradle(params)
  1002  	}
  1003  	return err
  1004  }
  1005  
  1006  func virtualIvyHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1007  	params := services.NewIvyVirtualRepositoryParams()
  1008  	err := json.Unmarshal(jsonConfig, &params)
  1009  	if errorutils.CheckError(err) != nil {
  1010  		return err
  1011  	}
  1012  	if isUpdate {
  1013  		err = servicesManager.UpdateVirtualRepository().Ivy(params)
  1014  	} else {
  1015  		err = servicesManager.CreateVirtualRepository().Ivy(params)
  1016  	}
  1017  	return err
  1018  }
  1019  
  1020  func virtualSbtHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1021  	params := services.NewSbtVirtualRepositoryParams()
  1022  	err := json.Unmarshal(jsonConfig, &params)
  1023  	if errorutils.CheckError(err) != nil {
  1024  		return err
  1025  	}
  1026  	if isUpdate {
  1027  		err = servicesManager.UpdateVirtualRepository().Sbt(params)
  1028  	} else {
  1029  		err = servicesManager.CreateVirtualRepository().Sbt(params)
  1030  	}
  1031  	return err
  1032  }
  1033  
  1034  func virtualHelmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1035  	params := services.NewHelmVirtualRepositoryParams()
  1036  	err := json.Unmarshal(jsonConfig, &params)
  1037  	if errorutils.CheckError(err) != nil {
  1038  		return err
  1039  	}
  1040  	if isUpdate {
  1041  		err = servicesManager.UpdateVirtualRepository().Helm(params)
  1042  	} else {
  1043  		err = servicesManager.CreateVirtualRepository().Helm(params)
  1044  	}
  1045  	return err
  1046  }
  1047  
  1048  func virtualRpmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1049  	params := services.NewRpmVirtualRepositoryParams()
  1050  	err := json.Unmarshal(jsonConfig, &params)
  1051  	if errorutils.CheckError(err) != nil {
  1052  		return err
  1053  	}
  1054  	if isUpdate {
  1055  		err = servicesManager.UpdateVirtualRepository().Rpm(params)
  1056  	} else {
  1057  		err = servicesManager.CreateVirtualRepository().Rpm(params)
  1058  	}
  1059  	return err
  1060  }
  1061  
  1062  func virtualNugetHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1063  	params := services.NewNugetVirtualRepositoryParams()
  1064  	err := json.Unmarshal(jsonConfig, &params)
  1065  	if errorutils.CheckError(err) != nil {
  1066  		return err
  1067  	}
  1068  	if isUpdate {
  1069  		err = servicesManager.UpdateVirtualRepository().Nuget(params)
  1070  	} else {
  1071  		err = servicesManager.CreateVirtualRepository().Nuget(params)
  1072  	}
  1073  	return err
  1074  }
  1075  
  1076  func virtualCranHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1077  	params := services.NewCranVirtualRepositoryParams()
  1078  	err := json.Unmarshal(jsonConfig, &params)
  1079  	if errorutils.CheckError(err) != nil {
  1080  		return err
  1081  	}
  1082  	if isUpdate {
  1083  		err = servicesManager.UpdateVirtualRepository().Cran(params)
  1084  	} else {
  1085  		err = servicesManager.CreateVirtualRepository().Cran(params)
  1086  	}
  1087  	return err
  1088  }
  1089  
  1090  func virtualGemsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1091  	params := services.NewGemsVirtualRepositoryParams()
  1092  	err := json.Unmarshal(jsonConfig, &params)
  1093  	if errorutils.CheckError(err) != nil {
  1094  		return err
  1095  	}
  1096  	if isUpdate {
  1097  		err = servicesManager.UpdateVirtualRepository().Gems(params)
  1098  	} else {
  1099  		err = servicesManager.CreateVirtualRepository().Gems(params)
  1100  	}
  1101  	return err
  1102  }
  1103  
  1104  func virtualNpmHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1105  	params := services.NewNpmVirtualRepositoryParams()
  1106  	err := json.Unmarshal(jsonConfig, &params)
  1107  	if errorutils.CheckError(err) != nil {
  1108  		return err
  1109  	}
  1110  	if isUpdate {
  1111  		err = servicesManager.UpdateVirtualRepository().Npm(params)
  1112  	} else {
  1113  		err = servicesManager.CreateVirtualRepository().Npm(params)
  1114  	}
  1115  	return err
  1116  }
  1117  
  1118  func virtualBowerHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1119  	params := services.NewBowerVirtualRepositoryParams()
  1120  	err := json.Unmarshal(jsonConfig, &params)
  1121  	if errorutils.CheckError(err) != nil {
  1122  		return err
  1123  	}
  1124  	if isUpdate {
  1125  		err = servicesManager.UpdateVirtualRepository().Bower(params)
  1126  	} else {
  1127  		err = servicesManager.CreateVirtualRepository().Bower(params)
  1128  	}
  1129  	return err
  1130  }
  1131  
  1132  func virtualDebianHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1133  	params := services.NewDebianVirtualRepositoryParams()
  1134  	err := json.Unmarshal(jsonConfig, &params)
  1135  	if errorutils.CheckError(err) != nil {
  1136  		return err
  1137  	}
  1138  	if isUpdate {
  1139  		err = servicesManager.UpdateVirtualRepository().Debian(params)
  1140  	} else {
  1141  		err = servicesManager.CreateVirtualRepository().Debian(params)
  1142  	}
  1143  	return err
  1144  }
  1145  
  1146  func virtualPypiHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1147  	params := services.NewPypiVirtualRepositoryParams()
  1148  	err := json.Unmarshal(jsonConfig, &params)
  1149  	if errorutils.CheckError(err) != nil {
  1150  		return err
  1151  	}
  1152  	if isUpdate {
  1153  		err = servicesManager.UpdateVirtualRepository().Pypi(params)
  1154  	} else {
  1155  		err = servicesManager.CreateVirtualRepository().Pypi(params)
  1156  	}
  1157  	return err
  1158  }
  1159  
  1160  func virtualDockerHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1161  	params := services.NewDockerVirtualRepositoryParams()
  1162  	err := json.Unmarshal(jsonConfig, &params)
  1163  	if errorutils.CheckError(err) != nil {
  1164  		return err
  1165  	}
  1166  	if isUpdate {
  1167  		err = servicesManager.UpdateVirtualRepository().Docker(params)
  1168  	} else {
  1169  		err = servicesManager.CreateVirtualRepository().Docker(params)
  1170  	}
  1171  	return err
  1172  }
  1173  
  1174  func virtualGitlfsHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1175  	params := services.NewGitlfsVirtualRepositoryParams()
  1176  	err := json.Unmarshal(jsonConfig, &params)
  1177  	if errorutils.CheckError(err) != nil {
  1178  		return err
  1179  	}
  1180  	if isUpdate {
  1181  		err = servicesManager.UpdateVirtualRepository().Gitlfs(params)
  1182  	} else {
  1183  		err = servicesManager.CreateVirtualRepository().Gitlfs(params)
  1184  	}
  1185  	return err
  1186  }
  1187  
  1188  func virtualGoHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1189  	params := services.NewGoVirtualRepositoryParams()
  1190  	err := json.Unmarshal(jsonConfig, &params)
  1191  	if errorutils.CheckError(err) != nil {
  1192  		return err
  1193  	}
  1194  	if isUpdate {
  1195  		err = servicesManager.UpdateVirtualRepository().Go(params)
  1196  	} else {
  1197  		err = servicesManager.CreateVirtualRepository().Go(params)
  1198  	}
  1199  	return err
  1200  }
  1201  
  1202  func virtualConanHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1203  	params := services.NewConanVirtualRepositoryParams()
  1204  	err := json.Unmarshal(jsonConfig, &params)
  1205  	if errorutils.CheckError(err) != nil {
  1206  		return err
  1207  	}
  1208  	if isUpdate {
  1209  		err = servicesManager.UpdateVirtualRepository().Conan(params)
  1210  	} else {
  1211  		err = servicesManager.CreateVirtualRepository().Conan(params)
  1212  	}
  1213  	return err
  1214  }
  1215  
  1216  func virtualChefHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1217  	params := services.NewChefVirtualRepositoryParams()
  1218  	err := json.Unmarshal(jsonConfig, &params)
  1219  	if errorutils.CheckError(err) != nil {
  1220  		return err
  1221  	}
  1222  	if isUpdate {
  1223  		err = servicesManager.UpdateVirtualRepository().Chef(params)
  1224  	} else {
  1225  		err = servicesManager.CreateVirtualRepository().Chef(params)
  1226  	}
  1227  	return err
  1228  }
  1229  
  1230  func virtualPuppetHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1231  	params := services.NewPuppetVirtualRepositoryParams()
  1232  	err := json.Unmarshal(jsonConfig, &params)
  1233  	if errorutils.CheckError(err) != nil {
  1234  		return err
  1235  	}
  1236  	if isUpdate {
  1237  		err = servicesManager.UpdateVirtualRepository().Puppet(params)
  1238  	} else {
  1239  		err = servicesManager.CreateVirtualRepository().Puppet(params)
  1240  	}
  1241  	return err
  1242  }
  1243  
  1244  func virtualYumHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1245  	params := services.NewYumVirtualRepositoryParams()
  1246  	err := json.Unmarshal(jsonConfig, &params)
  1247  	if errorutils.CheckError(err) != nil {
  1248  		return err
  1249  	}
  1250  	if isUpdate {
  1251  		err = servicesManager.UpdateVirtualRepository().Yum(params)
  1252  	} else {
  1253  		err = servicesManager.CreateVirtualRepository().Yum(params)
  1254  	}
  1255  	return err
  1256  }
  1257  
  1258  func virtualP2Handler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1259  	params := services.NewP2VirtualRepositoryParams()
  1260  	err := json.Unmarshal(jsonConfig, &params)
  1261  	if errorutils.CheckError(err) != nil {
  1262  		return err
  1263  	}
  1264  	if isUpdate {
  1265  		err = servicesManager.UpdateVirtualRepository().P2(params)
  1266  	} else {
  1267  		err = servicesManager.CreateVirtualRepository().P2(params)
  1268  	}
  1269  	return err
  1270  }
  1271  
  1272  func virtualCondaHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1273  	params := services.NewCondaVirtualRepositoryParams()
  1274  	err := json.Unmarshal(jsonConfig, &params)
  1275  	if errorutils.CheckError(err) != nil {
  1276  		return err
  1277  	}
  1278  	if isUpdate {
  1279  		err = servicesManager.UpdateVirtualRepository().Conda(params)
  1280  	} else {
  1281  		err = servicesManager.CreateVirtualRepository().Conda(params)
  1282  	}
  1283  	return err
  1284  }
  1285  
  1286  func virtualGenericHandler(servicesManager artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error {
  1287  	params := services.NewGenericVirtualRepositoryParams()
  1288  	err := json.Unmarshal(jsonConfig, &params)
  1289  	if errorutils.CheckError(err) != nil {
  1290  		return err
  1291  	}
  1292  	if isUpdate {
  1293  		err = servicesManager.UpdateVirtualRepository().Generic(params)
  1294  	} else {
  1295  		err = servicesManager.CreateVirtualRepository().Generic(params)
  1296  	}
  1297  	return err
  1298  }