armresourcegraph2

package
v0.0.0-...-0f4ba08 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: MIT, MIT Imports: 18 Imported by: 0

README

NOTE

This is a copy of the original package, adjusted for unmarshalling responses into custom types. All customisations are in zzz_custom.go file.

Azure Resource Graph Module for Go

PkgGoDev

The armresourcegraph module provides operations for working with Azure Resource Graph.

Source code

Getting started

Prerequisites

Install the package

This project uses Go modules for versioning and dependency management.

Install the Azure Resource Graph module:

go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph

Authorization

When creating a client, you will need to provide a credential for authenticating with Azure Resource Graph. The azidentity module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more.

cred, err := azidentity.NewDefaultAzureCredential(nil)

For more information on authentication, please see the documentation for azidentity at pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity.

Clients

Azure Resource Graph modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential.

client, err  := armresourcegraph.NewClient(<subscription ID>, cred, nil)

You can use ClientOptions in package github.com/Azure/azure-sdk-for-go/sdk/azcore/arm to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for azcore at pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore.

options := arm.ClientOptions {
    ClientOptions: azcore.ClientOptions {
        Cloud: cloud.AzureChina,
    },
}
client, err := armresourcegraph.NewClient(<subscription ID>, cred, &options)

Provide Feedback

If you encounter bugs or have suggestions, please open an issue and assign the Resource Graph label.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResourcesAll2

func ResourcesAll2[T any](client *Client, ctx context.Context, query QueryRequest) ([]T, error)

ResourcesAll2 is a convenience method which executes a query and returns all data unmarshalled into the specified type.

func ResourcesAll3

func ResourcesAll3(client *Client, ctx context.Context, query QueryRequest, out any) error

ResourcesAll3 is a convenience method which executes a query and returns all data unmarshalled into the specified type.

Types

type AuthorizationScopeFilter

type AuthorizationScopeFilter string

AuthorizationScopeFilter - Defines what level of authorization resources should be returned based on the which subscriptions and management groups are passed as scopes.

const (
	AuthorizationScopeFilterAtScopeAndBelow      AuthorizationScopeFilter = "AtScopeAndBelow"
	AuthorizationScopeFilterAtScopeAndAbove      AuthorizationScopeFilter = "AtScopeAndAbove"
	AuthorizationScopeFilterAtScopeExact         AuthorizationScopeFilter = "AtScopeExact"
	AuthorizationScopeFilterAtScopeAboveAndBelow AuthorizationScopeFilter = "AtScopeAboveAndBelow"
)

func PossibleAuthorizationScopeFilterValues

func PossibleAuthorizationScopeFilterValues() []AuthorizationScopeFilter

PossibleAuthorizationScopeFilterValues returns the possible values for the AuthorizationScopeFilter const type.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client contains the methods for the ResourceGraphClient group. Don't use this type directly, use NewClient() instead.

func NewClient

func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error)

NewClient creates a new instance of Client with the specified values. credential - used to authorize requests. Usually a credential from azidentity. options - pass nil to accept the default values.

func (*Client) Resources

func (client *Client) Resources(ctx context.Context, query QueryRequest, options *ClientResourcesOptions) (ClientResourcesResponse, error)

Resources - Queries the resources managed by Azure Resource Manager for scopes specified in the request. If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2021-06-01-preview query - Request specifying query and its options. options - ClientResourcesOptions contains the optional parameters for the Client.Resources method.

func (*Client) ResourcesHistory

ResourcesHistory - List all snapshots of a resource for a given time interval. If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2021-06-01-preview request - Request specifying the query and its options. options - ClientResourcesHistoryOptions contains the optional parameters for the Client.ResourcesHistory method.

type ClientResourcesHistoryOptions

type ClientResourcesHistoryOptions struct {
}

ClientResourcesHistoryOptions contains the optional parameters for the Client.ResourcesHistory method.

type ClientResourcesHistoryResponse

type ClientResourcesHistoryResponse struct {
	// Anything
	Interface interface{}
}

ClientResourcesHistoryResponse contains the response from method Client.ResourcesHistory.

type ClientResourcesOptions

type ClientResourcesOptions struct {
}

ClientResourcesOptions contains the optional parameters for the Client.Resources method.

type ClientResourcesResponse

type ClientResourcesResponse struct {
	QueryResponse
}

ClientResourcesResponse contains the response from method Client.Resources.

type Column

type Column struct {
	// REQUIRED; Column name.
	Name *string `json:"name,omitempty"`

	// REQUIRED; Column data type.
	Type *ColumnDataType `json:"type,omitempty"`
}

Column - Query result column descriptor.

type ColumnDataType

type ColumnDataType string

