Skip to content

Instantly share code, notes, and snippets.

@axeda
axeda / AddGeofence.groovy
Created September 11, 2013 20:24
Add a Geofence with Expression Rule and Rule Associations
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.geofence.Geofence
import com.axeda.drm.sdk.geofence.GeofenceFinder
import com.axeda.drm.sdk.rules.engine.Expression
import com.axeda.drm.sdk.rules.engine.ExpressionRule
import com.axeda.drm.sdk.rules.engine.ExpressionRuleFinder
import com.axeda.drm.sdk.rules.engine.RuleAssociation
import com.axeda.drm.sdk.rules.engine.RuleAssociationFinder
import com.axeda.drm.sdk.rules.engine.RuleType
import com.axeda.drm.sdk.common.EntityType
@axeda
axeda / HelpfulSDKv1Functions.groovy
Last active January 9, 2019 12:38
Helpful SDK v1 Functions
import com.axeda.common.id.Identifier
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.agent.commands.CommandStatus
import com.axeda.drm.sdk.agent.commands.SetDataItem
import com.axeda.drm.sdk.audit.AuditCategory
import com.axeda.drm.sdk.audit.AuditCategoryList
import com.axeda.drm.sdk.audit.AuditEntry
import com.axeda.drm.sdk.audit.AuditEntryFinder
import com.axeda.drm.sdk.audit.AuditMessage
import com.axeda.drm.sdk.common.Operator
@axeda
axeda / EmailAttachment.groovy
Last active January 9, 2019 12:40
Emails an attachment using bytes from a FileInfo
import com.axeda.drm.util.Emailer;
import com.axeda.drm.sdk.contact.Email
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.services.v2.FileInfoCriteria
import org.apache.commons.io.IOUtils
import java.security.MessageDigest
try {
@axeda
axeda / AddUserGroupAndUser.groovy
Last active December 21, 2015 19:29
Adds a User Group and a User and assigns a range of privileges
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.user.User
import com.axeda.drm.sdk.user.UserFinder
import com.axeda.drm.sdk.user.UserGroup
import com.axeda.drm.sdk.user.UserGroupFinder
import com.axeda.drm.sdk.device.Device
import com.axeda.drm.sdk.device.DeviceGroup
import com.axeda.drm.sdk.device.DeviceGroupFinder
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
@axeda
axeda / BareBonesImageUpload.js
Created August 8, 2013 15:34
The bare minimum code to upload an image file to the StoreScaledImage.groovy script
var PLATFORM_HOST = document.URL.split('/apps/')[0]; // this is how you would retrieve the host on an Axeda instance
var SESSION_ID = null // usually retrieved from login function included below
/***
* Depends on jQuery 1.7+ and HTML5, assumes an HTML5 element such as the following:
* <input type="file" id="fileinput" value="Upload" />
* **/
$("#fileinput").off("click.filein").on("click.filein", function () {
@axeda
axeda / StoreScaledImage.groovy
Created August 8, 2013 14:42
Check for an image file extension. If it has one, scale it to a smaller version and save it to the file store.
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.data.*
import com.axeda.drm.sdk.device.*
import com.axeda.drm.sdk.mobilelocation.CurrentMobileLocationFinder
import com.axeda.drm.sdk.mobilelocation.MobileLocation
import com.axeda.drm.sdk.mobilelocation.MobileLocationFinder
import com.axeda.sdk.v2.bridge.FileInfoBridge
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.services.v2.ExecutionResult
import com.axeda.services.v2.FileInfo
@axeda
axeda / DownloadImageFile.groovy
Created August 7, 2013 14:08
Download a file from the file store as an embeddable image file
import static com.axeda.sdk.v2.dsl.Bridges.*
import javax.activation.MimetypesFileTypeMap
import com.axeda.services.v2.*
import com.axeda.sdk.v2.exception.*
import com.axeda.drm.sdk.scripto.Request
def knowntypes = [
[png: 'image/png']
,[gif: 'image/gif']
,[jpg: 'image/jpeg']
@axeda
axeda / StoreFileSizeLimit.groovy
Created August 7, 2013 14:00
Store a file in the FileStore
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.data.*
import com.axeda.drm.sdk.device.*
import com.axeda.drm.sdk.mobilelocation.CurrentMobileLocationFinder
import com.axeda.drm.sdk.mobilelocation.MobileLocation
import com.axeda.drm.sdk.mobilelocation.MobileLocationFinder
import com.axeda.sdk.v2.bridge.FileInfoBridge
import com.axeda.services.v2.FileInfoCriteria
import com.axeda.services.v2.ModelCriteria
import static com.axeda.sdk.v2.dsl.Bridges.*
@axeda
axeda / PrivilegeList.groovy
Created August 2, 2013 14:11
Find or create a user group, add any privileges, then list out the privileges in alpha order.
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.privilege.PrivilegeFinder
import com.axeda.drm.sdk.user.UserGroup
import com.axeda.drm.sdk.user.UserGroupFinder
/****
* PrivilegeList.groovy
* --------
* Find or create a user group, add any privileges, then list out the privileges in alpha order.
*
@axeda
axeda / UpdateModelProperties.groovy
Last active December 20, 2015 03:39
Update properties on a model
import com.axeda.drm.sdk.device.DeviceProperty
import com.axeda.drm.sdk.device.ModelFinder
import com.axeda.drm.sdk.device.Model
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.device.DevicePropertyFinder
import com.axeda.drm.sdk.device.Property
import com.axeda.drm.sdk.device.PropertyType
import com.axeda.common.sdk.id.Identifier
Set<String> REQUIRED_PROPERTIES = [