|
| 1 | +package org.jfrog.build.extractor.clientConfiguration.client.distribution; |
| 2 | + |
| 3 | +import org.apache.commons.lang.StringUtils; |
| 4 | +import org.jfrog.build.api.util.Log; |
| 5 | +import org.jfrog.build.extractor.clientConfiguration.client.ManagerBase; |
| 6 | +import org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest; |
| 7 | +import org.jfrog.build.extractor.clientConfiguration.client.distribution.request.DeleteReleaseBundleRequest; |
| 8 | +import org.jfrog.build.extractor.clientConfiguration.client.distribution.request.DistributeReleaseBundleRequest; |
| 9 | +import org.jfrog.build.extractor.clientConfiguration.client.distribution.request.UpdateReleaseBundleRequest; |
| 10 | +import org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributeReleaseBundleResponse; |
| 11 | +import org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributionStatusResponse; |
| 12 | +import org.jfrog.build.extractor.clientConfiguration.client.distribution.response.GetReleaseBundleStatusResponse; |
| 13 | +import org.jfrog.build.extractor.clientConfiguration.client.distribution.services.*; |
| 14 | + |
| 15 | +import java.io.IOException; |
| 16 | + |
| 17 | +/** |
| 18 | + * @author yahavi |
| 19 | + */ |
| 20 | +@SuppressWarnings("unused") |
| 21 | +public class DistributionManager extends ManagerBase { |
| 22 | + public DistributionManager(String url, String username, String password, String accessToken, Log logger) { |
| 23 | + super(url, username, password, accessToken, logger); |
| 24 | + } |
| 25 | + |
| 26 | + public DistributionManager(String url, String username, String password, Log log) { |
| 27 | + super(url, username, password, StringUtils.EMPTY, log); |
| 28 | + } |
| 29 | + |
| 30 | + public DistributionManager(String url, String accessToken, Log log) { |
| 31 | + super(url, StringUtils.EMPTY, StringUtils.EMPTY, accessToken, log); |
| 32 | + } |
| 33 | + |
| 34 | + public DistributionManager(String url, Log log) { |
| 35 | + super(url, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, log); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Get version of JFrog distribution. |
| 40 | + * |
| 41 | + * @return version of JFrog distribution |
| 42 | + * @throws IOException in case of any error |
| 43 | + */ |
| 44 | + public org.jfrog.build.client.Version getVersion() throws IOException { |
| 45 | + Version versionService = new Version(log); |
| 46 | + return versionService.execute(jfrogHttpClient); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Create a release bundle. |
| 51 | + * |
| 52 | + * @param request - The release bundle details |
| 53 | + * @param gpgPassphrase - GPG passphrase |
| 54 | + * @throws IOException in case of any error |
| 55 | + */ |
| 56 | + public void createReleaseBundle(CreateReleaseBundleRequest request, String gpgPassphrase) throws IOException { |
| 57 | + new CreateReleaseBundle(request, gpgPassphrase, log).execute(jfrogHttpClient); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Create a release bundle. |
| 62 | + * |
| 63 | + * @param request - The release bundle details |
| 64 | + * @throws IOException in case of any error |
| 65 | + */ |
| 66 | + public void createReleaseBundle(CreateReleaseBundleRequest request) throws IOException { |
| 67 | + createReleaseBundle(request, ""); |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * Update a release bundle. |
| 72 | + * |
| 73 | + * @param request - The release bundle details |
| 74 | + * @param gpgPassphrase - GPG passphrase |
| 75 | + * @throws IOException in case of any error |
| 76 | + */ |
| 77 | + public void updateReleaseBundle(String name, String version, UpdateReleaseBundleRequest request, String gpgPassphrase) throws IOException { |
| 78 | + new UpdateReleaseBundle(request, name, version, gpgPassphrase, log).execute(jfrogHttpClient); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Update a release bundle. |
| 83 | + * |
| 84 | + * @param request - The release bundle details |
| 85 | + * @throws IOException in case of any error |
| 86 | + */ |
| 87 | + public void updateReleaseBundle(String name, String version, UpdateReleaseBundleRequest request) throws IOException { |
| 88 | + updateReleaseBundle(name, version, request, ""); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Sign a release bundle |
| 93 | + * |
| 94 | + * @param name - Release bundle name to sign |
| 95 | + * @param version - Release bundle version to sign |
| 96 | + * @param gpgPassphrase - GPG passphrase |
| 97 | + * @param storingRepository - The storing repository |
| 98 | + * @throws IOException in case of any error |
| 99 | + */ |
| 100 | + public void signReleaseBundle(String name, String version, String gpgPassphrase, String storingRepository) throws IOException { |
| 101 | + new SignReleaseBundle(name, version, gpgPassphrase, storingRepository, log).execute(jfrogHttpClient); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Sign a release bundle |
| 106 | + * |
| 107 | + * @param name - Release bundle name to sign |
| 108 | + * @param version - Release bundle version to sign |
| 109 | + * @param gpgPassphrase - GPG passphrase |
| 110 | + * @throws IOException in case of any error |
| 111 | + */ |
| 112 | + public void signReleaseBundle(String name, String version, String gpgPassphrase) throws IOException { |
| 113 | + signReleaseBundle(name, version, gpgPassphrase, ""); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Get release bundle status. |
| 118 | + * |
| 119 | + * @param name - Release bundle name |
| 120 | + * @param version - Release bundle version |
| 121 | + * @return release bundle status |
| 122 | + * @throws IOException in case of any error |
| 123 | + */ |
| 124 | + public GetReleaseBundleStatusResponse getReleaseBundleStatus(String name, String version) throws IOException { |
| 125 | + return new GetReleaseBundleVersion(name, version, log).execute(jfrogHttpClient); |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Distribute a release bundle. |
| 130 | + * |
| 131 | + * @param name - Release bundle name |
| 132 | + * @param version - Release bundle version |
| 133 | + * @param sync - Set to true to enable sync distribution |
| 134 | + * @param request - The distribution details |
| 135 | + * @return the tracker id and sites details |
| 136 | + * @throws IOException in case of any error |
| 137 | + */ |
| 138 | + public DistributeReleaseBundleResponse distributeReleaseBundle(String name, String version, boolean sync, DistributeReleaseBundleRequest request) throws IOException { |
| 139 | + return new DistributeReleaseBundle(name, version, sync, request, log).execute(jfrogHttpClient); |
| 140 | + } |
| 141 | + |
| 142 | + /** |
| 143 | + * Get status of a distributed release bundle |
| 144 | + * |
| 145 | + * @param name - Release bundle name |
| 146 | + * @param version - Release bundle version |
| 147 | + * @return status of a distributed release bundle |
| 148 | + * @throws IOException in case of any error |
| 149 | + */ |
| 150 | + public DistributionStatusResponse getDistributionStatus(String name, String version) throws IOException { |
| 151 | + return new GetDistributionStatus(name, version, "", log).execute(jfrogHttpClient); |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Get status of a distributed release bundle |
| 156 | + * |
| 157 | + * @param name - Release bundle name |
| 158 | + * @param version - Release bundle version |
| 159 | + * @param trackerId - The tracker ID received from distributeReleaseBundle command |
| 160 | + * @return status of a distributed release bundle |
| 161 | + * @throws IOException in case of any error |
| 162 | + */ |
| 163 | + public DistributionStatusResponse getDistributionStatus(String name, String version, String trackerId) throws IOException { |
| 164 | + return new GetDistributionStatus(name, version, trackerId, log).execute(jfrogHttpClient); |
| 165 | + } |
| 166 | + |
| 167 | + /** |
| 168 | + * Delete a release bundle from local Artifactory |
| 169 | + * |
| 170 | + * @param name - Release bundle name |
| 171 | + * @param version - Release bundle version |
| 172 | + * @throws IOException in case of any error |
| 173 | + */ |
| 174 | + public void deleteLocalReleaseBundle(String name, String version) throws IOException { |
| 175 | + new DeleteLocalReleaseBundle(name, version, log).execute(jfrogHttpClient); |
| 176 | + } |
| 177 | + |
| 178 | + /** |
| 179 | + * Delete a release bundle from edge node, and optionally from the local Artifactory. |
| 180 | + * |
| 181 | + * @param name - Release bundle name |
| 182 | + * @param version - Release bundle version |
| 183 | + * @param sync - Set to true to enable sync deletion |
| 184 | + * @param request - The distribution details |
| 185 | + * @return sites details |
| 186 | + * @throws IOException in case of any error |
| 187 | + */ |
| 188 | + public DistributeReleaseBundleResponse deleteReleaseBundle(String name, String version, boolean sync, DeleteReleaseBundleRequest request) throws IOException { |
| 189 | + return new DeleteReleaseBundle(name, version, sync, request, log).execute(jfrogHttpClient); |
| 190 | + } |
| 191 | +} |
0 commit comments