private static void InstallApp(Pebble pebble) { var progress = new Progress <ProgressValue>(pv => Console.WriteLine(pv.ProgressPercentage + " " + pv.Message)); string appPath = SelectApp(); if (!string.IsNullOrEmpty(appPath) && File.Exists(appPath)) { using (var stream = new FileStream(appPath, FileMode.Open)) { using (var zip = new Zip()) { zip.Open(stream); var bundle = new AppBundle(); stream.Position = 0; bundle.Load(zip, pebble.Firmware.HardwarePlatform.GetSoftwarePlatform()); pebble.InstallClient.InstallAppAsync(bundle, progress).Wait(); //for firmware v3, launch is done as part of the install //Console.WriteLine("App Installed, launching..."); //var uuid=new UUID(bundle.AppInfo.UUID); //pebble.LaunchApp(uuid); //Console.WriteLine ("Launched"); } } } else { Console.WriteLine("No .pbw"); } }
public async Task <int> UpdateAppBundleAsync(AppBundle app, string label, string packagePath) { var id = app.Id; try { app.Id = null; var item = await this.CreateAppBundleVersionAsync(id, app); await UploadAppBundleBits(item.UploadParameters, packagePath); var resp = await this.AppBundlesApi.ModifyAppBundleAliasAsync(id, label, new AliasPatch() { Version = item.Version.Value }, throwOnError : false); if (resp.HttpResponse.StatusCode == System.Net.HttpStatusCode.NotFound) { await this.AppBundlesApi.CreateAppBundleAliasAsync(id, new Alias() { Id = label, Version = item.Version.Value }); } else { await resp.HttpResponse.EnsureSuccessStatusCodeAsync(); } return(item.Version.Value); } finally { app.Id = id; } }
private async void OnInstallApp() { var openDialog = new OpenFileDialog { CheckFileExists = true, CheckPathExists = true, DefaultExt = "*.pbw", Filter = "Pebble Apps|*.pbw|All Files|*", RestoreDirectory = true, Title = "Pebble App" }; if (openDialog.ShowDialog() == true) { var bundle = new AppBundle(); using (var zip = new Zip.Zip()) { bundle.Load(openDialog.OpenFile(), zip); } if (_pebble.IsAlive == false) { return; } await _pebble.InstallAppAsync(bundle); await LoadAppsAsync(); } }
private async Task <dynamic> CreateNewAppBundle(string appBundleName, string engineName, string Alias, int version) { AppBundle appBundleSpec = new AppBundle() { Package = appBundleName, Engine = engineName, Id = appBundleName, Description = string.Format("Description for {0}", appBundleName) }; dynamic newAppVersion = await _repository.CreateAsync(appBundleSpec); CheckOutToNull(newAppVersion); Alias aliasSpec = new Alias() { Id = Alias, Version = version }; await _repository.CreateAppBundleAsync(appBundleName, aliasSpec); return(newAppVersion); }
public void GeneratesCorrectChecksumForApp() { var bundle = new AppBundle(); bundle.Load(ResourceManager.GetAppBundle(), new ZipImplementation()); Assert.AreEqual(bundle.Manifest.Application.CRC, Crc32.Calculate(bundle.App)); }
protected void RunGeneratesCorrectChecksumForApp() { var bundle = new AppBundle(); bundle.Load(ResourceManager.GetAppBundle(), GetZip()); Assert.AreEqual(bundle.Manifest.Application.CRC, Crc32.Calculate(bundle.App)); }
protected void RunGeneratesCorrectChecksumForApp() { var bundle = new AppBundle(); bundle.Load(GetZip(), SoftwarePlatform.UNKNOWN); Assert.AreEqual(bundle.Manifest.Application.CRC, Crc32.Calculate(bundle.App)); }
/// <summary> /// Creates a new AppBundle from the metadata in <paramref name="app"/> and the code in <paramref name="packagePath"/> /// and labels with with <paramref name="label"/>. /// </summary> /// <param name="app"></param> /// <param name="label"></param> /// <param name="packagePath"></param> /// <returns></returns> public async Task CreateAppBundleAsync(AppBundle app, string label, string packagePath) { var item = await this.CreateAppBundleAsync(app); await UploadAppBundleBits(item.UploadParameters, packagePath); await this.CreateAppBundleAliasAsync(app.Id, new Alias() { Id = label, Version = item.Version.Value }); }
public async Task InstallAppAsync(AppBundle bundle, IProgress <ProgressValue> progress = null) { IList <int> versionComponents = _pebble.Firmware.ParseVersionComponents(); if (versionComponents[0] < 3) { await InstallAppLegacyV2(bundle, progress); } else { await InstallAppAsyncV3(bundle, progress); } }
private async Task <string> SetupAppBundleAsync() { Console.WriteLine("Setting up appbundle..."); var myApp = $"{Owner}.{PackageName}+{Label}"; var appResponse = await this.api.AppBundlesApi.GetAppBundleAsync(myApp, throwOnError : false); var app = new AppBundle() { Engine = TargetEngine, Id = PackageName }; var package = CreateZip(); if (appResponse.HttpResponse.StatusCode == HttpStatusCode.NotFound) { Console.WriteLine($"\tCreating appbundle {myApp}..."); await api.CreateAppBundleAsync(app, Label, package); return(myApp); } await appResponse.HttpResponse.EnsureSuccessStatusCodeAsync(); Console.WriteLine("\tFound existing appbundle..."); if (!await EqualsAsync(package, appResponse.Content.Package)) { Console.WriteLine($"\tUpdating appbundle {myApp}..."); await api.UpdateAppBundleAsync(app, Label, package); } return(myApp); async Task <bool> EqualsAsync(string a, string b) { Console.Write("\tComparing bundles..."); using (var aStream = File.OpenRead(a)) { var bLocal = await DownloadToDocsAsync(b, "das-appbundle.zip"); using (var bStream = File.OpenRead(bLocal)) { using (var hasher = SHA256.Create()) { var res = hasher.ComputeHash(aStream).SequenceEqual(hasher.ComputeHash(bStream)); Console.WriteLine(res ? "Same." : "Different"); return(res); } } } } }
private static void SendAppMessage(Pebble pebble) { string uuidAppPath = SelectApp(); if (!string.IsNullOrEmpty(uuidAppPath) && File.Exists(uuidAppPath)) { using (var stream = new FileStream(uuidAppPath, FileMode.Open)) { using (var zip = new Zip()) { zip.Open(stream); var bundle = new AppBundle(); stream.Position = 0; bundle.Load(zip, pebble.Firmware.HardwarePlatform.GetSoftwarePlatform()); System.Console.Write("Enter Message:"); var messageText = System.Console.ReadLine(); //format a message var rand = new Random().Next(); AppMessagePacket message = new AppMessagePacket(); message.Command = (byte)Command.Push; message.Values.Add(new AppMessageUInt32() { Key = 0, Value = (uint)rand }); message.Values.Add(new AppMessageString() { Key = 1, Value = messageText }); message.ApplicationId = bundle.AppMetadata.UUID; message.TransactionId = 255; //send it Console.WriteLine("Sending Status " + rand + " to " + bundle.AppMetadata.UUID.ToString()); var task = pebble.SendApplicationMessage(message); task.Wait(); Console.WriteLine("Response received"); } } } else { Console.WriteLine("No .pbw"); } }
public static AppMetaData FromAppBundle(AppBundle bundle, byte appFaceTemplateId = 0, byte appFaceBackgroundColor = 0) { var meta = new PebbleSharp.Core.BlobDB.AppMetaData(); meta.AppFaceTemplateId = appFaceTemplateId; meta.AppFaceBackgroundColor = appFaceBackgroundColor; meta.AppVersionMajor = bundle.AppMetadata.AppMajorVersion; meta.AppVersionMinor = bundle.AppMetadata.AppMinorVersion; meta.SdkVersionMajor = bundle.AppMetadata.SDKMajorVersion; meta.SdkVersionMinor = bundle.AppMetadata.SDKMinorVersion; meta.Flags = bundle.AppMetadata.Flags; meta.Icon = bundle.AppMetadata.IconResourceID; meta.UUID = bundle.AppMetadata.UUID; meta.Name = bundle.AppMetadata.AppName; return(meta); }
public async Task InstallAppAsync(AppBundle bundle, IProgress <ProgressValue> progress = null) { string version = _pebble.Firmware.Version; version = version.Replace("v", ""); var components = version.Split(new char[] { '.', '-' }, StringSplitOptions.RemoveEmptyEntries); int i; IList <int> versionComponents = components.Where(x => int.TryParse(x, out i)).Select(x => int.Parse(x)).ToList(); if (versionComponents[0] < 3) { await InstallAppLegacyV2(bundle, progress); } else { await InstallAppAsyncV3(bundle, progress); } }
private async Task <dynamic> CreateNewVersion(string engineName, string appBundleName, string Alias) { AppBundle appBundleSpec = new AppBundle() { Engine = engineName, Description = appBundleName }; dynamic newAppVersion = await _repository.CreateAppBundleVersionAsync(appBundleName, appBundleSpec); CheckOutToNull(newAppVersion); AliasPatch aliasPatch = new AliasPatch() { Version = newAppVersion.Version }; await _repository.ModifyAsync(appBundleName, Alias, aliasPatch); return(newAppVersion); }
protected void RunCanLoadInformationFromAppBundle() { Stream testBundle = ResourceManager.GetAppBundle(); var bundle = new AppBundle(); var zip = GetZip(); zip.Open(testBundle); bundle.Load(zip, SoftwarePlatform.APLITE); var manifest = bundle.Manifest; Assert.IsNotNull(manifest); Assert.AreEqual(new DateTime(2013, 4, 13, 18, 3, 16), manifest.GeneratedAtDateTime); Assert.AreEqual("frontier", manifest.GeneratedBy); Assert.AreEqual(1, manifest.ManifestVersion); Assert.AreEqual("application", manifest.Type); Assert.IsTrue(manifest.Resources.Size > 0); Assert.IsTrue(bundle.HasResources); Assert.AreEqual(1, bundle.AppMetadata.AppMajorVersion); Assert.AreEqual(0, bundle.AppMetadata.AppMinorVersion); Assert.AreEqual("Shades", bundle.AppMetadata.AppName); Assert.AreEqual("1.0", bundle.AppMetadata.AppVersion); Assert.AreEqual("Barometz", bundle.AppMetadata.CompanyName); Assert.AreEqual((uint)1515157755, bundle.AppMetadata.CRC); Assert.AreEqual((uint)1, bundle.AppMetadata.Flags); Assert.AreEqual("PBLAPP", bundle.AppMetadata.Header); Assert.AreEqual((uint)0, bundle.AppMetadata.IconResourceID); Assert.AreEqual((uint)552, bundle.AppMetadata.Offset); Assert.AreEqual((uint)2, bundle.AppMetadata.RelocationListItemCount); Assert.AreEqual(3, bundle.AppMetadata.SDKMajorVersion); Assert.AreEqual(1, bundle.AppMetadata.SDKMinorVersion); Assert.AreEqual("3.1", bundle.AppMetadata.SDKVersion); Assert.AreEqual(3860, bundle.AppMetadata.Size); Assert.AreEqual(8, bundle.AppMetadata.StructMajorVersion); Assert.AreEqual(1, bundle.AppMetadata.StructMinorVersion); Assert.AreEqual("8.1", bundle.AppMetadata.StructVersion); Assert.AreEqual((uint)2796, bundle.AppMetadata.SymbolTableAddress); Assert.AreEqual("ae9984f3-0404-409b-8a17-d50478c02d3e", bundle.AppMetadata.UUID.ToString()); }
private async Task <AppBundle> UpdateBundleAsync(string engine, string packageName) { var bundle = new AppBundle(); bundle.Engine = engine; bundle.Description = $"Grid Generator: {packageName}"; var bundleVersion = await designAutoClient.CreateAppBundleVersionAsync(packageName, bundle); if (bundleVersion == null) { throw new Exception("Error trying to update existing bundle version"); } var alias = new AliasPatch(); alias.Version = (int)bundleVersion.Version; await this.designAutoClient.ModifyAppBundleAliasAsync(packageName, this.forgeEnv, alias); return(bundleVersion); }
public PebbleViewer(ILogger logger, PebblePlugin plugin, PebbleSharp.Core.Pebble pebble, IZip appBundleZip, Action <Action <ISystemController, IRaceController> > queueCommand) { _queueCommand = queueCommand; _plugin = plugin; _logger = logger; _pebble = pebble; _pebble.ConnectAsync().Wait(); _logger.Info("Connected to pebble " + _pebble.PebbleID); _transactionId = 255; var progress = new Progress <ProgressValue> (pv => _logger.Debug("Installing app on pebble " + pebble.PebbleID + ", " + pv.ProgressPercentage + "% complete. " + pv.Message)); var bundle = new AppBundle(); bundle.Load(appBundleZip, _pebble.Firmware.HardwarePlatform.GetPlatform()); _uuid = bundle.AppMetadata.UUID; _pebble.InstallClient.InstallAppAsync(bundle, progress).Wait(); _logger.Info("Installed app on pebble " + pebble.PebbleID); _pebble.RegisterCallback <AppMessagePacket> (Receive); InitializeViewer(); }
private async Task <AppBundle> CreateNewBundleAsync(string engine, string packageName) { var bundle = new AppBundle(); bundle.Package = packageName; bundle.Engine = engine; bundle.Id = packageName; bundle.Description = $"Grid Generator: {packageName}"; var bundleVersion = await this.designAutoClient.CreateAppBundleAsync(bundle); if (bundleVersion == null) { throw new Exception("Error trying to create new first bundle version"); } var alias = new Alias(); alias.Id = this.forgeEnv; alias.Version = 1; await designAutoClient.CreateAppBundleAliasAsync(packageName, alias); return(bundleVersion); }
public async Task <AppBundle> CreateAsync(AppBundle entity) { return(await _designAutomation.CreateAppBundleAsync(entity)); }
public async Task <dynamic> CreateAppBundleVersionAsync(string appBundleName, AppBundle appBundleSpec) { return(await _designAutomation.CreateAppBundleVersionAsync(appBundleName, appBundleSpec)); }
public async Task <IActionResult> CreateAppBundle([FromBody] JObject appBundleSpecs) { // basic input validation string zipFileName = appBundleSpecs["zipFileName"].Value <string>(); string engineName = appBundleSpecs["engine"].Value <string>(); // standard name for this sample string appBundleName = zipFileName + "AppBundle"; // check if ZIP with bundle is here string packageZipPath = Path.Combine(LocalBundlesFolder, zipFileName + ".zip"); if (!System.IO.File.Exists(packageZipPath)) { throw new Exception("Appbundle not found at " + packageZipPath); } // define Activities API dynamic oauth = await OAuthController.GetInternalAsync(); AppBundlesApi appBundlesApi = new AppBundlesApi(); appBundlesApi.Configuration.AccessToken = oauth.access_token; // get defined app bundles PageString appBundles = await appBundlesApi.AppBundlesGetItemsAsync(); // check if app bundle is already define dynamic newAppVersion; string qualifiedAppBundleId = string.Format("{0}.{1}+{2}", NickName, appBundleName, Alias); if (!appBundles.Data.Contains(qualifiedAppBundleId)) { // create an appbundle (version 1) AppBundle appBundleSpec = new AppBundle(appBundleName, null, engineName, null, null, string.Format("Description for {0}", appBundleName), null, appBundleName); newAppVersion = await appBundlesApi.AppBundlesCreateItemAsync(appBundleSpec); if (newAppVersion == null) { throw new Exception("Cannot create new app"); } // create alias pointing to v1 Alias aliasSpec = new Alias(1, null, Alias); Alias newAlias = await appBundlesApi.AppBundlesCreateAliasAsync(appBundleName, aliasSpec); } else { // create new version AppBundle appBundleSpec = new AppBundle(null, null, engineName, null, null, appBundleName, null, null); newAppVersion = await appBundlesApi.AppBundlesCreateItemVersionAsync(appBundleName, appBundleSpec); if (newAppVersion == null) { throw new Exception("Cannot create new version"); } // update alias pointing to v+1 Alias aliasSpec = new Alias(newAppVersion.Version, null, null); Alias newAlias = await appBundlesApi.AppBundlesModifyAliasAsync(appBundleName, Alias, aliasSpec); } // upload the zip with .bundle RestClient uploadClient = new RestClient(newAppVersion.UploadParameters.EndpointURL); RestRequest request = new RestRequest(string.Empty, Method.POST); request.AlwaysMultipartFormData = true; foreach (KeyValuePair <string, object> x in newAppVersion.UploadParameters.FormData) { request.AddParameter(x.Key, x.Value); } request.AddFile("file", packageZipPath); request.AddHeader("Cache-Control", "no-cache"); await uploadClient.ExecuteTaskAsync(request); return(Ok(new { AppBundle = qualifiedAppBundleId, Version = newAppVersion.Version })); }
private static async Task ShowPebbleMenu(Pebble pebble) { //string uuid = "22a27b9a-0b07-47af-ad87-b2c29305bab6"; var menu = new Menu( "Disconnect", "Get Time", "Set Current Time", "Get Firmware Info", "Send Ping", "Media Commands", "Install App", "Send App Message", "Reset", "Send Notification"); while (true) { switch (menu.ShowMenu()) { case 0: pebble.Disconnect(); return; case 1: var timeResult = await pebble.GetTimeAsync(); DisplayResult(timeResult, x => string.Format("Pebble Time: " + x.Time.ToString("G"))); break; case 2: await pebble.SetTimeAsync(DateTime.Now); goto case 1; case 3: var firmwareResult = await pebble.GetFirmwareVersionAsync(); DisplayResult(firmwareResult, x => string.Join(Environment.NewLine, "Firmware", x.Firmware.ToString(), "Recovery Firmware", x.RecoveryFirmware.ToString())); break; case 4: var pingResult = await pebble.PingAsync(); DisplayResult(pingResult, x => "Received Ping Response"); break; case 5: ShowMediaCommands(pebble); break; case 6: var progress = new Progress <ProgressValue>( pv => Console.WriteLine(pv.ProgressPercentage + " " + pv.Message)); string appPath = SelectApp(); if (!string.IsNullOrEmpty(appPath) && File.Exists(appPath)) { using (var stream = new FileStream(appPath, FileMode.Open)) { using (var zip = new Zip()) { zip.Open(stream); var bundle = new AppBundle(); stream.Position = 0; bundle.Load(zip, pebble.Firmware.HardwarePlatform.GetPlatform()); var task = pebble.InstallClient.InstallAppAsync(bundle, progress); await task; if (task.IsFaulted) { Console.WriteLine("Failed to install"); } //for firmware v3, launch is done as part of the install //Console.WriteLine("App Installed, launching..."); //var uuid=new UUID(bundle.AppInfo.UUID); //pebble.LaunchApp(uuid); //Console.WriteLine ("Launched"); } } } else { Console.WriteLine("No .pbw"); } break; case 7: //read the uuid from the pbw string uuidAppPath = SelectApp(); if (!string.IsNullOrEmpty(uuidAppPath) && File.Exists(uuidAppPath)) { using (var stream = new FileStream(uuidAppPath, FileMode.Open)) { using (var zip = new Zip()) { zip.Open(stream); var bundle = new AppBundle(); stream.Position = 0; bundle.Load(zip, pebble.Firmware.HardwarePlatform.GetPlatform()); //format a message var rand = new Random().Next(); AppMessagePacket message = new AppMessagePacket(); message.Values.Add(new AppMessageUInt32() { Value = (uint)rand }); message.Values.Add(new AppMessageString() { Value = "Hello from .net" }); message.ApplicationId = bundle.AppMetadata.UUID; message.TransactionId = 255; //send it Console.WriteLine("Sending Status " + rand + " to " + bundle.AppMetadata.UUID.ToString()); var t = pebble.SendApplicationMessage(message); await t; Console.WriteLine("Response received"); } } } else { Console.WriteLine("No .pbw"); } break; case 8: pebble.Reset(ResetCommand.Reset); break; case 9: TestNotification(pebble); break; } } }
/// <summary> /// Creates a new version of the AppBundle. /// </summary> /// <remarks> /// Creates a new version of the AppBundle. | Limit: | 1. Number of versions (LimitVersions). | 2. Size of AppBundle. | This method creates new AppBundle returned in response value. | POST upload is required to limit upload size. The endpoint url and all form fields are retrieved in AppBundle.UploadParameters. | | After this request, you need to upload the AppBundle zip. | Use data received in the response to create multipart/form-data request. An example: | | curl https://bucketname.s3.amazonaws.com/ | -F key = apps/myApp/myfile.zip | -F content-type = application/octet-stream | -F policy = eyJleHBpcmF0aW9uIjoiMjAxOC0wNi0yMVQxMzo...(trimmed) | -F x-amz-signature = 800e52d73579387757e1c1cd88762...(trimmed) | -F x-amz-credential = AKIAIOSFODNN7EXAMPLE/20180621/us-west-2/s3/aws4_request/ | -F x-amz-algorithm = AWS4-HMAC-SHA256 | -F x-amz-date = 20180621T091656Z | -F file=@E:\\myfile.zip The 'file' field must be at the end, all fields after 'file' will be ignored. /// </remarks> /// <exception cref="HttpRequestException">Thrown when fails to make API call</exception> /// <param name="id">Name of AppBundle (unqualified).</param> /// <param name="item"></param> /// <returns>Task of AppBundle</returns> public async System.Threading.Tasks.Task <AppBundle> CreateAppBundleVersionAsync(string id, AppBundle item) { var response = await this.AppBundlesApi.CreateAppBundleVersionAsync(id, item); return(response.Content); }
/// <summary> /// Creates Activity /// </summary> /// <returns>True if successful</returns> public static async Task <dynamic> CreateActivity() { Bearer bearer = (await Get2LeggedTokenAsync(new Scope[] { Scope.CodeAll })).ToObject <Bearer>(); string nickName = ConsumerKey; AppBundlesApi appBundlesApi = new AppBundlesApi(); appBundlesApi.Configuration.AccessToken = bearer.AccessToken; PageString appBundles = await appBundlesApi.AppBundlesGetItemsAsync(); string appBundleID = string.Format("{0}.{1}+{2}", nickName, APPNAME, ALIAS); if (!appBundles.Data.Contains(appBundleID)) { if (!System.IO.File.Exists(LocalAppPackageZip)) { return(new Output(Output.StatusEnum.Error, "Bundle not found at " + LocalAppPackageZip)); } // create new bundle AppBundle appBundleSpec = new AppBundle(APPNAME, null, EngineName, null, null, APPNAME, null, APPNAME); AppBundle newApp = await appBundlesApi.AppBundlesCreateItemAsync(appBundleSpec); if (newApp == null) { return(new Output(Output.StatusEnum.Error, "Cannot create new app")); } // create alias Alias aliasSpec = new Alias(1, null, ALIAS); Alias newAlias = await appBundlesApi.AppBundlesCreateAliasAsync(APPNAME, aliasSpec); // upload the zip bundle RestClient uploadClient = new RestClient(newApp.UploadParameters.EndpointURL); RestRequest request = new RestRequest(string.Empty, Method.POST); request.AlwaysMultipartFormData = true; foreach (KeyValuePair <string, object> x in newApp.UploadParameters.FormData) { request.AddParameter(x.Key, x.Value); } request.AddFile("file", LocalAppPackageZip); request.AddHeader("Cache-Control", "no-cache"); var res = await uploadClient.ExecuteTaskAsync(request); } ActivitiesApi activitiesApi = new ActivitiesApi(); activitiesApi.Configuration.AccessToken = bearer.AccessToken; PageString activities = await activitiesApi.ActivitiesGetItemsAsync(); string activityID = string.Format("{0}.{1}+{2}", nickName, ACTIVITY_NAME, ALIAS); if (!activities.Data.Contains(activityID)) { // create activity string commandLine = string.Format(@"$(engine.path)\\inventorcoreconsole.exe /i $(args[InputIPT].path) /al $(appbundles[{0}].path) $(args[InputParams].path)", APPNAME); ModelParameter iptFile = new ModelParameter(false, false, ModelParameter.VerbEnum.Get, "Input Ipt File", true, inputFileName); ModelParameter result = new ModelParameter(false, false, ModelParameter.VerbEnum.Put, "Resulting Ipt File", true, outputFileName); ModelParameter inputParams = new ModelParameter(false, false, ModelParameter.VerbEnum.Get, "Input params", false, "params.json"); Activity activitySpec = new Activity( new List <string> { commandLine }, new Dictionary <string, ModelParameter>() { { "InputIPT", iptFile }, { "InputParams", inputParams }, { "ResultIPT", result }, }, EngineName, new List <string>() { string.Format("{0}.{1}+{2}", nickName, APPNAME, ALIAS) }, null, ACTIVITY_NAME, null, ACTIVITY_NAME ); Activity newActivity = await activitiesApi.ActivitiesCreateItemAsync(activitySpec); Alias aliasSpec = new Alias(1, null, ALIAS); Alias newAlias = await activitiesApi.ActivitiesCreateAliasAsync(ACTIVITY_NAME, aliasSpec); } return(new Output(Output.StatusEnum.Sucess, "Activity created")); }
/// <summary> /// Creates a new version of the AppBundle. Creates a new version of the AppBundle. | Limit: | 1. Number of versions (LimitVersions). | 2. Size of AppBundle. | This method creates new AppBundle returned in response value. | POST upload is required to limit upload size. The endpoint url and all form fields are retrieved in AppBundle.UploadParameters. | | After this request, you need to upload the AppBundle zip. | Use data received in the response to create multipart/form-data request. An example: | | curl https://bucketname.s3.amazonaws.com/ | -F key = apps/myApp/myfile.zip | -F content-type = application/octet-stream | -F policy = eyJleHBpcmF0aW9uIjoiMjAxOC0wNi0yMVQxMzo...(trimmed) | -F x-amz-signature = 800e52d73579387757e1c1cd88762...(trimmed) | -F x-amz-credential = AKIAIOSFODNN7EXAMPLE/20180621/us-west-2/s3/aws4_request/ | -F x-amz-algorithm = AWS4-HMAC-SHA256 | -F x-amz-date = 20180621T091656Z | -F file=@E:\\myfile.zip The 'file' field must be at the end, all fields after 'file' will be ignored. /// </summary> /// <exception cref="HttpRequestException">Thrown when fails to make API call</exception> /// <param name="id">Name of app (unqualified).</param>/// <param name="item"></param> /// <returns>Task of ApiResponse<AppBundle></returns> public async System.Threading.Tasks.Task <ApiResponse <AppBundle> > CreateAppBundleVersionAsync(string id, AppBundle item, string scopes = null, IDictionary <string, string> headers = null, bool throwOnError = true) { using (var request = new HttpRequestMessage()) { request.RequestUri = Marshalling.BuildRequestUri("/v3/appbundles/{id}/versions", routeParameters: new Dictionary <string, object> { { "id", id }, }, queryParameters: new Dictionary <string, object> { } ); request.Headers.TryAddWithoutValidation("Accept", "application/json"); if (headers != null) { foreach (var header in headers) { request.Headers.TryAddWithoutValidation(header.Key, header.Value); } } request.Content = Marshalling.Serialize(item); // http body (model) parameter // tell the underlying pipeline what scope we'd like to use if (scopes == null) { request.Properties.Add(ForgeConfiguration.ScopeKey, "code:all"); } else { request.Properties.Add(ForgeConfiguration.ScopeKey, scopes); } request.Method = new HttpMethod("POST"); // make the HTTP request var response = await this.Service.Client.SendAsync(request); if (throwOnError) { await response.EnsureSuccessStatusCodeAsync(); } else if (!response.IsSuccessStatusCode) { return(new ApiResponse <AppBundle>(response, default(AppBundle))); } return(new ApiResponse <AppBundle>(response, await Marshalling.DeserializeAsync <AppBundle>(response.Content))); } // using }
public async Task CreateVoidAsync(AppBundle entity) { await _designAutomation.CreateAppBundleAsync(entity); }
public async Task InstallAppAsync(AppBundle bundle, IProgress <ProgressValue> progress = null) { if (bundle == null) { throw new ArgumentNullException("bundle"); } if (progress != null) { progress.Report(new ProgressValue("Removing previous install(s) of the app if they exist", 1)); } ApplicationMetadata metaData = bundle.AppMetadata; UUID uuid = metaData.UUID; AppbankInstallResponse appbankInstallResponse = await RemoveAppByUUID(uuid); if (appbankInstallResponse.Success == false) { return; } if (progress != null) { progress.Report(new ProgressValue("Getting current apps", 20)); } AppbankResponse appBankResult = await GetAppbankContentsAsync(); if (appBankResult.Success == false) { throw new PebbleException("Could not obtain app list; try again"); } AppBank appBank = appBankResult.AppBank; byte firstFreeIndex = 1; foreach (App app in appBank.Apps) { if (app.Index == firstFreeIndex) { firstFreeIndex++; } } if (firstFreeIndex == appBank.Size) { throw new PebbleException("All app banks are full"); } if (progress != null) { progress.Report(new ProgressValue("Transferring app to Pebble", 40)); } if (await PutBytes(bundle.App, firstFreeIndex, TransferType.Binary) == false) { throw new PebbleException("Failed to send application binary pebble-app.bin"); } if (bundle.HasResources) { if (progress != null) { progress.Report(new ProgressValue("Transferring app resources to Pebble", 60)); } if (await PutBytes(bundle.Resources, firstFreeIndex, TransferType.Resources) == false) { throw new PebbleException("Failed to send application resources app_resources.pbpack"); } } if (progress != null) { progress.Report(new ProgressValue("Adding app", 80)); } await AddApp(firstFreeIndex); if (progress != null) { progress.Report(new ProgressValue("Done", 100)); } }
private async Task InstallAppAsyncV3(AppBundle bundle, IProgress <ProgressValue> progress) { //https://github.com/pebble/libpebble2/blob/master/libpebble2/services/install.py var meta = AppMetaData.FromAppBundle(bundle); var bytes = meta.GetBytes(); var result = await _pebble.BlobDBClient.Delete(BlobDatabase.App, meta.UUID.Data); result = await _pebble.BlobDBClient.Insert(BlobDatabase.App, meta.UUID.Data, bytes); if (result.Response == BlobStatus.Success) { var startPacket = new AppRunStatePacket(); startPacket.Command = AppRunState.Start; startPacket.UUID = meta.UUID; //app_fetch = self._pebble.send_and_read(AppRunState(data=AppRunStateStart(uuid=app_uuid)), AppFetchRequest) var runStateResult = await _pebble.SendMessageAsync <AppFetchRequestPacket>(Endpoint.AppRunState, startPacket.GetBytes()); if (!runStateResult.Success) { throw new InvalidOperationException("Pebble replied invalid run state"); } if (!meta.UUID.Equals(runStateResult.UUID)) { var response = new AppFetchResponsePacket(); response.Response = AppFetchStatus.InvalidUUID; await _pebble.SendMessageNoResponseAsync(Endpoint.AppFetch, response.GetBytes()); throw new InvalidOperationException("The pebble requested the wrong UUID"); } var putBytesResponse = await _pebble.PutBytesClient.PutBytes(bundle.App, TransferType.Binary, appInstallId : (uint)runStateResult.AppId); if (!putBytesResponse) { throw new InvalidOperationException("Putbytes failed"); } if (bundle.HasResources) { putBytesResponse = await _pebble.PutBytesClient.PutBytes(bundle.Resources, TransferType.Resources, appInstallId : (uint)runStateResult.AppId); if (!putBytesResponse) { throw new InvalidOperationException("Putbytes failed"); } } //TODO: add worker to manifest and transfer it if necassary //if (bundle.HasWorker) //{ //await PutBytesV3(bundle.Worker, TransferType.Worker, runStateResult.AppId); //} } else { throw new DataMisalignedException("BlobDB Insert Failed"); } }