ColumnDataType - Data type of a column in a table.

const (
	ColumnDataTypeString   ColumnDataType = "string"
	ColumnDataTypeInteger  ColumnDataType = "integer"
	ColumnDataTypeNumber   ColumnDataType = "number"
	ColumnDataTypeBoolean  ColumnDataType = "boolean"
	ColumnDataTypeObject   ColumnDataType = "object"
	ColumnDataTypeDatetime ColumnDataType = "datetime"
)

func PossibleColumnDataTypeValues

func PossibleColumnDataTypeValues() []ColumnDataType

PossibleColumnDataTypeValues returns the possible values for the ColumnDataType const type.

type DateTimeInterval

type DateTimeInterval struct {
	// REQUIRED; 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 *time.Time `json:"end,omitempty"`

	// REQUIRED; 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 *time.Time `json:"start,omitempty"`
}

DateTimeInterval - An interval in time specifying the date and time for the inclusive start and exclusive end, i.e. [start, end).

func (DateTimeInterval) MarshalJSON

func (d DateTimeInterval) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type DateTimeInterval.

func (*DateTimeInterval) UnmarshalJSON

func (d *DateTimeInterval) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type DateTimeInterval.

type Error

type Error struct {
	// REQUIRED; Error code identifying the specific error.
	Code *string `json:"code,omitempty"`

	// REQUIRED; A human readable error message.
	Message *string `json:"message,omitempty"`

	// Error details
	Details []*ErrorDetails `json:"details,omitempty"`
}

Error details.

type ErrorDetails

type ErrorDetails struct {
	// REQUIRED; Error code identifying the specific error.
	Code *string `json:"code,omitempty"`

	// REQUIRED; A human readable error message.
	Message *string `json:"message,omitempty"`

	// OPTIONAL; Contains additional key/value pairs not defined in the schema.
	AdditionalProperties map[string]interface{}
}

ErrorDetails - Error details.

func (*ErrorDetails) UnmarshalJSON

func (e *ErrorDetails) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetails.

type ErrorResponse

type ErrorResponse struct {
	// REQUIRED; Error information.
	Error *Error `json:"error,omitempty"`
}

ErrorResponse - An error response from the API.

type Facet

type Facet struct {
	// REQUIRED; Facet expression, same as in the corresponding facet request.
	Expression *string `json:"expression,omitempty"`

	// REQUIRED; Result type
	ResultType *string `json:"resultType,omitempty"`
}

Facet - A facet containing additional statistics on the response of a query. Can be either FacetResult or FacetError.

func (*Facet) GetFacet

func (f *Facet) GetFacet() *Facet

GetFacet implements the FacetClassification interface for type Facet.

type FacetClassification

type FacetClassification interface {
	// GetFacet returns the Facet content of the underlying type.
	GetFacet() *Facet
}

FacetClassification provides polymorphic access to related types. Call the interface's GetFacet() method to access the common type. Use a type switch to determine the concrete type. The possible types are: - *Facet, *FacetError, *FacetResult

type FacetError

type FacetError struct {
	// REQUIRED; An array containing detected facet errors with details.
	Errors []*ErrorDetails `json:"errors,omitempty"`

	// REQUIRED; Facet expression, same as in the corresponding facet request.
	Expression *string `json:"expression,omitempty"`

	// REQUIRED; Result type
	ResultType *string `json:"resultType,omitempty"`
}

FacetError - A facet whose execution resulted in an error.

func (*FacetError) GetFacet

func (f *FacetError) GetFacet() *Facet

GetFacet implements the FacetClassification interface for type FacetError.

func (*FacetError) UnmarshalJSON

func (f *FacetError) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type FacetError.

type FacetRequest

type FacetRequest struct {
	// REQUIRED; The column or list of columns to summarize by
	Expression *string `json:"expression,omitempty"`

	// The options for facet evaluation
	Options *FacetRequestOptions `json:"options,omitempty"`
}

FacetRequest - A request to compute additional statistics (facets) over the query results.

type FacetRequestOptions

type FacetRequestOptions struct {
	// 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"`

	// The column name or query expression to sort on. Defaults to count if not present.
	SortBy *string `json:"sortBy,omitempty"`

	// The sorting order by the selected column (count by default).
	SortOrder *FacetSortOrder `json:"sortOrder,omitempty"`

	// The maximum number of facet rows that should be returned.
	Top *int32 `json:"$top,omitempty"`
}

FacetRequestOptions - The options for facet evaluation

type FacetResult

