public IHttpActionResult CreateProject(string projectID, string projectName)
        {
            var service = new CloudResourceManagerService(new BaseClientService.Initializer
            {
                HttpClientInitializer = AppFlowMetadata.UserCredential,
                ApplicationName       = AppFlowMetadata.AppName,
            });

            Data.Project requestBody = new Data.Project()
            {
                ProjectId = projectID, Name = projectName
            };
            ProjectsResource.CreateRequest request = service.Projects.Create(requestBody);

            var response = request.Execute();

            return(Ok());
        }
Example #2
0
        private ProjectNetworkModel asModel(Google.Apis.CloudResourceManager.v1.Data.Project project,
                                            IDictionary <Network, IList <Subnetwork> > networks)
        {
            var result = new ProjectNetworkModel()
            {
                Parent        = project.Parent,
                ProjectId     = project.ProjectId,
                ProjectNumber = project.ProjectNumber,
                Name          = project.Name,
                Networks      = new List <NetworkModel>()
            };

            foreach (var network in networks)
            {
                var networkModel = new NetworkModel()
                {
                    Name     = network.Key.Name,
                    Peerings = network.Key.Peerings,
                    Subnets  = new List <SubnetworkModel>()
                };

                foreach (var subnet in network.Value)
                {
                    var subnetModel = new SubnetworkModel()
                    {
                        GatewayAddress    = subnet.GatewayAddress,
                        IpCidrRange       = subnet.IpCidrRange,
                        Name              = subnet.Name,
                        Region            = subnet.Region,
                        SecondaryIpRanges = subnet.SecondaryIpRanges
                    };
                    networkModel.Subnets.Add(subnetModel);
                }

                result.Networks.Add(networkModel);
            }

            return(result);
        }
Example #3
0
        private bool CreateProject(UserCredential userCredential, string projectID, string projectName)
        {
            try
            {
                var service = new CloudResourceManagerService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = userCredential,
                    ApplicationName       = AppName,
                });

                Data.Project requestBody = new Data.Project()
                {
                    ProjectId = projectID, Name = projectName
                };
                Google.Apis.CloudResourceManager.v1.ProjectsResource.CreateRequest request = service.Projects.Create(requestBody);

                var response = request.Execute();
            }
            catch (Exception)
            {
            }

            return(true);
        }