1package security 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 "github.com/Azure/go-autorest/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// IoTSecuritySolutionsResourceGroupClient is the API spec for Microsoft.Security (Azure Security Center) resource 30// provider 31type IoTSecuritySolutionsResourceGroupClient struct { 32 BaseClient 33} 34 35// NewIoTSecuritySolutionsResourceGroupClient creates an instance of the IoTSecuritySolutionsResourceGroupClient 36// client. 37func NewIoTSecuritySolutionsResourceGroupClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsResourceGroupClient { 38 return NewIoTSecuritySolutionsResourceGroupClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) 39} 40 41// NewIoTSecuritySolutionsResourceGroupClientWithBaseURI creates an instance of the 42// IoTSecuritySolutionsResourceGroupClient client. 43func NewIoTSecuritySolutionsResourceGroupClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsResourceGroupClient { 44 return IoTSecuritySolutionsResourceGroupClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} 45} 46 47// List list of security solutions 48// Parameters: 49// resourceGroupName - the name of the resource group within the user's subscription. The name is case 50// insensitive. 51// filter - filter the Security Solution with OData syntax. supporting filter by iotHubs 52func (client IoTSecuritySolutionsResourceGroupClient) List(ctx context.Context, resourceGroupName string, filter string) (result IoTSecuritySolutionsListPage, err error) { 53 if tracing.IsEnabled() { 54 ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsResourceGroupClient.List") 55 defer func() { 56 sc := -1 57 if result.itssl.Response.Response != nil { 58 sc = result.itssl.Response.Response.StatusCode 59 } 60 tracing.EndSpan(ctx, sc, err) 61 }() 62 } 63 if err := validation.Validate([]validation.Validation{ 64 {TargetValue: client.SubscriptionID, 65 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, 66 {TargetValue: resourceGroupName, 67 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 68 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 69 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 70 return result, validation.NewError("security.IoTSecuritySolutionsResourceGroupClient", "List", err.Error()) 71 } 72 73 result.fn = client.listNextResults 74 req, err := client.ListPreparer(ctx, resourceGroupName, filter) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "List", nil, "Failure preparing request") 77 return 78 } 79 80 resp, err := client.ListSender(req) 81 if err != nil { 82 result.itssl.Response = autorest.Response{Response: resp} 83 err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "List", resp, "Failure sending request") 84 return 85 } 86 87 result.itssl, err = client.ListResponder(resp) 88 if err != nil { 89 err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "List", resp, "Failure responding to request") 90 } 91 92 return 93} 94 95// ListPreparer prepares the List request. 96func (client IoTSecuritySolutionsResourceGroupClient) ListPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { 97 pathParameters := map[string]interface{}{ 98 "resourceGroupName": autorest.Encode("path", resourceGroupName), 99 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 100 } 101 102 const APIVersion = "2017-08-01-preview" 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.Security/iotSecuritySolutions", pathParameters), 114 autorest.WithQueryParameters(queryParameters)) 115 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 116} 117 118// ListSender sends the List request. The method will close the 119// http.Response Body if it receives an error. 120func (client IoTSecuritySolutionsResourceGroupClient) ListSender(req *http.Request) (*http.Response, error) { 121 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 122 return autorest.SendWithSender(client, req, sd...) 123} 124 125// ListResponder handles the response to the List request. The method always 126// closes the http.Response Body. 127func (client IoTSecuritySolutionsResourceGroupClient) ListResponder(resp *http.Response) (result IoTSecuritySolutionsList, err error) { 128 err = autorest.Respond( 129 resp, 130 client.ByInspecting(), 131 azure.WithErrorUnlessStatusCode(http.StatusOK), 132 autorest.ByUnmarshallingJSON(&result), 133 autorest.ByClosing()) 134 result.Response = autorest.Response{Response: resp} 135 return 136} 137 138// listNextResults retrieves the next set of results, if any. 139func (client IoTSecuritySolutionsResourceGroupClient) listNextResults(ctx context.Context, lastResults IoTSecuritySolutionsList) (result IoTSecuritySolutionsList, err error) { 140 req, err := lastResults.ioTSecuritySolutionsListPreparer(ctx) 141 if err != nil { 142 return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "listNextResults", nil, "Failure preparing next results request") 143 } 144 if req == nil { 145 return 146 } 147 resp, err := client.ListSender(req) 148 if err != nil { 149 result.Response = autorest.Response{Response: resp} 150 return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "listNextResults", resp, "Failure sending next results request") 151 } 152 result, err = client.ListResponder(resp) 153 if err != nil { 154 err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "listNextResults", resp, "Failure responding to next results request") 155 } 156 return 157} 158 159// ListComplete enumerates all values, automatically crossing page boundaries as required. 160func (client IoTSecuritySolutionsResourceGroupClient) ListComplete(ctx context.Context, resourceGroupName string, filter string) (result IoTSecuritySolutionsListIterator, err error) { 161 if tracing.IsEnabled() { 162 ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsResourceGroupClient.List") 163 defer func() { 164 sc := -1 165 if result.Response().Response.Response != nil { 166 sc = result.page.Response().Response.Response.StatusCode 167 } 168 tracing.EndSpan(ctx, sc, err) 169 }() 170 } 171 result.page, err = client.List(ctx, resourceGroupName, filter) 172 return 173} 174