Exemplo n.º 1
0
        /// <summary>
        /// Updates an existing resource. This method supports patch semantics.
        /// Documentation https://developers.google.com/groupssettings/v1/reference/groups/patch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Groupssettings service.</param>
        /// <param name="groupUniqueId">The resource ID</param>
        /// <param name="body">A valid Groupssettings v1 body.</param>
        /// <returns>GroupsResponse</returns>
        public static Groups Patch(GroupssettingsService service, string groupUniqueId, Groups body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (groupUniqueId == null)
                {
                    throw new ArgumentNullException(groupUniqueId);
                }

                // Make the request.
                return(service.Groups.Patch(body, groupUniqueId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Groups.Patch failed.", ex);
            }
        }
 private void ServiceInstance(string accountId, string certPath)
 {
     var auth = new ServiceOAuth(accountId, certPath);
     DirectoryService = auth.DirectoryService();
     GroupSettingsService = auth.GroupSettingsService();
     LicensingService = auth.LicensingService();
     ReportsService = auth.ReportsService();
     CalendarService = auth.CalendarService();
     DriveService = auth.DriveService();
     AuditService = auth.AuditService();
     TasksService = auth.TasksService();
 }
        static void Main(string[] args)
        {
            UserCredential credential;

            using (var stream =
                       new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
            {
                // The file token.json stores the user's access and refresh tokens, and is created
                // automatically when the authorization flow completes for the first time.
                string credPath = "token.json";
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.FromStream(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
                Console.WriteLine("Credential file saved to: {0}", credPath);
            }

            // Create Directory API service.
            var service = new GroupssettingsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            // Service ready to use

            if (args.Length == 0)
            {
                Console.WriteLine("No group email specified.");
                return;
            }

            String groupEmail = args[0];

            try
            {
                Groups settings = service.Groups.Get(groupEmail).Execute();
                Console.Write("Description: {0}", settings.Description);
            }
            catch (Exception err)
            {
                // TODO(developer) - handle exception
                Console.Error.WriteLine(err);
            }
        }
Exemplo n.º 4
0
        internal GroupSettingsRequestFactory(GoogleServiceCredentials creds, string[] scopes, int poolSize)
        {
            this.groupSettingsServicePool = new BaseClientServicePool <GroupssettingsService>(poolSize, () =>
            {
                GroupssettingsService x = new GroupssettingsService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer           = new ServiceAccountCredential(creds.GetInitializer(scopes)),
                    ApplicationName                 = "LithnetGoogleAppsLibrary",
                    GZipEnabled                     = !Settings.DisableGzip,
                    Serializer                      = new GoogleJsonSerializer(),
                    DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.None
                });

                x.HttpClient.Timeout = Settings.DefaultTimeout;
                return(x);
            });
        }
 private void SimpleInstance(string clientId, string clientSecret)
 {
     var auth = new SimpleOAuth(clientId, clientSecret);
     DirectoryService = auth.DirectoryService();
     GroupSettingsService = auth.GroupSettingsService();
     LicensingService = auth.LicensingService();
 }