コード例 #1
0
 public AzureADApp GetApp(BasePSCmdlet cmdlet, HttpClient httpClient, string accessToken)
 {
     if (_id != Guid.Empty)
     {
         var results = Utilities.REST.GraphHelper.GetAsync <RestResultCollection <AzureADApp> >(httpClient, $"/v1.0/applications?$filter=appId eq '{_id}'", accessToken).GetAwaiter().GetResult();
         if (results != null && results.Items.Any())
         {
             return(results.Items.First());
         }
         else
         {
             return(Utilities.REST.GraphHelper.GetAsync <AzureADApp>(httpClient, $"/v1.0/applications/{_id}", accessToken).GetAwaiter().GetResult());
         }
     }
     if (!string.IsNullOrEmpty(_name))
     {
         var results = Utilities.REST.GraphHelper.GetAsync <RestResultCollection <AzureADApp> >(httpClient, $"/v1.0/applications?$filter=displayName eq '{_name}'", accessToken).GetAwaiter().GetResult();
         if (results != null && results.Items.Any())
         {
             return(results.Items.First());
         }
     }
     cmdlet.WriteError(new PSArgumentException("Azure AD App not found"), ErrorCategory.ObjectNotFound);
     return(null);
 }
コード例 #2
0
 public TeamTab GetTab(BasePSCmdlet cmdlet, HttpClient httpClient, string accessToken, string groupId, string channelId)
 {
     if (_tab != null)
     {
         return(_tab);
     }
     else
     {
         var tab = TeamsUtility.GetTabAsync(accessToken, httpClient, groupId, channelId, _id).GetAwaiter().GetResult();
         if (string.IsNullOrEmpty(tab.Id))
         {
             var tabs = TeamsUtility.GetTabsAsync(accessToken, httpClient, groupId, channelId).GetAwaiter().GetResult();
             if (tabs != null)
             {
                 // find the tab by id
                 tab = tabs.FirstOrDefault(t => t.DisplayName.Equals(_displayName, System.StringComparison.OrdinalIgnoreCase));
             }
         }
         if (tab != null)
         {
             return(tab);
         }
         else
         {
             cmdlet.WriteError(new PSArgumentException("Cannot find tab"), ErrorCategory.ObjectNotFound);
             return(null);
         }
     }
 }