diff --git a/sdk/resourcemanager/orbital/armorbital/CHANGELOG.md b/sdk/resourcemanager/orbital/armorbital/CHANGELOG.md new file mode 100644 index 000000000000..64e453b2e5e1 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 0.1.0 (2021-11-18) diff --git a/sdk/resourcemanager/orbital/armorbital/LICENSE.txt b/sdk/resourcemanager/orbital/armorbital/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/LICENSE.txt @@ -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. \ No newline at end of file diff --git a/sdk/resourcemanager/orbital/armorbital/README.md b/sdk/resourcemanager/orbital/armorbital/README.md new file mode 100644 index 000000000000..6a649cad3d8c --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/README.md @@ -0,0 +1,75 @@ +# Azure Orbital Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/orbital/armorbital)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/orbital/armorbital) + +The `armorbital` module provides operations for working with Azure Orbital. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/orbital/armorbital) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Orbital module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/orbital/armorbital +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Orbital. 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). + +## Clients + +Azure Orbital 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. + +```go +client := armorbital.NewContactProfilesClient(, 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{ + Host: arm.AzureChina, +} +client := armorbital.NewContactProfilesClient(, cred, &options) +``` + +## 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 `Orbital` 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. \ No newline at end of file diff --git a/sdk/resourcemanager/orbital/armorbital/autorest.md b/sdk/resourcemanager/orbital/armorbital/autorest.md new file mode 100644 index 000000000000..e1621242a62c --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/orbital/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/orbital/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +``` \ No newline at end of file diff --git a/sdk/resourcemanager/orbital/armorbital/build.go b/sdk/resourcemanager/orbital/armorbital/build.go new file mode 100644 index 000000000000..6b2b316b4af3 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/build.go @@ -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.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/orbital/armorbital + +package armorbital diff --git a/sdk/resourcemanager/orbital/armorbital/ci.yml b/sdk/resourcemanager/orbital/armorbital/ci.yml new file mode 100644 index 000000000000..6adea13e6c91 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/ci.yml @@ -0,0 +1,27 @@ +# 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/orbital/armorbital/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/orbital/armorbital/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/orbital/armorbital' diff --git a/sdk/resourcemanager/orbital/armorbital/go.mod b/sdk/resourcemanager/orbital/armorbital/go.mod new file mode 100644 index 000000000000..2f2fe07a56b0 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/orbital/armorbital + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.2.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/orbital/armorbital/go.sum b/sdk/resourcemanager/orbital/armorbital/go.sum new file mode 100644 index 000000000000..e33416043ba9 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.2.0+incompatible h1:mbxiZy1K820hQ+dI+YIO/+a0wQDYqOu18BAGe4lXjVk= +github.com/Azure/azure-sdk-for-go v59.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/orbital/armorbital/go_mod_tidy_hack.go b/sdk/resourcemanager/orbital/armorbital/go_mod_tidy_hack.go new file mode 100644 index 000000000000..99530404776f --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armorbital + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_availablegroundstations_client.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_availablegroundstations_client.go new file mode 100644 index 000000000000..26a2cafb1eda --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_availablegroundstations_client.go @@ -0,0 +1,159 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "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" +) + +// AvailableGroundStationsClient contains the methods for the AvailableGroundStations group. +// Don't use this type directly, use NewAvailableGroundStationsClient() instead. +type AvailableGroundStationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAvailableGroundStationsClient creates a new instance of AvailableGroundStationsClient with the specified values. +func NewAvailableGroundStationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AvailableGroundStationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AvailableGroundStationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Gets the specified available ground station +// If the operation fails it returns the *CloudError error type. +func (client *AvailableGroundStationsClient) Get(ctx context.Context, groundStationName string, options *AvailableGroundStationsGetOptions) (AvailableGroundStationsGetResponse, error) { + req, err := client.getCreateRequest(ctx, groundStationName, options) + if err != nil { + return AvailableGroundStationsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AvailableGroundStationsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AvailableGroundStationsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AvailableGroundStationsClient) getCreateRequest(ctx context.Context, groundStationName string, options *AvailableGroundStationsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Orbital/availableGroundStations/{groundStationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if groundStationName == "" { + return nil, errors.New("parameter groundStationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groundStationName}", url.PathEscape(groundStationName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AvailableGroundStationsClient) getHandleResponse(resp *http.Response) (AvailableGroundStationsGetResponse, error) { + result := AvailableGroundStationsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailableGroundStation); err != nil { + return AvailableGroundStationsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AvailableGroundStationsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByCapability - Returns list of available ground stations +// If the operation fails it returns the *CloudError error type. +func (client *AvailableGroundStationsClient) ListByCapability(capability Enum6, options *AvailableGroundStationsListByCapabilityOptions) *AvailableGroundStationsListByCapabilityPager { + return &AvailableGroundStationsListByCapabilityPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByCapabilityCreateRequest(ctx, capability, options) + }, + advancer: func(ctx context.Context, resp AvailableGroundStationsListByCapabilityResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AvailableGroundStationListResult.NextLink) + }, + } +} + +// listByCapabilityCreateRequest creates the ListByCapability request. +func (client *AvailableGroundStationsClient) listByCapabilityCreateRequest(ctx context.Context, capability Enum6, options *AvailableGroundStationsListByCapabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Orbital/availableGroundStations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + reqQP.Set("capability", string(capability)) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByCapabilityHandleResponse handles the ListByCapability response. +func (client *AvailableGroundStationsClient) listByCapabilityHandleResponse(resp *http.Response) (AvailableGroundStationsListByCapabilityResponse, error) { + result := AvailableGroundStationsListByCapabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailableGroundStationListResult); err != nil { + return AvailableGroundStationsListByCapabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByCapabilityHandleError handles the ListByCapability error response. +func (client *AvailableGroundStationsClient) listByCapabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_constants.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_constants.go new file mode 100644 index 000000000000..90c840cd4f0d --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_constants.go @@ -0,0 +1,264 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +const ( + module = "armorbital" + version = "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, + } +} + +// ToPtr returns a *ActionType pointing to the current value. +func (c ActionType) ToPtr() *ActionType { + return &c +} + +// AuthorizationStatus - Authorization status of spacecraft. +type AuthorizationStatus string + +const ( + AuthorizationStatusAllowed AuthorizationStatus = "Allowed" + AuthorizationStatusPending AuthorizationStatus = "Pending" + AuthorizationStatusDenied AuthorizationStatus = "Denied" +) + +// PossibleAuthorizationStatusValues returns the possible values for the AuthorizationStatus const type. +func PossibleAuthorizationStatusValues() []AuthorizationStatus { + return []AuthorizationStatus{ + AuthorizationStatusAllowed, + AuthorizationStatusPending, + AuthorizationStatusDenied, + } +} + +// ToPtr returns a *AuthorizationStatus pointing to the current value. +func (c AuthorizationStatus) ToPtr() *AuthorizationStatus { + return &c +} + +// AutoTrackingConfiguration - Auto track configuration. +type AutoTrackingConfiguration string + +const ( + AutoTrackingConfigurationDisabled AutoTrackingConfiguration = "disabled" + AutoTrackingConfigurationXBand AutoTrackingConfiguration = "xBand" + AutoTrackingConfigurationSBand AutoTrackingConfiguration = "sBand" +) + +// PossibleAutoTrackingConfigurationValues returns the possible values for the AutoTrackingConfiguration const type. +func PossibleAutoTrackingConfigurationValues() []AutoTrackingConfiguration { + return []AutoTrackingConfiguration{ + AutoTrackingConfigurationDisabled, + AutoTrackingConfigurationXBand, + AutoTrackingConfigurationSBand, + } +} + +// ToPtr returns a *AutoTrackingConfiguration pointing to the current value. +func (c AutoTrackingConfiguration) ToPtr() *AutoTrackingConfiguration { + return &c +} + +// Capability - Capability of the Ground Station. +type Capability string + +const ( + CapabilityCommunication Capability = "Communication" + CapabilityEarthObservation Capability = "EarthObservation" +) + +// PossibleCapabilityValues returns the possible values for the Capability const type. +func PossibleCapabilityValues() []Capability { + return []Capability{ + CapabilityCommunication, + CapabilityEarthObservation, + } +} + +// ToPtr returns a *Capability pointing to the current value. +func (c Capability) ToPtr() *Capability { + return &c +} + +// 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, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// Direction - Direction (uplink or downlink) +type Direction string + +const ( + DirectionDownlink Direction = "downlink" + DirectionUplink Direction = "uplink" +) + +// PossibleDirectionValues returns the possible values for the Direction const type. +func PossibleDirectionValues() []Direction { + return []Direction{ + DirectionDownlink, + DirectionUplink, + } +} + +// ToPtr returns a *Direction pointing to the current value. +func (c Direction) ToPtr() *Direction { + return &c +} + +type Enum6 string + +const ( + Enum6Communication Enum6 = "Communication" + Enum6EarthObservation Enum6 = "EarthObservation" +) + +// PossibleEnum6Values returns the possible values for the Enum6 const type. +func PossibleEnum6Values() []Enum6 { + return []Enum6{ + Enum6Communication, + Enum6EarthObservation, + } +} + +// ToPtr returns a *Enum6 pointing to the current value. +func (c Enum6) ToPtr() *Enum6 { + return &c +} + +// 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, + } +} + +// ToPtr returns a *Origin pointing to the current value. +func (c Origin) ToPtr() *Origin { + return &c +} + +// Polarization - polarization. eg (RHCP, LHCP) +type Polarization string + +const ( + PolarizationDualRhcpLhcp Polarization = "dualRhcpLhcp" + PolarizationLHCP Polarization = "LHCP" + PolarizationLinearHorizontal Polarization = "linearHorizontal" + PolarizationLinearVertical Polarization = "linearVertical" + PolarizationRHCP Polarization = "RHCP" +) + +// PossiblePolarizationValues returns the possible values for the Polarization const type. +func PossiblePolarizationValues() []Polarization { + return []Polarization{ + PolarizationDualRhcpLhcp, + PolarizationLHCP, + PolarizationLinearHorizontal, + PolarizationLinearVertical, + PolarizationRHCP, + } +} + +// ToPtr returns a *Polarization pointing to the current value. +func (c Polarization) ToPtr() *Polarization { + return &c +} + +// Protocol - Protocol either UDP or TCP. +type Protocol string + +const ( + ProtocolTCP Protocol = "TCP" + ProtocolUDP Protocol = "UDP" +) + +// PossibleProtocolValues returns the possible values for the Protocol const type. +func PossibleProtocolValues() []Protocol { + return []Protocol{ + ProtocolTCP, + ProtocolUDP, + } +} + +// ToPtr returns a *Protocol pointing to the current value. +func (c Protocol) ToPtr() *Protocol { + return &c +} + +// Status - Status of a contact. +type Status string + +const ( + StatusScheduled Status = "scheduled" + StatusCancelled Status = "cancelled" + StatusSucceeded Status = "succeeded" + StatusFailed Status = "failed" + StatusProviderCancelled Status = "providerCancelled" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusScheduled, + StatusCancelled, + StatusSucceeded, + StatusFailed, + StatusProviderCancelled, + } +} + +// ToPtr returns a *Status pointing to the current value. +func (c Status) ToPtr() *Status { + return &c +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_contactprofiles_client.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_contactprofiles_client.go new file mode 100644 index 000000000000..3ad1036ca044 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_contactprofiles_client.go @@ -0,0 +1,443 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "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" +) + +// ContactProfilesClient contains the methods for the ContactProfiles group. +// Don't use this type directly, use NewContactProfilesClient() instead. +type ContactProfilesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewContactProfilesClient creates a new instance of ContactProfilesClient with the specified values. +func NewContactProfilesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ContactProfilesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ContactProfilesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Creates or updates a contact profile +// If the operation fails it returns the *CloudError error type. +func (client *ContactProfilesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, contactProfileName string, parameters ContactProfile, options *ContactProfilesBeginCreateOrUpdateOptions) (ContactProfilesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, contactProfileName, parameters, options) + if err != nil { + return ContactProfilesCreateOrUpdatePollerResponse{}, err + } + result := ContactProfilesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ContactProfilesClient.CreateOrUpdate", "azure-async-operation", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ContactProfilesCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ContactProfilesCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates or updates a contact profile +// If the operation fails it returns the *CloudError error type. +func (client *ContactProfilesClient) createOrUpdate(ctx context.Context, resourceGroupName string, contactProfileName string, parameters ContactProfile, options *ContactProfilesBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, contactProfileName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ContactProfilesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, contactProfileName string, parameters ContactProfile, options *ContactProfilesBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/contactProfiles/{contactProfileName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if contactProfileName == "" { + return nil, errors.New("parameter contactProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactProfileName}", url.PathEscape(contactProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ContactProfilesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Deletes a specified contact profile resource. +// If the operation fails it returns the *CloudError error type. +func (client *ContactProfilesClient) BeginDelete(ctx context.Context, resourceGroupName string, contactProfileName string, options *ContactProfilesBeginDeleteOptions) (ContactProfilesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, contactProfileName, options) + if err != nil { + return ContactProfilesDeletePollerResponse{}, err + } + result := ContactProfilesDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ContactProfilesClient.Delete", "location", resp, client.pl, client.deleteHandleError) + if err != nil { + return ContactProfilesDeletePollerResponse{}, err + } + result.Poller = &ContactProfilesDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a specified contact profile resource. +// If the operation fails it returns the *CloudError error type. +func (client *ContactProfilesClient) deleteOperation(ctx context.Context, resourceGroupName string, contactProfileName string, options *ContactProfilesBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, contactProfileName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ContactProfilesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, contactProfileName string, options *ContactProfilesBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/contactProfiles/{contactProfileName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if contactProfileName == "" { + return nil, errors.New("parameter contactProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactProfileName}", url.PathEscape(contactProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ContactProfilesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the specified contact Profile in a specified resource group +// If the operation fails it returns the *CloudError error type. +func (client *ContactProfilesClient) Get(ctx context.Context, resourceGroupName string, contactProfileName string, options *ContactProfilesGetOptions) (ContactProfilesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, contactProfileName, options) + if err != nil { + return ContactProfilesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactProfilesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactProfilesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ContactProfilesClient) getCreateRequest(ctx context.Context, resourceGroupName string, contactProfileName string, options *ContactProfilesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/contactProfiles/{contactProfileName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if contactProfileName == "" { + return nil, errors.New("parameter contactProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactProfileName}", url.PathEscape(contactProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ContactProfilesClient) getHandleResponse(resp *http.Response) (ContactProfilesGetResponse, error) { + result := ContactProfilesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContactProfile); err != nil { + return ContactProfilesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ContactProfilesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Returns list of contact profiles +// If the operation fails it returns the *CloudError error type. +func (client *ContactProfilesClient) List(ctx context.Context, resourceGroupName string, options *ContactProfilesListOptions) (ContactProfilesListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return ContactProfilesListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactProfilesListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactProfilesListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *ContactProfilesClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *ContactProfilesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/contactProfiles" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ContactProfilesClient) listHandleResponse(resp *http.Response) (ContactProfilesListResponse, error) { + result := ContactProfilesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContactProfileListResult); err != nil { + return ContactProfilesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ContactProfilesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Returns list of contact profiles +// If the operation fails it returns the *CloudError error type. +func (client *ContactProfilesClient) ListBySubscription(ctx context.Context, options *ContactProfilesListBySubscriptionOptions) (ContactProfilesListBySubscriptionResponse, error) { + req, err := client.listBySubscriptionCreateRequest(ctx, options) + if err != nil { + return ContactProfilesListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactProfilesListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactProfilesListBySubscriptionResponse{}, client.listBySubscriptionHandleError(resp) + } + return client.listBySubscriptionHandleResponse(resp) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ContactProfilesClient) listBySubscriptionCreateRequest(ctx context.Context, options *ContactProfilesListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Orbital/contactProfiles" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ContactProfilesClient) listBySubscriptionHandleResponse(resp *http.Response) (ContactProfilesListBySubscriptionResponse, error) { + result := ContactProfilesListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContactProfileListResult); err != nil { + return ContactProfilesListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *ContactProfilesClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// UpdateTags - Updates the specified contact profile tags. +// If the operation fails it returns the *CloudError error type. +func (client *ContactProfilesClient) UpdateTags(ctx context.Context, resourceGroupName string, contactProfileName string, parameters TagsObject, options *ContactProfilesUpdateTagsOptions) (ContactProfilesUpdateTagsResponse, error) { + req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, contactProfileName, parameters, options) + if err != nil { + return ContactProfilesUpdateTagsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactProfilesUpdateTagsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactProfilesUpdateTagsResponse{}, client.updateTagsHandleError(resp) + } + return client.updateTagsHandleResponse(resp) +} + +// updateTagsCreateRequest creates the UpdateTags request. +func (client *ContactProfilesClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, contactProfileName string, parameters TagsObject, options *ContactProfilesUpdateTagsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/contactProfiles/{contactProfileName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if contactProfileName == "" { + return nil, errors.New("parameter contactProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactProfileName}", url.PathEscape(contactProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateTagsHandleResponse handles the UpdateTags response. +func (client *ContactProfilesClient) updateTagsHandleResponse(resp *http.Response) (ContactProfilesUpdateTagsResponse, error) { + result := ContactProfilesUpdateTagsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContactProfile); err != nil { + return ContactProfilesUpdateTagsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateTagsHandleError handles the UpdateTags error response. +func (client *ContactProfilesClient) updateTagsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_contacts_client.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_contacts_client.go new file mode 100644 index 000000000000..ab3f1c9816e8 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_contacts_client.go @@ -0,0 +1,337 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "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" +) + +// ContactsClient contains the methods for the Contacts group. +// Don't use this type directly, use NewContactsClient() instead. +type ContactsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewContactsClient creates a new instance of ContactsClient with the specified values. +func NewContactsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ContactsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ContactsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreate - Creates a contact. +// If the operation fails it returns the *CloudError error type. +func (client *ContactsClient) BeginCreate(ctx context.Context, resourceGroupName string, spacecraftName string, contactName string, parameters Contact, options *ContactsBeginCreateOptions) (ContactsCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, spacecraftName, contactName, parameters, options) + if err != nil { + return ContactsCreatePollerResponse{}, err + } + result := ContactsCreatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ContactsClient.Create", "azure-async-operation", resp, client.pl, client.createHandleError) + if err != nil { + return ContactsCreatePollerResponse{}, err + } + result.Poller = &ContactsCreatePoller{ + pt: pt, + } + return result, nil +} + +// Create - Creates a contact. +// If the operation fails it returns the *CloudError error type. +func (client *ContactsClient) create(ctx context.Context, resourceGroupName string, spacecraftName string, contactName string, parameters Contact, options *ContactsBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, spacecraftName, contactName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ContactsClient) createCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, contactName string, parameters Contact, options *ContactsBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}/contacts/{contactName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + if contactName == "" { + return nil, errors.New("parameter contactName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactName}", url.PathEscape(contactName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createHandleError handles the Create error response. +func (client *ContactsClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Deletes a specified contact +// If the operation fails it returns the *CloudError error type. +func (client *ContactsClient) BeginDelete(ctx context.Context, resourceGroupName string, spacecraftName string, contactName string, options *ContactsBeginDeleteOptions) (ContactsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, spacecraftName, contactName, options) + if err != nil { + return ContactsDeletePollerResponse{}, err + } + result := ContactsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ContactsClient.Delete", "location", resp, client.pl, client.deleteHandleError) + if err != nil { + return ContactsDeletePollerResponse{}, err + } + result.Poller = &ContactsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a specified contact +// If the operation fails it returns the *CloudError error type. +func (client *ContactsClient) deleteOperation(ctx context.Context, resourceGroupName string, spacecraftName string, contactName string, options *ContactsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, spacecraftName, contactName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ContactsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, contactName string, options *ContactsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}/contacts/{contactName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + if contactName == "" { + return nil, errors.New("parameter contactName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactName}", url.PathEscape(contactName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ContactsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the specified contact in a specified resource group +// If the operation fails it returns the *CloudError error type. +func (client *ContactsClient) Get(ctx context.Context, resourceGroupName string, spacecraftName string, contactName string, options *ContactsGetOptions) (ContactsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, spacecraftName, contactName, options) + if err != nil { + return ContactsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ContactsClient) getCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, contactName string, options *ContactsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}/contacts/{contactName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + if contactName == "" { + return nil, errors.New("parameter contactName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactName}", url.PathEscape(contactName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ContactsClient) getHandleResponse(resp *http.Response) (ContactsGetResponse, error) { + result := ContactsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Contact); err != nil { + return ContactsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ContactsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Returns list of contacts by spacecraftName +// If the operation fails it returns the *CloudError error type. +func (client *ContactsClient) List(ctx context.Context, resourceGroupName string, spacecraftName string, options *ContactsListOptions) (ContactsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, spacecraftName, options) + if err != nil { + return ContactsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *ContactsClient) listCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, options *ContactsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}/contacts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ContactsClient) listHandleResponse(resp *http.Response) (ContactsListResponse, error) { + result := ContactsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContactListResult); err != nil { + return ContactsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ContactsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_models.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_models.go new file mode 100644 index 000000000000..6d9c5443fc63 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_models.go @@ -0,0 +1,1003 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AvailableContacts - Customer retrieves list of Available Contacts for a spacecraft resource. Later, one of the available contact can be selected to create +// a contact. +type AvailableContacts struct { + // Properties of Contact resource. + Properties *ContactInstanceProperties `json:"properties,omitempty"` + + // The reference to the spacecraft resource. + Spacecraft *ResourceReference `json:"spacecraft,omitempty"` + + // READ-ONLY; Name of Azure Ground Station. + GroundStationName *string `json:"groundStationName,omitempty" azure:"ro"` +} + +// AvailableContactsListResult - Response for the ListAvailableContacts API service call. +type AvailableContactsListResult struct { + // A list of available contacts + Value []*AvailableContacts `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AvailableContactsListResult. +func (a AvailableContactsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AvailableGroundStation - GroundStations available to schedule Contacts +type AvailableGroundStation struct { + // Azure region + Location *string `json:"location,omitempty"` + + // The properties bag for this resource + Properties *AvailableGroundStationProperties `json:"properties,omitempty"` + + // READ-ONLY; Id of groundStation + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the ground station. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// AvailableGroundStationListResult - Response for the AvailableGroundStations API service call. +type AvailableGroundStationListResult struct { + // A list of ground station resources. + Value []*AvailableGroundStation `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AvailableGroundStationListResult. +func (a AvailableGroundStationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AvailableGroundStationProperties - Properties object for Available groundstation. +type AvailableGroundStationProperties struct { + // Altitude of the ground station + AltitudeMeters *float32 `json:"altitudeMeters,omitempty"` + + // City of ground station. + City *string `json:"city,omitempty"` + + // Latitude of the ground station in decimal degrees. + LatitudeDegrees *float32 `json:"latitudeDegrees,omitempty"` + + // Longitude of the ground station in decimal degrees. + LongitudeDegrees *float32 `json:"longitudeDegrees,omitempty"` + + // Ground station provider name. + ProviderName *string `json:"providerName,omitempty"` +} + +// AvailableGroundStationsGetOptions contains the optional parameters for the AvailableGroundStations.Get method. +type AvailableGroundStationsGetOptions struct { + // placeholder for future optional parameters +} + +// AvailableGroundStationsListByCapabilityOptions contains the optional parameters for the AvailableGroundStations.ListByCapability method. +type AvailableGroundStationsListByCapabilityOptions struct { + // placeholder for future optional parameters +} + +// CloudError - An error response from the service. +// Implements the error and azcore.HTTPResponse interfaces. +type CloudError struct { + raw string + // An error response from the service. + InnerError *CloudErrorBody `json:"error,omitempty"` +} + +// Error implements the error interface for type CloudError. +// The contents of the error text are not contractual and subject to change. +func (e CloudError) Error() string { + return e.raw +} + +// CloudErrorBody - An error response from the service. +type CloudErrorBody struct { + // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + + // A list of additional details about the error. + Details []*CloudErrorBody `json:"details,omitempty"` + + // A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + + // The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBody. +func (c CloudErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +// Contact - Customer creates a contact resource for a spacecraft resource. +type Contact struct { + ProxyResource + // Properties of the Contact Resource. + Properties *ContactsProperties `json:"properties,omitempty"` + + // READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Contact. +func (c Contact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "etag", c.Etag) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// ContactInstanceProperties - Contact Instance Properties +type ContactInstanceProperties struct { + // READ-ONLY; Azimuth of the antenna at the end of the contact in decimal degrees. + EndAzimuthDegrees *float32 `json:"endAzimuthDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Spacecraft elevation above the horizon at contact end. + EndElevationDegrees *float32 `json:"endElevationDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Maximum elevation of the antenna during the contact in decimal degrees. + MaximumElevationDegrees *float32 `json:"maximumElevationDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Time to lost receiving a signal. + RxEndTime *time.Time `json:"rxEndTime,omitempty" azure:"ro"` + + // READ-ONLY; Earliest time to receive a signal. + RxStartTime *time.Time `json:"rxStartTime,omitempty" azure:"ro"` + + // READ-ONLY; Azimuth of the antenna at the start of the contact in decimal degrees. + StartAzimuthDegrees *float32 `json:"startAzimuthDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Spacecraft elevation above the horizon at contact start. + StartElevationDegrees *float32 `json:"startElevationDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Time at which antenna transmit will be disabled. + TxEndTime *time.Time `json:"txEndTime,omitempty" azure:"ro"` + + // READ-ONLY; Time at which antenna transmit will be enabled. + TxStartTime *time.Time `json:"txStartTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactInstanceProperties. +func (c ContactInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "endAzimuthDegrees", c.EndAzimuthDegrees) + populate(objectMap, "endElevationDegrees", c.EndElevationDegrees) + populate(objectMap, "maximumElevationDegrees", c.MaximumElevationDegrees) + populateTimeRFC3339(objectMap, "rxEndTime", c.RxEndTime) + populateTimeRFC3339(objectMap, "rxStartTime", c.RxStartTime) + populate(objectMap, "startAzimuthDegrees", c.StartAzimuthDegrees) + populate(objectMap, "startElevationDegrees", c.StartElevationDegrees) + populateTimeRFC3339(objectMap, "txEndTime", c.TxEndTime) + populateTimeRFC3339(objectMap, "txStartTime", c.TxStartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContactInstanceProperties. +func (c *ContactInstanceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "endAzimuthDegrees": + err = unpopulate(val, &c.EndAzimuthDegrees) + delete(rawMsg, key) + case "endElevationDegrees": + err = unpopulate(val, &c.EndElevationDegrees) + delete(rawMsg, key) + case "maximumElevationDegrees": + err = unpopulate(val, &c.MaximumElevationDegrees) + delete(rawMsg, key) + case "rxEndTime": + err = unpopulateTimeRFC3339(val, &c.RxEndTime) + delete(rawMsg, key) + case "rxStartTime": + err = unpopulateTimeRFC3339(val, &c.RxStartTime) + delete(rawMsg, key) + case "startAzimuthDegrees": + err = unpopulate(val, &c.StartAzimuthDegrees) + delete(rawMsg, key) + case "startElevationDegrees": + err = unpopulate(val, &c.StartElevationDegrees) + delete(rawMsg, key) + case "txEndTime": + err = unpopulateTimeRFC3339(val, &c.TxEndTime) + delete(rawMsg, key) + case "txStartTime": + err = unpopulateTimeRFC3339(val, &c.TxStartTime) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ContactListResult - Response for the ListContacts API service call. +type ContactListResult struct { + // A list of contact resources in a resource group. + Value []*Contact `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactListResult. +func (c ContactListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ContactParameters - Parameters that define the contact resource. +type ContactParameters struct { + // REQUIRED; The reference to the contact profile resource. + ContactProfile *ResourceReference `json:"contactProfile,omitempty"` + + // REQUIRED; End time of a contact. + EndTime *time.Time `json:"endTime,omitempty"` + + // REQUIRED; Name of Azure Ground Station. + GroundStationName *string `json:"groundStationName,omitempty"` + + // REQUIRED; Start time of a contact. + StartTime *time.Time `json:"startTime,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactParameters. +func (c ContactParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "contactProfile", c.ContactProfile) + populateTimeRFC3339(objectMap, "endTime", c.EndTime) + populate(objectMap, "groundStationName", c.GroundStationName) + populateTimeRFC3339(objectMap, "startTime", c.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContactParameters. +func (c *ContactParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "contactProfile": + err = unpopulate(val, &c.ContactProfile) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, &c.EndTime) + delete(rawMsg, key) + case "groundStationName": + err = unpopulate(val, &c.GroundStationName) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, &c.StartTime) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ContactProfile - Customer creates a Contact Profile Resource, which will contain all of the configurations required for scheduling a contact. +type ContactProfile struct { + TrackedResource + // Properties of the spacecraft resource. + Properties *ContactProfilesProperties `json:"properties,omitempty"` + + // READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactProfile. +func (c ContactProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "etag", c.Etag) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// ContactProfileLink - Contact Profile link +type ContactProfileLink struct { + // REQUIRED; Contact Profile Link Channel + Channels []*ContactProfileLinkChannel `json:"channels,omitempty"` + + // REQUIRED; Direction (uplink or downlink) + Direction *Direction `json:"direction,omitempty"` + + // REQUIRED; polarization. eg (RHCP, LHCP) + Polarization *Polarization `json:"polarization,omitempty"` + + // Effective Isotropic Radiated Power (EIRP) in dBW. + EirpdBW *float32 `json:"eirpdBW,omitempty"` + + // Gain To Noise Temperature in db/K. + GainOverTemperature *float32 `json:"gainOverTemperature,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactProfileLink. +func (c ContactProfileLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "channels", c.Channels) + populate(objectMap, "direction", c.Direction) + populate(objectMap, "eirpdBW", c.EirpdBW) + populate(objectMap, "gainOverTemperature", c.GainOverTemperature) + populate(objectMap, "polarization", c.Polarization) + return json.Marshal(objectMap) +} + +// ContactProfileLinkChannel - Contact Profile Link Channel +type ContactProfileLinkChannel struct { + // REQUIRED; Bandwidth in MHz + BandwidthMHz *float32 `json:"bandwidthMHz,omitempty"` + + // REQUIRED; Center Frequency in MHz + CenterFrequencyMHz *float32 `json:"centerFrequencyMHz,omitempty"` + + // REQUIRED; Customer End point to store/retrieve data during a contact. + EndPoint *EndPoint `json:"endPoint,omitempty"` + + // Configuration for decoding + DecodingConfiguration *string `json:"decodingConfiguration,omitempty"` + + // Configuration for demodulation + DemodulationConfiguration *string `json:"demodulationConfiguration,omitempty"` + + // Configuration for encoding + EncodingConfiguration *string `json:"encodingConfiguration,omitempty"` + + // Configuration for modulation + ModulationConfiguration *string `json:"modulationConfiguration,omitempty"` +} + +// ContactProfileListResult - Response for the ListContactProfiles API service call. +type ContactProfileListResult struct { + // A list of contact profile resources in a resource group. + Value []*ContactProfile `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactProfileListResult. +func (c ContactProfileListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ContactProfilesBeginCreateOrUpdateOptions contains the optional parameters for the ContactProfiles.BeginCreateOrUpdate method. +type ContactProfilesBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ContactProfilesBeginDeleteOptions contains the optional parameters for the ContactProfiles.BeginDelete method. +type ContactProfilesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ContactProfilesGetOptions contains the optional parameters for the ContactProfiles.Get method. +type ContactProfilesGetOptions struct { + // placeholder for future optional parameters +} + +// ContactProfilesListBySubscriptionOptions contains the optional parameters for the ContactProfiles.ListBySubscription method. +type ContactProfilesListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ContactProfilesListOptions contains the optional parameters for the ContactProfiles.List method. +type ContactProfilesListOptions struct { + // placeholder for future optional parameters +} + +// ContactProfilesProperties - List of Contact Profile Resource Properties. +type ContactProfilesProperties struct { + // REQUIRED; Links of the Contact Profile + Links []*ContactProfileLink `json:"links,omitempty"` + + // Auto track configuration. + AutoTrackingConfiguration *AutoTrackingConfiguration `json:"autoTrackingConfiguration,omitempty"` + + // Minimum viable elevation for the contact in decimal degrees. + MinimumElevationDegrees *float32 `json:"minimumElevationDegrees,omitempty"` + + // Minimum viable contact duration in ISO 8601 format. + MinimumViableContactDuration *string `json:"minimumViableContactDuration,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactProfilesProperties. +func (c ContactProfilesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "autoTrackingConfiguration", c.AutoTrackingConfiguration) + populate(objectMap, "links", c.Links) + populate(objectMap, "minimumElevationDegrees", c.MinimumElevationDegrees) + populate(objectMap, "minimumViableContactDuration", c.MinimumViableContactDuration) + return json.Marshal(objectMap) +} + +// ContactProfilesUpdateTagsOptions contains the optional parameters for the ContactProfiles.UpdateTags method. +type ContactProfilesUpdateTagsOptions struct { + // placeholder for future optional parameters +} + +// ContactsBeginCreateOptions contains the optional parameters for the Contacts.BeginCreate method. +type ContactsBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ContactsBeginDeleteOptions contains the optional parameters for the Contacts.BeginDelete method. +type ContactsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ContactsGetOptions contains the optional parameters for the Contacts.Get method. +type ContactsGetOptions struct { + // placeholder for future optional parameters +} + +// ContactsListOptions contains the optional parameters for the Contacts.List method. +type ContactsListOptions struct { + // placeholder for future optional parameters +} + +// ContactsProperties - Properties of the Contact Resource. +type ContactsProperties struct { + // REQUIRED; The reference to the contact profile resource. + ContactProfile *ResourceReference `json:"contactProfile,omitempty"` + + // REQUIRED; Azure Ground Station name. + GroundStationName *string `json:"groundStationName,omitempty"` + + // REQUIRED; Reservation end time of a contact. + ReservationEndTime *time.Time `json:"reservationEndTime,omitempty"` + + // REQUIRED; Reservation start time of a contact. + ReservationStartTime *time.Time `json:"reservationStartTime,omitempty"` + + // READ-ONLY; Azimuth of the antenna at the end of the contact in decimal degrees. + EndAzimuthDegrees *float32 `json:"endAzimuthDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Spacecraft elevation above the horizon at contact end. + EndElevationDegrees *float32 `json:"endElevationDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Any error message while scheduling a contact. + ErrorMessage *string `json:"errorMessage,omitempty" azure:"ro"` + + // READ-ONLY; Maximum elevation of the antenna during the contact in decimal degrees. + MaximumElevationDegrees *float32 `json:"maximumElevationDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Receive end time of a contact. + RxEndTime *time.Time `json:"rxEndTime,omitempty" azure:"ro"` + + // READ-ONLY; Receive start time of a contact. + RxStartTime *time.Time `json:"rxStartTime,omitempty" azure:"ro"` + + // READ-ONLY; Azimuth of the antenna at the start of the contact in decimal degrees. + StartAzimuthDegrees *float32 `json:"startAzimuthDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Spacecraft elevation above the horizon at contact start. + StartElevationDegrees *float32 `json:"startElevationDegrees,omitempty" azure:"ro"` + + // READ-ONLY; Status of a contact. + Status *Status `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; Transmit end time of a contact. + TxEndTime *time.Time `json:"txEndTime,omitempty" azure:"ro"` + + // READ-ONLY; Transmit start time of a contact. + TxStartTime *time.Time `json:"txStartTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactsProperties. +func (c ContactsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "contactProfile", c.ContactProfile) + populate(objectMap, "endAzimuthDegrees", c.EndAzimuthDegrees) + populate(objectMap, "endElevationDegrees", c.EndElevationDegrees) + populate(objectMap, "errorMessage", c.ErrorMessage) + populate(objectMap, "groundStationName", c.GroundStationName) + populate(objectMap, "maximumElevationDegrees", c.MaximumElevationDegrees) + populateTimeRFC3339(objectMap, "reservationEndTime", c.ReservationEndTime) + populateTimeRFC3339(objectMap, "reservationStartTime", c.ReservationStartTime) + populateTimeRFC3339(objectMap, "rxEndTime", c.RxEndTime) + populateTimeRFC3339(objectMap, "rxStartTime", c.RxStartTime) + populate(objectMap, "startAzimuthDegrees", c.StartAzimuthDegrees) + populate(objectMap, "startElevationDegrees", c.StartElevationDegrees) + populate(objectMap, "status", c.Status) + populateTimeRFC3339(objectMap, "txEndTime", c.TxEndTime) + populateTimeRFC3339(objectMap, "txStartTime", c.TxStartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContactsProperties. +func (c *ContactsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "contactProfile": + err = unpopulate(val, &c.ContactProfile) + delete(rawMsg, key) + case "endAzimuthDegrees": + err = unpopulate(val, &c.EndAzimuthDegrees) + delete(rawMsg, key) + case "endElevationDegrees": + err = unpopulate(val, &c.EndElevationDegrees) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, &c.ErrorMessage) + delete(rawMsg, key) + case "groundStationName": + err = unpopulate(val, &c.GroundStationName) + delete(rawMsg, key) + case "maximumElevationDegrees": + err = unpopulate(val, &c.MaximumElevationDegrees) + delete(rawMsg, key) + case "reservationEndTime": + err = unpopulateTimeRFC3339(val, &c.ReservationEndTime) + delete(rawMsg, key) + case "reservationStartTime": + err = unpopulateTimeRFC3339(val, &c.ReservationStartTime) + delete(rawMsg, key) + case "rxEndTime": + err = unpopulateTimeRFC3339(val, &c.RxEndTime) + delete(rawMsg, key) + case "rxStartTime": + err = unpopulateTimeRFC3339(val, &c.RxStartTime) + delete(rawMsg, key) + case "startAzimuthDegrees": + err = unpopulate(val, &c.StartAzimuthDegrees) + delete(rawMsg, key) + case "startElevationDegrees": + err = unpopulate(val, &c.StartElevationDegrees) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &c.Status) + delete(rawMsg, key) + case "txEndTime": + err = unpopulateTimeRFC3339(val, &c.TxEndTime) + delete(rawMsg, key) + case "txStartTime": + err = unpopulateTimeRFC3339(val, &c.TxStartTime) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// EndPoint - Customer End point to store/retrieve data during a contact. +type EndPoint struct { + // REQUIRED; Name of an end point. + EndPointName *string `json:"endPointName,omitempty"` + + // REQUIRED; IP Address. + IPAddress *string `json:"ipAddress,omitempty"` + + // REQUIRED; TCP port to listen on to receive data. + Port *string `json:"port,omitempty"` + + // REQUIRED; Protocol either UDP or TCP. + Protocol *Protocol `json:"protocol,omitempty"` +} + +// 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 `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // 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 `json:"isDataAction,omitempty" azure:"ro"` + + // 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 `json:"name,omitempty" azure:"ro"` + + // 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 `json:"origin,omitempty" azure:"ro"` +} + +// 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 `json:"description,omitempty" azure:"ro"` + + // 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 `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// 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 `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal(objectMap map[string]interface{}) { + p.Resource.marshalInternal(objectMap) +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) +} + +// ResourceIDListResult - Response for an API service call that lists the resource IDs of resources associated with another resource. +type ResourceIDListResult struct { + // A list of Azure Resource IDs. + Value []*ResourceIDListResultValueItem `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceIDListResult. +func (r ResourceIDListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +type ResourceIDListResultValueItem struct { + // The Azure Resource ID + ID *string `json:"id,omitempty"` +} + +// ResourceReference - Resource Reference +type ResourceReference struct { + // Resource ID. + ID *string `json:"id,omitempty"` +} + +// Spacecraft - Customer creates a spacecraft resource to schedule a contact. +type Spacecraft struct { + TrackedResource + // Spacecraft Properties + Properties *SpacecraftsProperties `json:"properties,omitempty"` + + // READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Spacecraft. +func (s Spacecraft) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "etag", s.Etag) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// SpacecraftLink - Spacecraft Link +type SpacecraftLink struct { + // REQUIRED; Bandwidth in MHz + BandwidthMHz *float32 `json:"bandwidthMHz,omitempty"` + + // REQUIRED; Center Frequency in MHz + CenterFrequencyMHz *float32 `json:"centerFrequencyMHz,omitempty"` + + // REQUIRED; Direction (uplink or downlink) + Direction *Direction `json:"direction,omitempty"` + + // REQUIRED; polarization. eg (RHCP, LHCP) + Polarization *Polarization `json:"polarization,omitempty"` +} + +// SpacecraftListResult - Response for the ListSpacecrafts API service call. +type SpacecraftListResult struct { + // A list of spacecraft resources in a resource group. + Value []*Spacecraft `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SpacecraftListResult. +func (s SpacecraftListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// SpacecraftsBeginCreateOrUpdateOptions contains the optional parameters for the Spacecrafts.BeginCreateOrUpdate method. +type SpacecraftsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SpacecraftsBeginDeleteOptions contains the optional parameters for the Spacecrafts.BeginDelete method. +type SpacecraftsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// SpacecraftsBeginListAvailableContactsOptions contains the optional parameters for the Spacecrafts.BeginListAvailableContacts method. +type SpacecraftsBeginListAvailableContactsOptions struct { + // placeholder for future optional parameters +} + +// SpacecraftsGetOptions contains the optional parameters for the Spacecrafts.Get method. +type SpacecraftsGetOptions struct { + // placeholder for future optional parameters +} + +// SpacecraftsListBySubscriptionOptions contains the optional parameters for the Spacecrafts.ListBySubscription method. +type SpacecraftsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// SpacecraftsListOptions contains the optional parameters for the Spacecrafts.List method. +type SpacecraftsListOptions struct { + // placeholder for future optional parameters +} + +// SpacecraftsProperties - List of Spacecraft Resource Properties. +type SpacecraftsProperties struct { + // REQUIRED; NORAD ID of the spacecraft. + NoradID *string `json:"noradId,omitempty"` + + // Links of the Spacecraft + Links []*SpacecraftLink `json:"links,omitempty"` + + // Title line of Two Line Element (TLE). + TitleLine *string `json:"titleLine,omitempty"` + + // Line 1 of Two Line Element (TLE). + TleLine1 *string `json:"tleLine1,omitempty"` + + // Line 2 of Two Line Element (TLE). + TleLine2 *string `json:"tleLine2,omitempty"` + + // READ-ONLY; Authorization status of spacecraft. + AuthorizationStatus *AuthorizationStatus `json:"authorizationStatus,omitempty" azure:"ro"` + + // READ-ONLY; Details of the authorization status. + AuthorizationStatusExtended *string `json:"authorizationStatusExtended,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SpacecraftsProperties. +func (s SpacecraftsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorizationStatus", s.AuthorizationStatus) + populate(objectMap, "authorizationStatusExtended", s.AuthorizationStatusExtended) + populate(objectMap, "links", s.Links) + populate(objectMap, "noradId", s.NoradID) + populate(objectMap, "titleLine", s.TitleLine) + populate(objectMap, "tleLine1", s.TleLine1) + populate(objectMap, "tleLine2", s.TleLine2) + return json.Marshal(objectMap) +} + +// SpacecraftsUpdateTagsOptions contains the optional parameters for the Spacecrafts.UpdateTags method. +type SpacecraftsUpdateTagsOptions struct { + // placeholder for future optional parameters +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TagsObject - Tags object for patch operations. +type TagsObject struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TagsObject. +func (t TagsObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +func populate(m map[string]interface{}, k string, v interface{}) { + 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, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_operations_client.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_operations_client.go new file mode 100644 index 000000000000..7f40b65154c9 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_operations_client.go @@ -0,0 +1,92 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available Orbital Rest API operations. +// If the operation fails it returns the *CloudError error type. +func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationsListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Orbital/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_pagers.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_pagers.go new file mode 100644 index 000000000000..73e6d5f97fe0 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_pagers.go @@ -0,0 +1,71 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// AvailableGroundStationsListByCapabilityPager provides operations for iterating over paged responses. +type AvailableGroundStationsListByCapabilityPager struct { + client *AvailableGroundStationsClient + current AvailableGroundStationsListByCapabilityResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AvailableGroundStationsListByCapabilityResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AvailableGroundStationsListByCapabilityPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *AvailableGroundStationsListByCapabilityPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AvailableGroundStationListResult.NextLink == nil || len(*p.current.AvailableGroundStationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByCapabilityHandleError(resp) + return false + } + result, err := p.client.listByCapabilityHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current AvailableGroundStationsListByCapabilityResponse page. +func (p *AvailableGroundStationsListByCapabilityPager) PageResponse() AvailableGroundStationsListByCapabilityResponse { + return p.current +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_pollers.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_pollers.go new file mode 100644 index 000000000000..2e9936be50c7 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_pollers.go @@ -0,0 +1,316 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// ContactProfilesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ContactProfilesCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ContactProfilesCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ContactProfilesCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ContactProfilesCreateOrUpdateResponse will be returned. +func (p *ContactProfilesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ContactProfilesCreateOrUpdateResponse, error) { + respType := ContactProfilesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ContactProfile) + if err != nil { + return ContactProfilesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ContactProfilesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ContactProfilesDeletePoller provides polling facilities until the operation reaches a terminal state. +type ContactProfilesDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ContactProfilesDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ContactProfilesDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ContactProfilesDeleteResponse will be returned. +func (p *ContactProfilesDeletePoller) FinalResponse(ctx context.Context) (ContactProfilesDeleteResponse, error) { + respType := ContactProfilesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ContactProfilesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ContactProfilesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ContactsCreatePoller provides polling facilities until the operation reaches a terminal state. +type ContactsCreatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ContactsCreatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ContactsCreatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ContactsCreateResponse will be returned. +func (p *ContactsCreatePoller) FinalResponse(ctx context.Context) (ContactsCreateResponse, error) { + respType := ContactsCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Contact) + if err != nil { + return ContactsCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ContactsCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ContactsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ContactsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ContactsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ContactsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ContactsDeleteResponse will be returned. +func (p *ContactsDeletePoller) FinalResponse(ctx context.Context) (ContactsDeleteResponse, error) { + respType := ContactsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ContactsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ContactsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// SpacecraftsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type SpacecraftsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *SpacecraftsCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *SpacecraftsCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final SpacecraftsCreateOrUpdateResponse will be returned. +func (p *SpacecraftsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (SpacecraftsCreateOrUpdateResponse, error) { + respType := SpacecraftsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Spacecraft) + if err != nil { + return SpacecraftsCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *SpacecraftsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// SpacecraftsDeletePoller provides polling facilities until the operation reaches a terminal state. +type SpacecraftsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *SpacecraftsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *SpacecraftsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final SpacecraftsDeleteResponse will be returned. +func (p *SpacecraftsDeletePoller) FinalResponse(ctx context.Context) (SpacecraftsDeleteResponse, error) { + respType := SpacecraftsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return SpacecraftsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *SpacecraftsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// SpacecraftsListAvailableContactsPoller provides polling facilities until the operation reaches a terminal state. +type SpacecraftsListAvailableContactsPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *SpacecraftsListAvailableContactsPoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *SpacecraftsListAvailableContactsPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final SpacecraftsListAvailableContactsResponse will be returned. +func (p *SpacecraftsListAvailableContactsPoller) FinalResponse(ctx context.Context) (SpacecraftsListAvailableContactsResponse, error) { + respType := SpacecraftsListAvailableContactsResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.AvailableContactsListResult) + if err != nil { + return SpacecraftsListAvailableContactsResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *SpacecraftsListAvailableContactsPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_response_types.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_response_types.go new file mode 100644 index 000000000000..a423e9bac627 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_response_types.go @@ -0,0 +1,518 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// AvailableGroundStationsGetResponse contains the response from method AvailableGroundStations.Get. +type AvailableGroundStationsGetResponse struct { + AvailableGroundStationsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AvailableGroundStationsGetResult contains the result from method AvailableGroundStations.Get. +type AvailableGroundStationsGetResult struct { + AvailableGroundStation +} + +// AvailableGroundStationsListByCapabilityResponse contains the response from method AvailableGroundStations.ListByCapability. +type AvailableGroundStationsListByCapabilityResponse struct { + AvailableGroundStationsListByCapabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AvailableGroundStationsListByCapabilityResult contains the result from method AvailableGroundStations.ListByCapability. +type AvailableGroundStationsListByCapabilityResult struct { + AvailableGroundStationListResult +} + +// ContactProfilesCreateOrUpdatePollerResponse contains the response from method ContactProfiles.CreateOrUpdate. +type ContactProfilesCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ContactProfilesCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ContactProfilesCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ContactProfilesCreateOrUpdateResponse, error) { + respType := ContactProfilesCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ContactProfile) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ContactProfilesCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ContactProfilesCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ContactProfilesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ContactProfilesClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ContactProfilesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ContactProfilesCreateOrUpdateResponse contains the response from method ContactProfiles.CreateOrUpdate. +type ContactProfilesCreateOrUpdateResponse struct { + ContactProfilesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactProfilesCreateOrUpdateResult contains the result from method ContactProfiles.CreateOrUpdate. +type ContactProfilesCreateOrUpdateResult struct { + ContactProfile +} + +// ContactProfilesDeletePollerResponse contains the response from method ContactProfiles.Delete. +type ContactProfilesDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ContactProfilesDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ContactProfilesDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ContactProfilesDeleteResponse, error) { + respType := ContactProfilesDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ContactProfilesDeletePollerResponse from the provided client and resume token. +func (l *ContactProfilesDeletePollerResponse) Resume(ctx context.Context, client *ContactProfilesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ContactProfilesClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ContactProfilesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ContactProfilesDeleteResponse contains the response from method ContactProfiles.Delete. +type ContactProfilesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactProfilesGetResponse contains the response from method ContactProfiles.Get. +type ContactProfilesGetResponse struct { + ContactProfilesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactProfilesGetResult contains the result from method ContactProfiles.Get. +type ContactProfilesGetResult struct { + ContactProfile +} + +// ContactProfilesListBySubscriptionResponse contains the response from method ContactProfiles.ListBySubscription. +type ContactProfilesListBySubscriptionResponse struct { + ContactProfilesListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactProfilesListBySubscriptionResult contains the result from method ContactProfiles.ListBySubscription. +type ContactProfilesListBySubscriptionResult struct { + ContactProfileListResult +} + +// ContactProfilesListResponse contains the response from method ContactProfiles.List. +type ContactProfilesListResponse struct { + ContactProfilesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactProfilesListResult contains the result from method ContactProfiles.List. +type ContactProfilesListResult struct { + ContactProfileListResult +} + +// ContactProfilesUpdateTagsResponse contains the response from method ContactProfiles.UpdateTags. +type ContactProfilesUpdateTagsResponse struct { + ContactProfilesUpdateTagsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactProfilesUpdateTagsResult contains the result from method ContactProfiles.UpdateTags. +type ContactProfilesUpdateTagsResult struct { + ContactProfile +} + +// ContactsCreatePollerResponse contains the response from method Contacts.Create. +type ContactsCreatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ContactsCreatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ContactsCreatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ContactsCreateResponse, error) { + respType := ContactsCreateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Contact) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ContactsCreatePollerResponse from the provided client and resume token. +func (l *ContactsCreatePollerResponse) Resume(ctx context.Context, client *ContactsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ContactsClient.Create", token, client.pl, client.createHandleError) + if err != nil { + return err + } + poller := &ContactsCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ContactsCreateResponse contains the response from method Contacts.Create. +type ContactsCreateResponse struct { + ContactsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactsCreateResult contains the result from method Contacts.Create. +type ContactsCreateResult struct { + Contact +} + +// ContactsDeletePollerResponse contains the response from method Contacts.Delete. +type ContactsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ContactsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ContactsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ContactsDeleteResponse, error) { + respType := ContactsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ContactsDeletePollerResponse from the provided client and resume token. +func (l *ContactsDeletePollerResponse) Resume(ctx context.Context, client *ContactsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ContactsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ContactsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ContactsDeleteResponse contains the response from method Contacts.Delete. +type ContactsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactsGetResponse contains the response from method Contacts.Get. +type ContactsGetResponse struct { + ContactsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactsGetResult contains the result from method Contacts.Get. +type ContactsGetResult struct { + Contact +} + +// ContactsListResponse contains the response from method Contacts.List. +type ContactsListResponse struct { + ContactsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContactsListResult contains the result from method Contacts.List. +type ContactsListResult struct { + ContactListResult +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// SpacecraftsCreateOrUpdatePollerResponse contains the response from method Spacecrafts.CreateOrUpdate. +type SpacecraftsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *SpacecraftsCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l SpacecraftsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (SpacecraftsCreateOrUpdateResponse, error) { + respType := SpacecraftsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Spacecraft) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a SpacecraftsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *SpacecraftsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *SpacecraftsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("SpacecraftsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &SpacecraftsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// SpacecraftsCreateOrUpdateResponse contains the response from method Spacecrafts.CreateOrUpdate. +type SpacecraftsCreateOrUpdateResponse struct { + SpacecraftsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpacecraftsCreateOrUpdateResult contains the result from method Spacecrafts.CreateOrUpdate. +type SpacecraftsCreateOrUpdateResult struct { + Spacecraft +} + +// SpacecraftsDeletePollerResponse contains the response from method Spacecrafts.Delete. +type SpacecraftsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *SpacecraftsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l SpacecraftsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (SpacecraftsDeleteResponse, error) { + respType := SpacecraftsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a SpacecraftsDeletePollerResponse from the provided client and resume token. +func (l *SpacecraftsDeletePollerResponse) Resume(ctx context.Context, client *SpacecraftsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("SpacecraftsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &SpacecraftsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// SpacecraftsDeleteResponse contains the response from method Spacecrafts.Delete. +type SpacecraftsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpacecraftsGetResponse contains the response from method Spacecrafts.Get. +type SpacecraftsGetResponse struct { + SpacecraftsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpacecraftsGetResult contains the result from method Spacecrafts.Get. +type SpacecraftsGetResult struct { + Spacecraft +} + +// SpacecraftsListAvailableContactsPollerResponse contains the response from method Spacecrafts.ListAvailableContacts. +type SpacecraftsListAvailableContactsPollerResponse struct { + // Poller contains an initialized poller. + Poller *SpacecraftsListAvailableContactsPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l SpacecraftsListAvailableContactsPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (SpacecraftsListAvailableContactsResponse, error) { + respType := SpacecraftsListAvailableContactsResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.AvailableContactsListResult) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a SpacecraftsListAvailableContactsPollerResponse from the provided client and resume token. +func (l *SpacecraftsListAvailableContactsPollerResponse) Resume(ctx context.Context, client *SpacecraftsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("SpacecraftsClient.ListAvailableContacts", token, client.pl, client.listAvailableContactsHandleError) + if err != nil { + return err + } + poller := &SpacecraftsListAvailableContactsPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// SpacecraftsListAvailableContactsResponse contains the response from method Spacecrafts.ListAvailableContacts. +type SpacecraftsListAvailableContactsResponse struct { + SpacecraftsListAvailableContactsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpacecraftsListAvailableContactsResult contains the result from method Spacecrafts.ListAvailableContacts. +type SpacecraftsListAvailableContactsResult struct { + AvailableContactsListResult +} + +// SpacecraftsListBySubscriptionResponse contains the response from method Spacecrafts.ListBySubscription. +type SpacecraftsListBySubscriptionResponse struct { + SpacecraftsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpacecraftsListBySubscriptionResult contains the result from method Spacecrafts.ListBySubscription. +type SpacecraftsListBySubscriptionResult struct { + SpacecraftListResult +} + +// SpacecraftsListResponse contains the response from method Spacecrafts.List. +type SpacecraftsListResponse struct { + SpacecraftsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpacecraftsListResult contains the result from method Spacecrafts.List. +type SpacecraftsListResult struct { + SpacecraftListResult +} + +// SpacecraftsUpdateTagsResponse contains the response from method Spacecrafts.UpdateTags. +type SpacecraftsUpdateTagsResponse struct { + SpacecraftsUpdateTagsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpacecraftsUpdateTagsResult contains the result from method Spacecrafts.UpdateTags. +type SpacecraftsUpdateTagsResult struct { + Spacecraft +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_spacecrafts_client.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_spacecrafts_client.go new file mode 100644 index 000000000000..eb0fed1256e9 --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_spacecrafts_client.go @@ -0,0 +1,519 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "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" +) + +// SpacecraftsClient contains the methods for the Spacecrafts group. +// Don't use this type directly, use NewSpacecraftsClient() instead. +type SpacecraftsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewSpacecraftsClient creates a new instance of SpacecraftsClient with the specified values. +func NewSpacecraftsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *SpacecraftsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &SpacecraftsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Creates or updates a spacecraft resource +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, spacecraftName string, parameters Spacecraft, options *SpacecraftsBeginCreateOrUpdateOptions) (SpacecraftsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, spacecraftName, parameters, options) + if err != nil { + return SpacecraftsCreateOrUpdatePollerResponse{}, err + } + result := SpacecraftsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("SpacecraftsClient.CreateOrUpdate", "azure-async-operation", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return SpacecraftsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &SpacecraftsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates or updates a spacecraft resource +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) createOrUpdate(ctx context.Context, resourceGroupName string, spacecraftName string, parameters Spacecraft, options *SpacecraftsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, spacecraftName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SpacecraftsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, parameters Spacecraft, options *SpacecraftsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *SpacecraftsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Deletes a specified spacecraft resource. +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) BeginDelete(ctx context.Context, resourceGroupName string, spacecraftName string, options *SpacecraftsBeginDeleteOptions) (SpacecraftsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, spacecraftName, options) + if err != nil { + return SpacecraftsDeletePollerResponse{}, err + } + result := SpacecraftsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("SpacecraftsClient.Delete", "location", resp, client.pl, client.deleteHandleError) + if err != nil { + return SpacecraftsDeletePollerResponse{}, err + } + result.Poller = &SpacecraftsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a specified spacecraft resource. +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) deleteOperation(ctx context.Context, resourceGroupName string, spacecraftName string, options *SpacecraftsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, spacecraftName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SpacecraftsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, options *SpacecraftsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *SpacecraftsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the specified spacecraft in a specified resource group +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) Get(ctx context.Context, resourceGroupName string, spacecraftName string, options *SpacecraftsGetOptions) (SpacecraftsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, spacecraftName, options) + if err != nil { + return SpacecraftsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpacecraftsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SpacecraftsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SpacecraftsClient) getCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, options *SpacecraftsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SpacecraftsClient) getHandleResponse(resp *http.Response) (SpacecraftsGetResponse, error) { + result := SpacecraftsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Spacecraft); err != nil { + return SpacecraftsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *SpacecraftsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Return list of spacecrafts +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) List(ctx context.Context, resourceGroupName string, options *SpacecraftsListOptions) (SpacecraftsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return SpacecraftsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpacecraftsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SpacecraftsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *SpacecraftsClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *SpacecraftsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SpacecraftsClient) listHandleResponse(resp *http.Response) (SpacecraftsListResponse, error) { + result := SpacecraftsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SpacecraftListResult); err != nil { + return SpacecraftsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *SpacecraftsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginListAvailableContacts - Return list of available contacts +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) BeginListAvailableContacts(ctx context.Context, resourceGroupName string, spacecraftName string, parameters ContactParameters, options *SpacecraftsBeginListAvailableContactsOptions) (SpacecraftsListAvailableContactsPollerResponse, error) { + resp, err := client.listAvailableContacts(ctx, resourceGroupName, spacecraftName, parameters, options) + if err != nil { + return SpacecraftsListAvailableContactsPollerResponse{}, err + } + result := SpacecraftsListAvailableContactsPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("SpacecraftsClient.ListAvailableContacts", "azure-async-operation", resp, client.pl, client.listAvailableContactsHandleError) + if err != nil { + return SpacecraftsListAvailableContactsPollerResponse{}, err + } + result.Poller = &SpacecraftsListAvailableContactsPoller{ + pt: pt, + } + return result, nil +} + +// ListAvailableContacts - Return list of available contacts +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) listAvailableContacts(ctx context.Context, resourceGroupName string, spacecraftName string, parameters ContactParameters, options *SpacecraftsBeginListAvailableContactsOptions) (*http.Response, error) { + req, err := client.listAvailableContactsCreateRequest(ctx, resourceGroupName, spacecraftName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return nil, client.listAvailableContactsHandleError(resp) + } + return resp, nil +} + +// listAvailableContactsCreateRequest creates the ListAvailableContacts request. +func (client *SpacecraftsClient) listAvailableContactsCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, parameters ContactParameters, options *SpacecraftsBeginListAvailableContactsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}/listAvailableContacts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// listAvailableContactsHandleError handles the ListAvailableContacts error response. +func (client *SpacecraftsClient) listAvailableContactsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Return list of spacecrafts +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) ListBySubscription(ctx context.Context, options *SpacecraftsListBySubscriptionOptions) (SpacecraftsListBySubscriptionResponse, error) { + req, err := client.listBySubscriptionCreateRequest(ctx, options) + if err != nil { + return SpacecraftsListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpacecraftsListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SpacecraftsListBySubscriptionResponse{}, client.listBySubscriptionHandleError(resp) + } + return client.listBySubscriptionHandleResponse(resp) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *SpacecraftsClient) listBySubscriptionCreateRequest(ctx context.Context, options *SpacecraftsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Orbital/spacecrafts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *SpacecraftsClient) listBySubscriptionHandleResponse(resp *http.Response) (SpacecraftsListBySubscriptionResponse, error) { + result := SpacecraftsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SpacecraftListResult); err != nil { + return SpacecraftsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *SpacecraftsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// UpdateTags - Updates the specified spacecraft tags. +// If the operation fails it returns the *CloudError error type. +func (client *SpacecraftsClient) UpdateTags(ctx context.Context, resourceGroupName string, spacecraftName string, parameters TagsObject, options *SpacecraftsUpdateTagsOptions) (SpacecraftsUpdateTagsResponse, error) { + req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, spacecraftName, parameters, options) + if err != nil { + return SpacecraftsUpdateTagsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpacecraftsUpdateTagsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SpacecraftsUpdateTagsResponse{}, client.updateTagsHandleError(resp) + } + return client.updateTagsHandleResponse(resp) +} + +// updateTagsCreateRequest creates the UpdateTags request. +func (client *SpacecraftsClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, spacecraftName string, parameters TagsObject, options *SpacecraftsUpdateTagsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Orbital/spacecrafts/{spacecraftName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if spacecraftName == "" { + return nil, errors.New("parameter spacecraftName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spacecraftName}", url.PathEscape(spacecraftName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-04-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateTagsHandleResponse handles the UpdateTags response. +func (client *SpacecraftsClient) updateTagsHandleResponse(resp *http.Response) (SpacecraftsUpdateTagsResponse, error) { + result := SpacecraftsUpdateTagsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Spacecraft); err != nil { + return SpacecraftsUpdateTagsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateTagsHandleError handles the UpdateTags error response. +func (client *SpacecraftsClient) updateTagsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/orbital/armorbital/zz_generated_time_rfc3339.go b/sdk/resourcemanager/orbital/armorbital/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..c518fab348ef --- /dev/null +++ b/sdk/resourcemanager/orbital/armorbital/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armorbital + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// 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+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, 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] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + *t = (*time.Time)(&aux) + return nil +}