Exemplo n.º 1
0
        public static int Main(string[] args)
        {
            // Read projectId from args
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: Project ID must be passed as first argument.");
                Console.WriteLine();
                return(1);
            }
            string projectId = args[0];

            // Create client
            CompanyServiceClient client = CompanyServiceClient.Create();

            // Initialize request argument(s)
            TenantOrProjectName parent = TenantOrProjectName.FromProject(projectId);

            // Call API method
            PagedEnumerable <ListCompaniesResponse, Company> pagedResponse = client.ListCompanies(parent);

            // Show the result
            foreach (var item in pagedResponse)
            {
                Console.WriteLine(item);
            }

            // Success
            Console.WriteLine("Smoke test passed OK");
            return(0);
        }
Exemplo n.º 2
0
        private CompanyName CreateSampleCompany()
        {
            CompanyServiceClient client = CompanyServiceClient.Create();
            Company company             = new Company
            {
                DisplayName = "Sample company created by fixture",
                ExternalId  = GenerateCompanyExternalId(),
                Size        = CompanySize.Giant
            };
            Company created = client.CreateCompany(TenantOrProjectName.FromProject(ProjectId), company);

            return(created.CompanyName);
        }
Exemplo n.º 3
0
        private static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Error.WriteLine("Specify the project ID as the only command line argument");
                return(1);
            }
            string projectId     = args[0];
            var    companyClient = CompanyServiceClient.Create();
            var    jobClient     = JobServiceClient.Create();
            var    parentName    = TenantOrProjectName.FromProject(projectId);

            var testCompanies = companyClient.ListCompanies(parentName)
                                .Where(cn => cn.ExternalId.StartsWith("test-"))
                                .Select(c => c.CompanyName)
                                .ToList();

            Console.WriteLine($"Companies to delete: {testCompanies.Count}");

            foreach (var companyName in testCompanies)
            {
                var jobs = jobClient.ListJobs(parentName, $"companyName=\"{companyName}\"").ToList();
                Console.WriteLine($"Jobs for company {companyName}: {jobs.Count}");
                foreach (var job in jobs)
                {
                    try
                    {
                        jobClient.DeleteJob(job.JobName);
                    }
                    catch (RpcException e)
                    {
                        Console.WriteLine($"Failed to delete job {job.Name}: {e.Message}");
                    }
                }

                try
                {
                    companyClient.DeleteCompany(companyName);
                }
                catch (RpcException e)
                {
                    Console.WriteLine($"Failed to delete company {companyName}: {e.Message}");
                }
            }
            return(0);
        }