[Release] sdk/resourcemanager/databoundaries/armdataboundaries/0.1.0 (#23610)
* [Release] sdk/resourcemanager/databoundaries/armdataboundaries/1.0.0 generation from spec commit: d426a4238db8dcd4da1c03c2c380fa27628093e7 * update * change version * format
This commit is contained in:
Родитель
de1c93f661
Коммит
e236888b07
|
@ -0,0 +1,8 @@
|
|||
# Release History
|
||||
|
||||
## 0.1.0 (2024-10-21)
|
||||
### Other Changes
|
||||
|
||||
The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html).
|
||||
|
||||
To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt).
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,92 @@
|
|||
# Azure Data Boundary Module for Go
|
||||
|
||||
[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries)
|
||||
|
||||
The `armdataboundaries` module provides operations for working with Azure Data Boundary.
|
||||
|
||||
[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/databoundaries/armdataboundaries)
|
||||
|
||||
# Getting started
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- an [Azure subscription](https://azure.microsoft.com/free/)
|
||||
- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).)
|
||||
|
||||
## Install the package
|
||||
|
||||
This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management.
|
||||
|
||||
Install the Azure Data Boundary module:
|
||||
|
||||
```sh
|
||||
go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries
|
||||
```
|
||||
|
||||
## Authorization
|
||||
|
||||
When creating a client, you will need to provide a credential for authenticating with Azure Data Boundary. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more.
|
||||
|
||||
```go
|
||||
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](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity).
|
||||
|
||||
## Client Factory
|
||||
|
||||
Azure Data Boundary module consists of one or more clients. We provide a client factory which could be used to create any client in this module.
|
||||
|
||||
```go
|
||||
clientFactory, err := armdataboundaries.NewClientFactory(<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](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore).
|
||||
|
||||
```go
|
||||
options := arm.ClientOptions {
|
||||
ClientOptions: azcore.ClientOptions {
|
||||
Cloud: cloud.AzureChina,
|
||||
},
|
||||
}
|
||||
clientFactory, err := armdataboundaries.NewClientFactory(<subscription ID>, cred, &options)
|
||||
```
|
||||
|
||||
## Clients
|
||||
|
||||
A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory.
|
||||
|
||||
```go
|
||||
client := clientFactory.()
|
||||
```
|
||||
|
||||
## Fakes
|
||||
|
||||
The fake package contains types used for constructing in-memory fake servers used in unit tests.
|
||||
This allows writing tests to cover various success/error conditions without the need for connecting to a live service.
|
||||
|
||||
Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes.
|
||||
|
||||
## Provide Feedback
|
||||
|
||||
If you encounter bugs or have suggestions, please
|
||||
[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Data Boundary` 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](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](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information, see the
|
||||
[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
|
||||
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any
|
||||
additional questions or comments.
|
|
@ -0,0 +1,13 @@
|
|||
### AutoRest Configuration
|
||||
|
||||
> see https://aka.ms/autorest
|
||||
|
||||
``` yaml
|
||||
azure-arm: true
|
||||
require:
|
||||
- https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/readme.md
|
||||
- https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/readme.go.md
|
||||
license-header: MICROSOFT_MIT_NO_VERSION
|
||||
module-version: 0.1.0
|
||||
package-databoundaries: true
|
||||
```
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
// This file enables 'go generate' to regenerate this specific SDK
|
||||
//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/databoundaries/armdataboundaries
|
||||
|
||||
package armdataboundaries
|
|
@ -0,0 +1,28 @@
|
|||
# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- main
|
||||
- feature/*
|
||||
- hotfix/*
|
||||
- release/*
|
||||
paths:
|
||||
include:
|
||||
- sdk/resourcemanager/databoundaries/armdataboundaries/
|
||||
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- main
|
||||
- feature/*
|
||||
- hotfix/*
|
||||
- release/*
|
||||
paths:
|
||||
include:
|
||||
- sdk/resourcemanager/databoundaries/armdataboundaries/
|
||||
|
||||
extends:
|
||||
template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
|
||||
parameters:
|
||||
IncludeRelease: true
|
||||
ServiceDirectory: 'resourcemanager/databoundaries/armdataboundaries'
|
|
@ -0,0 +1,212 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armdataboundaries
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Client contains the methods for the DataBoundaries group.
|
||||
// Don't use this type directly, use NewClient() instead.
|
||||
type Client struct {
|
||||
internal *arm.Client
|
||||
}
|
||||
|
||||
// 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 NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) {
|
||||
cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client := &Client{
|
||||
internal: cl,
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// GetScope - Get data boundary at specified scope
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
//
|
||||
// Generated from API version 2024-08-01
|
||||
// - scope - The scope at which the operation is performed.
|
||||
// - defaultParam - Default string modeled as parameter for auto generation to work correctly.
|
||||
// - options - ClientGetScopeOptions contains the optional parameters for the Client.GetScope method.
|
||||
func (client *Client) GetScope(ctx context.Context, scope string, defaultParam DefaultName, options *ClientGetScopeOptions) (ClientGetScopeResponse, error) {
|
||||
var err error
|
||||
const operationName = "Client.GetScope"
|
||||
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
|
||||
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
|
||||
defer func() { endSpan(err) }()
|
||||
req, err := client.getScopeCreateRequest(ctx, scope, defaultParam, options)
|
||||
if err != nil {
|
||||
return ClientGetScopeResponse{}, err
|
||||
}
|
||||
httpResp, err := client.internal.Pipeline().Do(req)
|
||||
if err != nil {
|
||||
return ClientGetScopeResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(httpResp, http.StatusOK) {
|
||||
err = runtime.NewResponseError(httpResp)
|
||||
return ClientGetScopeResponse{}, err
|
||||
}
|
||||
resp, err := client.getScopeHandleResponse(httpResp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// getScopeCreateRequest creates the GetScope request.
|
||||
func (client *Client) getScopeCreateRequest(ctx context.Context, scope string, defaultParam DefaultName, options *ClientGetScopeOptions) (*policy.Request, error) {
|
||||
urlPath := "/{scope}/providers/Microsoft.Resources/dataBoundaries/{default}"
|
||||
urlPath = strings.ReplaceAll(urlPath, "{scope}", scope)
|
||||
if defaultParam == "" {
|
||||
return nil, errors.New("parameter defaultParam cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{default}", url.PathEscape(string(defaultParam)))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2024-08-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header["Accept"] = []string{"application/json"}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// getScopeHandleResponse handles the GetScope response.
|
||||
func (client *Client) getScopeHandleResponse(resp *http.Response) (ClientGetScopeResponse, error) {
|
||||
result := ClientGetScopeResponse{}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.DataBoundaryDefinition); err != nil {
|
||||
return ClientGetScopeResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetTenant - Get data boundary of tenant.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
//
|
||||
// Generated from API version 2024-08-01
|
||||
// - defaultParam - Default string modeled as parameter for auto generation to work correctly.
|
||||
// - options - ClientGetTenantOptions contains the optional parameters for the Client.GetTenant method.
|
||||
func (client *Client) GetTenant(ctx context.Context, defaultParam DefaultName, options *ClientGetTenantOptions) (ClientGetTenantResponse, error) {
|
||||
var err error
|
||||
const operationName = "Client.GetTenant"
|
||||
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
|
||||
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
|
||||
defer func() { endSpan(err) }()
|
||||
req, err := client.getTenantCreateRequest(ctx, defaultParam, options)
|
||||
if err != nil {
|
||||
return ClientGetTenantResponse{}, err
|
||||
}
|
||||
httpResp, err := client.internal.Pipeline().Do(req)
|
||||
if err != nil {
|
||||
return ClientGetTenantResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(httpResp, http.StatusOK) {
|
||||
err = runtime.NewResponseError(httpResp)
|
||||
return ClientGetTenantResponse{}, err
|
||||
}
|
||||
resp, err := client.getTenantHandleResponse(httpResp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// getTenantCreateRequest creates the GetTenant request.
|
||||
func (client *Client) getTenantCreateRequest(ctx context.Context, defaultParam DefaultName, options *ClientGetTenantOptions) (*policy.Request, error) {
|
||||
urlPath := "/providers/Microsoft.Resources/dataBoundaries/{default}"
|
||||
if defaultParam == "" {
|
||||
return nil, errors.New("parameter defaultParam cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{default}", url.PathEscape(string(defaultParam)))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2024-08-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header["Accept"] = []string{"application/json"}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// getTenantHandleResponse handles the GetTenant response.
|
||||
func (client *Client) getTenantHandleResponse(resp *http.Response) (ClientGetTenantResponse, error) {
|
||||
result := ClientGetTenantResponse{}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.DataBoundaryDefinition); err != nil {
|
||||
return ClientGetTenantResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Put - Opt-in tenant to data boundary.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
//
|
||||
// Generated from API version 2024-08-01
|
||||
// - defaultParam - Default string modeled as parameter for auto generation to work correctly.
|
||||
// - dataBoundaryDefinition - The data boundary to opt the tenant to.
|
||||
// - options - ClientPutOptions contains the optional parameters for the Client.Put method.
|
||||
func (client *Client) Put(ctx context.Context, defaultParam DefaultName, dataBoundaryDefinition DataBoundaryDefinition, options *ClientPutOptions) (ClientPutResponse, error) {
|
||||
var err error
|
||||
const operationName = "Client.Put"
|
||||
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
|
||||
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
|
||||
defer func() { endSpan(err) }()
|
||||
req, err := client.putCreateRequest(ctx, defaultParam, dataBoundaryDefinition, options)
|
||||
if err != nil {
|
||||
return ClientPutResponse{}, err
|
||||
}
|
||||
httpResp, err := client.internal.Pipeline().Do(req)
|
||||
if err != nil {
|
||||
return ClientPutResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) {
|
||||
err = runtime.NewResponseError(httpResp)
|
||||
return ClientPutResponse{}, err
|
||||
}
|
||||
resp, err := client.putHandleResponse(httpResp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// putCreateRequest creates the Put request.
|
||||
func (client *Client) putCreateRequest(ctx context.Context, defaultParam DefaultName, dataBoundaryDefinition DataBoundaryDefinition, options *ClientPutOptions) (*policy.Request, error) {
|
||||
urlPath := "/providers/Microsoft.Resources/dataBoundaries/{default}"
|
||||
if defaultParam == "" {
|
||||
return nil, errors.New("parameter defaultParam cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{default}", url.PathEscape(string(defaultParam)))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2024-08-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header["Accept"] = []string{"application/json"}
|
||||
if err := runtime.MarshalAsJSON(req, dataBoundaryDefinition); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// putHandleResponse handles the Put response.
|
||||
func (client *Client) putHandleResponse(resp *http.Response) (ClientPutResponse, error) {
|
||||
result := ClientPutResponse{}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.DataBoundaryDefinition); err != nil {
|
||||
return ClientPutResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
// DO NOT EDIT.
|
||||
|
||||
package armdataboundaries_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries"
|
||||
)
|
||||
|
||||
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json
|
||||
func ExampleClient_Put() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
clientFactory, err := armdataboundaries.NewClientFactory(cred, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create client: %v", err)
|
||||
}
|
||||
res, err := clientFactory.NewClient().Put(ctx, armdataboundaries.DefaultNameDefault, armdataboundaries.DataBoundaryDefinition{
|
||||
Properties: &armdataboundaries.DataBoundaryProperties{
|
||||
DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU),
|
||||
},
|
||||
}, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to finish the request: %v", err)
|
||||
}
|
||||
// You could use response here. We use blank identifier for just demo purposes.
|
||||
_ = res
|
||||
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
|
||||
// res.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{
|
||||
// Name: to.Ptr("00000000-0000-0000-0000-000000000000"),
|
||||
// ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"),
|
||||
// Properties: &armdataboundaries.DataBoundaryProperties{
|
||||
// DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU),
|
||||
// ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded),
|
||||
// },
|
||||
// }
|
||||
}
|
||||
|
||||
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json
|
||||
func ExampleClient_GetTenant() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
clientFactory, err := armdataboundaries.NewClientFactory(cred, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create client: %v", err)
|
||||
}
|
||||
res, err := clientFactory.NewClient().GetTenant(ctx, armdataboundaries.DefaultNameDefault, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to finish the request: %v", err)
|
||||
}
|
||||
// You could use response here. We use blank identifier for just demo purposes.
|
||||
_ = res
|
||||
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
|
||||
// res.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{
|
||||
// Name: to.Ptr("00000000-0000-0000-0000-000000000000"),
|
||||
// ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"),
|
||||
// Properties: &armdataboundaries.DataBoundaryProperties{
|
||||
// DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU),
|
||||
// ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded),
|
||||
// },
|
||||
// }
|
||||
}
|
||||
|
||||
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetScopedDataBoundary.json
|
||||
func ExampleClient_GetScope() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
clientFactory, err := armdataboundaries.NewClientFactory(cred, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create client: %v", err)
|
||||
}
|
||||
res, err := clientFactory.NewClient().GetScope(ctx, "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group", armdataboundaries.DefaultNameDefault, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to finish the request: %v", err)
|
||||
}
|
||||
// You could use response here. We use blank identifier for just demo purposes.
|
||||
_ = res
|
||||
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
|
||||
// res.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{
|
||||
// Name: to.Ptr("00000000-0000-0000-0000-000000000000"),
|
||||
// ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"),
|
||||
// Properties: &armdataboundaries.DataBoundaryProperties{
|
||||
// DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU),
|
||||
// ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded),
|
||||
// },
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armdataboundaries
|
||||
|
||||
import (
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
|
||||
)
|
||||
|
||||
// ClientFactory is a client factory used to create any client in this module.
|
||||
// Don't use this type directly, use NewClientFactory instead.
|
||||
type ClientFactory struct {
|
||||
internal *arm.Client
|
||||
}
|
||||
|
||||
// NewClientFactory creates a new instance of ClientFactory with the specified values.
|
||||
// The parameter values will be propagated to any client created from this factory.
|
||||
// - credential - used to authorize requests. Usually a credential from azidentity.
|
||||
// - options - pass nil to accept the default values.
|
||||
func NewClientFactory(credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) {
|
||||
internal, err := arm.NewClient(moduleName, moduleVersion, credential, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ClientFactory{
|
||||
internal: internal,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewClient creates a new instance of Client.
|
||||
func (c *ClientFactory) NewClient() *Client {
|
||||
return &Client{
|
||||
internal: c.internal,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armdataboundaries
|
||||
|
||||
const (
|
||||
moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries"
|
||||
moduleVersion = "v0.1.0"
|
||||
)
|
||||
|
||||
// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.
|
||||
type ActionType string
|
||||
|
||||
const (
|
||||
ActionTypeInternal ActionType = "Internal"
|
||||
)
|
||||
|
||||
// PossibleActionTypeValues returns the possible values for the ActionType const type.
|
||||
func PossibleActionTypeValues() []ActionType {
|
||||
return []ActionType{
|
||||
ActionTypeInternal,
|
||||
}
|
||||
}
|
||||
|
||||
// CreatedByType - The type of identity that created the resource.
|
||||
type CreatedByType string
|
||||
|
||||
const (
|
||||
CreatedByTypeApplication CreatedByType = "Application"
|
||||
CreatedByTypeKey CreatedByType = "Key"
|
||||
CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity"
|
||||
CreatedByTypeUser CreatedByType = "User"
|
||||
)
|
||||
|
||||
// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type.
|
||||
func PossibleCreatedByTypeValues() []CreatedByType {
|
||||
return []CreatedByType{
|
||||
CreatedByTypeApplication,
|
||||
CreatedByTypeKey,
|
||||
CreatedByTypeManagedIdentity,
|
||||
CreatedByTypeUser,
|
||||
}
|
||||
}
|
||||
|
||||
// DataBoundary - The data boundary definition.
|
||||
type DataBoundary string
|
||||
|
||||
const (
|
||||
DataBoundaryEU DataBoundary = "EU"
|
||||
DataBoundaryGlobal DataBoundary = "Global"
|
||||
DataBoundaryNotDefined DataBoundary = "NotDefined"
|
||||
)
|
||||
|
||||
// PossibleDataBoundaryValues returns the possible values for the DataBoundary const type.
|
||||
func PossibleDataBoundaryValues() []DataBoundary {
|
||||
return []DataBoundary{
|
||||
DataBoundaryEU,
|
||||
DataBoundaryGlobal,
|
||||
DataBoundaryNotDefined,
|
||||
}
|
||||
}
|
||||
|
||||
type DefaultName string
|
||||
|
||||
const (
|
||||
DefaultNameDefault DefaultName = "default"
|
||||
)
|
||||
|
||||
// PossibleDefaultNameValues returns the possible values for the DefaultName const type.
|
||||
func PossibleDefaultNameValues() []DefaultName {
|
||||
return []DefaultName{
|
||||
DefaultNameDefault,
|
||||
}
|
||||
}
|
||||
|
||||
// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default
|
||||
// value is "user,system"
|
||||
type Origin string
|
||||
|
||||
const (
|
||||
OriginSystem Origin = "system"
|
||||
OriginUser Origin = "user"
|
||||
OriginUserSystem Origin = "user,system"
|
||||
)
|
||||
|
||||
// PossibleOriginValues returns the possible values for the Origin const type.
|
||||
func PossibleOriginValues() []Origin {
|
||||
return []Origin{
|
||||
OriginSystem,
|
||||
OriginUser,
|
||||
OriginUserSystem,
|
||||
}
|
||||
}
|
||||
|
||||
// ProvisioningState - Denotes the state of provisioning.
|
||||
type ProvisioningState string
|
||||
|
||||
const (
|
||||
ProvisioningStateAccepted ProvisioningState = "Accepted"
|
||||
ProvisioningStateCanceled ProvisioningState = "Canceled"
|
||||
ProvisioningStateCreating ProvisioningState = "Creating"
|
||||
ProvisioningStateFailed ProvisioningState = "Failed"
|
||||
ProvisioningStateRunning ProvisioningState = "Running"
|
||||
ProvisioningStateSucceeded ProvisioningState = "Succeeded"
|
||||
ProvisioningStateUpdating ProvisioningState = "Updating"
|
||||
)
|
||||
|
||||
// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type.
|
||||
func PossibleProvisioningStateValues() []ProvisioningState {
|
||||
return []ProvisioningState{
|
||||
ProvisioningStateAccepted,
|
||||
ProvisioningStateCanceled,
|
||||
ProvisioningStateCreating,
|
||||
ProvisioningStateFailed,
|
||||
ProvisioningStateRunning,
|
||||
ProvisioningStateSucceeded,
|
||||
ProvisioningStateUpdating,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type nonRetriableError struct {
|
||||
error
|
||||
}
|
||||
|
||||
func (nonRetriableError) NonRetriable() {
|
||||
// marker method
|
||||
}
|
||||
|
||||
func contains[T comparable](s []T, v T) bool {
|
||||
for _, vv := range s {
|
||||
if vv == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func parseWithCast[T any](v string, parse func(v string) (T, error)) (T, error) {
|
||||
t, err := parse(v)
|
||||
if err != nil {
|
||||
return *new(T), err
|
||||
}
|
||||
return t, err
|
||||
}
|
||||
|
||||
func newTracker[T any]() *tracker[T] {
|
||||
return &tracker[T]{
|
||||
items: map[string]*T{},
|
||||
}
|
||||
}
|
||||
|
||||
type tracker[T any] struct {
|
||||
items map[string]*T
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (p *tracker[T]) get(req *http.Request) *T {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok {
|
||||
return item
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *tracker[T]) add(req *http.Request, item *T) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item
|
||||
}
|
||||
|
||||
func (p *tracker[T]) remove(req *http.Request) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
delete(p.items, server.SanitizePagerPollerPath(req.URL.Path))
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// Server is a fake server for instances of the armdataboundaries.Client type.
|
||||
type Server struct {
|
||||
// GetScope is the fake for method Client.GetScope
|
||||
// HTTP status codes to indicate success: http.StatusOK
|
||||
GetScope func(ctx context.Context, scope string, defaultParam armdataboundaries.DefaultName, options *armdataboundaries.ClientGetScopeOptions) (resp azfake.Responder[armdataboundaries.ClientGetScopeResponse], errResp azfake.ErrorResponder)
|
||||
|
||||
// GetTenant is the fake for method Client.GetTenant
|
||||
// HTTP status codes to indicate success: http.StatusOK
|
||||
GetTenant func(ctx context.Context, defaultParam armdataboundaries.DefaultName, options *armdataboundaries.ClientGetTenantOptions) (resp azfake.Responder[armdataboundaries.ClientGetTenantResponse], errResp azfake.ErrorResponder)
|
||||
|
||||
// Put is the fake for method Client.Put
|
||||
// HTTP status codes to indicate success: http.StatusOK, http.StatusCreated
|
||||
Put func(ctx context.Context, defaultParam armdataboundaries.DefaultName, dataBoundaryDefinition armdataboundaries.DataBoundaryDefinition, options *armdataboundaries.ClientPutOptions) (resp azfake.Responder[armdataboundaries.ClientPutResponse], errResp azfake.ErrorResponder)
|
||||
}
|
||||
|
||||
// NewServerTransport creates a new instance of ServerTransport with the provided implementation.
|
||||
// The returned ServerTransport instance is connected to an instance of armdataboundaries.Client via the
|
||||
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
|
||||
func NewServerTransport(srv *Server) *ServerTransport {
|
||||
return &ServerTransport{srv: srv}
|
||||
}
|
||||
|
||||
// ServerTransport connects instances of armdataboundaries.Client to instances of Server.
|
||||
// Don't use this type directly, use NewServerTransport instead.
|
||||
type ServerTransport struct {
|
||||
srv *Server
|
||||
}
|
||||
|
||||
// Do implements the policy.Transporter interface for ServerTransport.
|
||||
func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) {
|
||||
rawMethod := req.Context().Value(runtime.CtxAPINameKey{})
|
||||
method, ok := rawMethod.(string)
|
||||
if !ok {
|
||||
return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")}
|
||||
}
|
||||
|
||||
var resp *http.Response
|
||||
var err error
|
||||
|
||||
switch method {
|
||||
case "Client.GetScope":
|
||||
resp, err = s.dispatchGetScope(req)
|
||||
case "Client.GetTenant":
|
||||
resp, err = s.dispatchGetTenant(req)
|
||||
case "Client.Put":
|
||||
resp, err = s.dispatchPut(req)
|
||||
default:
|
||||
err = fmt.Errorf("unhandled API %s", method)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *ServerTransport) dispatchGetScope(req *http.Request) (*http.Response, error) {
|
||||
if s.srv.GetScope == nil {
|
||||
return nil, &nonRetriableError{errors.New("fake for method GetScope not implemented")}
|
||||
}
|
||||
const regexStr = `/(?P<scope>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/dataBoundaries/(?P<default>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
|
||||
regex := regexp.MustCompile(regexStr)
|
||||
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
|
||||
if matches == nil || len(matches) < 2 {
|
||||
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
|
||||
}
|
||||
scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defaultParamParam, err := parseWithCast(matches[regex.SubexpIndex("default")], func(v string) (armdataboundaries.DefaultName, error) {
|
||||
p, unescapeErr := url.PathUnescape(v)
|
||||
if unescapeErr != nil {
|
||||
return "", unescapeErr
|
||||
}
|
||||
return armdataboundaries.DefaultName(p), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
respr, errRespr := s.srv.GetScope(req.Context(), scopeParam, defaultParamParam, nil)
|
||||
if respErr := server.GetError(errRespr, req); respErr != nil {
|
||||
return nil, respErr
|
||||
}
|
||||
respContent := server.GetResponseContent(respr)
|
||||
if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
|
||||
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
|
||||
}
|
||||
resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataBoundaryDefinition, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *ServerTransport) dispatchGetTenant(req *http.Request) (*http.Response, error) {
|
||||
if s.srv.GetTenant == nil {
|
||||
return nil, &nonRetriableError{errors.New("fake for method GetTenant not implemented")}
|
||||
}
|
||||
const regexStr = `/providers/Microsoft\.Resources/dataBoundaries/(?P<default>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
|
||||
regex := regexp.MustCompile(regexStr)
|
||||
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
|
||||
if matches == nil || len(matches) < 1 {
|
||||
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
|
||||
}
|
||||
defaultParamParam, err := parseWithCast(matches[regex.SubexpIndex("default")], func(v string) (armdataboundaries.DefaultName, error) {
|
||||
p, unescapeErr := url.PathUnescape(v)
|
||||
if unescapeErr != nil {
|
||||
return "", unescapeErr
|
||||
}
|
||||
return armdataboundaries.DefaultName(p), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
respr, errRespr := s.srv.GetTenant(req.Context(), defaultParamParam, nil)
|
||||
if respErr := server.GetError(errRespr, req); respErr != nil {
|
||||
return nil, respErr
|
||||
}
|
||||
respContent := server.GetResponseContent(respr)
|
||||
if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
|
||||
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
|
||||
}
|
||||
resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataBoundaryDefinition, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *ServerTransport) dispatchPut(req *http.Request) (*http.Response, error) {
|
||||
if s.srv.Put == nil {
|
||||
return nil, &nonRetriableError{errors.New("fake for method Put not implemented")}
|
||||
}
|
||||
const regexStr = `/providers/Microsoft\.Resources/dataBoundaries/(?P<default>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
|
||||
regex := regexp.MustCompile(regexStr)
|
||||
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
|
||||
if matches == nil || len(matches) < 1 {
|
||||
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
|
||||
}
|
||||
body, err := server.UnmarshalRequestAsJSON[armdataboundaries.DataBoundaryDefinition](req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defaultParamParam, err := parseWithCast(matches[regex.SubexpIndex("default")], func(v string) (armdataboundaries.DefaultName, error) {
|
||||
p, unescapeErr := url.PathUnescape(v)
|
||||
if unescapeErr != nil {
|
||||
return "", unescapeErr
|
||||
}
|
||||
return armdataboundaries.DefaultName(p), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
respr, errRespr := s.srv.Put(req.Context(), defaultParamParam, body, nil)
|
||||
if respErr := server.GetError(errRespr, req); respErr != nil {
|
||||
return nil, respErr
|
||||
}
|
||||
respContent := server.GetResponseContent(respr)
|
||||
if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) {
|
||||
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)}
|
||||
}
|
||||
resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataBoundaryDefinition, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// ServerFactory is a fake server for instances of the armdataboundaries.ClientFactory type.
|
||||
type ServerFactory struct {
|
||||
Server Server
|
||||
}
|
||||
|
||||
// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation.
|
||||
// The returned ServerFactoryTransport instance is connected to an instance of armdataboundaries.ClientFactory via the
|
||||
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
|
||||
func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport {
|
||||
return &ServerFactoryTransport{
|
||||
srv: srv,
|
||||
}
|
||||
}
|
||||
|
||||
// ServerFactoryTransport connects instances of armdataboundaries.ClientFactory to instances of ServerFactory.
|
||||
// Don't use this type directly, use NewServerFactoryTransport instead.
|
||||
type ServerFactoryTransport struct {
|
||||
srv *ServerFactory
|
||||
trMu sync.Mutex
|
||||
trServer *ServerTransport
|
||||
}
|
||||
|
||||
// Do implements the policy.Transporter interface for ServerFactoryTransport.
|
||||
func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) {
|
||||
rawMethod := req.Context().Value(runtime.CtxAPINameKey{})
|
||||
method, ok := rawMethod.(string)
|
||||
if !ok {
|
||||
return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")}
|
||||
}
|
||||
|
||||
client := method[:strings.Index(method, ".")]
|
||||
var resp *http.Response
|
||||
var err error
|
||||
|
||||
switch client {
|
||||
case "Client":
|
||||
initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) })
|
||||
resp, err = s.trServer.Do(req)
|
||||
default:
|
||||
err = fmt.Errorf("unhandled client %s", client)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) {
|
||||
s.trMu.Lock()
|
||||
if *dst == nil {
|
||||
*dst = src()
|
||||
}
|
||||
s.trMu.Unlock()
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases.
|
||||
var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`)
|
||||
|
||||
const (
|
||||
utcDateTime = "2006-01-02T15:04:05.999999999"
|
||||
utcDateTimeJSON = `"` + utcDateTime + `"`
|
||||
utcDateTimeNoT = "2006-01-02 15:04:05.999999999"
|
||||
utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"`
|
||||
dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00`
|
||||
dateTimeJSON = `"` + time.RFC3339Nano + `"`
|
||||
dateTimeJSONNoT = `"` + dateTimeNoT + `"`
|
||||
)
|
||||
|
||||
type dateTimeRFC3339 time.Time
|
||||
|
||||
func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) {
|
||||
tt := time.Time(t)
|
||||
return tt.MarshalJSON()
|
||||
}
|
||||
|
||||
func (t dateTimeRFC3339) MarshalText() ([]byte, error) {
|
||||
tt := time.Time(t)
|
||||
return tt.MarshalText()
|
||||
}
|
||||
|
||||
func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error {
|
||||
tzOffset := tzOffsetRegex.Match(data)
|
||||
hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t")
|
||||
var layout string
|
||||
if tzOffset && hasT {
|
||||
layout = dateTimeJSON
|
||||
} else if tzOffset {
|
||||
layout = dateTimeJSONNoT
|
||||
} else if hasT {
|
||||
layout = utcDateTimeJSON
|
||||
} else {
|
||||
layout = utcDateTimeJSONNoT
|
||||
}
|
||||
return t.Parse(layout, string(data))
|
||||
}
|
||||
|
||||
func (t *dateTimeRFC3339) UnmarshalText(data []byte) error {
|
||||
tzOffset := tzOffsetRegex.Match(data)
|
||||
hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t")
|
||||
var layout string
|
||||
if tzOffset && hasT {
|
||||
layout = time.RFC3339Nano
|
||||
} else if tzOffset {
|
||||
layout = dateTimeNoT
|
||||
} else if hasT {
|
||||
layout = utcDateTime
|
||||
} else {
|
||||
layout = utcDateTimeNoT
|
||||
}
|
||||
return t.Parse(layout, string(data))
|
||||
}
|
||||
|
||||
func (t *dateTimeRFC3339) Parse(layout, value string) error {
|
||||
p, err := time.Parse(layout, strings.ToUpper(value))
|
||||
*t = dateTimeRFC3339(p)
|
||||
return err
|
||||
}
|
||||
|
||||
func (t dateTimeRFC3339) String() string {
|
||||
return time.Time(t).Format(time.RFC3339Nano)
|
||||
}
|
||||
|
||||
func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) {
|
||||
if t == nil {
|
||||
return
|
||||
} else if azcore.IsNullValue(t) {
|
||||
m[k] = nil
|
||||
return
|
||||
} else if reflect.ValueOf(t).IsNil() {
|
||||
return
|
||||
}
|
||||
m[k] = (*dateTimeRFC3339)(t)
|
||||
}
|
||||
|
||||
func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error {
|
||||
if data == nil || string(data) == "null" {
|
||||
return nil
|
||||
}
|
||||
var aux dateTimeRFC3339
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return fmt.Errorf("struct field %s: %v", fn, err)
|
||||
}
|
||||
*t = (*time.Time)(&aux)
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/kylelemons/godebug v1.1.0 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
golang.org/x/crypto v0.27.0 // indirect
|
||||
golang.org/x/net v0.29.0 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
golang.org/x/text v0.18.0 // indirect
|
||||
)
|
|
@ -0,0 +1,35 @@
|
|||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 h1:B/dfvscEQtew9dVuoxqxrUKKv8Ih2f55PydknDamU+g=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0/go.mod h1:fiPSssYvltE08HJchL04dOy+RD4hgrjph0cwGGMntdI=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.0 h1:+m0M/LFxN43KvULkDNfdXOgrjtg6UYJPFBJyuEcRCAw=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY=
|
||||
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
||||
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
@ -0,0 +1,108 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armdataboundaries
|
||||
|
||||
import "time"
|
||||
|
||||
// DataBoundaryDefinition - A data boundary definition.
|
||||
type DataBoundaryDefinition struct {
|
||||
// Data boundary properties
|
||||
Properties *DataBoundaryProperties
|
||||
|
||||
// READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
||||
ID *string
|
||||
|
||||
// READ-ONLY; The name of the resource
|
||||
Name *string
|
||||
|
||||
// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
||||
SystemData *SystemData
|
||||
|
||||
// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
||||
Type *string
|
||||
}
|
||||
|
||||
// DataBoundaryProperties - Data boundary properties
|
||||
type DataBoundaryProperties struct {
|
||||
// The data boundary definition.
|
||||
DataBoundary *DataBoundary
|
||||
|
||||
// READ-ONLY; Denotes the state of provisioning.
|
||||
ProvisioningState *ProvisioningState
|
||||
}
|
||||
|
||||
// Operation - Details of a REST API operation, returned from the Resource Provider Operations API
|
||||
type Operation struct {
|
||||
// Localized display information for this particular operation.
|
||||
Display *OperationDisplay
|
||||
|
||||
// READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.
|
||||
ActionType *ActionType
|
||||
|
||||
// READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane
|
||||
// operations.
|
||||
IsDataAction *bool
|
||||
|
||||
// READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write",
|
||||
// "Microsoft.Compute/virtualMachines/capture/action"
|
||||
Name *string
|
||||
|
||||
// READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default
|
||||
// value is "user,system"
|
||||
Origin *Origin
|
||||
}
|
||||
|
||||
// OperationDisplay - Localized display information for this particular operation.
|
||||
type OperationDisplay struct {
|
||||
// READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views.
|
||||
Description *string
|
||||
|
||||
// READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual
|
||||
// Machine", "Restart Virtual Machine".
|
||||
Operation *string
|
||||
|
||||
// READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft
|
||||
// Compute".
|
||||
Provider *string
|
||||
|
||||
// READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job
|
||||
// Schedule Collections".
|
||||
Resource *string
|
||||
}
|
||||
|
||||
// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to
|
||||
// get the next set of results.
|
||||
type OperationListResult struct {
|
||||
// READ-ONLY; URL to get the next set of operation list results (if there are any).
|
||||
NextLink *string
|
||||
|
||||
// READ-ONLY; List of operations supported by the resource provider
|
||||
Value []*Operation
|
||||
}
|
||||
|
||||
// SystemData - Metadata pertaining to creation and last modification of the resource.
|
||||
type SystemData struct {
|
||||
// The timestamp of resource creation (UTC).
|
||||
CreatedAt *time.Time
|
||||
|
||||
// The identity that created the resource.
|
||||
CreatedBy *string
|
||||
|
||||
// The type of identity that created the resource.
|
||||
CreatedByType *CreatedByType
|
||||
|
||||
// The timestamp of resource last modification (UTC)
|
||||
LastModifiedAt *time.Time
|
||||
|
||||
// The identity that last modified the resource.
|
||||
LastModifiedBy *string
|
||||
|
||||
// The type of identity that last modified the resource.
|
||||
LastModifiedByType *CreatedByType
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armdataboundaries
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type DataBoundaryDefinition.
|
||||
func (d DataBoundaryDefinition) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "id", d.ID)
|
||||
populate(objectMap, "name", d.Name)
|
||||
populate(objectMap, "properties", d.Properties)
|
||||
populate(objectMap, "systemData", d.SystemData)
|
||||
populate(objectMap, "type", d.Type)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type DataBoundaryDefinition.
|
||||
func (d *DataBoundaryDefinition) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", d, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "id":
|
||||
err = unpopulate(val, "ID", &d.ID)
|
||||
delete(rawMsg, key)
|
||||
case "name":
|
||||
err = unpopulate(val, "Name", &d.Name)
|
||||
delete(rawMsg, key)
|
||||
case "properties":
|
||||
err = unpopulate(val, "Properties", &d.Properties)
|
||||
delete(rawMsg, key)
|
||||
case "systemData":
|
||||
err = unpopulate(val, "SystemData", &d.SystemData)
|
||||
delete(rawMsg, key)
|
||||
case "type":
|
||||
err = unpopulate(val, "Type", &d.Type)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", d, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type DataBoundaryProperties.
|
||||
func (d DataBoundaryProperties) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "dataBoundary", d.DataBoundary)
|
||||
populate(objectMap, "provisioningState", d.ProvisioningState)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type DataBoundaryProperties.
|
||||
func (d *DataBoundaryProperties) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", d, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "dataBoundary":
|
||||
err = unpopulate(val, "DataBoundary", &d.DataBoundary)
|
||||
delete(rawMsg, key)
|
||||
case "provisioningState":
|
||||
err = unpopulate(val, "ProvisioningState", &d.ProvisioningState)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", d, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type Operation.
|
||||
func (o Operation) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "actionType", o.ActionType)
|
||||
populate(objectMap, "display", o.Display)
|
||||
populate(objectMap, "isDataAction", o.IsDataAction)
|
||||
populate(objectMap, "name", o.Name)
|
||||
populate(objectMap, "origin", o.Origin)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type Operation.
|
||||
func (o *Operation) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "actionType":
|
||||
err = unpopulate(val, "ActionType", &o.ActionType)
|
||||
delete(rawMsg, key)
|
||||
case "display":
|
||||
err = unpopulate(val, "Display", &o.Display)
|
||||
delete(rawMsg, key)
|
||||
case "isDataAction":
|
||||
err = unpopulate(val, "IsDataAction", &o.IsDataAction)
|
||||
delete(rawMsg, key)
|
||||
case "name":
|
||||
err = unpopulate(val, "Name", &o.Name)
|
||||
delete(rawMsg, key)
|
||||
case "origin":
|
||||
err = unpopulate(val, "Origin", &o.Origin)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type OperationDisplay.
|
||||
func (o OperationDisplay) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "description", o.Description)
|
||||
populate(objectMap, "operation", o.Operation)
|
||||
populate(objectMap, "provider", o.Provider)
|
||||
populate(objectMap, "resource", o.Resource)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay.
|
||||
func (o *OperationDisplay) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "description":
|
||||
err = unpopulate(val, "Description", &o.Description)
|
||||
delete(rawMsg, key)
|
||||
case "operation":
|
||||
err = unpopulate(val, "Operation", &o.Operation)
|
||||
delete(rawMsg, key)
|
||||
case "provider":
|
||||
err = unpopulate(val, "Provider", &o.Provider)
|
||||
delete(rawMsg, key)
|
||||
case "resource":
|
||||
err = unpopulate(val, "Resource", &o.Resource)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type OperationListResult.
|
||||
func (o OperationListResult) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "nextLink", o.NextLink)
|
||||
populate(objectMap, "value", o.Value)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult.
|
||||
func (o *OperationListResult) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "nextLink":
|
||||
err = unpopulate(val, "NextLink", &o.NextLink)
|
||||
delete(rawMsg, key)
|
||||
case "value":
|
||||
err = unpopulate(val, "Value", &o.Value)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type SystemData.
|
||||
func (s SystemData) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt)
|
||||
populate(objectMap, "createdBy", s.CreatedBy)
|
||||
populate(objectMap, "createdByType", s.CreatedByType)
|
||||
populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt)
|
||||
populate(objectMap, "lastModifiedBy", s.LastModifiedBy)
|
||||
populate(objectMap, "lastModifiedByType", s.LastModifiedByType)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData.
|
||||
func (s *SystemData) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", s, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "createdAt":
|
||||
err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt)
|
||||
delete(rawMsg, key)
|
||||
case "createdBy":
|
||||
err = unpopulate(val, "CreatedBy", &s.CreatedBy)
|
||||
delete(rawMsg, key)
|
||||
case "createdByType":
|
||||
err = unpopulate(val, "CreatedByType", &s.CreatedByType)
|
||||
delete(rawMsg, key)
|
||||
case "lastModifiedAt":
|
||||
err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt)
|
||||
delete(rawMsg, key)
|
||||
case "lastModifiedBy":
|
||||
err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy)
|
||||
delete(rawMsg, key)
|
||||
case "lastModifiedByType":
|
||||
err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", s, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func populate(m map[string]any, k string, v any) {
|
||||
if v == nil {
|
||||
return
|
||||
} else if azcore.IsNullValue(v) {
|
||||
m[k] = nil
|
||||
} else if !reflect.ValueOf(v).IsNil() {
|
||||
m[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
func unpopulate(data json.RawMessage, fn string, v any) error {
|
||||
if data == nil || string(data) == "null" {
|
||||
return nil
|
||||
}
|
||||
if err := json.Unmarshal(data, v); err != nil {
|
||||
return fmt.Errorf("struct field %s: %v", fn, err)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armdataboundaries
|
||||
|
||||
// ClientGetScopeOptions contains the optional parameters for the Client.GetScope method.
|
||||
type ClientGetScopeOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ClientGetTenantOptions contains the optional parameters for the Client.GetTenant method.
|
||||
type ClientGetTenantOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ClientPutOptions contains the optional parameters for the Client.Put method.
|
||||
type ClientPutOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method.
|
||||
type OperationsClientListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armdataboundaries
|
||||
|
||||
// ClientGetScopeResponse contains the response from method Client.GetScope.
|
||||
type ClientGetScopeResponse struct {
|
||||
// A data boundary definition.
|
||||
DataBoundaryDefinition
|
||||
}
|
||||
|
||||
// ClientGetTenantResponse contains the response from method Client.GetTenant.
|
||||
type ClientGetTenantResponse struct {
|
||||
// A data boundary definition.
|
||||
DataBoundaryDefinition
|
||||
}
|
||||
|
||||
// ClientPutResponse contains the response from method Client.Put.
|
||||
type ClientPutResponse struct {
|
||||
// A data boundary definition.
|
||||
DataBoundaryDefinition
|
||||
}
|
||||
|
||||
// OperationsClientListResponse contains the response from method OperationsClient.NewListPager.
|
||||
type OperationsClientListResponse struct {
|
||||
// A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results.
|
||||
OperationListResult
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armdataboundaries
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases.
|
||||
var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`)
|
||||
|
||||
const (
|
||||
utcDateTime = "2006-01-02T15:04:05.999999999"
|
||||
utcDateTimeJSON = `"` + utcDateTime + `"`
|
||||
utcDateTimeNoT = "2006-01-02 15:04:05.999999999"
|
||||
utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"`
|
||||
dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00`
|
||||
dateTimeJSON = `"` + time.RFC3339Nano + `"`
|
||||
dateTimeJSONNoT = `"` + dateTimeNoT + `"`
|
||||
)
|
||||
|
||||
type dateTimeRFC3339 time.Time
|
||||
|
||||
func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) {
|
||||
tt := time.Time(t)
|
||||
return tt.MarshalJSON()
|
||||
}
|
||||
|
||||
func (t dateTimeRFC3339) MarshalText() ([]byte, error) {
|
||||
tt := time.Time(t)
|
||||
return tt.MarshalText()
|
||||
}
|
||||
|
||||
func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error {
|
||||
tzOffset := tzOffsetRegex.Match(data)
|
||||
hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t")
|
||||
var layout string
|
||||
if tzOffset && hasT {
|
||||
layout = dateTimeJSON
|
||||
} else if tzOffset {
|
||||
layout = dateTimeJSONNoT
|
||||
} else if hasT {
|
||||
layout = utcDateTimeJSON
|
||||
} else {
|
||||
layout = utcDateTimeJSONNoT
|
||||
}
|
||||
return t.Parse(layout, string(data))
|
||||
}
|
||||
|
||||
func (t *dateTimeRFC3339) UnmarshalText(data []byte) error {
|
||||
tzOffset := tzOffsetRegex.Match(data)
|
||||
hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t")
|
||||
var layout string
|
||||
if tzOffset && hasT {
|
||||
layout = time.RFC3339Nano
|
||||
} else if tzOffset {
|
||||
layout = dateTimeNoT
|
||||
} else if hasT {
|
||||
layout = utcDateTime
|
||||
} else {
|
||||
layout = utcDateTimeNoT
|
||||
}
|
||||
return t.Parse(layout, string(data))
|
||||
}
|
||||
|
||||
func (t *dateTimeRFC3339) Parse(layout, value string) error {
|
||||
p, err := time.Parse(layout, strings.ToUpper(value))
|
||||
*t = dateTimeRFC3339(p)
|
||||
return err
|
||||
}
|
||||
|
||||
func (t dateTimeRFC3339) String() string {
|
||||
return time.Time(t).Format(time.RFC3339Nano)
|
||||
}
|
||||
|
||||
func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) {
|
||||
if t == nil {
|
||||
return
|
||||
} else if azcore.IsNullValue(t) {
|
||||
m[k] = nil
|
||||
return
|
||||
} else if reflect.ValueOf(t).IsNil() {
|
||||
return
|
||||
}
|
||||
m[k] = (*dateTimeRFC3339)(t)
|
||||
}
|
||||
|
||||
func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error {
|
||||
if data == nil || string(data) == "null" {
|
||||
return nil
|
||||
}
|
||||
var aux dateTimeRFC3339
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return fmt.Errorf("struct field %s: %v", fn, err)
|
||||
}
|
||||
*t = (*time.Time)(&aux)
|
||||
return nil
|
||||
}
|
Загрузка…
Ссылка в новой задаче