public void GetContainerTags(ContainerID identity) { ShowLoader(); PlayFabMultiplayerAPI.ListContainerImageTags(new ListContainerImageTagsRequest { ImageName = identity.containerName }, result => { HideLoader(); string tags = ""; foreach (var tag in result.Tags) { tags += "\n" + tag; if (tag.Equals("latest")) { identity.containerTag = tag; } } InformTags(string.Format("Tags for '<b>{0}</b>':\n{1}", identity.containerName, tags), identity); Debug.Log("GOT TAGS OK: " + result.ToJson()); }, error => { HideLoader(); Debug.LogError("GET TAGS FAILED: " + error.ToString()); Inform("Failed to retrieve information for the container!\n\n" + error.ErrorMessage); }); }
public void TestObjectDelete() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var cid = ContainerID.FromBase58String("Bun3sfMBpnjKc3Tx7SdwrMxyNi8ha8JT3dhuFGvYBRTz"); var oid = ObjectID.FromBase58String("CnBNgUmXiA5KJeGvMDgUEGiKrbZctjwxT5v3sBYjnmf1"); var address = new Address(cid, oid); var client = new Client.Client(key, host); var source1 = new CancellationTokenSource(); source1.CancelAfter(TimeSpan.FromMinutes(1)); var session = client.CreateSession(source1.Token, ulong.MaxValue); source1.Cancel(); var source2 = new CancellationTokenSource(); source2.CancelAfter(TimeSpan.FromMinutes(1)); var o = client.DeleteObject(source2.Token, new DeleteObjectParams { Address = address }, new CallOptions { Ttl = 2, Session = session }); Assert.IsTrue(o); }
public EAclWithSignature GetEAclWithSignature(CancellationToken context, ContainerID cid, CallOptions options = null) { var container_client = new ContainerService.ContainerServiceClient(channel); var opts = DefaultCallOptions.ApplyCustomOptions(options); var req = new GetExtendedACLRequest { Body = new GetExtendedACLRequest.Types.Body { ContainerId = cid } }; req.MetaHeader = opts.GetRequestMetaHeader(); req.SignRequest(key); var resp = container_client.GetExtendedACL(req, cancellationToken: context); if (!resp.VerifyResponse()) { throw new InvalidOperationException("invalid container put response"); } var eacl = resp.Body.Eacl; var sig = resp.Body.Signature; if (!eacl.VerifyMessagePart(sig)) { throw new InvalidOperationException("invalid eacl"); } return(new EAclWithSignature { Table = eacl, Signature = sig, }); }
public void TestSetExtendedACL() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var cid = ContainerID.FromBase58String("Bun3sfMBpnjKc3Tx7SdwrMxyNi8ha8JT3dhuFGvYBRTz"); var client = new Client.Client(key, host); var eacl = new EACLTable { Version = Refs.Version.SDKVersion(), ContainerId = cid, }; var filter = new EACLRecord.Types.Filter { HeaderType = HeaderType.HeaderUnspecified, MatchType = MatchType.StringEqual, Key = "test", Value = "test" }; var target = new EACLRecord.Types.Target { Role = Role.Others, }; var record = new EACLRecord { Operation = Acl.Operation.Get, Action = Acl.Action.Deny, }; record.Filters.Add(filter); record.Targets.Add(target); var source = new CancellationTokenSource(); source.CancelAfter(10000); client.SetEACL(source.Token, eacl); }
public void ListContainerImages() { ShowLoader(); PlayFabMultiplayerAPI.ListContainerImages(new ListContainerImagesRequest(), result => { HideLoader(); Debug.Log("GOT IMAGES OK: " + result.ToJson().ToString()); foreach (var container in result.Images) { GameObject newContainerButton = Instantiate(containerButton, Vector3.zero, Quaternion.identity, containerButton.transform.parent) as GameObject; ContainerID identity = newContainerButton.GetComponent <ContainerID>(); identity.containerName = container; identity.text.text = container; newContainerButton.SetActive(true); } containerWindow.SetActive(true); }, error => { HideLoader(); Inform("GET IMAGES FAILED: " + error.ErrorMessage); Debug.LogError("GET IMAGES FAILED: " + error.ToString()); }); }
/// <summary> /// GetAsync returns neofs object from the provided url. /// If Command is not provided, full object is requested. /// </summary> /// <param name="uri">URI scheme is "neofs:<Container-ID>/<Object-ID>/<Command>/<offset|length>".</param> /// <param name="host">Client host.</param> /// <param name="cancellation">Cancellation token object.</param> /// <returns>Returns neofs object.</returns> private Task <string> GetAsync(Uri uri, string host, CancellationToken cancellation) { string[] ps = uri.AbsolutePath.Split("/"); if (ps.Length < 2) { throw new FormatException("Invalid neofs url"); } ContainerID containerID = ContainerID.FromBase58String(ps[0]); ObjectID objectID = ObjectID.FromBase58String(ps[1]); Address objectAddr = new() { ContainerId = containerID, ObjectId = objectID }; Client client = new(privateKey, host); var tokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellation); tokenSource.CancelAfter(Settings.Default.NeoFS.Timeout); if (ps.Length == 2) { return(GetPayloadAsync(client, objectAddr, tokenSource.Token)); } return(ps[2] switch { "range" => GetRangeAsync(client, objectAddr, ps.Skip(3).ToArray(), tokenSource.Token), "header" => GetHeaderAsync(client, objectAddr, tokenSource.Token), "hash" => GetHashAsync(client, objectAddr, ps.Skip(3).ToArray(), tokenSource.Token), _ => throw new Exception("invalid command") }); }
public void InformTags(string message, ContainerID identity) { HideLoader(); informTagsText.text = message; informTagsModal.GetComponent <ContainerID>().containerName = identity.containerName; informTagsModal.GetComponent <ContainerID>().containerTag = identity.containerTag; informTagsModal.SetActive(true); }
public void CreateNewBuild(ContainerID identity) { string containerName = identity.containerName; string containerTag = identity.containerTag; buildID.containerName.text = containerName; buildID.containerTag.text = containerTag; buildID.gameObject.SetActive(true); }
public void TestDeleteContainer() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var client = new Client.Client(key, host); var cid = ContainerID.FromBase58String("Bun3sfMBpnjKc3Tx7SdwrMxyNi8ha8JT3dhuFGvYBRTz"); var source = new CancellationTokenSource(); source.CancelAfter(10000); client.DeleteContainer(source.Token, cid); }
public void TestGetContainer() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var client = new Client.Client(key, host); var cid = ContainerID.FromBase58String("GcB1gWcwSDbATLQce4J81RYj9B4MhdFqevsnegQnMaye"); var source = new CancellationTokenSource(); source.CancelAfter(10000); var container = client.GetContainer(source.Token, cid); Assert.AreEqual(cid, container.CalCulateAndGetID); }
public void TestObjectGetWithoutOptions() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var cid = ContainerID.FromBase58String("RuzuV3RDstuVtWoDzsTsuNFiakaaGGN24EbNSUFGaiQ"); var oid = ObjectID.FromBase58String("6VLqsZAvYTRzt8yY4NvGweWfGmqBiAfQwd6novRNFYiG"); var address = new Address(cid, oid); var client = new Client.Client(key, host); var source = new CancellationTokenSource(); source.CancelAfter(TimeSpan.FromMinutes(1)); var o = client.GetObject(source.Token, new GetObjectParams { Address = address }).Result; Assert.AreEqual(oid, o.ObjectId); }
public async Task <EAclWithSignature> GetEAcl(ContainerID cid, CallOptions options = null, CancellationToken context = default) { if (cid is null) { throw new ArgumentNullException(nameof(cid)); } var opts = DefaultCallOptions.ApplyCustomOptions(options); CheckOptions(opts); var req = new GetExtendedACLRequest { Body = new GetExtendedACLRequest.Types.Body { ContainerId = cid } }; req.MetaHeader = opts.GetRequestMetaHeader(); opts.Key.Sign(req); return(await GetEAcl(req, opts.Deadline, context)); }
public Container.Container GetContainer(CancellationToken context, ContainerID cid, CallOptions options = null) { var container_client = new ContainerService.ContainerServiceClient(channel); var opts = DefaultCallOptions.ApplyCustomOptions(options); var req = new GetRequest { Body = new GetRequest.Types.Body { ContainerId = cid } }; req.MetaHeader = opts.GetRequestMetaHeader(); req.SignRequest(key); var resp = container_client.Get(req, cancellationToken: context); if (!resp.VerifyResponse()) { throw new InvalidOperationException("invalid container get response"); } return(resp.Body.Container); }
public void DeleteContainer(CancellationToken context, ContainerID cid, CallOptions options = null) { var container_client = new ContainerService.ContainerServiceClient(channel); var opts = DefaultCallOptions.ApplyCustomOptions(options); var req = new DeleteRequest { Body = new DeleteRequest.Types.Body { ContainerId = cid, } }; req.Body.Signature = req.Body.SignMessagePart(key); req.MetaHeader = opts.GetRequestMetaHeader(); req.SignRequest(key); var resp = container_client.Delete(req, cancellationToken: context); if (!resp.VerifyResponse()) { throw new InvalidOperationException("invalid container put response"); } }
public void TestContainerID() { var cid = ContainerID.FromString("4pQhKT9XN9Fj1WFoEPAWXenWopjAQLWLtsQNn5q2z56U"); Console.WriteLine(cid.Value.ToBase64()); }
// Load items from save data and sort them. private void loadItem(ContainerID containerID) { int count = containers[(int)containerID].Count; Item[] items = new Item[count]; int localOffset = containers[(int)containerID].Offset; for (int i = 0; i < count; i++) { byte[] itemBytes = new byte[12]; Array.Copy(MainForm.SaveData, localOffset, itemBytes, 0, 12); Item item = new Item(itemBytes); items[i] = item; if (item.Quality < -1) { // Fix quality error in older version int tempQuality = items[i].Quality & 0xFFFF; if (tempQuality >= 0 && tempQuality <= Item.MaxQuality) items[i].Quality = tempQuality; else items[i].Quality = Item.BaseQuality[items[i].Index]; IsModified = true; } localOffset += 12; } Array.Sort<Item>(items, (x, y) => x.CompareTo(y)); containers[(int)containerID].Items = items; }
// Save item data for specified container private void saveItems(ContainerID containerID) { Item[] items = containers[(int)containerID].Items; int count = containers[(int)containerID].Count; int offset = containers[(int)containerID].Offset; DataGridView dataGridView = containers[(int)containerID].ContainerDataGridView; byte[] itemBytes = new byte[12 * count]; for (int i = 0; i < count; i++) { Array.Copy(items[i].ToArray(), 0, itemBytes, 12 * i, 12); } Array.Copy(itemBytes, 0, MainForm.SaveData, offset, 12 * count); }
// Display item data when needed private void dataGridView_CellValueNeeded(ContainerID containerID, DataGridViewCellValueEventArgs e) { Item[] items = containers[(int)containerID].Items; int col = e.ColumnIndex; int row = e.RowIndex; switch (col) { case 0: e.Value = items[row].GetItemName(); break; case 1: e.Value = 5; if (items[row].Quality == -1) e.Value = StarQualityList[0]; if (items[row].Quality == 0) e.Value = StarQualityList[1]; if (items[row].Quality > 0 && items[row].Quality <= Item.MaxQuality) e.Value = StarQualityList[(items[row].Quality - 1) / 30 + 2]; if (items[row].Quality > Item.MaxQuality) { e.Value = StarQualityList[12]; } break; case 2: e.Value = items[row].Quality; break; case 3: e.Value = items[row].Quantity; break; } }
// Push changes back to Item[] arrays private void dataGridView_CellValuePushed(ContainerID containerID, DataGridViewCellValueEventArgs e) { Item[] items = containers[(int)containerID].Items; DataGridView dataGridView = containers[(int)containerID].ContainerDataGridView; switch (e.ColumnIndex) { case 0: int itemIndex = Array.IndexOf(Item.ItemNameList, e.Value); if (itemIndex == -1) items[e.RowIndex] = new Item(); else items[e.RowIndex] = new Item((ushort)itemIndex); dataGridView.InvalidateRow(e.RowIndex); // Repaint break; case 1: int starQualityIndex = Array.IndexOf(StarQualityList, e.Value.ToString()); if (starQualityIndex == 0) items[e.RowIndex].Quality = -1; else if (starQualityIndex == 12) dataGridView.CancelEdit(); else items[e.RowIndex].Quality = (starQualityIndex - 1) * 30; dataGridView.InvalidateRow(e.RowIndex); break; // Quality (column 2) and Quantity (column 3) were handled in CellValidating event. } }
// Grayed out some cells based on their value. private void dataGridView_CellFormatting(ContainerID containerID, DataGridViewCellFormattingEventArgs e) { Item[] items = containers[(int)containerID].Items; DataGridView dataGridView = containers[(int)containerID].ContainerDataGridView; switch (e.ColumnIndex) { case 1: case 2: Item item = items[e.RowIndex]; if ((item.Index == 0xFFFF) || (item.Quality > Item.MaxQuality) || (Item.BaseQuality[item.Index] == -1)) { e.CellStyle.BackColor = Color.LightGray; dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly = true; } else { e.CellStyle.BackColor = dataGridView.DefaultCellStyle.BackColor; dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly = false; } break; case 3: if ((items[e.RowIndex].Index == 0xFFFF) || (Item.BaseQuality[items[e.RowIndex].Index] == -1)) { e.CellStyle.BackColor = Color.LightGray; dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly = true; } else { e.CellStyle.BackColor = dataGridView.DefaultCellStyle.BackColor; dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly = false; } break; } }
// Validate and push new values into Item[] arrays. private void dataGridView_CellValidating(ContainerID containerID, DataGridViewCellValidatingEventArgs e) { DataGridView dataGridView = containers[(int)containerID].ContainerDataGridView; if (dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly) return; switch (e.ColumnIndex) { case 2: int quality; bool isValidQuality = Int32.TryParse(e.FormattedValue.ToString(), out quality); if (!isValidQuality || quality < -1 || quality > Item.MaxQuality) { dataGridView.Rows[e.RowIndex].Cells[2].ErrorText = "Quality value must be a valid number between -1 and 300"; dataGridView.CancelEdit(); } else { dataGridView.Rows[e.RowIndex].Cells[2].ErrorText = null; containers[(int)containerID].Items[e.RowIndex].Quality = quality; } break; case 3: byte quantity; bool isValidQuantity = Byte.TryParse(e.FormattedValue.ToString(), out quantity); if (!isValidQuantity || quantity < 1 || quantity > 99) { dataGridView.Rows[e.RowIndex].Cells[3].ErrorText = "Must be a valid number between 1 and 99"; dataGridView.CancelEdit(); } else { dataGridView.Rows[e.RowIndex].Cells[3].ErrorText = null; containers[(int)containerID].Items[e.RowIndex].Quantity = quantity; } break; } }
public void TestSimulation() { var nodes_json_str = "[{\"id\":17245477228755262,\"capacity\":0,\"index\":0,\"price\":22,\"nodeinfo\":{\"publicKey\":\"Aiu0BBxQ1gf/hx3sfkzXd4OI4OpoSdhMy9mqjzLhaoEx\",\"addresses\":[\"/dns4/s01.neofs.devenv/tcp/8080\"],\"attributes\":[{\"key\":\"Capacity\",\"value\":\"0\"},{\"key\":\"Continent\",\"value\":\"Asia\"},{\"key\":\"Country\",\"value\":\"Russia\"},{\"key\":\"CountryCode\",\"value\":\"RU\"},{\"key\":\"Location\",\"value\":\"Mishkino\"},{\"key\":\"Price\",\"value\":\"22\"},{\"key\":\"UN-LOCODE\",\"value\":\"RU MSK\"}],\"state\":\"Online\"}},{\"id\":14040999376522263000,\"capacity\":0,\"index\":1,\"price\":44,\"nodeinfo\":{\"publicKey\":\"A4yGKVnla0PiD3kYfE/p4Lx8jGbBYD5s8Ox/h6trCNw1\",\"addresses\":[\"/dns4/s04.neofs.devenv/tcp/8080\"],\"attributes\":[{\"key\":\"Capacity\",\"value\":\"0\"},{\"key\":\"Continent\",\"value\":\"Europe\"},{\"key\":\"Country\",\"value\":\"Finland\"},{\"key\":\"CountryCode\",\"value\":\"FI\"},{\"key\":\"Location\",\"value\":\"Helsinki (Helsingfors)\"},{\"key\":\"Price\",\"value\":\"44\"},{\"key\":\"SubDiv\",\"value\":\"Uusimaa\"},{\"key\":\"SubDivCode\",\"value\":\"18\"},{\"key\":\"UN-LOCODE\",\"value\":\"FI HEL\"}],\"state\":\"Online\"}},{\"id\":1508609683428895200,\"capacity\":0,\"index\":2,\"price\":33,\"nodeinfo\":{\"publicKey\":\"A/9ltq55E0pNzp0NOdOFHpurTul6v4boHhxbvFDNKCau\",\"addresses\":[\"/dns4/s02.neofs.devenv/tcp/8080\"],\"attributes\":[{\"key\":\"Capacity\",\"value\":\"0\"},{\"key\":\"Continent\",\"value\":\"Europe\"},{\"key\":\"Country\",\"value\":\"Russia\"},{\"key\":\"CountryCode\",\"value\":\"RU\"},{\"key\":\"Location\",\"value\":\"Saint Petersburg (ex Leningrad)\"},{\"key\":\"Price\",\"value\":\"33\"},{\"key\":\"SubDiv\",\"value\":\"Sankt-Peterburg\"},{\"key\":\"SubDivCode\",\"value\":\"SPE\"},{\"key\":\"UN-LOCODE\",\"value\":\"RU LED\"}],\"state\":\"Online\"}},{\"id\":11537578107108880000,\"capacity\":0,\"index\":3,\"price\":11,\"nodeinfo\":{\"publicKey\":\"AqySDNffC2GyiQcua5RuLaThoxuascYhu0deMPpKsQLD\",\"addresses\":[\"/dns4/s03.neofs.devenv/tcp/8080\"],\"attributes\":[{\"key\":\"Capacity\",\"value\":\"0\"},{\"key\":\"Continent\",\"value\":\"Europe\"},{\"key\":\"Country\",\"value\":\"Sweden\"},{\"key\":\"CountryCode\",\"value\":\"SE\"},{\"key\":\"Location\",\"value\":\"Stockholm\"},{\"key\":\"Price\",\"value\":\"11\"},{\"key\":\"SubDiv\",\"value\":\"Stockholms l�n\"},{\"key\":\"SubDivCode\",\"value\":\"AB\"},{\"key\":\"UN-LOCODE\",\"value\":\"SE STO\"}],\"state\":\"Online\"}}]"; var cid = ContainerID.FromString("AaCymCBPpMYeagJcBAxcMHKRZ9GEZYHDfLKsV1FwqAma"); var oid1 = ObjectID.FromString("GMBa69wUJEgfoHnu37MKwudeYsemxHD38ynNsyuAZv2M"); PlacementPolicy policy = new(0, new Replica[] { new(2, "SPB") }, new Selector[] { new("SPB", "City", Clause.Unspecified, 1, "*") }, null);
public override int GetHashCode() { return((int)(ID.GetHashCode() ^ ContainerID.GetHashCode())); }
public EACLTable GetEACL(CancellationToken context, ContainerID cid, CallOptions options = null) { var eacl_with_sig = GetEAclWithSignature(context, cid, options); return(eacl_with_sig.Table); }
public void AddObjectContainerIDFilter(MatchType op, ContainerID cid) { AddFilter(Filter.FilterHeaderContainerID, cid.ToBase58String(), op); }
public IHttpActionResult CreateChildInstance(int id, EAV.Store.IStoreInstance instance) { try { return(Ok <EAV.Store.IStoreInstance>(instanceClient.CreateChildInstance(instance, ContainerID.GetValueOrDefault(), id))); } catch (Exception ex) { return(InternalServerError(ex)); } }