| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.ComponentModel; |
| | | 6 | | using Azure.Core; |
| | | 7 | | |
| | | 8 | | namespace Azure.AI.TextAnalytics |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Text Analytics error code values. |
| | | 12 | | /// </summary> |
| | | 13 | | public readonly struct TextAnalyticsErrorCode : IEquatable<TextAnalyticsErrorCode> |
| | | 14 | | { |
| | | 15 | | private readonly string _value; |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Specifies that the error code is an invalid request. |
| | | 19 | | /// </summary> |
| | 2 | 20 | | public static readonly string InvalidRequest = "InvalidRequest"; |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Specifies that the error code is an invalid argument. |
| | | 24 | | /// </summary> |
| | 2 | 25 | | public static readonly string InvalidArgument = "InvalidArgument"; |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Specifies that the error code is an internal server error. |
| | | 29 | | /// </summary> |
| | 2 | 30 | | public static readonly string InternalServerError = "InternalServerError"; |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Specifies that the error code is service unavailable. |
| | | 34 | | /// </summary> |
| | 2 | 35 | | public static readonly string ServiceUnavailable = "ServiceUnavailable"; |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Specifies that the error code is an invalid parameter value. |
| | | 39 | | /// </summary> |
| | 2 | 40 | | public static readonly string InvalidParameterValue = "InvalidParameterValue"; |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Specifies that the error code is an invalid request body format. |
| | | 44 | | /// </summary> |
| | 2 | 45 | | public static readonly string InvalidRequestBodyFormat = "InvalidRequestBodyFormat"; |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Specifies that the error code is an empty request. |
| | | 49 | | /// </summary> |
| | 2 | 50 | | public static readonly string EmptyRequest = "EmptyRequest"; |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// Specifies that the error code is a missing input records. |
| | | 54 | | /// </summary> |
| | 2 | 55 | | public static readonly string MissingInputRecords = "MissingInputRecords"; |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Specifies that the error code is an invalid document. |
| | | 59 | | /// </summary> |
| | 2 | 60 | | public static readonly string InvalidDocument = "InvalidDocument"; |
| | | 61 | | |
| | | 62 | | /// <summary> |
| | | 63 | | /// Specifies that the error code is model version incorrect. |
| | | 64 | | /// </summary> |
| | 2 | 65 | | public static readonly string ModelVersionIncorrect = "ModelVersionIncorrect"; |
| | | 66 | | |
| | | 67 | | /// <summary> |
| | | 68 | | /// Specifies that the error code is an invalid document batch. |
| | | 69 | | /// </summary> |
| | 2 | 70 | | public static readonly string InvalidDocumentBatch = "InvalidDocumentBatch"; |
| | | 71 | | |
| | | 72 | | /// <summary> |
| | | 73 | | /// Specifies that the error code is an unsupported language code. |
| | | 74 | | /// </summary> |
| | 2 | 75 | | public static readonly string UnsupportedLanguageCode = "UnsupportedLanguageCode"; |
| | | 76 | | |
| | | 77 | | /// <summary> |
| | | 78 | | /// Specifies that the error code is an invalid country hint. |
| | | 79 | | /// </summary> |
| | 2 | 80 | | public static readonly string InvalidCountryHint = "InvalidCountryHint"; |
| | | 81 | | |
| | | 82 | | private TextAnalyticsErrorCode(string errorCode) |
| | | 83 | | { |
| | 52 | 84 | | Argument.AssertNotNullOrEmpty(errorCode, nameof(errorCode)); |
| | 52 | 85 | | _value = errorCode; |
| | 52 | 86 | | } |
| | | 87 | | |
| | | 88 | | /// <summary> |
| | | 89 | | /// Defines implicit conversion from string to TextAnalyticsErrorCode. |
| | | 90 | | /// </summary> |
| | | 91 | | /// <param name="errorCode">string to convert.</param> |
| | | 92 | | /// <returns>The string as an TextAnalyticsErrorCode.</returns> |
| | 52 | 93 | | public static implicit operator TextAnalyticsErrorCode(string errorCode) => new TextAnalyticsErrorCode(errorCode |
| | | 94 | | |
| | | 95 | | /// <summary> |
| | | 96 | | /// Defines explicit conversion from TextAnalyticsErrorCode to string. |
| | | 97 | | /// </summary> |
| | | 98 | | /// <param name="errorCode">TextAnalyticsErrorCode to convert.</param> |
| | | 99 | | /// <returns>The TextAnalyticsErrorCode as a string.</returns> |
| | 0 | 100 | | public static explicit operator string(TextAnalyticsErrorCode errorCode) => errorCode._value; |
| | | 101 | | |
| | | 102 | | /// <summary> |
| | | 103 | | /// Compares two TextAnalyticsErrorCode values for equality. |
| | | 104 | | /// </summary> |
| | | 105 | | /// <param name="left">The first TextAnalyticsErrorCode to compare.</param> |
| | | 106 | | /// <param name="right">The second TextAnalyticsErrorCode to compare.</param> |
| | | 107 | | /// <returns>true if the TextAnalyticsErrorCode objects are equal or are both null; false otherwise.</returns> |
| | 72 | 108 | | public static bool operator ==(TextAnalyticsErrorCode left, TextAnalyticsErrorCode right) => Equals(left, right) |
| | | 109 | | |
| | | 110 | | /// <summary> |
| | | 111 | | /// Compares two TextAnalyticsErrorCode values for inequality. |
| | | 112 | | /// </summary> |
| | | 113 | | /// <param name="left">The first TextAnalyticsErrorCode to compare.</param> |
| | | 114 | | /// <param name="right">The second TextAnalyticsErrorCode to compare.</param> |
| | | 115 | | /// <returns>true if the TextAnalyticsErrorCode objects are not equal; false otherwise.</returns> |
| | 472 | 116 | | public static bool operator !=(TextAnalyticsErrorCode left, TextAnalyticsErrorCode right) => !Equals(left, right |
| | | 117 | | |
| | | 118 | | /// <summary> |
| | | 119 | | /// Compares the TextAnalyticsErrorCode for equality with another TextAnalyticsErrorCode. |
| | | 120 | | /// </summary> |
| | | 121 | | /// <param name="other">The TextAnalyticsErrorCode with which to compare.</param> |
| | | 122 | | /// <returns><c>true</c> if the TextAnalyticsErrorCode objects are equal; otherwise, <c>false</c>.</returns> |
| | 544 | 123 | | public bool Equals(TextAnalyticsErrorCode other) => _value == other._value; |
| | | 124 | | |
| | | 125 | | /// <summary> |
| | | 126 | | /// Determines whether the specified object is equal to the current object. |
| | | 127 | | /// </summary> |
| | | 128 | | /// <param name="obj">The object to compare with the current object.</param> |
| | | 129 | | /// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</retur |
| | | 130 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 544 | 131 | | public override bool Equals(object obj) => obj is TextAnalyticsErrorCode errorCode && Equals(errorCode); |
| | | 132 | | |
| | | 133 | | /// <summary> |
| | | 134 | | /// Serves as the default hash function. |
| | | 135 | | /// </summary> |
| | | 136 | | /// <returns>A hash code for the current object.</returns> |
| | | 137 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 138 | | public override int GetHashCode() => _value.GetHashCode(); |
| | | 139 | | |
| | | 140 | | /// <summary> |
| | | 141 | | /// Returns a string representation of the TextAnalyticsErrorCode. |
| | | 142 | | /// </summary> |
| | | 143 | | /// <returns>The TextAnalyticsErrorCode as a string.</returns> |
| | 44 | 144 | | public override string ToString() => _value; |
| | | 145 | | } |
| | | 146 | | } |