1package postgresql 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "net/http" 25) 26 27// LogFilesClient is the the Microsoft Azure management API provides create, read, update, and delete functionality for 28// Azure PostgreSQL resources including servers, databases, firewall rules, log files and configurations. 29type LogFilesClient struct { 30 BaseClient 31} 32 33// NewLogFilesClient creates an instance of the LogFilesClient client. 34func NewLogFilesClient(subscriptionID string) LogFilesClient { 35 return NewLogFilesClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewLogFilesClientWithBaseURI creates an instance of the LogFilesClient client. 39func NewLogFilesClientWithBaseURI(baseURI string, subscriptionID string) LogFilesClient { 40 return LogFilesClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// ListByServer list all the log files in a given server. 44// 45// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from 46// the Azure Resource Manager API or the portal. serverName is the name of the server. 47func (client LogFilesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result LogFileListResult, err error) { 48 req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) 49 if err != nil { 50 err = autorest.NewErrorWithError(err, "postgresql.LogFilesClient", "ListByServer", nil, "Failure preparing request") 51 return 52 } 53 54 resp, err := client.ListByServerSender(req) 55 if err != nil { 56 result.Response = autorest.Response{Response: resp} 57 err = autorest.NewErrorWithError(err, "postgresql.LogFilesClient", "ListByServer", resp, "Failure sending request") 58 return 59 } 60 61 result, err = client.ListByServerResponder(resp) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "postgresql.LogFilesClient", "ListByServer", resp, "Failure responding to request") 64 } 65 66 return 67} 68 69// ListByServerPreparer prepares the ListByServer request. 70func (client LogFilesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { 71 pathParameters := map[string]interface{}{ 72 "resourceGroupName": autorest.Encode("path", resourceGroupName), 73 "serverName": autorest.Encode("path", serverName), 74 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 75 } 76 77 const APIVersion = "2017-04-30-preview" 78 queryParameters := map[string]interface{}{ 79 "api-version": APIVersion, 80 } 81 82 preparer := autorest.CreatePreparer( 83 autorest.AsGet(), 84 autorest.WithBaseURL(client.BaseURI), 85 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/logFiles", pathParameters), 86 autorest.WithQueryParameters(queryParameters)) 87 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 88} 89 90// ListByServerSender sends the ListByServer request. The method will close the 91// http.Response Body if it receives an error. 92func (client LogFilesClient) ListByServerSender(req *http.Request) (*http.Response, error) { 93 return autorest.SendWithSender(client, req, 94 azure.DoRetryWithRegistration(client.Client)) 95} 96 97// ListByServerResponder handles the response to the ListByServer request. The method always 98// closes the http.Response Body. 99func (client LogFilesClient) ListByServerResponder(resp *http.Response) (result LogFileListResult, err error) { 100 err = autorest.Respond( 101 resp, 102 client.ByInspecting(), 103 azure.WithErrorUnlessStatusCode(http.StatusOK), 104 autorest.ByUnmarshallingJSON(&result), 105 autorest.ByClosing()) 106 result.Response = autorest.Response{Response: resp} 107 return 108} 109