Esempio n. 1
0
 /// <summary>
 /// Creates new MBeanOperationInfo object.
 /// </summary>
 /// <param name="name">The name of the method.</param>
 /// <param name="description">A human readable description of the operation.</param>
 /// <param name="returnType">The type of the method's return value.</param>
 /// <param name="signature">MBeanParameterInfo objects describing the parameters(arguments) of the method. It should be an empty list if operation has no parameters.</param>
 /// <param name="impact">The impact of the method.</param>
 /// <param name="descriptor">Initial descriptor values.</param>
 public MBeanOperationInfo(string name, string description, string returnType, IEnumerable<MBeanParameterInfo> signature, OperationImpact impact, Descriptor descriptor)
     : base(name, description, descriptor)
 {
     _returnType = returnType;
        _signature = new List<MBeanParameterInfo>(signature).AsReadOnly();
     _impact = impact;
 }
Esempio n. 2
0
 /// <summary>
 /// Creates new MBeanOperationInfo object.
 /// </summary>
 /// <param name="name">The name of the method.</param>
 /// <param name="description">A human readable description of the operation.</param>
 /// <param name="returnType">The type of the method's return value.</param>
 /// <param name="signature">MBeanParameterInfo objects describing the parameters(arguments) of the method. It should be an empty list if operation has no parameters.</param>
 /// <param name="impact">The impact of the method.</param>
 /// <param name="descriptor">Initial descriptor values.</param>
 public MBeanOperationInfo(string name, string description, string returnType, IEnumerable <MBeanParameterInfo> signature, OperationImpact impact, Descriptor descriptor)
     : base(name, description, descriptor)
 {
     _returnType = returnType;
     _signature  = new List <MBeanParameterInfo>(signature).AsReadOnly();
     _impact     = impact;
 }
Esempio n. 3
0
        public MBeanOperationInfo Deserialize()
        {
            OperationImpact impactEnum = OperationImpact.Unknown;

            if (impact != null && impact.IndexOf('r') != -1)
            {
                impactEnum |= OperationImpact.Info;
            }
            if (impact != null && impact.IndexOf('w') != -1)
            {
                impactEnum |= OperationImpact.Action;
            }
            XmlQualifiedName typeQualifiedName = null;

            if (Output != null)
            {
                typeQualifiedName = Output.type;
            }
            return(new MBeanOperationInfo(name, Description.Value, JmxTypeMapping.GetCLRTypeName(typeQualifiedName),
                                          Input.EmptyIfNull().Select(x => x.Deserialize()).ToArray(),
                                          impactEnum, GetDescriptorFromFieldValues()));
        }
 /// <summary>
 /// Creates new OpenMBeanOperationAttribute object.
 /// </summary>
 /// <param name="impact">Impact of the operation.</param>
 public OpenMBeanOperationAttribute(OperationImpact impact)
 {
     _impact = impact;
 }
 /// <summary>
 /// Creates new OpenMBeanOperationAttribute object.
 /// </summary>
 /// <param name="impact">Impact of the operation.</param>
 public OpenMBeanOperationAttribute(OperationImpact impact)
 {
     _impact = impact;
 }
Esempio n. 6
0
 /// <summary>
 /// Creates new MBeanOperationInfo object.
 /// </summary>
 /// <param name="name">The name of the method.</param>
 /// <param name="description">A human readable description of the operation.</param>
 /// <param name="returnType">The type of the method's return value.</param>
 /// <param name="signature">MBeanParameterInfo objects describing the parameters(arguments) of the method. It should be an empty list if operation has no parameters.</param>
 /// <param name="impact">The impact of the method.</param>
 public MBeanOperationInfo(string name, string description, string returnType, IEnumerable <MBeanParameterInfo> signature, OperationImpact impact)
     : this(name, description, returnType, signature, impact, new Descriptor())
 {
 }
 public OperationBuilder(string name, string description, OperationImpact impact)
 {
     _name        = name;
     _impact      = impact;
     _description = description;
 }
 public OperationBuilder(string name, string description, OperationImpact impact)
 {
     _name = name;
     _impact = impact;
     _description = description;
 }
