1package synapse 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// SQLPoolTableColumnsClient is the azure Synapse Analytics Management Client 19type SQLPoolTableColumnsClient struct { 20 BaseClient 21} 22 23// NewSQLPoolTableColumnsClient creates an instance of the SQLPoolTableColumnsClient client. 24func NewSQLPoolTableColumnsClient(subscriptionID string) SQLPoolTableColumnsClient { 25 return NewSQLPoolTableColumnsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewSQLPoolTableColumnsClientWithBaseURI creates an instance of the SQLPoolTableColumnsClient client using a custom 29// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 30// stack). 31func NewSQLPoolTableColumnsClientWithBaseURI(baseURI string, subscriptionID string) SQLPoolTableColumnsClient { 32 return SQLPoolTableColumnsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// ListByTableName gets columns in a given table in a SQL pool. 36// Parameters: 37// resourceGroupName - the name of the resource group. The name is case insensitive. 38// workspaceName - the name of the workspace 39// SQLPoolName - SQL pool name 40// schemaName - the name of the schema. 41// tableName - the name of the table. 42// filter - an OData filter expression that filters elements in the collection. 43func (client SQLPoolTableColumnsClient) ListByTableName(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, schemaName string, tableName string, filter string) (result SQLPoolColumnListResultPage, err error) { 44 if tracing.IsEnabled() { 45 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolTableColumnsClient.ListByTableName") 46 defer func() { 47 sc := -1 48 if result.spclr.Response.Response != nil { 49 sc = result.spclr.Response.Response.StatusCode 50 } 51 tracing.EndSpan(ctx, sc, err) 52 }() 53 } 54 if err := validation.Validate([]validation.Validation{ 55 {TargetValue: client.SubscriptionID, 56 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 57 {TargetValue: resourceGroupName, 58 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 59 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 60 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 61 return result, validation.NewError("synapse.SQLPoolTableColumnsClient", "ListByTableName", err.Error()) 62 } 63 64 result.fn = client.listByTableNameNextResults 65 req, err := client.ListByTableNamePreparer(ctx, resourceGroupName, workspaceName, SQLPoolName, schemaName, tableName, filter) 66 if err != nil { 67 err = autorest.NewErrorWithError(err, "synapse.SQLPoolTableColumnsClient", "ListByTableName", nil, "Failure preparing request") 68 return 69 } 70 71 resp, err := client.ListByTableNameSender(req) 72 if err != nil { 73 result.spclr.Response = autorest.Response{Response: resp} 74 err = autorest.NewErrorWithError(err, "synapse.SQLPoolTableColumnsClient", "ListByTableName", resp, "Failure sending request") 75 return 76 } 77 78 result.spclr, err = client.ListByTableNameResponder(resp) 79 if err != nil { 80 err = autorest.NewErrorWithError(err, "synapse.SQLPoolTableColumnsClient", "ListByTableName", resp, "Failure responding to request") 81 return 82 } 83 if result.spclr.hasNextLink() && result.spclr.IsEmpty() { 84 err = result.NextWithContext(ctx) 85 return 86 } 87 88 return 89} 90 91// ListByTableNamePreparer prepares the ListByTableName request. 92func (client SQLPoolTableColumnsClient) ListByTableNamePreparer(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, schemaName string, tableName string, filter string) (*http.Request, error) { 93 pathParameters := map[string]interface{}{ 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "schemaName": autorest.Encode("path", schemaName), 96 "sqlPoolName": autorest.Encode("path", SQLPoolName), 97 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 98 "tableName": autorest.Encode("path", tableName), 99 "workspaceName": autorest.Encode("path", workspaceName), 100 } 101 102 const APIVersion = "2021-03-01" 103 queryParameters := map[string]interface{}{ 104 "api-version": APIVersion, 105 } 106 if len(filter) > 0 { 107 queryParameters["$filter"] = autorest.Encode("query", filter) 108 } 109 110 preparer := autorest.CreatePreparer( 111 autorest.AsGet(), 112 autorest.WithBaseURL(client.BaseURI), 113 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns", pathParameters), 114 autorest.WithQueryParameters(queryParameters)) 115 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 116} 117 118// ListByTableNameSender sends the ListByTableName request. The method will close the 119// http.Response Body if it receives an error. 120func (client SQLPoolTableColumnsClient) ListByTableNameSender(req *http.Request) (*http.Response, error) { 121 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 122} 123 124// ListByTableNameResponder handles the response to the ListByTableName request. The method always 125// closes the http.Response Body. 126func (client SQLPoolTableColumnsClient) ListByTableNameResponder(resp *http.Response) (result SQLPoolColumnListResult, err error) { 127 err = autorest.Respond( 128 resp, 129 azure.WithErrorUnlessStatusCode(http.StatusOK), 130 autorest.ByUnmarshallingJSON(&result), 131 autorest.ByClosing()) 132 result.Response = autorest.Response{Response: resp} 133 return 134} 135 136// listByTableNameNextResults retrieves the next set of results, if any. 137func (client SQLPoolTableColumnsClient) listByTableNameNextResults(ctx context.Context, lastResults SQLPoolColumnListResult) (result SQLPoolColumnListResult, err error) { 138 req, err := lastResults.sQLPoolColumnListResultPreparer(ctx) 139 if err != nil { 140 return result, autorest.NewErrorWithError(err, "synapse.SQLPoolTableColumnsClient", "listByTableNameNextResults", nil, "Failure preparing next results request") 141 } 142 if req == nil { 143 return 144 } 145 resp, err := client.ListByTableNameSender(req) 146 if err != nil { 147 result.Response = autorest.Response{Response: resp} 148 return result, autorest.NewErrorWithError(err, "synapse.SQLPoolTableColumnsClient", "listByTableNameNextResults", resp, "Failure sending next results request") 149 } 150 result, err = client.ListByTableNameResponder(resp) 151 if err != nil { 152 err = autorest.NewErrorWithError(err, "synapse.SQLPoolTableColumnsClient", "listByTableNameNextResults", resp, "Failure responding to next results request") 153 } 154 return 155} 156 157// ListByTableNameComplete enumerates all values, automatically crossing page boundaries as required. 158func (client SQLPoolTableColumnsClient) ListByTableNameComplete(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, schemaName string, tableName string, filter string) (result SQLPoolColumnListResultIterator, err error) { 159 if tracing.IsEnabled() { 160 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolTableColumnsClient.ListByTableName") 161 defer func() { 162 sc := -1 163 if result.Response().Response.Response != nil { 164 sc = result.page.Response().Response.Response.StatusCode 165 } 166 tracing.EndSpan(ctx, sc, err) 167 }() 168 } 169 result.page, err = client.ListByTableName(ctx, resourceGroupName, workspaceName, SQLPoolName, schemaName, tableName, filter) 170 return 171} 172