Skip to content

Commit

Permalink
Removed request.utils import
Browse files Browse the repository at this point in the history
  • Loading branch information
ladamato committed May 6, 2022
1 parent a1e75f4 commit e804e54
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defaultTasks 'build'

apply plugin: 'java'

version = "2.0.0"
version = "2.0.2"

xlDocker {
compileImage = 'xebialabsunsupported/xld_dev_compile'
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/mule/get_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import json
import requests
import requests.utils
from com.xebialabs.deployit.plugin.api.reflect import Type
# Fixes some issues with TLS
import mule.mulesoftUtils as mulesoftUtils
Expand All @@ -24,6 +23,6 @@
print ('Got Cloudhub token')


mulesoftUtils.create_env(thisCi.OrgId, thisCi.id, token, repositoryService, metadataService)
mulesoftUtils.create_env(thisCi.OrgId, thisCi.id, token, repositoryService, metadataService, thisCi.masterDomain.serviceType)

print('Done')
12 changes: 6 additions & 6 deletions src/main/resources/mule/get_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import json
import requests
import requests.utils
from com.xebialabs.deployit.plugin.api.reflect import Type
# Fixes some issues with TLS
import mule.mulesoftUtils as mulesoftUtils
Expand All @@ -29,8 +28,8 @@
profileResponseJson = profileResponse.json()

if profileResponse.status_code != 200 :
print('Status:', profileResponse.status_code, 'Content: ', profileResponse.content);
raise Exception("Failed to get profile. Server returned %s.\n%s" % (profileResponse.status_code, profileResponse.reason));
print('Status:', profileResponse.status_code, 'Content: ', profileResponse.content)
raise Exception("Failed to get profile. Server returned %s.\n%s" % (profileResponse.status_code, profileResponse.reason))

# We don't actually need the Org ID right now, but it's needed for some other API requests
# so we'll save it for later use, while we have it.
Expand All @@ -50,16 +49,17 @@
print ('Adding: ' + newCiId)
if repositoryService.exists(newCiId) :
print (' ' + domainItem['name'] + ' already exists, skipping.')
mulesoftUtils.create_env(str(domainItem['id']), str(newCiId), token, repositoryService, metadataService)
mulesoftUtils.create_env(str(domainItem['id']), str(newCiId), token, repositoryService, metadataService, thisCi.serviceType)
else :
newTeCi = metadataService.findDescriptor(Type.valueOf('mule.Mulesoft.Domain')).newInstance(newCiId)
newTeCi.OrgDomain = domainItem['name']
newTeCi.OrgId = domainItem['id']
repositoryService.create(newCiId, newTeCi)
try:
mulesoftUtils.create_env(str(domainItem['id']), str(newCiId), token, repositoryService, metadataService)
except:
mulesoftUtils.create_env(str(domainItem['id']), str(newCiId), token, repositoryService, metadataService, thisCi.serviceType)
except Exception as e:
print("Unable to retrieve envionments for this domain - %s, will delete this domain and continue" % str(newCiId))
print("Exeception = %s" % e)
repositoryService.delete(newCiId)


Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/mule/mulesoftUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import json
import requests
import requests.utils
from com.xebialabs.deployit.plugin.api.reflect import Type
# Fixes some issues with TLS
import os
Expand Down Expand Up @@ -47,7 +46,7 @@ def get_token_conn_app(username, password):
responseJson = response.json()
return responseJson['access_token']

def create_env(id, name, token, repositoryService, metadataService):
def create_env(id, name, token, repositoryService, metadataService, serviceType):
print("Debug - id = %s, name = %s, " % (id, name))
envUrl = "https://anypoint.mulesoft.com/accounts/api/organizations/%s/environments" % id
authHeader = {"Authorization":"Bearer " + token}
Expand All @@ -65,7 +64,10 @@ def create_env(id, name, token, repositoryService, metadataService):
if repositoryService.exists(newCiId) :
print(' ' + envItem['name'] + ' already exists, skipping.')
else :
newTeCi =metadataService.findDescriptor(Type.valueOf('mule.Mulesoft.Domain.TargetEnvironment')).newInstance(newCiId)
if serviceType == "Runtime Fabric":
newTeCi =metadataService.findDescriptor(Type.valueOf('mule.Mulesoft.Domain.RTFTargetEnvironment')).newInstance(newCiId)
else:
newTeCi =metadataService.findDescriptor(Type.valueOf('mule.Mulesoft.Domain.TargetEnvironment')).newInstance(newCiId)
newTeCi.envName = envItem['name']
newTeCi.envId = envItem['id']
repositoryService.create(newCiId, newTeCi)
Expand Down

0 comments on commit e804e54

Please sign in to comment.