Beispiel #1
0
 /// <summary>Snippet for AddPeering</summary>
 public void AddPeering()
 {
     // Snippet: AddPeering(string, string, NetworksAddPeeringRequest, CallSettings)
     // Create client
     NetworksClient networksClient = NetworksClient.Create();
     // Initialize request argument(s)
     string project = "";
     string network = "";
     NetworksAddPeeringRequest networksAddPeeringRequestResource = new NetworksAddPeeringRequest();
     // Make the request
     Operation response = networksClient.AddPeering(project, network, networksAddPeeringRequestResource);
     // End snippet
 }
Beispiel #2
0
        /// <summary>Snippet for AddPeeringAsync</summary>
        public async Task AddPeeringAsync()
        {
            // Snippet: AddPeeringAsync(string, string, NetworksAddPeeringRequest, CallSettings)
            // Additional: AddPeeringAsync(string, string, NetworksAddPeeringRequest, CancellationToken)
            // Create client
            NetworksClient networksClient = await NetworksClient.CreateAsync();

            // Initialize request argument(s)
            string project = "";
            string network = "";
            NetworksAddPeeringRequest networksAddPeeringRequestResource = new NetworksAddPeeringRequest();
            // Make the request
            Operation response = await networksClient.AddPeeringAsync(project, network, networksAddPeeringRequestResource);

            // End snippet
        }
        /// <summary>
        /// Adds a peering to the specified network.
        /// Documentation https://developers.google.com/compute/beta/reference/networks/addPeering
        /// 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 Compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="network">Name of the network resource to add peering to.</param>
        /// <param name="body">A valid Compute beta body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation AddPeering(ComputeService service, string project, string network, NetworksAddPeeringRequest body, NetworksAddPeeringOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (network == null)
                {
                    throw new ArgumentNullException(network);
                }

                // Building the initial request.
                var request = service.Networks.AddPeering(body, project, network);

                // Applying optional parameters to the request.
                request = (NetworksResource.AddPeeringRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Networks.AddPeering failed.", ex);
            }
        }
        /// <summary>
        /// Adds a peering to the specified network.
        /// Documentation https://developers.google.com/compute/alpha/reference/networks/addPeering
        /// 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 compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="network">Name of the network resource to add peering to.</param>
        /// <param name="body">A valid compute alpha body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation AddPeering(computeService service, string project, string network, NetworksAddPeeringRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (network == null)
                {
                    throw new ArgumentNullException(network);
                }

                // Make the request.
                return(service.Networks.AddPeering(body, project, network).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Networks.AddPeering failed.", ex);
            }
        }