Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

Managing Cloud Code Programmatically

Managing Cloud Code Programmatically

The Backend Services .NET SDK includes a set of methods for administratively managing Cloud Code for Data. All require Master Key authentication.

Reading Cloud Code for a Certain Content Type

To get the cloud code associated with a certain content type use the following code:

public async Task<string> GetCloudCode(Guid applicationId, Guid typeId, string masterKey)
{
    var metadata = new EverliveAccount(new EverliveAccountSettings(AuthorizationStrategy.MasterKey, masterKey));
    return await metadata.WorkWith().Application(applicationId).Type(typeId).CloudCode().GetCloudCode().ExecuteAsync();
}

Setting Cloud Code

To set the cloud code for a content type use the following code:

public async Task<bool> SetCloudCode(Guid applicationId, Guid typeId, Stream codeStream, string masterKey)
{
    var metadata = new EverliveAccount(new EverliveAccountSettings(AuthorizationStrategy.MasterKey, masterKey));
    return await metadata.WorkWith().Application(applicationId).Type(typeId).CloudCode().SetCloudCode(codeStream).ExecuteAsync();
}

Deleting Cloud Code

To delete the cloud code for a content type use the following code:

public async Task DeleteCloudCode(Guid applicationId, Guid typeId, string masterKey)
{
    var metadata = new EverliveAccount(new EverliveAccountSettings(AuthorizationStrategy.MasterKey, masterKey));
    await metadata.WorkWith().Application(applicationId).Type(typeId).CloudCode().RemoveCloudCode().ExecuteAsync();
}
Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.