Exemple #1
0
        public async Task AnnounceContainerUsedSpace(List <UsedSpaceAnnouncement> announcements, CallOptions options = null, CancellationToken context = default)
        {
            if (announcements is null)
            {
                throw new ArgumentNullException(nameof(announcements));
            }
            var opts = DefaultCallOptions.ApplyCustomOptions(options);

            CheckOptions(opts);
            var body = new AnnounceUsedSpaceRequest.Types.Body();

            body.Announcements.AddRange(announcements);
            var req = new AnnounceUsedSpaceRequest
            {
                Body = body,
            };

            req.MetaHeader = opts.GetRequestMetaHeader();
            opts.Key.Sign(req);

            await AnnounceContainerUsedSpace(req, opts.Deadline, context);
        }
        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");
            }
        }