text:
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;

namespace Azure.Containers.ContainerRegistry
{
    internal partial class ContainerRegistryBlobRestClient
    {
        private string url;
        private ClientDiagnostics _clientDiagnostics;
        private HttpPipeline _pipeline;

        /// <summary> Initializes a new instance of ContainerRegistryBlobRestClient. </summary>
        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
        /// <param name="url"> Registry login URL. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="url"/> is null. </exception>
        public ContainerRegistryBlobRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string url)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            this.url = url;
            _clientDiagnostics = clientDiagnostics;
            _pipeline = pipeline;
        }

        internal HttpMessage CreateGetBlobRequest(string name, string digest)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/v2/", false);
            uri.AppendPath(name, true);
            uri.AppendPath("/blobs/", false);
            uri.AppendPath(digest, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/octet-stream");
            return message;
        }

        /// <summary> Retrieve the blob from the registry identified by digest. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/> or <paramref name="digest"/> is null. </exception>
        public async Task<ResponseWithHeaders<Stream, ContainerRegistryBlobGetBlobHeaders>> GetBlobAsync(string name, string digest, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }

            using var message = CreateGetBlobRequest(name, digest);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobGetBlobHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        var value = message.ExtractResponseContent();
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                case 307:
                    return ResponseWithHeaders.FromValue((Stream)null, headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Retrieve the blob from the registry identified by digest. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/> or <paramref name="digest"/> is null. </exception>
        public ResponseWithHeaders<Stream, ContainerRegistryBlobGetBlobHeaders> GetBlob(string name, string digest, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }

            using var message = CreateGetBlobRequest(name, digest);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobGetBlobHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        var value = message.ExtractResponseContent();
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                case 307:
                    return ResponseWithHeaders.FromValue((Stream)null, headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateCheckBlobExistsRequest(string name, string digest)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Head;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/v2/", false);
            uri.AppendPath(name, true);
            uri.AppendPath("/blobs/", false);
            uri.AppendPath(digest, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        /// <summary> Same as GET, except only the headers are returned. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/> or <paramref name="digest"/> is null. </exception>
        public async Task<ResponseWithHeaders<ContainerRegistryBlobCheckBlobExistsHeaders>> CheckBlobExistsAsync(string name, string digest, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }

            using var message = CreateCheckBlobExistsRequest(name, digest);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobCheckBlobExistsHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                case 307:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Same as GET, except only the headers are returned. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/> or <paramref name="digest"/> is null. </exception>
        public ResponseWithHeaders<ContainerRegistryBlobCheckBlobExistsHeaders> CheckBlobExists(string name, string digest, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }

            using var message = CreateCheckBlobExistsRequest(name, digest);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobCheckBlobExistsHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                case 307:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateDeleteBlobRequest(string name, string digest)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Delete;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/v2/", false);
            uri.AppendPath(name, true);
            uri.AppendPath("/blobs/", false);
            uri.AppendPath(digest, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/octet-stream");
            return message;
        }

        /// <summary> Removes an already uploaded blob. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/> or <paramref name="digest"/> is null. </exception>
        public async Task<ResponseWithHeaders<Stream, ContainerRegistryBlobDeleteBlobHeaders>> DeleteBlobAsync(string name, string digest, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }

            using var message = CreateDeleteBlobRequest(name, digest);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobDeleteBlobHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 202:
                    {
                        var value = message.ExtractResponseContent();
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Removes an already uploaded blob. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/> or <paramref name="digest"/> is null. </exception>
        public ResponseWithHeaders<Stream, ContainerRegistryBlobDeleteBlobHeaders> DeleteBlob(string name, string digest, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }

            using var message = CreateDeleteBlobRequest(name, digest);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobDeleteBlobHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 202:
                    {
                        var value = message.ExtractResponseContent();
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateMountBlobRequest(string name, string @from, string mount)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/v2/", false);
            uri.AppendPath(name, true);
            uri.AppendPath("/blobs/uploads/", false);
            uri.AppendQuery("from", @from, true);
            uri.AppendQuery("mount", mount, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        /// <summary> Mount a blob identified by the `mount` parameter from another repository. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="from"> Name of the source repository. </param>
        /// <param name="mount"> Digest of blob to mount from the source repository. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/>, <paramref name="from"/>, or <paramref name="mount"/> is null. </exception>
        public async Task<ResponseWithHeaders<ContainerRegistryBlobMountBlobHeaders>> MountBlobAsync(string name, string @from, string mount, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (@from == null)
            {
                throw new ArgumentNullException(nameof(@from));
            }
            if (mount == null)
            {
                throw new ArgumentNullException(nameof(mount));
            }

            using var message = CreateMountBlobRequest(name, @from, mount);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobMountBlobHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 201:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Mount a blob identified by the `mount` parameter from another repository. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="from"> Name of the source repository. </param>
        /// <param name="mount"> Digest of blob to mount from the source repository. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/>, <paramref name="from"/>, or <paramref name="mount"/> is null. </exception>
        public ResponseWithHeaders<ContainerRegistryBlobMountBlobHeaders> MountBlob(string name, string @from, string mount, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (@from == null)
            {
                throw new ArgumentNullException(nameof(@from));
            }
            if (mount == null)
            {
                throw new ArgumentNullException(nameof(mount));
            }

            using var message = CreateMountBlobRequest(name, @from, mount);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobMountBlobHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 201:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateGetUploadStatusRequest(string location)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/", false);
            uri.AppendPath(location, false);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        /// <summary> Retrieve status of upload identified by uuid. The primary purpose of this endpoint is to resolve the current status of a resumable upload. </summary>
        /// <param name="location"> Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ). </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="location"/> is null. </exception>
        public async Task<ResponseWithHeaders<ContainerRegistryBlobGetUploadStatusHeaders>> GetUploadStatusAsync(string location, CancellationToken cancellationToken = default)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            using var message = CreateGetUploadStatusRequest(location);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobGetUploadStatusHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 204:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Retrieve status of upload identified by uuid. The primary purpose of this endpoint is to resolve the current status of a resumable upload. </summary>
        /// <param name="location"> Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ). </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="location"/> is null. </exception>
        public ResponseWithHeaders<ContainerRegistryBlobGetUploadStatusHeaders> GetUploadStatus(string location, CancellationToken cancellationToken = default)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            using var message = CreateGetUploadStatusRequest(location);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobGetUploadStatusHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 204:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateUploadChunkRequest(string location, Stream value)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Patch;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/", false);
            uri.AppendPath(location, false);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/octet-stream");
            request.Content = RequestContent.Create(value);
            return message;
        }

        /// <summary> Upload a stream of data without completing the upload. </summary>
        /// <param name="location"> Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ). </param>
        /// <param name="value"> Raw data of blob. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="location"/> or <paramref name="value"/> is null. </exception>
        public async Task<ResponseWithHeaders<ContainerRegistryBlobUploadChunkHeaders>> UploadChunkAsync(string location, Stream value, CancellationToken cancellationToken = default)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            using var message = CreateUploadChunkRequest(location, value);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobUploadChunkHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 202:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Upload a stream of data without completing the upload. </summary>
        /// <param name="location"> Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ). </param>
        /// <param name="value"> Raw data of blob. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="location"/> or <paramref name="value"/> is null. </exception>
        public ResponseWithHeaders<ContainerRegistryBlobUploadChunkHeaders> UploadChunk(string location, Stream value, CancellationToken cancellationToken = default)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            using var message = CreateUploadChunkRequest(location, value);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobUploadChunkHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 202:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateCompleteUploadRequest(string digest, string location, Stream value)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/", false);
            uri.AppendPath(location, false);
            uri.AppendQuery("digest", digest, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            if (value != null)
            {
                request.Headers.Add("Content-Type", "application/octet-stream");
                request.Content = RequestContent.Create(value);
            }
            return message;
        }

        /// <summary> Complete the upload, providing all the data in the body, if necessary. A request without a body will just complete the upload with previously uploaded content. </summary>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="location"> Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ). </param>
        /// <param name="value"> Optional raw data of blob. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="digest"/> or <paramref name="location"/> is null. </exception>
        public async Task<ResponseWithHeaders<ContainerRegistryBlobCompleteUploadHeaders>> CompleteUploadAsync(string digest, string location, Stream value = null, CancellationToken cancellationToken = default)
        {
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            using var message = CreateCompleteUploadRequest(digest, location, value);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobCompleteUploadHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 201:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Complete the upload, providing all the data in the body, if necessary. A request without a body will just complete the upload with previously uploaded content. </summary>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="location"> Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ). </param>
        /// <param name="value"> Optional raw data of blob. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="digest"/> or <paramref name="location"/> is null. </exception>
        public ResponseWithHeaders<ContainerRegistryBlobCompleteUploadHeaders> CompleteUpload(string digest, string location, Stream value = null, CancellationToken cancellationToken = default)
        {
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            using var message = CreateCompleteUploadRequest(digest, location, value);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobCompleteUploadHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 201:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateCancelUploadRequest(string location)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Delete;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/", false);
            uri.AppendPath(location, false);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        /// <summary> Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout. </summary>
        /// <param name="location"> Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ). </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="location"/> is null. </exception>
        public async Task<Response> CancelUploadAsync(string location, CancellationToken cancellationToken = default)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            using var message = CreateCancelUploadRequest(location);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            switch (message.Response.Status)
            {
                case 204:
                    return message.Response;
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout. </summary>
        /// <param name="location"> Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ). </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="location"/> is null. </exception>
        public Response CancelUpload(string location, CancellationToken cancellationToken = default)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            using var message = CreateCancelUploadRequest(location);
            _pipeline.Send(message, cancellationToken);
            switch (message.Response.Status)
            {
                case 204:
                    return message.Response;
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateStartUploadRequest(string name)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/v2/", false);
            uri.AppendPath(name, true);
            uri.AppendPath("/blobs/uploads/", false);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        /// <summary> Initiate a resumable blob upload with an empty request body. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/> is null. </exception>
        public async Task<ResponseWithHeaders<ContainerRegistryBlobStartUploadHeaders>> StartUploadAsync(string name, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            using var message = CreateStartUploadRequest(name);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobStartUploadHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 202:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Initiate a resumable blob upload with an empty request body. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/> is null. </exception>
        public ResponseWithHeaders<ContainerRegistryBlobStartUploadHeaders> StartUpload(string name, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            using var message = CreateStartUploadRequest(name);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobStartUploadHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 202:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateGetChunkRequest(string name, string digest, string range)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/v2/", false);
            uri.AppendPath(name, true);
            uri.AppendPath("/blobs/", false);
            uri.AppendPath(digest, true);
            request.Uri = uri;
            request.Headers.Add("Range", range);
            request.Headers.Add("Accept", "application/octet-stream");
            return message;
        }

        /// <summary> Retrieve the blob from the registry identified by `digest`. This endpoint may also support RFC7233 compliant range requests. Support can be detected by issuing a HEAD request. If the header `Accept-Range: bytes` is returned, range requests can be used to fetch partial content. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="range"> Format : bytes=<start>-<end>,  HTTP Range header specifying blob chunk. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/>, <paramref name="digest"/>, or <paramref name="range"/> is null. </exception>
        public async Task<ResponseWithHeaders<Stream, ContainerRegistryBlobGetChunkHeaders>> GetChunkAsync(string name, string digest, string range, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }
            if (range == null)
            {
                throw new ArgumentNullException(nameof(range));
            }

            using var message = CreateGetChunkRequest(name, digest, range);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobGetChunkHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 206:
                    {
                        var value = message.ExtractResponseContent();
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Retrieve the blob from the registry identified by `digest`. This endpoint may also support RFC7233 compliant range requests. Support can be detected by issuing a HEAD request. If the header `Accept-Range: bytes` is returned, range requests can be used to fetch partial content. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="range"> Format : bytes=<start>-<end>,  HTTP Range header specifying blob chunk. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/>, <paramref name="digest"/>, or <paramref name="range"/> is null. </exception>
        public ResponseWithHeaders<Stream, ContainerRegistryBlobGetChunkHeaders> GetChunk(string name, string digest, string range, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }
            if (range == null)
            {
                throw new ArgumentNullException(nameof(range));
            }

            using var message = CreateGetChunkRequest(name, digest, range);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobGetChunkHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 206:
                    {
                        var value = message.ExtractResponseContent();
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateCheckChunkExistsRequest(string name, string digest, string range)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Head;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendPath("/v2/", false);
            uri.AppendPath(name, true);
            uri.AppendPath("/blobs/", false);
            uri.AppendPath(digest, true);
            request.Uri = uri;
            request.Headers.Add("Range", range);
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        /// <summary> Same as GET, except only the headers are returned. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="range"> Format : bytes=<start>-<end>,  HTTP Range header specifying blob chunk. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/>, <paramref name="digest"/>, or <paramref name="range"/> is null. </exception>
        public async Task<ResponseWithHeaders<ContainerRegistryBlobCheckChunkExistsHeaders>> CheckChunkExistsAsync(string name, string digest, string range, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }
            if (range == null)
            {
                throw new ArgumentNullException(nameof(range));
            }

            using var message = CreateCheckChunkExistsRequest(name, digest, range);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new ContainerRegistryBlobCheckChunkExistsHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        /// <summary> Same as GET, except only the headers are returned. </summary>
        /// <param name="name"> Name of the image (including the namespace). </param>
        /// <param name="digest"> Digest of a BLOB. </param>
        /// <param name="range"> Format : bytes=<start>-<end>,  HTTP Range header specifying blob chunk. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="name"/>, <paramref name="digest"/>, or <paramref name="range"/> is null. </exception>
        public ResponseWithHeaders<ContainerRegistryBlobCheckChunkExistsHeaders> CheckChunkExists(string name, string digest, string range, CancellationToken cancellationToken = default)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (digest == null)
            {
                throw new ArgumentNullException(nameof(digest));
            }
            if (range == null)
            {
                throw new ArgumentNullException(nameof(range));
            }

            using var message = CreateCheckChunkExistsRequest(name, digest, range);
            _pipeline.Send(message, cancellationToken);
            var headers = new ContainerRegistryBlobCheckChunkExistsHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }
    }
}


text:
namespace RedBlueGames.NotNull
{
    using System;
    using System.Collections.Generic;
    using System.Reflection;

    /// <summary>
    /// Utility methods to help with Reflection
    /// </summary>
    public static class ReflectionUtility
    {
        /// <summary>
        /// Gets all fields in a class that have a specified attribute. Default returns only public fields. Use binding flags
        /// to get NonPublic fields.
        /// </summary>
        /// <returns>A List of FieldInfo for all fields with the specified attribute.</returns>
        /// <param name="classToInspect">Class to inspect.</param>
        /// <param name="reflectionFlags">Reflection flags - supplying none uses default GetFields method.</param>
        /// <typeparam name="T">The Attribute type to search for.</typeparam>
        public static List<FieldInfo> GetFieldsWithAttributeFromType<T>(
            Type classToInspect,
            BindingFlags reflectionFlags = BindingFlags.Default)
        {
            List<FieldInfo> fieldsWithAttribute = new List<FieldInfo>();
            FieldInfo[] allFields;
            if (reflectionFlags == BindingFlags.Default)
            {
                allFields = classToInspect.GetFields();
            }
            else
            {
                allFields = classToInspect.GetFields(reflectionFlags);
            }

            foreach (FieldInfo fieldInfo in allFields)
            {
                foreach (var attribute in Attribute.GetCustomAttributes(fieldInfo))
                {
                    if (attribute.GetType() == typeof(T))
                    {
                        fieldsWithAttribute.Add(fieldInfo);
                        break;
                    }
                }
            }

            return fieldsWithAttribute;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
import os

ENVIRONMENTS = {
    "streaming": {
        "real": "stream-fxtrade.oanda.com",
        "practice": "stream-fxpractice.oanda.com",
        "sandbox": "stream-sandbox.oanda.com"
    },
    "api": {
        "real": "api-fxtrade.oanda.com",
        "practice": "api-fxpractice.oanda.com",
        "sandbox": "api-sandbox.oanda.com"
    }
}

DOMAIN = "practice"
STREAM_DOMAIN = ENVIRONMENTS["streaming"][DOMAIN]
API_DOMAIN = ENVIRONMENTS["api"][DOMAIN]
ACCESS_TOKEN = 'abcdef0123456abcdef0123456-abcdef0123456abcdef0123456'
ACCOUNT_ID = '12345678'


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- PYCSW_VERSION -->
<csw:GetRecordsResponse xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" version="2.0.2" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
  <csw:SearchStatus timestamp="PYCSW_TIMESTAMP"/>
  <csw:SearchResults numberOfRecordsMatched="2" numberOfRecordsReturned="2" nextRecord="0" recordSchema="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" elementSet="full">
    <rim:ExtrinsicObject xsi:schemaLocation="http://www.opengis.net/cat/wrs/1.0 http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/csw-ebrim.xsd" id="urn:uuid:94bc9c83-97f6-4b40-9eb8-a8e8787a5c63" lid="urn:uuid:94bc9c83-97f6-4b40-9eb8-a8e8787a5c63" objectType="http://purl.org/dc/dcmitype/Dataset" status="urn:oasis:names:tc:ebxml-regrep:StatusType:Submitted">
      <rim:VersionInfo versionName=""/>
      <rim:ExternalIdentifier value="urn:uuid:94bc9c83-97f6-4b40-9eb8-a8e8787a5c63" identificationScheme="foo" registryObject="None" id="urn:uuid:94bc9c83-97f6-4b40-9eb8-a8e8787a5c63"/>
      <rim:Name>
        <rim:LocalizedString value="Mauris sed neque"/>
      </rim:Name>
      <rim:Description>
        <rim:LocalizedString value="Curabitur lacinia, ante non porta tempus, mi lorem feugiat odio, eget suscipit eros pede ac velit."/>
      </rim:Description>
      <rim:Slot slotType="urn:ogc:def:dataType:ISO-19107:2003:GM_Envelope">
        <rim:ValueList>
          <rim:Value>
            <ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326" dimensions="2">
              <ows:LowerCorner>47.59 -4.1</ows:LowerCorner>
              <ows:UpperCorner>51.22 0.89</ows:UpperCorner>
            </ows:BoundingBox>
          </rim:Value>
        </rim:ValueList>
      </rim:Slot>
      <rim:Slot name="http://purl.org/dc/elements/1.1/subject">
        <rim:ValueList>
          <rim:Value>Vegetation-Cropland</rim:Value>
        </rim:ValueList>
      </rim:Slot>
    </rim:ExtrinsicObject>
    <rim:ExtrinsicObject xsi:schemaLocation="http://www.opengis.net/cat/wrs/1.0 http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/csw-ebrim.xsd" id="urn:uuid:9a669547-b69b-469f-a11f-2d875366bbdc" lid="urn:uuid:9a669547-b69b-469f-a11f-2d875366bbdc" objectType="http://purl.org/dc/dcmitype/Dataset" status="urn:oasis:names:tc:ebxml-regrep:StatusType:Submitted">
      <rim:VersionInfo versionName=""/>
      <rim:ExternalIdentifier value="urn:uuid:9a669547-b69b-469f-a11f-2d875366bbdc" identificationScheme="foo" registryObject="None" id="urn:uuid:9a669547-b69b-469f-a11f-2d875366bbdc"/>
      <rim:Name>
        <rim:LocalizedString value="Ñunç elementum"/>
      </rim:Name>
      <rim:Description>
        <rim:LocalizedString value="None"/>
      </rim:Description>
      <rim:Slot slotType="urn:ogc:def:dataType:ISO-19107:2003:GM_Envelope">
        <rim:ValueList>
          <rim:Value>
            <ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326" dimensions="2">
              <ows:LowerCorner>44.79 -6.17</ows:LowerCorner>
              <ows:UpperCorner>51.13 -2.23</ows:UpperCorner>
            </ows:BoundingBox>
          </rim:Value>
        </rim:ValueList>
      </rim:Slot>
      <rim:Slot name="http://purl.org/dc/elements/1.1/subject">
        <rim:ValueList>
          <rim:Value>Hydrography-Oceanographic</rim:Value>
        </rim:ValueList>
      </rim:Slot>
    </rim:ExtrinsicObject>
  </csw:SearchResults>
</csw:GetRecordsResponse>


text:
package seedu.addressbook.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import seedu.addressbook.data.AddressBook;
import seedu.addressbook.data.exception.IllegalValueException;
import seedu.addressbook.data.person.Address;
import seedu.addressbook.data.person.Email;
import seedu.addressbook.data.person.Name;
import seedu.addressbook.data.person.Person;
import seedu.addressbook.data.person.Phone;
import seedu.addressbook.data.person.ReadOnlyPerson;
import seedu.addressbook.data.person.UniquePersonList.DuplicatePersonException;
import seedu.addressbook.data.tag.UniqueTagList;

public class TestUtil {
    /**
     * Creates an address book containing the given persons.
     * @throws DuplicatePersonException if two or more given persons are the same
     */
    public static AddressBook createAddressBook(Person... persons) throws DuplicatePersonException {
        AddressBook addressBook = new AddressBook();

        for (Person person : persons) {
            addressBook.addPerson(person);
        }

        return addressBook;
    }

    /**
     * Creates a list of persons.
     */
    public static List<ReadOnlyPerson> createList(Person...persons) {
        List<ReadOnlyPerson> list = new ArrayList<ReadOnlyPerson>();

        for (Person person : persons) {
            list.add(person);
        }

        return list;
    }

    /**
     * Creates a copy of the original address book with the same entries
     * of Persons and Tags. The Persons and Tags are not cloned.
     */
    public static AddressBook clone(AddressBook addressBook) {
        return new AddressBook(addressBook.getAllPersons(), addressBook.getAllTags());
    }
    public static Person generateTestPerson() {
        try {
            return new Person(new Name(Name.EXAMPLE), new Phone(Phone.EXAMPLE, false),
                    new Email(Email.EXAMPLE, true), new Address(Address.EXAMPLE, false), new UniqueTagList());
        } catch (IllegalValueException e) {
            fail("test person data should be valid by definition");
            return null;
        }
    }

    /**
     * Asserts whether the text in the two given files are the same. Ignores any
     * differences in line endings
     */
    public static void assertTextFilesEqual(Path path1, Path path2) throws IOException {
        List<String> list1 = Files.readAllLines(path1, Charset.defaultCharset());
        List<String> list2 = Files.readAllLines(path2, Charset.defaultCharset());
        assertEquals(String.join("\n", list1), String.join("\n", list2));
    }
}


text:
from __future__ import absolute_import

import socket

import pytest
import tornado.iostream

from tchannel.tornado.connection import StreamConnection

@pytest.yield_fixture
def tornado_pair():
    server, client = socket.socketpair()

    server_stream = tornado.iostream.IOStream(server)
    client_stream = tornado.iostream.IOStream(client)

    server_conn = StreamConnection(server_stream)
    client_conn = StreamConnection(client_stream)

    try:
        yield server_conn, client_conn
    finally:
        server_stream.close()
        client_stream.close()


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This code was generated by https://github.com/googleapis/google-api-java-client-services/
 * Modify at your own risk.
 */

package com.google.api.services.contentwarehouse.v1.model;

/**
 * Model definition for VideoVideoStreamInfoVideoStreamCleanAperture.
 *
 *
 This is the Java data model class that specifies how to parse/serialize into the JSON that is
 * transmitted over HTTP when working with the contentwarehouse API. For a detailed explanation see:
 * https://developers.google.com/api-client-library/java/google-http-java-client/json
 *

 *
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public final class VideoVideoStreamInfoVideoStreamCleanAperture extends com.google.api.client.json.GenericJson {

  /**
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.Integer height;

  /**
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.Integer horizontalOffset;

  /**
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.Integer verticalOffset;

  /**
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.Integer width;

  /**
   * @return value or {@code null} for none
   */
  public java.lang.Integer getHeight() {
    return height;
  }

  /**
   * @param height height or {@code null} for none
   */
  public VideoVideoStreamInfoVideoStreamCleanAperture setHeight(java.lang.Integer height) {
    this.height = height;
    return this;
  }

  /**
   * @return value or {@code null} for none
   */
  public java.lang.Integer getHorizontalOffset() {
    return horizontalOffset;
  }

  /**
   * @param horizontalOffset horizontalOffset or {@code null} for none
   */
  public VideoVideoStreamInfoVideoStreamCleanAperture setHorizontalOffset(java.lang.Integer horizontalOffset) {
    this.horizontalOffset = horizontalOffset;
    return this;
  }

  /**
   * @return value or {@code null} for none
   */
  public java.lang.Integer getVerticalOffset() {
    return verticalOffset;
  }

  /**
   * @param verticalOffset verticalOffset or {@code null} for none
   */
  public VideoVideoStreamInfoVideoStreamCleanAperture setVerticalOffset(java.lang.Integer verticalOffset) {
    this.verticalOffset = verticalOffset;
    return this;
  }

  /**
   * @return value or {@code null} for none
   */
  public java.lang.Integer getWidth() {
    return width;
  }

  /**
   * @param width width or {@code null} for none
   */
  public VideoVideoStreamInfoVideoStreamCleanAperture setWidth(java.lang.Integer width) {
    this.width = width;
    return this;
  }

  @Override
  public VideoVideoStreamInfoVideoStreamCleanAperture set(String fieldName, Object value) {
    return (VideoVideoStreamInfoVideoStreamCleanAperture) super.set(fieldName, value);
  }

  @Override
  public VideoVideoStreamInfoVideoStreamCleanAperture clone() {
    return (VideoVideoStreamInfoVideoStreamCleanAperture) super.clone();
  }

}


text:
<title>MIPS ASE instruction generation overrides - Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<meta name="generator" content="makeinfo 4.7">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="MIPS_002dDependent.html#MIPS_002dDependent" title="MIPS-Dependent">
<link rel="prev" href="MIPS-option-stack.html#MIPS-option-stack" title="MIPS option stack">
<link rel="next" href="MIPS-floating_002dpoint.html#MIPS-floating_002dpoint" title="MIPS floating-point">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">

<meta http-equiv="Content-Style-Type" content="text/css">

Next: MIPS floating-point,
Previous: MIPS option stack,
Up: MIPS-Dependent

9.22.9 Directives to control generation of MIPS ASE instructions

The directive .set mips3d makes the assembler accept instructions
from the MIPS-3D Application Specific Extension from that point on
in the assembly.  The .set nomips3d directive prevents MIPS-3D
instructions from being accepted.

The directive .set smartmips makes the assembler accept
instructions from the SmartMIPS Application Specific Extension to the
MIPS32 isa from that point on in the assembly.  The
.set nosmartmips directive prevents SmartMIPS instructions from
being accepted.

The directive .set mdmx makes the assembler accept instructions
from the MDMX Application Specific Extension from that point on
in the assembly.  The .set nomdmx directive prevents MDMX
instructions from being accepted.

The directive .set dsp makes the assembler accept instructions
from the DSP Release 1 Application Specific Extension from that point
on in the assembly.  The .set nodsp directive prevents DSP
Release 1 instructions from being accepted.

The directive .set dspr2 makes the assembler accept instructions
from the DSP Release 2 Application Specific Extension from that point
on in the assembly.  This dirctive implies .set dsp.  The
.set nodspr2 directive prevents DSP Release 2 instructions from
being accepted.

The directive .set mt makes the assembler accept instructions
from the MT Application Specific Extension from that point on
in the assembly.  The .set nomt directive prevents MT
instructions from being accepted.

Traditional mips assemblers do not support these directives.


text:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="ro.pub.cs.systems.pdsd.lab05.addressbook.AddressBookActivity" >

    <!--  TODO: exercise 6a -->

</menu>


text:
package com.sirius.upns.protocol.test.unit;

import com.sirius.upns.protocol.business.msg.Custom;
import com.sirius.upns.protocol.business.sub.Ping;
import com.sirius.upns.protocol.transfer.MarshallerType;
import com.sirius.upns.protocol.transfer.Payload;
import org.junit.Before;
import org.junit.Test;

import java.util.HashMap;
import java.util.UUID;

/**
 * @project protocol
 * @date 2013-8-31-下午4:49:53
 * @author pippo
 */
public class BinayPackageSizeTest {

	private Ping ping = new Ping(System.currentTimeMillis());

	private Custom custom = new Custom();

	@Before
	public void init() {
		custom.appId = -1;
		custom.appId = -1;
		custom.groupId = UUID.randomUUID().toString();
		custom.title = "adbc";
		custom.content = "afasdfasdfasdfasdfasdfasdfasdfasdfasdfad";
		custom.extension = new HashMap<String, String>();
		custom.extension.put("a", "1");
		custom.extension.put("b", "2");
		custom.extension.put("c", "dsdfsdf");
	}

	@Test
	public void msgPack() throws Exception {
		System.out.println("msgPack@ping" + new Payload(MarshallerType.MSGPack, ping).getBytes().length);
		System.out.println("msgPack@custom" + new Payload(MarshallerType.MSGPack, custom).getBytes().length);
	}

	@Test
	public void json() throws Exception {
		System.out.println("json@ping" + new Payload(MarshallerType.JSON, ping).getBytes().length);
		System.out.println("json@custom" + new Payload(MarshallerType.JSON, custom).getBytes().length);
	}

}


text:
<?php

/**
 * @file
 * Run the automated tests.
 */

namespace AKlump\WebPackage;

$build
  ->setPhp('/Applications/MAMP/bin/php/php7.2.20/bin/php')
  ->setPhpUnit('/Users/aklump/opt/phpunit/phpunit-6.phar')
  ->runTests('phpunit.xml')
  ->displayMessages();


text:
from fabric.api import run, env, task, cd, sudo
from fabric.operations import get

"""
pip install fabric
how to run:
fab deploy -H root@www.jedutils.com
"""

@task
def deploy():
    prob_home = '/var/www/html/websites/toolsprj'
    with cd(prob_home):
        sudo('git pull')
        run('workon tools && ./manage.py collectstatic --noinput')
        run('workon tools && ./manage.py migrate')
        run('workon tools && gunicorn -w 2 -b 127.0.0.1:8080 -n toolsprj toolsprj.wsgi:application &')
# gunicorn -w 2 -b 127.0.0.1:8080 -n toolsprj toolsprj.wsgi:application &


text:
import $ from 'jquery';

import Container from '../container/container';

import rowTemplate from './fieldset_row.jade';
import colTemplate from './fieldset_col.jade';

import Factory from '../factory';

export default class FieldsetRow extends Container {
  get width() {
    return this.config.width;
  }

  get templateFn() {
    return rowTemplate;
  }

  appendChild(block) {
    const width = this.width && `col-xs-${this.width.shift()}`;
    this.el.append($(colTemplate({ width })).append(block.el));
  }

  afterRender() {
    super.afterRender();

    this.items.forEach(item => item.on('change', () => this.trigger('change')));
  }

  validate() {
    if (this.config.validateOnlyFirstField) {
      return this.items.every(block => {
        const isValid = block.validate();

        if (!isValid) {
          this.firstInvalidField = block;
        }

        return isValid;
      });
    }

    return this.items.reduce((acc, block) => {
      const isValid = block.validate();

      if (acc && !isValid) {
        this.firstInvalidField = block;
      }

      return isValid && acc;
    }, true);
  }

  focus() {
    this.firstInvalidField.focus();
  }

  hideErrors() {
    this.items.forEach(block => block.popover('hide'));
  }

  get sum() {
    return this.items.reduce((acc, block) => {
      if (!block.config.isSummable) {
        return acc;
      }

      const value = block.value || {};

      return acc + (parseFloat(value[block.name]) || 0);
    }, 0);
  }
}

Factory.register('fieldsetRow', FieldsetRow);


text:
USE mosaiktest;

CREATE TABLE IF NOT EXISTS menschen (
  name    VARCHAR(300),
  vorname VARCHAR(300)
);

INSERT INTO mosaiktest.menschen VALUE ("aydemir", "tolga");
INSERT INTO mosaiktest.menschen VALUE ("maffay", "peter");
INSERT INTO mosaiktest.menschen VALUE ("holzberger", "christian");
INSERT INTO mosaiktest.menschen VALUE ("christus", "jesus");


text:
Make sure Phalcon\Exception inheritance chain is correct - https://github.com/phalcon/cphalcon/issues/1770
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$e = new \Phalcon\Loader\Exception();
assert(!($e instanceof \Phalcon\Di\Exception));
assert($e instanceof \Phalcon\Exception);

$e = new \Phalcon\Forms\Exception();
assert(!($e instanceof \Phalcon\Di\Exception));
assert($e instanceof \Phalcon\Exception);

$e = new \Phalcon\Http\Request\Exception();
assert(!($e instanceof \Phalcon\Di\Exception));
assert($e instanceof \Phalcon\Exception);
?>
--EXPECT--


text:
from google.cloud import retail_v2alpha

def sample_update_catalog():
    # Create a client
    client = retail_v2alpha.CatalogServiceClient()

    # Initialize request argument(s)
    catalog = retail_v2alpha.Catalog()
    catalog.name = "name_value"
    catalog.display_name = "display_name_value"

    request = retail_v2alpha.UpdateCatalogRequest(
        catalog=catalog,
    )

    # Make the request
    response = client.update_catalog(request=request)

    # Handle the response
    print(response)

# [END retail_v2alpha_generated_CatalogService_UpdateCatalog_sync]


text:
"use strict";

const Constants = require("../../../../Constants");
const Events = Constants.Events;
const Endpoints = Constants.Endpoints;
const apiRequest = require("../../../../core/ApiRequest");

module.exports = function(guildId, userId, deleteMessageForDays) {
  deleteMessageForDays = deleteMessageForDays || 0;
  if (deleteMessageForDays && [1, 7].indexOf(deleteMessageForDays) < 0) {
    return Promise.reject(
      new Error("deleteMessageForDays can only be 0, 1 or 7")
    );
  }

  return new Promise((rs, rj) => {
    var request = apiRequest
    .put(this, {
      url: `${Endpoints.GUILD_BANS(guildId)}/${userId}`,
      query: { "delete-message-days": deleteMessageForDays }
    });

    this._queueManager.put(request, (err, res) => {
      return (!err && res.ok) ? rs() : rj(err);
    });
  });
};