@Override public String gitUrl() { String repoName; if (parent instanceof DeploymentSlot) { repoName = ((DeploymentSlot) parent).parent().name() + ".git"; } else { repoName = parent.name() + ".git"; } if (!gitUrl.startsWith("https://")) { gitUrl = "https://" + gitUrl; } return gitUrl + "/" + repoName; }
/** * Download publish profile of web app. * * @param sid subscription id * @param webAppId webapp id * @param filePath file path to save publish profile * @return status indicating whether it is successful or not * @throws Exception exception */ public boolean getPublishingProfileXmlWithSecrets(String sid, String webAppId, String filePath) throws Exception { WebApp app = getWebAppById(sid, webAppId); File file = new File(Paths.get(filePath, app.name() + "_" + System.currentTimeMillis() + ".PublishSettings") .toString()); file.createNewFile(); try (InputStream inputStream = app.manager().inner().webApps() .listPublishingProfileXmlWithSecrets(app.resourceGroupName(), app.name(), PublishingProfileFormat.FTP); OutputStream outputStream = new FileOutputStream(file); ) { IOUtils.copy(inputStream, outputStream); return true; } catch (IOException e) { e.printStackTrace(); return false; } }
/** * Download publish profile of deployment slot. */ public boolean getSlotPublishingProfileXmlWithSecrets(final String sid, final String webAppId, final String slotName, final String filePath) throws Exception { final WebApp app = getWebAppById(sid, webAppId); final DeploymentSlot slot = app.deploymentSlots().getByName(slotName); final File file = new File(Paths.get(filePath, slotName + "_" + System.currentTimeMillis() + ".PublishSettings") .toString()); file.createNewFile(); try (final InputStream inputStream = slot.manager().inner().webApps() .listPublishingProfileXmlWithSecretsSlot(slot.resourceGroupName(), app.name(), slotName, PublishingProfileFormat.FTP); OutputStream outputStream = new FileOutputStream(file); ) { IOUtils.copy(inputStream, outputStream); return true; } catch (IOException e) { e.printStackTrace(); return false; } }
/** * API to create a new Deployment Slot by setting model. */ public DeploymentSlot createDeploymentSlot(@NotNull WebAppSettingModel model) throws Exception { final WebApp app = getWebAppById(model.getSubscriptionId(), model.getWebAppId()); final String name = model.getNewSlotName(); final String configurationSource = model.getNewSlotConfigurationSource(); final DeploymentSlot.DefinitionStages.Blank definedSlot = app.deploymentSlots().define(name); if (configurationSource.equals(app.name())) { return definedSlot.withConfigurationFromParent().create(); } final DeploymentSlot configurationSourceSlot = app.deploymentSlots() .list() .stream() .filter(s -> configurationSource.equals(s.name())) .findAny() .orElse(null); if (configurationSourceSlot != null) { return definedSlot.withConfigurationFromDeploymentSlot(configurationSourceSlot).create(); } else { return definedSlot.withBrandNewConfiguration().create(); } }
@Override public void renderDeploymentSlots(@NotNull final List<DeploymentSlot> slots) { slots.forEach(slot -> addChildNode( new DeploymentSlotNode(slot.id(), slot.parent().id(), slot.parent().name(), this, slot.name(), slot.state(), slot.operatingSystem().toString(), this.subscriptionId, slot.defaultHostName()))); } }
ResourceId.fromString(webAppDetails.webApp.id()).subscriptionId(), webAppDetails.webApp.id(), webAppDetails.webApp.name(), webAppDetails.webApp.state(), webAppDetails.webApp.defaultHostName(),
@Override public Observable<Indexable> createAsync() { final HostNameBinding self = this; Func1<HostNameBindingInner, HostNameBinding> mapper = new Func1<HostNameBindingInner, HostNameBinding>() { @Override public HostNameBinding call(HostNameBindingInner hostNameBindingInner) { setInner(hostNameBindingInner); return self; } }; Observable<HostNameBinding> hostNameBindingObservable; if (parent instanceof DeploymentSlot) { hostNameBindingObservable = this.parent().manager().inner().webApps().createOrUpdateHostNameBindingSlotAsync( parent().resourceGroupName(), ((DeploymentSlot) parent).parent().name(), name, parent().name(), inner()).map(mapper); } else { hostNameBindingObservable = this.parent().manager().inner().webApps().createOrUpdateHostNameBindingAsync( parent().resourceGroupName(), parent().name(), name, inner()).map(mapper); } return hostNameBindingObservable.map(new Func1<HostNameBinding, Indexable>() { @Override public Indexable call(HostNameBinding hostNameBinding) { return hostNameBinding; } }); }
@Override public void renderChildren(@NotNull final List<ResourceEx<WebApp>> resourceExes) { for (final ResourceEx<WebApp> resourceEx : resourceExes) { final WebApp app = resourceEx.getResource(); final WebAppNode node = new WebAppNode(this, resourceEx.getSubscriptionId(), app.id(), app.name(), app.state(), app.defaultHostName(), app.operatingSystem().toString(), new HashMap<String, String>() { { put("regionName", app.regionName()); } }); addChildNode(node); node.refreshItems(); } } }
@Override public Observable<HostNameBinding> refreshAsync() { final HostNameBindingImpl<FluentT, FluentImplT> self = this; Observable<HostNameBindingInner> observable = null; if (parent instanceof DeploymentSlot) { observable = this.parent().manager().inner().webApps().getHostNameBindingSlotAsync( parent().resourceGroupName(), ((DeploymentSlot) parent).parent().name(), parent().name(), name()); } else { observable = this.parent().manager().inner().webApps().getHostNameBindingAsync(parent().resourceGroupName(), parent().name(), name()); } return observable.map(new Func1<HostNameBindingInner, HostNameBinding>() { @Override public HostNameBinding call(HostNameBindingInner hostNameBindingInner) { self.setInner(hostNameBindingInner); return self; } }); }