github.com/cobalt77/jfrog-client-go@v0.14.5/artifactory/services/deleteReplication.go (about) 1 package services 2 3 import ( 4 "errors" 5 "net/http" 6 7 "github.com/cobalt77/jfrog-client-go/auth" 8 9 rthttpclient "github.com/cobalt77/jfrog-client-go/artifactory/httpclient" 10 clientutils "github.com/cobalt77/jfrog-client-go/utils" 11 "github.com/cobalt77/jfrog-client-go/utils/errorutils" 12 "github.com/cobalt77/jfrog-client-go/utils/log" 13 ) 14 15 type DeleteReplicationService struct { 16 client *rthttpclient.ArtifactoryHttpClient 17 ArtDetails auth.ServiceDetails 18 } 19 20 func NewDeleteReplicationService(client *rthttpclient.ArtifactoryHttpClient) *DeleteReplicationService { 21 return &DeleteReplicationService{client: client} 22 } 23 24 func (drs *DeleteReplicationService) GetJfrogHttpClient() *rthttpclient.ArtifactoryHttpClient { 25 return drs.client 26 } 27 28 func (drs *DeleteReplicationService) DeleteReplication(repoKey string) error { 29 httpClientsDetails := drs.ArtDetails.CreateHttpClientDetails() 30 log.Info("Deleting replication job...") 31 resp, body, err := drs.client.SendDelete(drs.ArtDetails.GetUrl()+"api/replications/"+repoKey, nil, &httpClientsDetails) 32 if err != nil { 33 return err 34 } 35 if resp.StatusCode != http.StatusOK { 36 return errorutils.CheckError(errors.New("Artifactory response: " + resp.Status + "\n" + clientutils.IndentJson(body))) 37 } 38 log.Debug("Artifactory response:", resp.Status) 39 log.Info("Done Deleting replication job.") 40 return nil 41 }