protected override LoggingBaseServiceRequest <LogSink> GetRequest(LogSink logSink) { string formattedSinkName = PrefixProjectToSinkName(SinkName, Project); // If destinations are not given, we still have to set the destination to the existing log sink destination. // Otherwise, the API will throw error. if (GcsBucketDestination == null && BigQueryDataSetDestination == null && PubSubTopicDestination == null) { try { ProjectsResource.SinksResource.GetRequest getRequest = Service.Projects.Sinks.Get(formattedSinkName); LogSink existingSink = getRequest.Execute(); logSink.Destination = existingSink.Destination; } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { // Here we throw terminating error because the cmdlet cannot proceed without a valid sink. string exceptionMessage = $"Sink '{SinkName}' does not exist in project '{Project}'." + "Please use New-GcLogSink cmdlet to create it (Set-GcLogSink can only create a sink if you supply a destination)."; ErrorRecord errorRecord = new ErrorRecord( new ArgumentException(exceptionMessage), "SinkNotFound", ErrorCategory.ResourceUnavailable, SinkName); ThrowTerminatingError(errorRecord); } } ProjectsResource.SinksResource.UpdateRequest updateRequest = Service.Projects.Sinks.Update(logSink, formattedSinkName); if (UniqueWriterIdentity.IsPresent) { updateRequest.UniqueWriterIdentity = UniqueWriterIdentity.ToBool(); } return(updateRequest); }