Пример #1
0
        /// <summary>
        /// Constructs the response from a lower-level <see cref="JsonResponse"/>.
        /// </summary>
        /// <param name="response"></param>
        internal ServiceListResponse(JsonResponse response)
            : base(response)
        {
            this.Inner = response.AsDynamic();

            foreach (var service in this.Inner)
            {
                this.Services.Add(DockerClient.ParseObject <ServiceDetails>((JObject)service));
            }
        }
Пример #2
0
        /// <summary>
        /// Constructs the response from a lower-level <see cref="JsonResponse"/>.
        /// </summary>
        /// <param name="response"></param>
        internal DockerResponse(JsonResponse response)
        {
            var warnings = response.AsDynamic().Warnings;

            if (warnings != null)
            {
                foreach (string warning in warnings)
                {
                    Warnings.Add(warning);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Constructs the response from a lower-level <see cref="JsonResponse"/>.
        /// </summary>
        /// <param name="response"></param>
        internal VolumeListResponse(JsonResponse response)
            : base(response)
        {
            this.Inner = response.AsDynamic();

            var volumes = this.Inner.Volumes;

            if (volumes != null)
            {
                foreach (var volume in volumes)
                {
                    this.Volumes.Add(new DockerVolume(volume));
                }
            }
        }
Пример #4
0
        //---------------------------------------------------------------------
        // Static members

        /// <summary>
        /// Throws a <see cref="GatewayException"/> if the <see cref="JsonResponse"/> indicates
        /// that the server reported an error.
        /// </summary>
        /// <param name="jsonResponse">The JSON response returned by the Sync Gateway.</param>
        /// <returns>The corresponding <see cref="GatewayException"/>.</returns>
        internal static void ThrowOnError(JsonResponse jsonResponse)
        {
            if (jsonResponse.IsSuccess)
            {
                return;
            }

            var doc = jsonResponse.AsDynamic();

            if (doc == null)
            {
                throw new GatewayException($"[status={jsonResponse.StatusCode}]: {jsonResponse.HttpResponse.ReasonPhrase}");
            }

            throw new GatewayException($"[status={jsonResponse.StatusCode}]: {doc.reason}")
                  {
                      StatusCode = jsonResponse.StatusCode,
                      Error      = doc.error,
                      Reason     = doc.reason
                  };
        }
Пример #5
0
 /// <summary>
 /// Constructs the response from a lower-level <see cref="JsonResponse"/>.
 /// </summary>
 /// <param name="response"></param>
 internal NetworkCreateResponse(JsonResponse response)
     : base(response)
 {
     this.Inner = response.AsDynamic();
     this.Id    = Inner().Id;
 }