51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/cloudmunch_Ruby_sdk_v2/AssetHelper.rb', line 51
def addAsset(assetName, assetType, assetStatus, assetExternalRef, assetData)
if assetName.empty? || assetType.empty? || assetStatus.empty? then
log("ERROR", "Asset name ,status and type need to be provided")
return false
end
statusArray = [::STATUS_RUNNING, ::STATUS_STOPPED, ::STATUS_NIL]
if !statusArray.include?(assetStatus) then
log("ERROR", "Invalid status sent. Allowed values " + ::STATUS_RUNNING, ::STATUS_STOPPED, ::STATUS_NIL)
return false
end
assetData["name"] = assetName
assetData["type"] = assetType
assetData["status"] = assetStatus
assetData["external_reference"] = assetExternalRef
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/"
retResult = @cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), assetData)
if retResult == nil then
return nil
else
retResult = JSON.parse(retResult)
retData = retResult["data"]
if retData.nil? then
return nil
else
return retData
end
end
end
|