public ContainerID PutContainer(CancellationToken context, Container.Container container, CallOptions options = null) { var container_client = new ContainerService.ContainerServiceClient(channel); var opts = DefaultCallOptions.ApplyCustomOptions(options); container.Version = Refs.Version.SDKVersion(); if (container.OwnerId is null) { container.OwnerId = key.ToOwnerID(); } var req = new PutRequest { Body = new PutRequest.Types.Body { Container = container, Signature = container.SignMessagePart(key), } }; req.MetaHeader = opts.GetRequestMetaHeader(); req.SignRequest(key); var resp = container_client.Put(req, cancellationToken: context); if (!resp.VerifyResponse()) { throw new InvalidOperationException("invalid container put response"); } return(resp.Body.ContainerId); }
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 ContainersController(MyDbContext context, IHttpClientFactory factory) { _context = context; var connectionFactory = new ConnectionFactory() { HostName = MyConfig.MqHostName, UserName = MyConfig.MqUsername, Password = MyConfig.MqPassword }; connection = connectionFactory.CreateConnection(); channel = connection.CreateModel(); channel.BasicQos(0, 1, false); _factory = factory; var gRpcChannel = GrpcChannel.ForAddress("https://localhost:12000"); gRpcClient = new ContainerService.ContainerServiceClient(gRpcChannel); }
public MQListener() { var connectionFactory = new ConnectionFactory() { HostName = MyConfig.MqHostName, UserName = MyConfig.MqUsername, Password = MyConfig.MqPassword }; connection = connectionFactory.CreateConnection(); channel = connection.CreateModel(); channel.BasicQos(0, 1, false); client = new DockerClientConfiguration(new Uri("http://localhost:2375")).CreateClient(); var gRpcChannel = GrpcChannel.ForAddress("https://localhost:12000"); gRpcClient = new ContainerService.ContainerServiceClient(gRpcChannel); cSRedisClient = new CSRedisClient("127.0.0.1:6379,defaultDatabase=11"); RedisHelper.Initialization(cSRedisClient); }
public void AnnounceContainerUsedSpace(CancellationToken context, List <UsedSpaceAnnouncement> announcements, CallOptions options = null) { var container_client = new ContainerService.ContainerServiceClient(channel); var opts = DefaultCallOptions.ApplyCustomOptions(options); var body = new AnnounceUsedSpaceRequest.Types.Body(); body.Announcements.AddRange(announcements); var req = new AnnounceUsedSpaceRequest { Body = body, }; req.MetaHeader = opts.GetRequestMetaHeader(); req.SignRequest(key); var resp = container_client.AnnounceUsedSpace(req, cancellationToken: context); if (!resp.VerifyResponse()) { throw new InvalidOperationException("invalid announce used space response"); } }
public List <ContainerID> ListContainers(CancellationToken context, OwnerID owner, CallOptions options = null) { var container_client = new ContainerService.ContainerServiceClient(channel); var opts = DefaultCallOptions.ApplyCustomOptions(options); var req = new ListRequest { Body = new ListRequest.Types.Body { OwnerId = owner } }; req.MetaHeader = opts.GetRequestMetaHeader(); req.SignRequest(key); var resp = container_client.List(req, cancellationToken: context); if (!resp.VerifyResponse()) { throw new InvalidOperationException("invalid container put response"); } return(resp.Body.ContainerIds.ToList()); }
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 SetEACL(CancellationToken context, EACLTable eacl, CallOptions options = null) { var container_client = new ContainerService.ContainerServiceClient(channel); var opts = DefaultCallOptions.ApplyCustomOptions(options); var req = new SetExtendedACLRequest { Body = new SetExtendedACLRequest.Types.Body { Eacl = eacl, Signature = eacl.SignMessagePart(key), } }; req.MetaHeader = opts.GetRequestMetaHeader(); req.SignRequest(key); var resp = container_client.SetExtendedACL(req, cancellationToken: context); if (!resp.VerifyResponse()) { throw new InvalidOperationException("invalid container put response"); } }
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 TestInvalidRequest() { var channel = GrpcChannel.ForAddress(host, new() { Credentials = SslCredentials.Insecure }); var containerClient = new ContainerService.ContainerServiceClient(channel); var container = containerClient.Get(new GetRequest()); }