Esempio n. 9
0
        /// <summary>
        /// Returns details on recommended index.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// Required. The name of the Resource Group.
        /// </param>
        /// <param name='serverName'>
        /// Required. The name of the Azure SQL server.
        /// </param>
        /// <param name='databaseName'>
        /// Required. The name of the Azure SQL database.
        /// </param>
        /// <param name='schemaName'>
        /// Required. The name of the Azure SQL database schema.
        /// </param>
        /// <param name='tableName'>
        /// Required. The name of the Azure SQL database table.
        /// </param>
        /// <param name='indexName'>
        /// Required. The name of the Azure SQL database recommended index.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// Represents the response to a get recommended index request.
        /// </returns>
        public async Task <RecommendedIndexGetResponse> GetAsync(string resourceGroupName, string serverName, string databaseName, string schemaName, string tableName, string indexName, CancellationToken cancellationToken)
        {
            // Validate
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException("resourceGroupName");
            }
            if (serverName == null)
            {
                throw new ArgumentNullException("serverName");
            }
            if (databaseName == null)
            {
                throw new ArgumentNullException("databaseName");
            }
            if (schemaName == null)
            {
                throw new ArgumentNullException("schemaName");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }
            if (indexName == null)
            {
                throw new ArgumentNullException("indexName");
            }

            // Tracing
            bool   shouldTrace  = TracingAdapter.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("resourceGroupName", resourceGroupName);
                tracingParameters.Add("serverName", serverName);
                tracingParameters.Add("databaseName", databaseName);
                tracingParameters.Add("schemaName", schemaName);
                tracingParameters.Add("tableName", tableName);
                tracingParameters.Add("indexName", indexName);
                TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/subscriptions/";
            if (this.Client.Credentials.SubscriptionId != null)
            {
                url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId);
            }
            url = url + "/resourceGroups/";
            url = url + Uri.EscapeDataString(resourceGroupName);
            url = url + "/providers/";
            url = url + "Microsoft.Sql";
            url = url + "/servers/";
            url = url + Uri.EscapeDataString(serverName);
            url = url + "/databases/";
            url = url + Uri.EscapeDataString(databaseName);
            url = url + "/schemas/";
            url = url + Uri.EscapeDataString(schemaName);
            url = url + "/tables/";
            url = url + Uri.EscapeDataString(tableName);
            url = url + "/recommendedIndexes/";
            url = url + Uri.EscapeDataString(indexName);
            List <string> queryParameters = new List <string>();

            queryParameters.Add("api-version=2014-04-01");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;

            try
            {
                httpRequest            = new HttpRequestMessage();
                httpRequest.Method     = HttpMethod.Get;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    RecommendedIndexGetResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                        result = new RecommendedIndexGetResponse();
                        JToken responseDoc = null;
                        if (string.IsNullOrEmpty(responseContent) == false)
                        {
                            responseDoc = JToken.Parse(responseContent);
                        }

                        if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                        {
                            RecommendedIndex recommendedIndexInstance = new RecommendedIndex();
                            result.RecommendedIndex = recommendedIndexInstance;

                            JToken propertiesValue = responseDoc["properties"];
                            if (propertiesValue != null && propertiesValue.Type != JTokenType.Null)
                            {
                                RecommendedIndexProperties propertiesInstance = new RecommendedIndexProperties();
                                recommendedIndexInstance.Properties = propertiesInstance;

                                JToken actionValue = propertiesValue["action"];
                                if (actionValue != null && actionValue.Type != JTokenType.Null)
                                {
                                    string actionInstance = ((string)actionValue);
                                    propertiesInstance.Action = actionInstance;
                                }

                                JToken stateValue = propertiesValue["state"];
                                if (stateValue != null && stateValue.Type != JTokenType.Null)
                                {
                                    string stateInstance = ((string)stateValue);
                                    propertiesInstance.State = stateInstance;
                                }

                                JToken createdValue = propertiesValue["created"];
                                if (createdValue != null && createdValue.Type != JTokenType.Null)
                                {
                                    DateTime createdInstance = ((DateTime)createdValue);
                                    propertiesInstance.Created = createdInstance;
                                }

                                JToken lastModifiedValue = propertiesValue["lastModified"];
                                if (lastModifiedValue != null && lastModifiedValue.Type != JTokenType.Null)
                                {
                                    DateTime lastModifiedInstance = ((DateTime)lastModifiedValue);
                                    propertiesInstance.LastModified = lastModifiedInstance;
                                }

                                JToken indexTypeValue = propertiesValue["indexType"];
                                if (indexTypeValue != null && indexTypeValue.Type != JTokenType.Null)
                                {
                                    string indexTypeInstance = ((string)indexTypeValue);
                                    propertiesInstance.IndexType = indexTypeInstance;
                                }

                                JToken schemaValue = propertiesValue["schema"];
                                if (schemaValue != null && schemaValue.Type != JTokenType.Null)
                                {
                                    string schemaInstance = ((string)schemaValue);
                                    propertiesInstance.Schema = schemaInstance;
                                }

                                JToken tableValue = propertiesValue["table"];
                                if (tableValue != null && tableValue.Type != JTokenType.Null)
                                {
                                    string tableInstance = ((string)tableValue);
                                    propertiesInstance.Table = tableInstance;
                                }

                                JToken columnsArray = propertiesValue["columns"];
                                if (columnsArray != null && columnsArray.Type != JTokenType.Null)
                                {
                                    foreach (JToken columnsValue in ((JArray)columnsArray))
                                    {
                                        propertiesInstance.Columns.Add(((string)columnsValue));
                                    }
                                }

                                JToken includedColumnsArray = propertiesValue["includedColumns"];
                                if (includedColumnsArray != null && includedColumnsArray.Type != JTokenType.Null)
                                {
                                    foreach (JToken includedColumnsValue in ((JArray)includedColumnsArray))
                                    {
                                        propertiesInstance.IncludedColumns.Add(((string)includedColumnsValue));
                                    }
                                }

                                JToken indexScriptValue = propertiesValue["indexScript"];
                                if (indexScriptValue != null && indexScriptValue.Type != JTokenType.Null)
                                {
                                    string indexScriptInstance = ((string)indexScriptValue);
                                    propertiesInstance.IndexScript = indexScriptInstance;
                                }

                                JToken estimatedImpactArray = propertiesValue["estimatedImpact"];
                                if (estimatedImpactArray != null && estimatedImpactArray.Type != JTokenType.Null)
                                {
                                    foreach (JToken estimatedImpactValue in ((JArray)estimatedImpactArray))
                                    {
                                        OperationImpact operationImpactInstance = new OperationImpact();
                                        propertiesInstance.EstimatedImpact.Add(operationImpactInstance);

                                        JToken nameValue = estimatedImpactValue["name"];
                                        if (nameValue != null && nameValue.Type != JTokenType.Null)
                                        {
                                            string nameInstance = ((string)nameValue);
                                            operationImpactInstance.Name = nameInstance;
                                        }

                                        JToken unitValue = estimatedImpactValue["unit"];
                                        if (unitValue != null && unitValue.Type != JTokenType.Null)
                                        {
                                            string unitInstance = ((string)unitValue);
                                            operationImpactInstance.Unit = unitInstance;
                                        }

                                        JToken changeValueAbsoluteValue = estimatedImpactValue["changeValueAbsolute"];
                                        if (changeValueAbsoluteValue != null && changeValueAbsoluteValue.Type != JTokenType.Null)
                                        {
                                            double changeValueAbsoluteInstance = ((double)changeValueAbsoluteValue);
                                            operationImpactInstance.ChangeValueAbsolute = changeValueAbsoluteInstance;
                                        }

                                        JToken changeValueRelativeValue = estimatedImpactValue["changeValueRelative"];
                                        if (changeValueRelativeValue != null && changeValueRelativeValue.Type != JTokenType.Null)
                                        {
                                            double changeValueRelativeInstance = ((double)changeValueRelativeValue);
                                            operationImpactInstance.ChangeValueRelative = changeValueRelativeInstance;
                                        }
                                    }
                                }

                                JToken reportedImpactArray = propertiesValue["reportedImpact"];
                                if (reportedImpactArray != null && reportedImpactArray.Type != JTokenType.Null)
                                {
                                    foreach (JToken reportedImpactValue in ((JArray)reportedImpactArray))
                                    {
                                        OperationImpact operationImpactInstance2 = new OperationImpact();
                                        propertiesInstance.ReportedImpact.Add(operationImpactInstance2);

                                        JToken nameValue2 = reportedImpactValue["name"];
                                        if (nameValue2 != null && nameValue2.Type != JTokenType.Null)
                                        {
                                            string nameInstance2 = ((string)nameValue2);
                                            operationImpactInstance2.Name = nameInstance2;
                                        }

                                        JToken unitValue2 = reportedImpactValue["unit"];
                                        if (unitValue2 != null && unitValue2.Type != JTokenType.Null)
                                        {
                                            string unitInstance2 = ((string)unitValue2);
                                            operationImpactInstance2.Unit = unitInstance2;
                                        }

                                        JToken changeValueAbsoluteValue2 = reportedImpactValue["changeValueAbsolute"];
                                        if (changeValueAbsoluteValue2 != null && changeValueAbsoluteValue2.Type != JTokenType.Null)
                                        {
                                            double changeValueAbsoluteInstance2 = ((double)changeValueAbsoluteValue2);
                                            operationImpactInstance2.ChangeValueAbsolute = changeValueAbsoluteInstance2;
                                        }

                                        JToken changeValueRelativeValue2 = reportedImpactValue["changeValueRelative"];
                                        if (changeValueRelativeValue2 != null && changeValueRelativeValue2.Type != JTokenType.Null)
                                        {
                                            double changeValueRelativeInstance2 = ((double)changeValueRelativeValue2);
                                            operationImpactInstance2.ChangeValueRelative = changeValueRelativeInstance2;
                                        }
                                    }
                                }
                            }

                            JToken idValue = responseDoc["id"];
                            if (idValue != null && idValue.Type != JTokenType.Null)
                            {
                                string idInstance = ((string)idValue);
                                recommendedIndexInstance.Id = idInstance;
                            }

                            JToken nameValue3 = responseDoc["name"];
                            if (nameValue3 != null && nameValue3.Type != JTokenType.Null)
                            {
                                string nameInstance3 = ((string)nameValue3);
                                recommendedIndexInstance.Name = nameInstance3;
                            }

                            JToken typeValue = responseDoc["type"];
                            if (typeValue != null && typeValue.Type != JTokenType.Null)
                            {
                                string typeInstance = ((string)typeValue);
                                recommendedIndexInstance.Type = typeInstance;
                            }

                            JToken locationValue = responseDoc["location"];
                            if (locationValue != null && locationValue.Type != JTokenType.Null)
                            {
                                string locationInstance = ((string)locationValue);
                                recommendedIndexInstance.Location = locationInstance;
                            }

                            JToken tagsSequenceElement = ((JToken)responseDoc["tags"]);
                            if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null)
                            {
                                foreach (JProperty property in tagsSequenceElement)
                                {
                                    string tagsKey   = ((string)property.Name);
                                    string tagsValue = ((string)property.Value);
                                    recommendedIndexInstance.Tags.Add(tagsKey, tagsValue);
                                }
                            }
                        }
                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("x-ms-request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return(result);
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Creates new MBeanOperationInfo object.
 /// </summary>
 /// <param name="name">The name of the method.</param>
 /// <param name="description">A human readable description of the operation.</param>
 /// <param name="returnType">The type of the method's return value.</param>
 /// <param name="signature">MBeanParameterInfo objects describing the parameters(arguments) of the method. It should be an empty list if operation has no parameters.</param>
 /// <param name="impact">The impact of the method.</param>
 public MBeanOperationInfo(string name, string description, string returnType, IEnumerable<MBeanParameterInfo> signature, OperationImpact impact)
     : this(name, description, returnType, signature, impact, new Descriptor())
 {
 }