Exemple #1
0
 public void GetAccountHierarchyByUserUID()
 {
     // AccountHierarchyByUserUIDResponseString
     try
     {
         LogResult.Report(Log, "log_ForInfo", "Performing Get Account Hierarchy By User UID");
         AccountHierarchyByUserUIDResponseString = RestClientUtil.DoHttpRequest(CustomerServiceConfig.AccountHierarchyByUserUIDEndPoint, HeaderSettings.GetMethod, accessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Performing Get Account Hierarchy By User UID", e);
         throw new Exception(e + " Got Error While Performing Get Account Hierarchy By User UID");
     }
 }
Exemple #2
0
 public void PostAssociateAssetCustomer()
 {
     try
     {
         string AssociateAssetCustomerRequest = GetAssociateAssetCustomerRequestString();
         string AssociateAssetCustomer        = "https://api-stg.trimble.com/t/trimble.com/vss-dev-customerservice/1.0/AssociateCustomerAsset";
         var    Responsestring = RestClientUtil.DoHttpRequest(AssociateAssetCustomer, HeaderSettings.PostMethod, AccessToken, HeaderSettings.JsonMediaType, AssociateAssetCustomerRequest, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Exception Occured while associating asset to device" + "AssetUID-" + createAssetEvent.AssetUID + "Customer-" + associateAssetCustomer.CustomerUID);
         throw new Exception("Exception Occured while associating asset to device" + "AssetUID-" + createAssetEvent.AssetUID + "Customer-" + associateAssetCustomer.CustomerUID);
     }
 }
Exemple #3
0
 public string PostValidReadRequestToService(string accessToken)
 {
     try
     {
         LogResult.Report(Log, "log_ForInfo", "Reading the list of available geofences for the user accesstoken the request with Valid Values: " + accessToken);
         string ResponseString = RestClientUtil.DoHttpRequest(CustomerServiceConfig.CustomerServiceEndpoint + "/accounthierarchy", HeaderSettings.GetMethod, accessToken,
                                                              HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
         return(ResponseString);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To Geofence Service", e);
         throw new Exception(e + " Got Error While Posting Data To Geofence Service");
     }
 }
Exemple #4
0
        // Token: 0x0600011F RID: 287 RVA: 0x000039AC File Offset: 0x00001BAC
        public ListDvswitchsResp ListDvswitchs(string siteUri, ListDvswitchsReqEx reqEx)
        {
            ListDvswitchsResp listDvswitchsResp = new ListDvswitchsResp();
            StringBuilder     stringBuilder     = new StringBuilder(siteUri + "/dvswitchs?");

            if (null != reqEx)
            {
                stringBuilder.Append((reqEx.location == null) ? "" : ("location=" + reqEx.location + "&"));
                stringBuilder.Append((reqEx.name == null) ? "" : ("name=" + reqEx.name + "&"));
            }
            string text = RestClientUtil.sendRequest("GET", stringBuilder.ToString(0, stringBuilder.Length - 1), null, this.bean, "ListDvswitchs");

            CommonResource.log.Info("ListDvswitchs result : " + text);
            return(JsonConvert.DeserializeObject <ListDvswitchsResp>(text));
        }
Exemple #5
0
 private static string GetKafkaEndPointURL(string kafkatopicName)
 {
     try
     {
         string response = RestClientUtil.DoHttpRequest(DiscoveryServiceURI.ToString(), HeaderSettings.GetMethod, accessToken,
                                                        HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
         JObject jsonObj = JObject.Parse(response);
         var     token   = jsonObj.SelectToken("$.Topics[?(@.Name == '" + kafkatopicName + "')].URL");
         return(token.ToString());
     }
     catch (Exception)
     {
     }
     return(null);
 }
Exemple #6
0
 public void CreateDevice()
 {
     try
     {
         GetToken(true);
         var requestString = JsonConvert.SerializeObject(defaultValidDeviceServiceCreateModel);
         LogResult.Report(Log, "log_ForInfo", "Create Device: Starts" + requestString);
         var createDeviceRespoonse = RestClientUtil.DoHttpRequest(AssetServiceConfig.DeviceServiceEndpoint, HeaderSettings.PostMethod, AccessToken, HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
         LogResult.Report(Log, "log_ForInfo", "Create Device: Ends ");
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Exception Occured while creating Device" + defaultValidDeviceServiceCreateModel.DeviceUID);
         throw new Exception("Exception Occured while creating device\n" + defaultValidDeviceServiceCreateModel.DeviceUID);
     }
 }
Exemple #7
0
 public void PostInValidDeleteRequestToService(string customerUid, string actionUtc, string contentType, HttpStatusCode actualResponse)
 {
     try
     {
         string accessToken = CustomerServiceConfig.GetValidUserAccessToken();
         LogResult.Report(Log, "log_ForInfo", "Posting the request with Valid Values: " + customerUid);
         ResponseString = RestClientUtil.DoInvalidHttpRequest(string.Format("{0}?CustomerUID={1}&ActionUTC={2}", CustomerServiceConfig.CustomerServiceEndpoint, customerUid, actionUtc),
                                                              HeaderSettings.DeleteMethod, accessToken,
                                                              contentType, null, actualResponse, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To Customer Service", e);
         throw new Exception(e + " Got Error While Posting Data To Customer Service");
     }
 }
Exemple #8
0
 public void DeleteAsset()
 {
     try
     {
         LogResult.Report(Log, "log_ForInfo", "Delete Asset: Starts" + CreateAsset.AssetUID.ToString());
         GetToken(true);
         var endPoint    = AssetServiceConfig.AssetServiceEndpoint + "?" + AssetServiceConfig.AssetUID + "=" + CreateAsset.AssetUID + "&ActionUTC=" + DateTime.Today;
         var DeleteAsset = RestClientUtil.DoHttpRequest(endPoint, HeaderSettings.DeleteMethod, AccessToken, null, HeaderSettings.JsonMediaType, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
         LogResult.Report(Log, "log_ForInfo", "Delete Asset: Ends" + CreateAsset.AssetUID.ToString());
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Exception Occured while deleting asset" + CreateAsset.AssetUID);
         throw new Exception("Exception Occured while deleting asset\n" + CreateAsset.AssetUID);
     }
 }
Exemple #9
0
        // Token: 0x06000120 RID: 288 RVA: 0x00003A7C File Offset: 0x00001C7C
        public ListPortGroupsResp ListPortGroups(string dvswitchUri, ListPortGroupsReqEx reqEx)
        {
            ListPortGroupsResp listPortGroupsResp = new ListPortGroupsResp();
            StringBuilder      stringBuilder      = new StringBuilder(dvswitchUri + "/portgroups?");

            if (null != reqEx)
            {
                stringBuilder.Append((reqEx.limit == null) ? "" : ("limit=" + reqEx.limit + "&"));
                stringBuilder.Append((reqEx.offset == null) ? "" : ("offset=" + reqEx.offset + "&"));
                stringBuilder.Append((reqEx.portGroupName == null) ? "" : ("portGroupName=" + reqEx.portGroupName + "&"));
            }
            string text = RestClientUtil.sendRequest("GET", stringBuilder.ToString(0, stringBuilder.Length - 1), null, this.bean, "ListPortGroups");

            CommonResource.log.Info("ListPortGroups result : " + text);
            return(JsonConvert.DeserializeObject <ListPortGroupsResp>(text));
        }
Exemple #10
0
        public void PostValidUpdateRequestToService()
        {
            string requestString = JsonConvert.SerializeObject(UpdateCustomerModel);

            try
            {
                string accessToken = CustomerServiceConfig.GetValidUserAccessToken();
                LogResult.Report(Log, "log_ForInfo", "Posting the request with Valid Values: " + requestString);
                ResponseString = RestClientUtil.DoHttpRequest(CustomerServiceConfig.CustomerServiceEndpoint, HeaderSettings.PutMethod, accessToken,
                                                              HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To Customer Service", e);
                throw new Exception(e + " Got Error While Posting Data To Customer Service");
            }
        }
Exemple #11
0
        public void PostInValidCustomerAssetAssociateRequestToService(string contentType, HttpStatusCode actualResponse)
        {
            string requestString = JsonConvert.SerializeObject(InvalidAssociateCustomerAssetModel);

            try
            {
                string accessToken = CustomerServiceConfig.GetValidUserAccessToken();
                LogResult.Report(Log, "log_ForInfo", "Posting the request with Valid Values: " + requestString);
                ResponseString = RestClientUtil.DoInvalidHttpRequest(CustomerServiceConfig.CustomerServiceEndpoint + "/AssociateCustomerAsset", HeaderSettings.PostMethod, accessToken,
                                                                     contentType, requestString, actualResponse, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To customer Service", e);
                throw new Exception(e + " Got Error While Posting Data To customer Service");
            }
        }
Exemple #12
0
        // Token: 0x0600026D RID: 621 RVA: 0x00005EE0 File Offset: 0x000040E0
        public ListHostsResp ListHosts(string siteUri, ListHostsReq req)
        {
            StringBuilder stringBuilder = new StringBuilder(siteUri + "/hosts?");

            if (null != req)
            {
                stringBuilder.Append((req.limit == null) ? "" : ("limit=" + req.limit + "&"));
                stringBuilder.Append((req.offset == null) ? "" : ("offset=" + req.offset + "&"));
                stringBuilder.Append((req.name == null) ? "" : ("name=" + req.name + "&"));
                stringBuilder.Append((req.scope == null) ? "" : ("scope=" + req.scope + "&"));
                stringBuilder.Append((req.ip == null) ? "" : ("ip=" + req.ip + "&"));
                stringBuilder.Append((req.resourceGroupFlag == null) ? "" : ("resourceGroupFlag=" + req.resourceGroupFlag + "&"));
            }
            string text = RestClientUtil.sendRequest("GET", stringBuilder.ToString(0, stringBuilder.Length - 1), null, this.bean, "ListHosts");

            HostResource.log.Info("ListHosts result : " + text);
            return(JsonConvert.DeserializeObject <ListHostsResp>(text));
        }
Exemple #13
0
 public void CreateAssets(int no_of_Assets = 1)
 {
     try
     {
         SetDefaultValidValuesToAssets();
         GetToken(true);
         var requestString = JsonConvert.SerializeObject(CreateAsset);
         LogResult.Report(Log, "log_ForInfo", "Create Asset: Starts" + requestString);
         var createAssetResponse = RestClientUtil.DoHttpRequest(AssetServiceConfig.AssetServiceEndpoint, HeaderSettings.PostMethod, AccessToken,
                                                                HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
         LogResult.Report(Log, "log_ForInfo", "Create Asset: Ends ");
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Exception Occured while creating asset" + CreateAsset.AssetUID);
         throw new Exception("Exception Occured while creating asset\n" + CreateAsset.AssetUID);
     }
 }
Exemple #14
0
 public void GetFuelBurntRate()
 {
     try
     {
         var requestString = JsonConvert.SerializeObject(assetUIDS);
         LogResult.Report(Log, "log_ForInfo", "Get Fuel Burnt rate: Starts");
         string accessToken = AssetServiceConfig.GetValidUserAccessToken();
         var    response    = RestClientUtil.DoHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PostMethod, accessToken, HeaderSettings.JsonMediaType, requestString,
                                                           HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders);
         getFuelResponse = JsonConvert.DeserializeObject <FuelBurntRateResponse>(response);
         LogResult.Report(Log, "log_ForInfo", "Get Fuel Burnt rate: Ends");
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Exception Occured while getting fuel burnt rate " + e);
         throw new Exception("Exception Occured while getting fuel burnt rate \n");
     }
 }
Exemple #15
0
        // Token: 0x0600038C RID: 908 RVA: 0x00007660 File Offset: 0x00005860
        public ListUsersResp ListUsers(ListUsersReq req)
        {
            StringBuilder stringBuilder = new StringBuilder("/service/users?");

            if (null != req)
            {
                stringBuilder.Append((req.limit == null) ? "" : ("limit=" + req.limit + "&"));
                stringBuilder.Append((req.offset == null) ? "" : ("offset=" + req.offset + "&"));
                stringBuilder.Append((req.userType == null) ? "" : ("userType=" + req.userType + "&"));
                stringBuilder.Append((req.userName == null) ? "" : ("userName="******"&"));
                stringBuilder.Append((req.createStartTime == null) ? "" : ("createStartTime=" + req.createStartTime + "&"));
                stringBuilder.Append((req.createStopTime == null) ? "" : ("createStopTime=" + req.createStopTime + "&"));
                stringBuilder.Append((req.manageStatus == null) ? "" : ("manageStatus=" + req.manageStatus + "&"));
            }
            string text = RestClientUtil.sendRequest("Get", stringBuilder.ToString(0, stringBuilder.Length - 1), null, this.bean, "ListUsers");

            UserResource.log.Info("ListUsers result : " + text);
            return(JsonConvert.DeserializeObject <ListUsersResp>(text));
        }
Exemple #16
0
        public void PostValidDeleteRequestToService(Guid customerUid, DateTime actionUtc)
        {
            string actionUtcString = actionUtc.ToString("yyyy-MM-ddThh:mm:ss");
            string customerUID     = customerUid.ToString();

            try
            {
                string accessToken = CustomerServiceConfig.GetValidUserAccessToken();
                LogResult.Report(Log, "log_ForInfo", "Posting the request with Valid Values: " + customerUID);
                ResponseString = RestClientUtil.DoHttpRequest(string.Format("{0}?CustomerUID={1}&ActionUTC={2}", CustomerServiceConfig.CustomerServiceEndpoint, customerUID, actionUtcString),
                                                              HeaderSettings.DeleteMethod, accessToken,
                                                              HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To Customer Service", e);
                throw new Exception(e + " Got Error While Posting Data To Customer Service");
            }
        }
Exemple #17
0
        // Token: 0x0600011E RID: 286 RVA: 0x00003810 File Offset: 0x00001A10
        public ListDataStoresResp ListDataStores(string siteUri, ListDataStoresReqEx reqEx)
        {
            ListDataStoresResp listDataStoresResp = new ListDataStoresResp();
            StringBuilder      stringBuilder      = new StringBuilder(siteUri + "/datastores?");

            if (null != reqEx)
            {
                stringBuilder.Append((reqEx.limit == null) ? "" : ("limit=" + reqEx.limit + "&"));
                stringBuilder.Append((reqEx.offset == null) ? "" : ("offset=" + reqEx.offset + "&"));
                stringBuilder.Append((reqEx.scope == null) ? "" : ("scope=" + reqEx.scope + "&"));
                stringBuilder.Append((reqEx.status == null) ? "" : ("status=" + reqEx.status + "&"));
                stringBuilder.Append((reqEx.name == null) ? "" : ("name=" + reqEx.name + "&"));
                stringBuilder.Append((reqEx.exceptDatastoreType == null) ? "" : ("exceptDatastoreType=" + reqEx.exceptDatastoreType + "&"));
            }
            string text = RestClientUtil.sendRequest("GET", stringBuilder.ToString(0, stringBuilder.Length - 1), null, this.bean, "ListDataStores");

            CommonResource.log.Info("ListDataStores result : " + text);
            return(JsonConvert.DeserializeObject <ListDataStoresResp>(text));
        }
Exemple #18
0
        public void InvalidPutRequest()
        {
            var requestString = JsonConvert.SerializeObject(CreateproductivityTargetsRequest);

            try
            {
                GetToken();
                LogResult.Report(Log, "log_ForInfo", "Create Asset Productivity: Starts");
                var ProductivityResponse = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.CreateProductivityDetailsEndpoint, HeaderSettings.PutMethod, AccessToken,
                                                                               HeaderSettings.JsonMediaType, requestString, HttpStatusCode.BadRequest, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
                CreateProductitvityResponse = JsonConvert.DeserializeObject <ProductivityTargetsResponseModel>(ProductivityResponse);
                LogResult.Report(Log, "log_ForInfo", "Create Asset Productivity: Ends");
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Exception Occured while creating asset settings" + CreateproductivityTargetsRequest.assettargets.Select(a => a.assetuid));
                throw new Exception("Exception Occured while creating asset productivity \n");
            }
        }
Exemple #19
0
        public void CreateValidAssetSettings()
        {
            var requestString = JsonConvert.SerializeObject(createAssetSettingsRequest);

            try
            {
                GetToken();
                LogResult.Report(Log, "log_ForInfo", "Create Asset Settings: Starts");
                var createAssetResponse = RestClientUtil.DoHttpRequest("https://api-stg.trimble.com/t/trimble.com/vss-dev-assetservice/1.0/assetsettings/targets/Save", HeaderSettings.PutMethod, AccessToken,
                                                                       HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
                createAssetSettingsResponse = JsonConvert.DeserializeObject <CreateAssetSettingsResponse>(createAssetResponse);
                LogResult.Report(Log, "log_ForInfo", "Create Asset Settings: Ends");
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Exception Occured while creating asset settings" + createAssetSettingsRequest.assetTargetSettings.Select(a => a.assetUid));
                throw new Exception("Exception Occured while creating asset settings \n");
            }
        }
Exemple #20
0
 public void GetDeviceTypeDetails()
 {
     try
     {
         LogResult.Report(Log, "log_ForInfo", "GetDeviceTypeDetails: Starts for Customer" + CustomerUID);
         if (CustomHeaders == null)
         {
             CustomHeaders.Add(CustomerUid, CustomerUID.ToString());
         }
         GetToken(false);
         var ResponseJSON = RestClientUtil.DoHttpRequest(AssetServiceConfig.GetDeviceType, HeaderSettings.GetMethod, AccessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders);
         deviceTypeResponse = JsonConvert.DeserializeObject <DeviceTypeResponse>(ResponseJSON);
         LogResult.Report(Log, "log_ForInfo", "GetDeviceTypeDetails: Ends for Customer" + CustomerUID);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Exception Occured while getting device type details" + "CustomerUID-" + CustomerUID);
         throw new Exception("Exception Occured while getting device type details" + "CustomerUID - " + CustomerUID + "DeviceUID - ");
     }
 }
Exemple #21
0
        public void WhenIHitMakeCodeEndpoint()
        {
            try
            {
                string accessToken = AssetServiceConfig.GetValidUserAccessToken();

                //   public static string DoHttpRequest(string resourceUri, string httpMethod,
                //string mediaType, string payloadData, HttpStatusCode httpResponseCode)
                ResponseString = RestClientUtil.DoHttpRequestWithNoBody(AssetServiceConfig.MakeCodeEndpoint, HeaderSettings.GetMethod, accessToken,
                                                                        HeaderSettings.JsonMediaType, HttpStatusCode.OK);

                //DoHttpRequestWithNoBody(string resourceUri, string httpMethod, string authKey, string mediaType, HttpStatusCode httpResponseCode, string authKeyType = null,
                //                                               string contentType = null, Dictionary<string, string> customHeaders = null)
                MakeCodeAPIResponse = JsonConvert.DeserializeObject <List <MakeCodeResponse> >(ResponseString);
            }
            catch (Exception e)
            {
                throw new Exception("Unable To Perform Get MakeCode", e);
            }
        }
        // Token: 0x06000140 RID: 320 RVA: 0x00003F2C File Offset: 0x0000212C
        public ListVmsResp ListVms(string siteUri, ListVmsReq req)
        {
            StringBuilder stringBuilder = new StringBuilder(siteUri + "/vms?");

            if (null != req)
            {
                stringBuilder.Append((req.limit == null) ? "" : ("limit=" + req.limit + "&"));
                stringBuilder.Append((req.offset == null) ? "" : ("offset=" + req.offset + "&"));
                stringBuilder.Append((req.name == null) ? "" : ("name=" + req.name + "&"));
                stringBuilder.Append((req.scope == null) ? "" : ("scope=" + req.scope + "&"));
                stringBuilder.Append((req.isTemplate == null) ? "" : ("isTemplate=" + req.isTemplate + "&"));
                stringBuilder.Append((req.isLinkClone == null) ? "" : ("isLinkClone=" + req.isLinkClone + "&"));
                stringBuilder.Append((req.templateUrn == null) ? "" : ("templateUrn=" + req.templateUrn + "&"));
                stringBuilder.Append((req.status == null) ? "" : ("status=" + req.status + "&"));
                stringBuilder.Append((req.ip == null) ? "" : ("ip=" + req.ip + "&"));
                stringBuilder.Append((req.mac == null) ? "" : ("mac=" + req.mac + "&"));
                stringBuilder.Append((req.vmId == null) ? "" : ("vmId=" + req.vmId + "&"));
                stringBuilder.Append((req.uuid == null) ? "" : ("uuid=" + req.uuid + "&"));
                stringBuilder.Append((req.resourceGroupFlag == null) ? "" : ("resourceGroupFlag=" + req.resourceGroupFlag + "&"));
                stringBuilder.Append((req.detail == null) ? "" : ("detail=" + req.detail + "&"));
                stringBuilder.Append((req.description == null) ? "" : ("description=" + req.description + "&"));
                stringBuilder.Append((req.imcSetting == null) ? "" : ("imcSetting=" + req.imcSetting + "&"));
                stringBuilder.Append((req.isBindingHost == null) ? "" : ("isBindingHost=" + req.isBindingHost + "&"));
                stringBuilder.Append((req.vmType == null) ? "" : ("vmType=" + req.vmType + "&"));
                if (req.vmurns != null && req.vmurns.Count > 0)
                {
                    foreach (string text in req.vmurns)
                    {
                        if (null != text)
                        {
                            stringBuilder.Append("vmurns=").Append(text + "&");
                        }
                    }
                }
            }
            string text2 = RestClientUtil.sendRequest("GET", stringBuilder.ToString(0, stringBuilder.Length - 1), null, this.bean, "ListVms");

            VmResource.log.Info("ListVms result : " + text2);
            return(JsonConvert.DeserializeObject <ListVmsResp>(text2));
        }
Exemple #23
0
        public M3Response GetDataAsync(string program, string transaction, string queryParam, List <string> outputs, bool outputAllFields = false, int maxrecs = 0, bool metadata = false, bool excludempty = false)
        {
            M3Response responseDto = new M3Response();

            HttpClient request    = RestClientFactory.CreateBasicAuthRestClient(m3RestConfiguration);
            string     requestUri = $"{program}/{transaction};metadata={metadata};maxrecs={maxrecs};excludempty={excludempty}";

            if (!outputAllFields && outputs.Count > 0)
            {
                requestUri += $";returncols={string.Join(",", outputs)}";
            }
            requestUri += $" {RestClientUtil.GetInputParametersFromJson(queryParam)}";

            HttpResponseMessage response = request.GetAsync(requestUri).Result;

            if (response.IsSuccessStatusCode == false)
            {
                responseDto.Success = false;
                responseDto.Message = "M3 call failed.";
                return(responseDto);
            }

            var content = response.Content.ReadAsStringAsync().Result;
            var m3Error = this.GetM3ErrorMessage(content);

            if (!String.IsNullOrEmpty(m3Error))
            {
                responseDto.Success = false;
                responseDto.Message = m3Error;
                return(responseDto);
            }

            dynamic responseMessage = JObject.Parse(content);

            responseDto.Data = this.GetValueListFromM3ResultByMultipleSelectors(responseMessage, outputs, outputAllFields, metadata);

            return(responseDto);
        }
Exemple #24
0
        // Token: 0x0600011D RID: 285 RVA: 0x0000368C File Offset: 0x0000188C
        public ListClustersResp ListClusters(string siteUri, ListClustersReqEx reqEx)
        {
            ListClustersResp listClustersResp = new ListClustersResp();
            StringBuilder    stringBuilder    = new StringBuilder(siteUri + "/clusters?");

            if (null != reqEx)
            {
                stringBuilder.Append((reqEx.tag == null) ? "" : ("tag=" + reqEx.tag + "&"));
                stringBuilder.Append((reqEx.name == null) ? "" : ("name=" + reqEx.name + "&"));
                stringBuilder.Append((reqEx.parentObjUrn == null) ? "" : ("parentObjUrn=" + reqEx.parentObjUrn + "&"));
                if (reqEx.clusterUrns != null && reqEx.clusterUrns.Count > 0)
                {
                    foreach (string str in reqEx.clusterUrns)
                    {
                        stringBuilder.Append("clusterUrns=" + str + "&");
                    }
                }
            }
            string text = RestClientUtil.sendRequest("GET", stringBuilder.ToString(0, stringBuilder.Length - 1), null, this.bean, "ListClusters");

            CommonResource.log.Info("ListClusters result : " + text);
            return(JsonConvert.DeserializeObject <ListClustersResp>(text));
        }
Exemple #25
0
        public void AssociateAssetCustomer()
        {
            associateAssetCustomer = new AssociateAssetCustomer
            {
                CustomerUID  = CustomerUID,
                AssetUID     = CreateAsset.AssetUID,
                RelationType = "Customer",
                ActionUTC    = DateTime.Now,
                ReceivedUTC  = DateTime.Now
            };
            var requestString = JsonConvert.SerializeObject(associateAssetCustomer);

            try
            {
                GetToken(true);
                var response = RestClientUtil.DoHttpRequest("https://api-stg.trimble.com/t/trimble.com/vss-dev-customerservice/1.0/AssociateCustomerAsset", HeaderSettings.PostMethod, AccessToken,
                                                            HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Exception Occured while associating asset to device" + "AssetUID-" + CreateAsset.AssetUID + "Customer-" + associateAssetCustomer.CustomerUID);
                throw new Exception("Exception Occured while associating asset to device" + "AssetUID-" + CreateAsset.AssetUID + "Customer-" + associateAssetCustomer.CustomerUID);
            }
        }
Exemple #26
0
        public void CanDoExportSuccess()
        {
            Msg.Title("Scheduler web test 1", "Schedule export job happy path");

            //Schedule the export job...
            var filterUid = "81422acc-9b0c-401c-9987-0aedbf153f1d";
            var jobId     = GetScheduledJobId(filterUid, SUCCESS_JOB_ID);

            //Get the job status...
            var statusResult = WaitForExpectedStatus(jobId, "SUCCEEDED");

            Assert.IsTrue(!string.IsNullOrEmpty(statusResult.DownloadLink), "Should get a download link on success");

            //Download the zip file...
            var restClient    = new RestClientUtil();
            var response      = restClient.DoHttpRequest(statusResult.DownloadLink, "GET", null, HttpStatusCode.OK, string.Empty, CustomerUid.ToString());
            var actualSorted  = Common.SortCsvFileIntoString(response);
            var expectedBytes = JsonConvert.DeserializeObject <byte[]>(
                "\"UEsDBBQAAAgIAEsQe0tesHMI2AEAANUIAAAIAAAAVGVzdC5jc3bNlM1um0AQgO+V+g4op1aabPeH5Sc3Sn4q1SDLRpZ6stawjVcB1gXiqn21HvpIfYUu1CZSAlVRKsVcZhdmhk/fDvz68TNRhYRQ5nm8Lrp4ZeJVLveiUbo067mo6/i+2MgKZqJuFiJTetaU6Te4lLW6LWNhGkQi3apSwnInZba+K95tu+Sb+TLSmQQTgzRNdG76JaK6bXuG+r5sYCVylc11DTP1uelqwmjV5bSx3UeX827fxg7gcP+6kl/WH75366DYrYs/rZOtSu9KWdfmVQeqGykqWKmNXDaikV1BIk1F+voVxYSex3p/jrmF/QtuXzAHMQ8DoZgjwjBQj1LECQbue4i75glgiIK5hQmchUFihUvuvD8DijDMdNpZsxbJRwi1qGppvcGIYq94Cww+ydpUA8cmlTAX+UC6tbnaJAwLuZemBmLdWMFul6tUbHIJg5juA6btPsJ0qDuGySZi2m3BMzD5gE2PH2xye9ymPc0mRu5jzGtdfRVV9k+YQ4feY7Z6T+PQ+cCh95hs9NB9RKbatJ9jc2g2j5iOwRyx+fKzyRDxj7Ppj39C7jSbBNH/ZPMp5knOZo/J2QHTYadss8c8bZuee7T5l9/7y9vsMV06bpNPw/Qn2PwNUEsBAhQAFAAACAgASxB7S16wcwjYAQAA1QgAAAgAAAAAAAAAAAAgAAAAAAAAAFRlc3QuY3N2UEsFBgAAAAABAAEANgAAAP4BAAAAAA==\"");
            var expected       = Encoding.Default.GetString(Common.Decompress(expectedBytes));
            var expectedSorted = Common.SortCsvFileIntoString(expected);

            Assert.AreEqual(expectedSorted, actualSorted, "Export data does not match");
        }
Exemple #27
0
        public void GetAssetDeviceList(string searchType = null, string pageNo = null, string pageSize = null)
        {
            createAssetEvent = AssetServiceSteps.assetServiceSupport.CreateAssetModel;
            string searchString = string.Empty;
            string requestType  = string.Empty;

            if (searchType == "AssetSN")
            {
                searchString = createAssetEvent.SerialNumber;
            }
            else if (searchType == "AssetName")
            {
                searchString = createAssetEvent.AssetName;
            }
            else if (searchType == "DeviceSN")
            {
                searchString = CreateDeviceModel.DeviceSerialNumber;
            }
            else if (searchType == "AssetSNSorting" || searchType == "Valid")
            {
                searchString = validSearchString;
            }
            else if (searchType == "Wrong")
            {
                searchString = wrongSearchString;
            }
            else
            {
                searchString = searchType;
            }

            if (pageNo == "Valid")
            {
                pageNo = validPageNo;
            }
            else if (pageNo == "Invalid")
            {
                pageNo      = invalidPageNo;
                requestType = "Invalid";
            }
            else if (pageNo == "Wrong")
            {
                pageNo = wrongPageNo;
            }
            else if (pageNo == "0" || pageNo == "-1")
            {
                requestType = "Invalid";
            }

            if (pageSize == "Valid")
            {
                pageSize = validPageSize;
            }
            else if (pageSize == "Invalid")
            {
                pageSize    = invalidPageSize;
                requestType = "Invalid";
            }
            else if (pageSize == "Wrong")
            {
                pageSize = wrongPageSize;
            }
            else if (pageSize == "0" || pageSize == "-1")
            {
                requestType = "Invalid";
            }


            string parameters = string.Empty;

            if (searchString != null && pageNo == null && pageSize == null)
            {
                parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString;
            }
            else if (searchString == null && pageNo != null && pageSize == null)
            {
                parameters = "?" + AssetServiceConfig.PageNo + "=" + pageNo;
            }
            else if (searchString == null && pageNo == null && pageSize != null)
            {
                parameters = "?" + AssetServiceConfig.PageSize + "=" + pageSize;
            }
            else if (searchString != null && pageNo != null && pageSize == null)
            {
                parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageNo + "=" + pageNo;
            }
            else if (searchString != null && pageNo == null && pageSize != null)
            {
                parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageSize + "=" + pageSize;
            }
            else if (searchString == null && pageNo != null && pageSize != null)
            {
                parameters = "?" + AssetServiceConfig.PageNo + "=" + pageNo + "&" + AssetServiceConfig.PageSize + "=" + pageSize;
            }
            else if (searchString != null && pageNo != null && pageSize != null)
            {
                parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageNo + "=" + pageNo + "&" + AssetServiceConfig.PageSize + "=" + pageSize;
            }
            else if (searchString == null && pageNo == null && pageSize == null)
            {
                parameters = "";
            }

            try
            {
                string accessToken = AssetServiceConfig.GetValidUserAccessToken();
                LogResult.Report(Log, "log_ForInfo", "Getting the AssetDetail Values:");
                if (requestType == "Invalid")
                {
                    ResponseString = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.AssetSearchEndpoint + parameters, HeaderSettings.GetMethod, accessToken,
                                                                         HeaderSettings.JsonMediaType, null, HttpStatusCode.BadRequest, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
                }
                else
                {
                    ResponseString = RestClientUtil.DoHttpRequest(AssetServiceConfig.AssetSearchEndpoint + parameters, HeaderSettings.GetMethod, accessToken,
                                                                  HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
                }
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While Getting Data from Asset Device Search Service", e);
                throw new Exception(e + " Got Error While Getting Data from Asset Device Search Service");
            }
        }