diff --git a/profiles/latest/resourcegraph/mgmt/resourcegraph/models.go b/profiles/latest/resourcegraph/mgmt/resourcegraph/models.go new file mode 100644 index 000000000000..f858346d0c3f --- /dev/null +++ b/profiles/latest/resourcegraph/mgmt/resourcegraph/models.go @@ -0,0 +1,109 @@ +// +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 original "github.com/Azure/azure-sdk-for-go/services/resourcegraph/mgmt/2019-04-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 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 Error = original.Error +type ErrorDetails = original.ErrorDetails +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 Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationsClient = original.OperationsClient +type QueryRequest = original.QueryRequest +type QueryRequestOptions = original.QueryRequestOptions +type QueryResponse = original.QueryResponse +type Table = original.Table + +func New() BaseClient { + return original.New() +} +func NewOperationsClient() OperationsClient { + return original.NewOperationsClient() +} +func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI) +} +func NewWithBaseURI(baseURI string) BaseClient { + return original.NewWithBaseURI(baseURI) +} +func PossibleColumnDataTypeValues() []ColumnDataType { + return original.PossibleColumnDataTypeValues() +} +func PossibleFacetSortOrderValues() []FacetSortOrder { + return original.PossibleFacetSortOrderValues() +} +func PossibleResultTruncatedValues() []ResultTruncated { + return original.PossibleResultTruncatedValues() +} +func PossibleResultTypeValues() []ResultType { + return original.PossibleResultTypeValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/latest" +} +func Version() string { + return original.Version() +} diff --git a/profiles/latest/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go b/profiles/latest/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go new file mode 100644 index 000000000000..d9da3d718523 --- /dev/null +++ b/profiles/latest/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go @@ -0,0 +1,25 @@ +// +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/resourcegraph/mgmt/2019-04-01/resourcegraph/resourcegraphapi" + +type BaseClientAPI = original.BaseClientAPI +type OperationsClientAPI = original.OperationsClientAPI diff --git a/profiles/preview/resourcegraph/mgmt/resourcegraph/models.go b/profiles/preview/resourcegraph/mgmt/resourcegraph/models.go new file mode 100644 index 000000000000..0a1cb85e32d7 --- /dev/null +++ b/profiles/preview/resourcegraph/mgmt/resourcegraph/models.go @@ -0,0 +1,109 @@ +// +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 original "github.com/Azure/azure-sdk-for-go/services/resourcegraph/mgmt/2019-04-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 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 Error = original.Error +type ErrorDetails = original.ErrorDetails +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 Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationsClient = original.OperationsClient +type QueryRequest = original.QueryRequest +type QueryRequestOptions = original.QueryRequestOptions +type QueryResponse = original.QueryResponse +type Table = original.Table + +func New() BaseClient { + return original.New() +} +func NewOperationsClient() OperationsClient { + return original.NewOperationsClient() +} +func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI) +} +func NewWithBaseURI(baseURI string) BaseClient { + return original.NewWithBaseURI(baseURI) +} +func PossibleColumnDataTypeValues() []ColumnDataType { + return original.PossibleColumnDataTypeValues() +} +func PossibleFacetSortOrderValues() []FacetSortOrder { + return original.PossibleFacetSortOrderValues() +} +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/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go b/profiles/preview/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go new file mode 100644 index 000000000000..d9da3d718523 --- /dev/null +++ b/profiles/preview/resourcegraph/mgmt/resourcegraph/resourcegraphapi/models.go @@ -0,0 +1,25 @@ +// +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/resourcegraph/mgmt/2019-04-01/resourcegraph/resourcegraphapi" + +type BaseClientAPI = original.BaseClientAPI +type OperationsClientAPI = original.OperationsClientAPI diff --git a/services/resourcegraph/mgmt/2019-04-01/resourcegraph/client.go b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/client.go new file mode 100644 index 000000000000..06dfeef934d0 --- /dev/null +++ b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/client.go @@ -0,0 +1,141 @@ +// Package resourcegraph implements the Azure ARM Resourcegraph service API version 2019-04-01. +// +// Azure Resource Graph API Reference +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 +} + +// New creates an instance of the BaseClient client. +func New() BaseClient { + return NewWithBaseURI(DefaultBaseURI) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + } +} + +// 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 = "2019-04-01" + 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/resourcegraph/mgmt/2019-04-01/resourcegraph/models.go b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/models.go new file mode 100644 index 000000000000..19577fc42a97 --- /dev/null +++ b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/models.go @@ -0,0 +1,546 @@ +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 ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/resourcegraph/mgmt/2019-04-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} +} + +// 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"` +} + +// 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 +} + +// 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 +} + +// 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"` +} + +// 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 +} + +// 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/resourcegraph/mgmt/2019-04-01/resourcegraph/operations.go b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/operations.go new file mode 100644 index 000000000000..55f30efe55af --- /dev/null +++ b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/operations.go @@ -0,0 +1,109 @@ +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 azure Resource Graph API Reference +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient() OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI)} +} + +// List lists all of the available REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resourcegraph.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, 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 = "2019-04-01" + 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 +} diff --git a/services/resourcegraph/mgmt/2019-04-01/resourcegraph/resourcegraphapi/interfaces.go b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/resourcegraphapi/interfaces.go new file mode 100644 index 000000000000..3a14a46dafdd --- /dev/null +++ b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/resourcegraphapi/interfaces.go @@ -0,0 +1,37 @@ +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/resourcegraph/mgmt/2019-04-01/resourcegraph" +) + +// BaseClientAPI contains the set of methods on the BaseClient type. +type BaseClientAPI interface { + 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.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*resourcegraph.OperationsClient)(nil) diff --git a/services/resourcegraph/mgmt/2019-04-01/resourcegraph/version.go b/services/resourcegraph/mgmt/2019-04-01/resourcegraph/version.go new file mode 100644 index 000000000000..547f40455485 --- /dev/null +++ b/services/resourcegraph/mgmt/2019-04-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/2019-04-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}