gcp resource managment c#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

using Google.Apis.Auth.OAuth2;
using Google.Apis.CloudResourceManager.v1;
using Google.Apis.Services;

using Data = Google.Apis.CloudResourceManager.v1.Data;

namespace OurFirstProject
{
    public class Program
    {
        private const string projectId = [YOUR-PROJECT-ID];
        private const string applicationName = "Test";

        public static void Main(string[] args)
        {

            var scopes = new String[] {
                CloudResourceManagerService.Scope.CloudPlatform
            };

            GoogleCredential credential = Task.Run(
                () => GoogleCredential.GetApplicationDefaultAsync()
            ).Result;

            if (credential.IsCreateScopedRequired)
            {
                credential = credential.CreateScoped(scopes);
            }

            CloudResourceManagerService service = new CloudResourceManagerService(
                new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName = applicationName
                }
            );

            Console.WriteLine("1. Create Project");
            Data.Operation operation1 = service.Projects.Create(
                new Data.Project()
                {
                    ProjectId = projectId,
                }
            ).Execute();

            Console.Write("2. Awaiting Operation Completion");
            Data.Operation operation2;
            do
            {
                operation2 = service.Operations.Get(operation1.Name).Execute();
                Console.WriteLine(operation2.Done.ToString());
                System.Threading.Thread.Sleep(1000);
            } while (operation2.Done != true);

            Console.WriteLine();
            Console.WriteLine("Enter to continue");
            Console.ReadLine();

            Console.WriteLine("3. Deleting Project");
            var operation3 = service.Projects.Delete(projectId).Execute();
        }
    }
}

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source