Skip to content

Instantly share code, notes, and snippets.

View alanblyth's full-sized avatar

Alan Blyth alanblyth

View GitHub Profile
@alanblyth
alanblyth / HttpBuilder.groovy
Created January 9, 2019 12:50 — forked from axeda/HttpBuilder.groovy
HTTPBuilder Demo
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
http = new HTTPBuilder('http://ajax.googleapis.com')
// perform a GET request, expecting JSON response data
http.request( GET, JSON){
uri.path = '/ajax/services/search/web'
uri.query = [ v: '1.0', q: 'Axeda Corp.' ]
headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8/10 Firefox/3.0.4'
@alanblyth
alanblyth / HttpBuilderTimeouts.groovy
Created January 9, 2019 12:41 — forked from axeda/HttpBuilderTimeouts.groovy
Connection Timeouts with HttpBuilder
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
int TENSECONDS = 10*1000;
int THIRTYSECONDS = 30*1000;
HTTPBuilder builder = new HTTPBuilder('http://www.axeda.com')
//HTTPBuilder has no direct methods to add timeouts. We have to add them to the HttpParams of the underlying HttpClient
@alanblyth
alanblyth / EmailAttachment.groovy
Created January 9, 2019 12:40 — forked from axeda/EmailAttachment.groovy
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 {
@alanblyth
alanblyth / OutboundFTP.groovy
Created January 9, 2019 12:40 — forked from axeda/OutboundFTP.groovy
Sends a FileInfo out by FTP
import com.axeda.drm.sdk.Context
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.drm.sdk.scripto.Request
import com.axeda.drm.sdk.device.Device
import com.axeda.drm.sdk.device.DeviceFinder
import org.apache.commons.net.ftp.*
import groovy.json.*
import net.sf.json.JSONObject
import com.axeda.drm.sdk.device.Model
import com.axeda.drm.sdk.device.ModelFinder
@alanblyth
alanblyth / OutboundSFTP.groovy
Created January 9, 2019 12:40 — forked from axeda/OutboundSFTP.groovy
Transfers file to SFTP server
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.scripto.Request
import com.axeda.drm.sdk.audit.AuditCategory
import com.axeda.drm.sdk.audit.AuditMessage
import com.axeda.drm.sdk.contact.Location
import com.axeda.drm.sdk.contact.Organization
import com.axeda.drm.sdk.data.UploadedFile
import com.axeda.drm.sdk.device.Device
import com.axeda.drm.sdk.rules.ActionContext
import com.axeda.drm.util.Emailer
@alanblyth
alanblyth / HelloExtendedListsAndMaps.groovy
Created January 9, 2019 12:39 — forked from axeda/HelloExtendedListsAndMaps.groovy
Illustrates Simple Map/List Persistence to Extended Map/List
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.services.v2.ExtendedMap
import com.axeda.services.v2.ExtendedMapCriteria
import com.axeda.services.v2.ExtendedList
import com.axeda.services.v2.ExtendedListCriteria
import com.axeda.services.v2.FindExtendedMapResult
import com.axeda.services.v2.FindExtendedListResult
import com.axeda.services.v2.NamedValue
@alanblyth
alanblyth / HelpfulSDKv1Functions.groovy
Created January 9, 2019 12:38 — forked from axeda/HelpfulSDKv1Functions.groovy
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