diff --git a/profiles/preview/preview/resourcegraph/mgmt/resourcegraph/models.go b/profiles/preview/preview/resourcegraph/mgmt/resourcegraph/models.go new file mode 100644 index 000000000000..55f09b708ad4 --- /dev/null +++ b/profiles/preview/preview/resourcegraph/mgmt/resourcegraph/models.go @@ -0,0 +1,162 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package resourcegraph + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type ColumnDataType = original.ColumnDataType + +const ( + Boolean ColumnDataType = original.Boolean + Integer ColumnDataType = original.Integer + Number ColumnDataType = original.Number + Object ColumnDataType = original.Object + String ColumnDataType = original.String +) + +type FacetSortOrder = original.FacetSortOrder + +const ( + Asc FacetSortOrder = original.Asc + Desc FacetSortOrder = original.Desc +) + +type ResultKind = original.ResultKind + +const ( + Basic ResultKind = original.Basic +) + +type ResultTruncated = original.ResultTruncated + +const ( + False ResultTruncated = original.False + True ResultTruncated = original.True +) + +type ResultType = original.ResultType + +const ( + ResultTypeFacet ResultType = original.ResultTypeFacet + ResultTypeFacetError ResultType = original.ResultTypeFacetError + ResultTypeFacetResult ResultType = original.ResultTypeFacetResult +) + +type BaseClient = original.BaseClient +type BasicFacet = original.BasicFacet +type Column = original.Column +type DateTimeInterval = original.DateTimeInterval +type Error = original.Error +type ErrorDetails = original.ErrorDetails +type ErrorFieldContract = original.ErrorFieldContract +type ErrorResponse = original.ErrorResponse +type Facet = original.Facet +type FacetError = original.FacetError +type FacetRequest = original.FacetRequest +type FacetRequestOptions = original.FacetRequestOptions +type FacetResult = original.FacetResult +type GraphQueryClient = original.GraphQueryClient +type GraphQueryError = original.GraphQueryError +type GraphQueryListResult = original.GraphQueryListResult +type GraphQueryListResultIterator = original.GraphQueryListResultIterator +type GraphQueryListResultPage = original.GraphQueryListResultPage +type GraphQueryProperties = original.GraphQueryProperties +type GraphQueryPropertiesUpdateParameters = original.GraphQueryPropertiesUpdateParameters +type GraphQueryResource = original.GraphQueryResource +type GraphQueryUpdateParameters = original.GraphQueryUpdateParameters +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationListResultIterator = original.OperationListResultIterator +type OperationListResultPage = original.OperationListResultPage +type OperationsClient = original.OperationsClient +type QueryRequest = original.QueryRequest +type QueryRequestOptions = original.QueryRequestOptions +type QueryResponse = original.QueryResponse +type Resource = original.Resource +type ResourceChangeData = original.ResourceChangeData +type ResourceChangeDataAfterSnapshot = original.ResourceChangeDataAfterSnapshot +type ResourceChangeDataBeforeSnapshot = original.ResourceChangeDataBeforeSnapshot +type ResourceChangeDetailsRequestParameters = original.ResourceChangeDetailsRequestParameters +type ResourceChangeList = original.ResourceChangeList +type ResourceChangesRequestParameters = original.ResourceChangesRequestParameters +type ResourceChangesRequestParametersInterval = original.ResourceChangesRequestParametersInterval +type ResourceSnapshotData = original.ResourceSnapshotData +type Table = original.Table + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewGraphQueryClient(subscriptionID string) GraphQueryClient { + return original.NewGraphQueryClient(subscriptionID) +} +func NewGraphQueryClientWithBaseURI(baseURI string, subscriptionID string) GraphQueryClient { + return original.NewGraphQueryClientWithBaseURI(baseURI, subscriptionID) +} +func NewGraphQueryListResultIterator(page GraphQueryListResultPage) GraphQueryListResultIterator { + return original.NewGraphQueryListResultIterator(page) +} +func NewGraphQueryListResultPage(getNextPage func(context.Context, GraphQueryListResult) (GraphQueryListResult, error)) GraphQueryListResultPage { + return original.NewGraphQueryListResultPage(getNextPage) +} +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return original.NewOperationListResultIterator(page) +} +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return original.NewOperationListResultPage(getNextPage) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleColumnDataTypeValues() []ColumnDataType { + return original.PossibleColumnDataTypeValues() +} +func PossibleFacetSortOrderValues() []FacetSortOrder { + return original.PossibleFacetSortOrderValues() +} +func PossibleResultKindValues() []ResultKind { + return original.PossibleResultKindValues() +} +func PossibleResultTruncatedValues() []ResultTruncated { + return original.PossibleResultTruncatedValues() +} +func PossibleResultTypeValues() []ResultType { + return original.PossibleResultTypeValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/profiles/preview/preview/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go b/profiles/preview/preview/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go new file mode 100644 index 000000000000..64316d31bb03 --- /dev/null +++ b/profiles/preview/preview/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go @@ -0,0 +1,26 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package resourcegraphapi + +import original "github.com/Azure/azure-sdk-for-go/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/resourcegraphapi" + +type BaseClientAPI = original.BaseClientAPI +type GraphQueryClientAPI = original.GraphQueryClientAPI +type OperationsClientAPI = original.OperationsClientAPI diff --git a/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/client.go b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/client.go new file mode 100644 index 000000000000..fc98de8b6a74 --- /dev/null +++ b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/client.go @@ -0,0 +1,305 @@ +// Package resourcegraph implements the Azure ARM Resourcegraph service API version 2018-09-01-preview. +// +// +package resourcegraph + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +const ( + // DefaultBaseURI is the default URI used for the service Resourcegraph + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Resourcegraph. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} + +// ResourceChangeDetails get resource change details. +// Parameters: +// parameters - the parameters for this request for resource change details. +func (client BaseClient) ResourceChangeDetails(ctx context.Context, parameters ResourceChangeDetailsRequestParameters) (result ResourceChangeData, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.ResourceChangeDetails") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ChangeID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("resourcegraph.BaseClient", "ResourceChangeDetails", err.Error()) + } + + req, err := client.ResourceChangeDetailsPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "ResourceChangeDetails", nil, "Failure preparing request") + return + } + + resp, err := client.ResourceChangeDetailsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "ResourceChangeDetails", resp, "Failure sending request") + return + } + + result, err = client.ResourceChangeDetailsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "ResourceChangeDetails", resp, "Failure responding to request") + } + + return +} + +// ResourceChangeDetailsPreparer prepares the ResourceChangeDetails request. +func (client BaseClient) ResourceChangeDetailsPreparer(ctx context.Context, parameters ResourceChangeDetailsRequestParameters) (*http.Request, error) { + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ResourceGraph/resourceChangeDetails"), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResourceChangeDetailsSender sends the ResourceChangeDetails request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) ResourceChangeDetailsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ResourceChangeDetailsResponder handles the response to the ResourceChangeDetails request. The method always +// closes the http.Response Body. +func (client BaseClient) ResourceChangeDetailsResponder(resp *http.Response) (result ResourceChangeData, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ResourceChanges list changes to a resource for a given time interval. +// Parameters: +// parameters - the parameters for this request for changes. +func (client BaseClient) ResourceChanges(ctx context.Context, parameters ResourceChangesRequestParameters) (result ResourceChangeList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.ResourceChanges") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Interval", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "parameters.Top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("resourcegraph.BaseClient", "ResourceChanges", err.Error()) + } + + req, err := client.ResourceChangesPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "ResourceChanges", nil, "Failure preparing request") + return + } + + resp, err := client.ResourceChangesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "ResourceChanges", resp, "Failure sending request") + return + } + + result, err = client.ResourceChangesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "ResourceChanges", resp, "Failure responding to request") + } + + return +} + +// ResourceChangesPreparer prepares the ResourceChanges request. +func (client BaseClient) ResourceChangesPreparer(ctx context.Context, parameters ResourceChangesRequestParameters) (*http.Request, error) { + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ResourceGraph/resourceChanges"), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResourceChangesSender sends the ResourceChanges request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) ResourceChangesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ResourceChangesResponder handles the response to the ResourceChanges request. The method always +// closes the http.Response Body. +func (client BaseClient) ResourceChangesResponder(resp *http.Response) (result ResourceChangeList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Resources queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. +// Parameters: +// query - request specifying query and its options. +func (client BaseClient) Resources(ctx context.Context, query QueryRequest) (result QueryResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.Resources") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: query, + Constraints: []validation.Constraint{{Target: "query.Subscriptions", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "query.Query", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "query.Options", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "query.Options.Top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "query.Options.Top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "query.Options.Top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}, + {Target: "query.Options.Skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "query.Options.Skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("resourcegraph.BaseClient", "Resources", err.Error()) + } + + req, err := client.ResourcesPreparer(ctx, query) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "Resources", nil, "Failure preparing request") + return + } + + resp, err := client.ResourcesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "Resources", resp, "Failure sending request") + return + } + + result, err = client.ResourcesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.BaseClient", "Resources", resp, "Failure responding to request") + } + + return +} + +// ResourcesPreparer prepares the Resources request. +func (client BaseClient) ResourcesPreparer(ctx context.Context, query QueryRequest) (*http.Request, error) { + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ResourceGraph/resources"), + autorest.WithJSON(query), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResourcesSender sends the Resources request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) ResourcesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ResourcesResponder handles the response to the Resources request. The method always +// closes the http.Response Body. +func (client BaseClient) ResourcesResponder(resp *http.Response) (result QueryResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/graphquery.go b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/graphquery.go new file mode 100644 index 000000000000..c1bd37362109 --- /dev/null +++ b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/graphquery.go @@ -0,0 +1,476 @@ +package resourcegraph + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GraphQueryClient is the client for the GraphQuery methods of the Resourcegraph service. +type GraphQueryClient struct { + BaseClient +} + +// NewGraphQueryClient creates an instance of the GraphQueryClient client. +func NewGraphQueryClient(subscriptionID string) GraphQueryClient { + return NewGraphQueryClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGraphQueryClientWithBaseURI creates an instance of the GraphQueryClient client. +func NewGraphQueryClientWithBaseURI(baseURI string, subscriptionID string) GraphQueryClient { + return GraphQueryClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new graph query. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Graph Query resource. +// properties - properties that need to be specified to create a new graph query. +func (client GraphQueryClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, properties GraphQueryResource) (result GraphQueryResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GraphQueryClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.GraphQueryProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.GraphQueryProperties.Query", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("resourcegraph.GraphQueryClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GraphQueryClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, properties GraphQueryResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.ResourceGraph/queries/{resourceName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client GraphQueryClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GraphQueryClient) CreateOrUpdateResponder(resp *http.Response) (result GraphQueryResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a graph query. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Graph Query resource. +func (client GraphQueryClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GraphQueryClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GraphQueryClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.ResourceGraph/queries/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GraphQueryClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GraphQueryClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a single graph query by its resourceName. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Graph Query resource. +func (client GraphQueryClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result GraphQueryResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GraphQueryClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client GraphQueryClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.ResourceGraph/queries/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GraphQueryClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GraphQueryClient) GetResponder(resp *http.Response) (result GraphQueryResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all graph queries defined within a specified subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client GraphQueryClient) List(ctx context.Context, resourceGroupName string) (result GraphQueryListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GraphQueryClient.List") + defer func() { + sc := -1 + if result.gqlr.Response.Response != nil { + sc = result.gqlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.gqlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "List", resp, "Failure sending request") + return + } + + result.gqlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client GraphQueryClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.ResourceGraph/queries", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client GraphQueryClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client GraphQueryClient) ListResponder(resp *http.Response) (result GraphQueryListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client GraphQueryClient) listNextResults(ctx context.Context, lastResults GraphQueryListResult) (result GraphQueryListResult, err error) { + req, err := lastResults.graphQueryListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client GraphQueryClient) ListComplete(ctx context.Context, resourceGroupName string) (result GraphQueryListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GraphQueryClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName) + return +} + +// Update updates a graph query that has already been added. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Graph Query resource. +// body - properties that need to be specified to create a new graph query. +func (client GraphQueryClient) Update(ctx context.Context, resourceGroupName string, resourceName string, body GraphQueryUpdateParameters) (result GraphQueryResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GraphQueryClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.GraphQueryClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client GraphQueryClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, body GraphQueryUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ETag = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.ResourceGraph/queries/{resourceName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client GraphQueryClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client GraphQueryClient) UpdateResponder(resp *http.Response) (result GraphQueryResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/models.go b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/models.go new file mode 100644 index 000000000000..2cfc54533c8f --- /dev/null +++ b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/models.go @@ -0,0 +1,1165 @@ +package resourcegraph + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph" + +// ColumnDataType enumerates the values for column data type. +type ColumnDataType string + +const ( + // Boolean ... + Boolean ColumnDataType = "boolean" + // Integer ... + Integer ColumnDataType = "integer" + // Number ... + Number ColumnDataType = "number" + // Object ... + Object ColumnDataType = "object" + // String ... + String ColumnDataType = "string" +) + +// PossibleColumnDataTypeValues returns an array of possible values for the ColumnDataType const type. +func PossibleColumnDataTypeValues() []ColumnDataType { + return []ColumnDataType{Boolean, Integer, Number, Object, String} +} + +// FacetSortOrder enumerates the values for facet sort order. +type FacetSortOrder string + +const ( + // Asc ... + Asc FacetSortOrder = "asc" + // Desc ... + Desc FacetSortOrder = "desc" +) + +// PossibleFacetSortOrderValues returns an array of possible values for the FacetSortOrder const type. +func PossibleFacetSortOrderValues() []FacetSortOrder { + return []FacetSortOrder{Asc, Desc} +} + +// ResultKind enumerates the values for result kind. +type ResultKind string + +const ( + // Basic ... + Basic ResultKind = "basic" +) + +// PossibleResultKindValues returns an array of possible values for the ResultKind const type. +func PossibleResultKindValues() []ResultKind { + return []ResultKind{Basic} +} + +// ResultTruncated enumerates the values for result truncated. +type ResultTruncated string + +const ( + // False ... + False ResultTruncated = "false" + // True ... + True ResultTruncated = "true" +) + +// PossibleResultTruncatedValues returns an array of possible values for the ResultTruncated const type. +func PossibleResultTruncatedValues() []ResultTruncated { + return []ResultTruncated{False, True} +} + +// ResultType enumerates the values for result type. +type ResultType string + +const ( + // ResultTypeFacet ... + ResultTypeFacet ResultType = "Facet" + // ResultTypeFacetError ... + ResultTypeFacetError ResultType = "FacetError" + // ResultTypeFacetResult ... + ResultTypeFacetResult ResultType = "FacetResult" +) + +// PossibleResultTypeValues returns an array of possible values for the ResultType const type. +func PossibleResultTypeValues() []ResultType { + return []ResultType{ResultTypeFacet, ResultTypeFacetError, ResultTypeFacetResult} +} + +// Column query result column descriptor. +type Column struct { + // Name - Column name. + Name *string `json:"name,omitempty"` + // Type - Column data type. Possible values include: 'String', 'Integer', 'Number', 'Boolean', 'Object' + Type ColumnDataType `json:"type,omitempty"` +} + +// DateTimeInterval an interval in time specifying the date and time for the inclusive start and exclusive +// end, i.e. `[start, end)`. +type DateTimeInterval struct { + // Start - A datetime indicating the inclusive/closed start of the time interval, i.e. `[`**`start`**`, end)`. Specifying a `start` that occurs chronologically after `end` will result in an error. + Start *date.Time `json:"start,omitempty"` + // End - A datetime indicating the exclusive/open end of the time interval, i.e. `[start, `**`end`**`)`. Specifying an `end` that occurs chronologically before `start` will result in an error. + End *date.Time `json:"end,omitempty"` +} + +// Error error details. +type Error struct { + // Code - Error code identifying the specific error. + Code *string `json:"code,omitempty"` + // Message - A human readable error message. + Message *string `json:"message,omitempty"` + // Details - Error details + Details *[]ErrorDetails `json:"details,omitempty"` +} + +// ErrorDetails ... +type ErrorDetails struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Code - Error code identifying the specific error. + Code *string `json:"code,omitempty"` + // Message - A human readable error message. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetails. +func (ed ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ed.Code != nil { + objectMap["code"] = ed.Code + } + if ed.Message != nil { + objectMap["message"] = ed.Message + } + for k, v := range ed.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ErrorDetails struct. +func (ed *ErrorDetails) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if ed.AdditionalProperties == nil { + ed.AdditionalProperties = make(map[string]interface{}) + } + ed.AdditionalProperties[k] = additionalProperties + } + case "code": + if v != nil { + var code string + err = json.Unmarshal(*v, &code) + if err != nil { + return err + } + ed.Code = &code + } + case "message": + if v != nil { + var message string + err = json.Unmarshal(*v, &message) + if err != nil { + return err + } + ed.Message = &message + } + } + } + + return nil +} + +// ErrorFieldContract error Field contract. +type ErrorFieldContract struct { + // Code - Property level error code. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of property-level error. + Message *string `json:"message,omitempty"` + // Target - Property name. + Target *string `json:"target,omitempty"` +} + +// ErrorResponse an error response from the API. +type ErrorResponse struct { + // Error - Error information. + Error *Error `json:"error,omitempty"` +} + +// BasicFacet a facet containing additional statistics on the response of a query. Can be either FacetResult or +// FacetError. +type BasicFacet interface { + AsFacetResult() (*FacetResult, bool) + AsFacetError() (*FacetError, bool) + AsFacet() (*Facet, bool) +} + +// Facet a facet containing additional statistics on the response of a query. Can be either FacetResult or +// FacetError. +type Facet struct { + // Expression - Facet expression, same as in the corresponding facet request. + Expression *string `json:"expression,omitempty"` + // ResultType - Possible values include: 'ResultTypeFacet', 'ResultTypeFacetResult', 'ResultTypeFacetError' + ResultType ResultType `json:"resultType,omitempty"` +} + +func unmarshalBasicFacet(body []byte) (BasicFacet, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["resultType"] { + case string(ResultTypeFacetResult): + var fr FacetResult + err := json.Unmarshal(body, &fr) + return fr, err + case string(ResultTypeFacetError): + var fe FacetError + err := json.Unmarshal(body, &fe) + return fe, err + default: + var f Facet + err := json.Unmarshal(body, &f) + return f, err + } +} +func unmarshalBasicFacetArray(body []byte) ([]BasicFacet, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + fArray := make([]BasicFacet, len(rawMessages)) + + for index, rawMessage := range rawMessages { + f, err := unmarshalBasicFacet(*rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +// MarshalJSON is the custom marshaler for Facet. +func (f Facet) MarshalJSON() ([]byte, error) { + f.ResultType = ResultTypeFacet + objectMap := make(map[string]interface{}) + if f.Expression != nil { + objectMap["expression"] = f.Expression + } + if f.ResultType != "" { + objectMap["resultType"] = f.ResultType + } + return json.Marshal(objectMap) +} + +// AsFacetResult is the BasicFacet implementation for Facet. +func (f Facet) AsFacetResult() (*FacetResult, bool) { + return nil, false +} + +// AsFacetError is the BasicFacet implementation for Facet. +func (f Facet) AsFacetError() (*FacetError, bool) { + return nil, false +} + +// AsFacet is the BasicFacet implementation for Facet. +func (f Facet) AsFacet() (*Facet, bool) { + return &f, true +} + +// AsBasicFacet is the BasicFacet implementation for Facet. +func (f Facet) AsBasicFacet() (BasicFacet, bool) { + return &f, true +} + +// FacetError a facet whose execution resulted in an error. +type FacetError struct { + // Errors - An array containing detected facet errors with details. + Errors *[]ErrorDetails `json:"errors,omitempty"` + // Expression - Facet expression, same as in the corresponding facet request. + Expression *string `json:"expression,omitempty"` + // ResultType - Possible values include: 'ResultTypeFacet', 'ResultTypeFacetResult', 'ResultTypeFacetError' + ResultType ResultType `json:"resultType,omitempty"` +} + +// MarshalJSON is the custom marshaler for FacetError. +func (fe FacetError) MarshalJSON() ([]byte, error) { + fe.ResultType = ResultTypeFacetError + objectMap := make(map[string]interface{}) + if fe.Errors != nil { + objectMap["errors"] = fe.Errors + } + if fe.Expression != nil { + objectMap["expression"] = fe.Expression + } + if fe.ResultType != "" { + objectMap["resultType"] = fe.ResultType + } + return json.Marshal(objectMap) +} + +// AsFacetResult is the BasicFacet implementation for FacetError. +func (fe FacetError) AsFacetResult() (*FacetResult, bool) { + return nil, false +} + +// AsFacetError is the BasicFacet implementation for FacetError. +func (fe FacetError) AsFacetError() (*FacetError, bool) { + return &fe, true +} + +// AsFacet is the BasicFacet implementation for FacetError. +func (fe FacetError) AsFacet() (*Facet, bool) { + return nil, false +} + +// AsBasicFacet is the BasicFacet implementation for FacetError. +func (fe FacetError) AsBasicFacet() (BasicFacet, bool) { + return &fe, true +} + +// FacetRequest a request to compute additional statistics (facets) over the query results. +type FacetRequest struct { + // Expression - The column or list of columns to summarize by + Expression *string `json:"expression,omitempty"` + // Options - The options for facet evaluation + Options *FacetRequestOptions `json:"options,omitempty"` +} + +// FacetRequestOptions the options for facet evaluation +type FacetRequestOptions struct { + // SortBy - The column name or query expression to sort on. Defaults to count if not present. + SortBy *string `json:"sortBy,omitempty"` + // SortOrder - The sorting order by the selected column (count by default). Possible values include: 'Asc', 'Desc' + SortOrder FacetSortOrder `json:"sortOrder,omitempty"` + // Filter - Specifies the filter condition for the 'where' clause which will be run on main query's result, just before the actual faceting. + Filter *string `json:"filter,omitempty"` + // Top - The maximum number of facet rows that should be returned. + Top *int32 `json:"$top,omitempty"` +} + +// FacetResult successfully executed facet containing additional statistics on the response of a query. +type FacetResult struct { + // TotalRecords - Number of total records in the facet results. + TotalRecords *int64 `json:"totalRecords,omitempty"` + // Count - Number of records returned in the facet response. + Count *int32 `json:"count,omitempty"` + // Data - A table containing the desired facets. Only present if the facet is valid. + Data *Table `json:"data,omitempty"` + // Expression - Facet expression, same as in the corresponding facet request. + Expression *string `json:"expression,omitempty"` + // ResultType - Possible values include: 'ResultTypeFacet', 'ResultTypeFacetResult', 'ResultTypeFacetError' + ResultType ResultType `json:"resultType,omitempty"` +} + +// MarshalJSON is the custom marshaler for FacetResult. +func (fr FacetResult) MarshalJSON() ([]byte, error) { + fr.ResultType = ResultTypeFacetResult + objectMap := make(map[string]interface{}) + if fr.TotalRecords != nil { + objectMap["totalRecords"] = fr.TotalRecords + } + if fr.Count != nil { + objectMap["count"] = fr.Count + } + if fr.Data != nil { + objectMap["data"] = fr.Data + } + if fr.Expression != nil { + objectMap["expression"] = fr.Expression + } + if fr.ResultType != "" { + objectMap["resultType"] = fr.ResultType + } + return json.Marshal(objectMap) +} + +// AsFacetResult is the BasicFacet implementation for FacetResult. +func (fr FacetResult) AsFacetResult() (*FacetResult, bool) { + return &fr, true +} + +// AsFacetError is the BasicFacet implementation for FacetResult. +func (fr FacetResult) AsFacetError() (*FacetError, bool) { + return nil, false +} + +// AsFacet is the BasicFacet implementation for FacetResult. +func (fr FacetResult) AsFacet() (*Facet, bool) { + return nil, false +} + +// AsBasicFacet is the BasicFacet implementation for FacetResult. +func (fr FacetResult) AsBasicFacet() (BasicFacet, bool) { + return &fr, true +} + +// GraphQueryError error message body that will indicate why the operation failed. +type GraphQueryError struct { + // Code - Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of the error. + Message *string `json:"message,omitempty"` + // Details - The list of invalid fields send in request, in case of validation error. + Details *[]ErrorFieldContract `json:"details,omitempty"` +} + +// GraphQueryListResult graph query list result. +type GraphQueryListResult struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of queries. + NextLink *string `json:"nextLink,omitempty"` + // Value - READ-ONLY; An array of graph queries. + Value *[]GraphQueryResource `json:"value,omitempty"` +} + +// GraphQueryListResultIterator provides access to a complete listing of GraphQueryResource values. +type GraphQueryListResultIterator struct { + i int + page GraphQueryListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *GraphQueryListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GraphQueryListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *GraphQueryListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GraphQueryListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter GraphQueryListResultIterator) Response() GraphQueryListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter GraphQueryListResultIterator) Value() GraphQueryResource { + if !iter.page.NotDone() { + return GraphQueryResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GraphQueryListResultIterator type. +func NewGraphQueryListResultIterator(page GraphQueryListResultPage) GraphQueryListResultIterator { + return GraphQueryListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (gqlr GraphQueryListResult) IsEmpty() bool { + return gqlr.Value == nil || len(*gqlr.Value) == 0 +} + +// graphQueryListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (gqlr GraphQueryListResult) graphQueryListResultPreparer(ctx context.Context) (*http.Request, error) { + if gqlr.NextLink == nil || len(to.String(gqlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(gqlr.NextLink))) +} + +// GraphQueryListResultPage contains a page of GraphQueryResource values. +type GraphQueryListResultPage struct { + fn func(context.Context, GraphQueryListResult) (GraphQueryListResult, error) + gqlr GraphQueryListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *GraphQueryListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GraphQueryListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.gqlr) + if err != nil { + return err + } + page.gqlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *GraphQueryListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GraphQueryListResultPage) NotDone() bool { + return !page.gqlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GraphQueryListResultPage) Response() GraphQueryListResult { + return page.gqlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GraphQueryListResultPage) Values() []GraphQueryResource { + if page.gqlr.IsEmpty() { + return nil + } + return *page.gqlr.Value +} + +// Creates a new instance of the GraphQueryListResultPage type. +func NewGraphQueryListResultPage(getNextPage func(context.Context, GraphQueryListResult) (GraphQueryListResult, error)) GraphQueryListResultPage { + return GraphQueryListResultPage{fn: getNextPage} +} + +// GraphQueryProperties properties that contain a graph query. +type GraphQueryProperties struct { + // TimeModified - READ-ONLY; Date and time in UTC of the last modification that was made to this graph query definition. + TimeModified *date.Time `json:"timeModified,omitempty"` + // Description - The description of a graph query. + Description *string `json:"description,omitempty"` + // Query - KQL query that will be graph. + Query *string `json:"query,omitempty"` + // ResultKind - READ-ONLY; Enum indicating a type of graph query. Possible values include: 'Basic' + ResultKind ResultKind `json:"resultKind,omitempty"` +} + +// GraphQueryPropertiesUpdateParameters properties that contain a workbook for PATCH operation. +type GraphQueryPropertiesUpdateParameters struct { + // Description - The description of a graph query. + Description *string `json:"description,omitempty"` + // Query - KQL query that will be graph. + Query *string `json:"query,omitempty"` + // ResultKind - Enum indicating a type of graph query. Possible values include: 'Basic' + ResultKind ResultKind `json:"resultKind,omitempty"` +} + +// GraphQueryResource graph Query entity definition. +type GraphQueryResource struct { + autorest.Response `json:"-"` + // GraphQueryProperties - Metadata describing a graph query for an Azure resource. + *GraphQueryProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name. This is GUID value. The display name should be assigned within properties field. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // ETag - READ-ONLY; This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. + ETag *string `json:"eTag,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for GraphQueryResource. +func (gqr GraphQueryResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gqr.GraphQueryProperties != nil { + objectMap["properties"] = gqr.GraphQueryProperties + } + if gqr.Tags != nil { + objectMap["tags"] = gqr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GraphQueryResource struct. +func (gqr *GraphQueryResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var graphQueryProperties GraphQueryProperties + err = json.Unmarshal(*v, &graphQueryProperties) + if err != nil { + return err + } + gqr.GraphQueryProperties = &graphQueryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gqr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gqr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gqr.Type = &typeVar + } + case "eTag": + if v != nil { + var eTag string + err = json.Unmarshal(*v, &eTag) + if err != nil { + return err + } + gqr.ETag = &eTag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + gqr.Tags = tags + } + } + } + + return nil +} + +// GraphQueryUpdateParameters the parameters that can be provided when updating workbook properties +// properties. +type GraphQueryUpdateParameters struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // ETag - READ-ONLY; This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. + ETag *string `json:"eTag,omitempty"` + // GraphQueryPropertiesUpdateParameters - Metadata describing a graph query for an Azure resource. + *GraphQueryPropertiesUpdateParameters `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for GraphQueryUpdateParameters. +func (gqup GraphQueryUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gqup.Tags != nil { + objectMap["tags"] = gqup.Tags + } + if gqup.GraphQueryPropertiesUpdateParameters != nil { + objectMap["properties"] = gqup.GraphQueryPropertiesUpdateParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GraphQueryUpdateParameters struct. +func (gqup *GraphQueryUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + gqup.Tags = tags + } + case "eTag": + if v != nil { + var eTag string + err = json.Unmarshal(*v, &eTag) + if err != nil { + return err + } + gqup.ETag = &eTag + } + case "properties": + if v != nil { + var graphQueryPropertiesUpdateParameters GraphQueryPropertiesUpdateParameters + err = json.Unmarshal(*v, &graphQueryPropertiesUpdateParameters) + if err != nil { + return err + } + gqup.GraphQueryPropertiesUpdateParameters = &graphQueryPropertiesUpdateParameters + } + } + } + + return nil +} + +// Operation resource Graph REST API operation definition. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Display metadata associated with the operation. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - The origin of operations. + Origin *string `json:"origin,omitempty"` +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft Resource Graph. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed etc. + Resource *string `json:"resource,omitempty"` + // Operation - Type of operation: get, read, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - Description for the operation. + Description *string `json:"description,omitempty"` +} + +// OperationListResult result of the request to list Resource Graph operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Resource Graph operations supported by the Resource Graph resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - The link used to get the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// QueryRequest describes a query to be executed. +type QueryRequest struct { + // Subscriptions - Azure subscriptions against which to execute the query. + Subscriptions *[]string `json:"subscriptions,omitempty"` + // Query - The resources query. + Query *string `json:"query,omitempty"` + // Options - The query evaluation options + Options *QueryRequestOptions `json:"options,omitempty"` + // Facets - An array of facet requests to be computed against the query result. + Facets *[]FacetRequest `json:"facets,omitempty"` +} + +// QueryRequestOptions the options for query evaluation +type QueryRequestOptions struct { + // SkipToken - Continuation token for pagination, capturing the next page size and offset, as well as the context of the query. + SkipToken *string `json:"$skipToken,omitempty"` + // Top - The maximum number of rows that the query should return. Overrides the page size when ```$skipToken``` property is present. + Top *int32 `json:"$top,omitempty"` + // Skip - The number of rows to skip from the beginning of the results. Overrides the next page offset when ```$skipToken``` property is present. + Skip *int32 `json:"$skip,omitempty"` +} + +// QueryResponse query result. +type QueryResponse struct { + autorest.Response `json:"-"` + // TotalRecords - Number of total records matching the query. + TotalRecords *int64 `json:"totalRecords,omitempty"` + // Count - Number of records returned in the current response. In the case of paging, this is the number of records in the current page. + Count *int64 `json:"count,omitempty"` + // ResultTruncated - Indicates whether the query results are truncated. Possible values include: 'True', 'False' + ResultTruncated ResultTruncated `json:"resultTruncated,omitempty"` + // SkipToken - When present, the value can be passed to a subsequent query call (together with the same query and subscriptions used in the current request) to retrieve the next page of data. + SkipToken *string `json:"$skipToken,omitempty"` + // Data - Query output in tabular format. + Data *Table `json:"data,omitempty"` + // Facets - Query facets. + Facets *[]BasicFacet `json:"facets,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for QueryResponse struct. +func (qr *QueryResponse) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "totalRecords": + if v != nil { + var totalRecords int64 + err = json.Unmarshal(*v, &totalRecords) + if err != nil { + return err + } + qr.TotalRecords = &totalRecords + } + case "count": + if v != nil { + var count int64 + err = json.Unmarshal(*v, &count) + if err != nil { + return err + } + qr.Count = &count + } + case "resultTruncated": + if v != nil { + var resultTruncated ResultTruncated + err = json.Unmarshal(*v, &resultTruncated) + if err != nil { + return err + } + qr.ResultTruncated = resultTruncated + } + case "$skipToken": + if v != nil { + var skipToken string + err = json.Unmarshal(*v, &skipToken) + if err != nil { + return err + } + qr.SkipToken = &skipToken + } + case "data": + if v != nil { + var data Table + err = json.Unmarshal(*v, &data) + if err != nil { + return err + } + qr.Data = &data + } + case "facets": + if v != nil { + facets, err := unmarshalBasicFacetArray(*v) + if err != nil { + return err + } + qr.Facets = &facets + } + } + } + + return nil +} + +// Resource an azure resource object +type Resource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name. This is GUID value. The display name should be assigned within properties field. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // ETag - READ-ONLY; This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. + ETag *string `json:"eTag,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// ResourceChangeData data on a specific change, represented by a pair of before and after resource +// snapshots. +type ResourceChangeData struct { + autorest.Response `json:"-"` + // ChangeID - The change ID. Valid and unique within the specified resource only. + ChangeID *string `json:"changeId,omitempty"` + // BeforeSnapshot - The snapshot before the change. + BeforeSnapshot *ResourceChangeDataBeforeSnapshot `json:"beforeSnapshot,omitempty"` + // AfterSnapshot - The snapshot after the change. + AfterSnapshot *ResourceChangeDataAfterSnapshot `json:"afterSnapshot,omitempty"` +} + +// ResourceChangeDataAfterSnapshot the snapshot after the change. +type ResourceChangeDataAfterSnapshot struct { + // Timestamp - The time when the snapshot was created. + // The snapshot timestamp provides an approximation as to when a modification to a resource was detected. There can be a difference between the actual modification time and the detection time. This is due to differences in how operations that modify a resource are processed, versus how operation that record resource snapshots are processed. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Content - The resource snapshot content (in resourceChangeDetails response only). + Content interface{} `json:"content,omitempty"` +} + +// ResourceChangeDataBeforeSnapshot the snapshot before the change. +type ResourceChangeDataBeforeSnapshot struct { + // Timestamp - The time when the snapshot was created. + // The snapshot timestamp provides an approximation as to when a modification to a resource was detected. There can be a difference between the actual modification time and the detection time. This is due to differences in how operations that modify a resource are processed, versus how operation that record resource snapshots are processed. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Content - The resource snapshot content (in resourceChangeDetails response only). + Content interface{} `json:"content,omitempty"` +} + +// ResourceChangeDetailsRequestParameters the parameters for a specific change details request. +type ResourceChangeDetailsRequestParameters struct { + // ResourceID - Specifies the resource for a change details request. + ResourceID *string `json:"resourceId,omitempty"` + // ChangeID - Specifies the change ID. + ChangeID *string `json:"changeId,omitempty"` +} + +// ResourceChangeList a list of changes associated with a resource over a specific time interval. +type ResourceChangeList struct { + autorest.Response `json:"-"` + // Changes - The pageable value returned by the operation, i.e. a list of changes to the resource. + // - The list is ordered from the most recent changes to the least recent changes. + // - This list will be empty if there were no changes during the requested interval. + // - The `Before` snapshot timestamp value of the oldest change can be outside of the specified time interval. + Changes *[]ResourceChangeData `json:"changes,omitempty"` + // SkipToken - Skip token that encodes the skip information while executing the current request + SkipToken interface{} `json:"$skipToken,omitempty"` +} + +// ResourceChangesRequestParameters the parameters for a specific changes request. +type ResourceChangesRequestParameters struct { + // ResourceID - Specifies the resource for a changes request. + ResourceID *string `json:"resourceId,omitempty"` + // Interval - Specifies the date and time interval for a changes request. + Interval *ResourceChangesRequestParametersInterval `json:"interval,omitempty"` + // SkipToken - Acts as the continuation token for paged responses. + SkipToken *string `json:"$skipToken,omitempty"` + // Top - The maximum number of changes the client can accept in a paged response. + Top *int32 `json:"$top,omitempty"` +} + +// ResourceChangesRequestParametersInterval specifies the date and time interval for a changes request. +type ResourceChangesRequestParametersInterval struct { + // Start - A datetime indicating the inclusive/closed start of the time interval, i.e. `[`**`start`**`, end)`. Specifying a `start` that occurs chronologically after `end` will result in an error. + Start *date.Time `json:"start,omitempty"` + // End - A datetime indicating the exclusive/open end of the time interval, i.e. `[start, `**`end`**`)`. Specifying an `end` that occurs chronologically before `start` will result in an error. + End *date.Time `json:"end,omitempty"` +} + +// ResourceSnapshotData data on a specific resource snapshot. +type ResourceSnapshotData struct { + // Timestamp - The time when the snapshot was created. + // The snapshot timestamp provides an approximation as to when a modification to a resource was detected. There can be a difference between the actual modification time and the detection time. This is due to differences in how operations that modify a resource are processed, versus how operation that record resource snapshots are processed. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Content - The resource snapshot content (in resourceChangeDetails response only). + Content interface{} `json:"content,omitempty"` +} + +// Table query output in tabular format. +type Table struct { + // Columns - Query result column descriptors. + Columns *[]Column `json:"columns,omitempty"` + // Rows - Query result rows. + Rows *[][]interface{} `json:"rows,omitempty"` +} diff --git a/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/operations.go b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/operations.go new file mode 100644 index 000000000000..525a45f7d3f2 --- /dev/null +++ b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/operations.go @@ -0,0 +1,147 @@ +package resourcegraph + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the Resourcegraph service. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ResourceGraph/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "resourcegraph.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "resourcegraph.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resourcegraph.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/resourcegraphapi/interfaces.go b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/resourcegraphapi/interfaces.go new file mode 100644 index 000000000000..a717c0430d30 --- /dev/null +++ b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/resourcegraphapi/interfaces.go @@ -0,0 +1,51 @@ +package resourcegraphapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph" + "github.com/Azure/go-autorest/autorest" +) + +// BaseClientAPI contains the set of methods on the BaseClient type. +type BaseClientAPI interface { + ResourceChangeDetails(ctx context.Context, parameters resourcegraph.ResourceChangeDetailsRequestParameters) (result resourcegraph.ResourceChangeData, err error) + ResourceChanges(ctx context.Context, parameters resourcegraph.ResourceChangesRequestParameters) (result resourcegraph.ResourceChangeList, err error) + Resources(ctx context.Context, query resourcegraph.QueryRequest) (result resourcegraph.QueryResponse, err error) +} + +var _ BaseClientAPI = (*resourcegraph.BaseClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result resourcegraph.OperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*resourcegraph.OperationsClient)(nil) + +// GraphQueryClientAPI contains the set of methods on the GraphQueryClient type. +type GraphQueryClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, properties resourcegraph.GraphQueryResource) (result resourcegraph.GraphQueryResource, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result resourcegraph.GraphQueryResource, err error) + List(ctx context.Context, resourceGroupName string) (result resourcegraph.GraphQueryListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, body resourcegraph.GraphQueryUpdateParameters) (result resourcegraph.GraphQueryResource, err error) +} + +var _ GraphQueryClientAPI = (*resourcegraph.GraphQueryClient)(nil) diff --git a/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/version.go b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/version.go new file mode 100644 index 000000000000..39f2e4800e53 --- /dev/null +++ b/services/preview/resourcegraph/mgmt/2018-09-01/resourcegraph/version.go @@ -0,0 +1,30 @@ +package resourcegraph + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " resourcegraph/2018-09-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}