type FacetResult struct {
	// REQUIRED; Number of records returned in the facet response.
	Count *int32 `json:"count,omitempty"`

	// REQUIRED; A JObject array or Table containing the desired facets. Only present if the facet is valid.
	Data interface{} `json:"data,omitempty"`

	// REQUIRED; Facet expression, same as in the corresponding facet request.
	Expression *string `json:"expression,omitempty"`

	// REQUIRED; Result type
	ResultType *string `json:"resultType,omitempty"`

	// REQUIRED; Number of total records in the facet results.
	TotalRecords *int64 `json:"totalRecords,omitempty"`
}

FacetResult - Successfully executed facet containing additional statistics on the response of a query.

func (*FacetResult) GetFacet

func (f *FacetResult) GetFacet() *Facet

GetFacet implements the FacetClassification interface for type FacetResult.

func (*FacetResult) UnmarshalJSON

func (f *FacetResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type FacetResult.

type FacetSortOrder

type FacetSortOrder string

FacetSortOrder - The sorting order by the selected column (count by default).

const (
	FacetSortOrderAsc  FacetSortOrder = "asc"
	FacetSortOrderDesc FacetSortOrder = "desc"
)

func PossibleFacetSortOrderValues

func PossibleFacetSortOrderValues() []FacetSortOrder

PossibleFacetSortOrderValues returns the possible values for the FacetSortOrder const type.

type Operation

type Operation struct {
	// Display metadata associated with the operation.
	Display *OperationDisplay `json:"display,omitempty"`

	// Operation name: {provider}/{resource}/{operation}
	Name *string `json:"name,omitempty"`

	// The origin of operations.
	Origin *string `json:"origin,omitempty"`
}

Operation - Resource Graph REST API operation definition.

type OperationDisplay

type OperationDisplay struct {
	// Description for the operation.
	Description *string `json:"description,omitempty"`

	// Type of operation: get, read, delete, etc.
	Operation *string `json:"operation,omitempty"`

	// Service provider: Microsoft Resource Graph.
	Provider *string `json:"provider,omitempty"`

	// Resource on which the operation is performed etc.
	Resource *string `json:"resource,omitempty"`
}

OperationDisplay - Display metadata associated with the operation.

type OperationListResult

type OperationListResult struct {
	// List of Resource Graph operations supported by the Resource Graph resource provider.
	Value []*Operation `json:"value,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 OperationsClient

type OperationsClient struct {
	// contains filtered or unexported fields
}

OperationsClient contains the methods for the Operations group. Don't use this type directly, use NewOperationsClient() instead.

func NewOperationsClient

func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error)

NewOperationsClient creates a new instance of OperationsClient with the specified values. credential - used to authorize requests. Usually a credential from azidentity. options - pass nil to accept the default values.

func (*OperationsClient) NewListPager

NewListPager - Lists all of the available REST API operations. If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2021-06-01-preview options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method.

type OperationsClientListOptions

type OperationsClientListOptions struct {
}

OperationsClientListOptions contains the optional parameters for the OperationsClient.List method.

type OperationsClientListResponse

type OperationsClientListResponse struct {
	OperationListResult
}

OperationsClientListResponse contains the response from method OperationsClient.List.

type QueryRequest

type QueryRequest struct {
	// REQUIRED; The resources query.
	Query *string `json:"query,omitempty"`

	// An array of facet requests to be computed against the query result.
	Facets []*FacetRequest `json:"facets,omitempty"`

	// Azure management groups against which to execute the query. Example: [ 'mg1', 'mg2' ]
	ManagementGroups []*string `json:"managementGroups,omitempty"`

	// The query evaluation options
	Options *QueryRequestOptions `json:"options,omitempty"`

	// Azure subscriptions against which to execute the query.
	Subscriptions []*string `json:"subscriptions,omitempty"`
}

QueryRequest - Describes a query to be executed.

func (QueryRequest) MarshalJSON

func (q QueryRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type QueryRequest.

type QueryRequestOptions

type QueryRequestOptions struct {
	// Only applicable for tenant and management group level queries to decide whether to allow partial scopes for result in case
	// the number of subscriptions exceed allowed limits.
	AllowPartialScopes *bool `json:"allowPartialScopes,omitempty"`

	// Defines what level of authorization resources should be returned based on the which subscriptions and management groups
	// are passed as scopes.
	AuthorizationScopeFilter *AuthorizationScopeFilter `json:"authorizationScopeFilter,omitempty"`

	// Defines in which format query result returned.
	ResultFormat *ResultFormat `json:"resultFormat,omitempty"`

	// 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"`

	// Continuation token for pagination, capturing the next page size and offset, as well as the context of the query.
	SkipToken *string `json:"$skipToken,omitempty"`

	// The maximum number of rows that the query should return. Overrides the page size when $skipToken property is present.
	Top *int32 `json:"$top,omitempty"`
}

QueryRequestOptions - The options for query evaluation

type QueryResponse

type QueryResponse struct {
	// REQUIRED; 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"`

	// REQUIRED; Query output in JObject array or Table format.
	Data interface{} `json:"data,omitempty"`

	// REQUIRED; Indicates whether the query results are truncated.
	ResultTruncated *ResultTruncated `json:"resultTruncated,omitempty"`

	// REQUIRED; Number of total records matching the query.
	TotalRecords *int64 `json:"totalRecords,omitempty"`

	// Query facets.
	Facets []FacetClassification `json:"facets,omitempty"`

	// When present, the value can be passed to a subsequent query call (together with the same query and scopes used in the current
	// request) to retrieve the next page of data.
	SkipToken *string `json:"$skipToken,omitempty"`
}

QueryResponse - Query result.

func (*QueryResponse) UnmarshalJSON

func (q *QueryResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type QueryResponse.

type QueryResultPager2

type QueryResultPager2[T any] struct {
	// contains filtered or unexported fields
}

QueryResultPager2 iterates over the query result pages.

func Resources2

func Resources2[T any](client *Client, ctx context.Context, query QueryRequest) *QueryResultPager2[T]

Resources2 executes a query and returns data unmarshalled into the specified type.

func (*QueryResultPager2[T]) Get

func (q *QueryResultPager2[T]) Get() ([]T, error)

Get returns the data for the current page and advances to the next page.

func (*QueryResultPager2[T]) HasNext

func (q *QueryResultPager2[T]) HasNext() bool

HasNext tells if there is next page.

type QueryResultPager3

type QueryResultPager3 struct {
	// contains filtered or unexported fields
}

QueryResultPager3 iterates over the query result pages.

func Resources3

func Resources3(client *Client, ctx context.Context, query QueryRequest) *QueryResultPager3

Resources3 executes a query and returns data unmarshalled into the specified type.

func (*QueryResultPager3) Get

func (q *QueryResultPager3) Get(out any) error

Get returns the data for the current page and advances to the next page.

func (*QueryResultPager3) HasNext

func (q *QueryResultPager3) HasNext() bool

HasNext tells if there is next page.

type ResourcesHistoryRequest

type ResourcesHistoryRequest struct {
	// Azure management groups against which to execute the query. Example: [ 'mg1', 'mg2' ]
	ManagementGroups []*string `json:"managementGroups,omitempty"`

	// The history request evaluation options
	Options *ResourcesHistoryRequestOptions `json:"options,omitempty"`

	// The resources query.
	Query *string `json:"query,omitempty"`

	// Azure subscriptions against which to execute the query.
	Subscriptions []*string `json:"subscriptions,omitempty"`
}

ResourcesHistoryRequest - Describes a history request to be executed.

func (ResourcesHistoryRequest) MarshalJSON

func (r ResourcesHistoryRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ResourcesHistoryRequest.

type ResourcesHistoryRequestOptions

type ResourcesHistoryRequestOptions struct {
	// The time interval used to fetch history.
	Interval *DateTimeInterval `json:"interval,omitempty"`

	// Defines in which format query result returned.
	ResultFormat *ResultFormat `json:"resultFormat,omitempty"`

	// 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"`

	// Continuation token for pagination, capturing the next page size and offset, as well as the context of the query.
	SkipToken *string `json:"$skipToken,omitempty"`

	// The maximum number of rows that the query should return. Overrides the page size when $skipToken property is present.
	Top *int32 `json:"$top,omitempty"`
}

ResourcesHistoryRequestOptions - The options for history request evaluation

type ResultFormat

type ResultFormat string

ResultFormat - Defines in which format query result returned.

const (
	ResultFormatTable       ResultFormat = "table"
	ResultFormatObjectArray ResultFormat = "objectArray"
)

func PossibleResultFormatValues

func PossibleResultFormatValues() []ResultFormat

PossibleResultFormatValues returns the possible values for the ResultFormat const type.

type ResultTruncated

type ResultTruncated string

ResultTruncated - Indicates whether the query results are truncated.

const (
	ResultTruncatedTrue  ResultTruncated = "true"
	ResultTruncatedFalse ResultTruncated = "false"
)

func PossibleResultTruncatedValues

func PossibleResultTruncatedValues() []ResultTruncated

PossibleResultTruncatedValues returns the possible values for the ResultTruncated const type.

type Table

type Table struct {
	// REQUIRED; Query result column descriptors.
	Columns []*Column `json:"columns,omitempty"`

	// REQUIRED; Query result rows.
	Rows [][]interface{} `json:"rows,omitempty"`
}

Table - Query output in tabular format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL