Class: Google::Cloud::Compute::V1::LicenseCodes::Rest::ServiceStub

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/compute/v1/license_codes/rest/service_stub.rb

Overview

REST service stub for the LicenseCodes service. service stub contains baseline method implementations including transcoding, making the REST call and deserialing the response

Instance Method Summary collapse

Constructor Details

#initialize(endpoint:, credentials:) ⇒ ServiceStub

Returns a new instance of ServiceStub.



33
34
35
36
37
38
39
# File 'lib/google/cloud/compute/v1/license_codes/rest/service_stub.rb', line 33

def initialize endpoint:, credentials:
  # These require statements are intentionally placed here to initialize
  # the REST modules only when it's required.
  require "gapic/rest"

  @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials
end

Instance Method Details

#get(request_pb, options = nil) {|result, response| ... } ⇒ ::Google::Cloud::Compute::V1::LicenseCode

Baseline implementation for the get REST call

Parameters:

  • request_pb (::Google::Cloud::Compute::V1::GetLicenseCodeRequest)

    A request object representing the call parameters. Required.

  • options (::Gapic::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

Yields:

  • (result, response)

    Access the result along with the Faraday response object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/google/cloud/compute/v1/license_codes/rest/service_stub.rb', line 55

def get request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  uri, _body, _query_string_params = transcode_get_request request_pb
  response = @client_stub.make_get_request(
    uri:     uri,
    options: options
  )
  result = ::Google::Cloud::Compute::V1::LicenseCode.decode_json response.body, ignore_unknown_fields: true

  yield result, response if block_given?
  result
end

#test_iam_permissions(request_pb, options = nil) {|result, response| ... } ⇒ ::Google::Cloud::Compute::V1::TestPermissionsResponse

Baseline implementation for the test_iam_permissions REST call

Parameters:

Yields:

  • (result, response)

    Access the result along with the Faraday response object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/google/cloud/compute/v1/license_codes/rest/service_stub.rb', line 98

def test_iam_permissions request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  uri, body, _query_string_params = transcode_test_iam_permissions_request request_pb
  response = @client_stub.make_post_request(
    uri:     uri,
    body:    body,
    options: options
  )
  result = ::Google::Cloud::Compute::V1::TestPermissionsResponse.decode_json response.body, ignore_unknown_fields: true

  yield result, response if block_given?
  result
end

#transcode_get_request(request_pb) ⇒ Array(String, [String, nil], Hash{String => String})

GRPC transcoding helper method for the get REST call

Parameters:

Returns:

  • (Array(String, [String, nil], Hash{String => String}))

    Uri, Body, Query string parameters



76
77
78
79
80
81
82
# File 'lib/google/cloud/compute/v1/license_codes/rest/service_stub.rb', line 76

def transcode_get_request request_pb
  uri = "/compute/v1/projects/#{request_pb.project}/global/licenseCodes/#{request_pb.license_code}"
  body = nil
  query_string_params = {}

  [uri, body, query_string_params]
end

#transcode_test_iam_permissions_request(request_pb) ⇒ Array(String, [String, nil], Hash{String => String})

GRPC transcoding helper method for the test_iam_permissions REST call

Parameters:

Returns:

  • (Array(String, [String, nil], Hash{String => String}))

    Uri, Body, Query string parameters



120
121
122
123
124
125
126
# File 'lib/google/cloud/compute/v1/license_codes/rest/service_stub.rb', line 120

def transcode_test_iam_permissions_request request_pb
  uri = "/compute/v1/projects/#{request_pb.project}/global/licenseCodes/#{request_pb.resource}/testIamPermissions"
  body = request_pb.test_permissions_request_resource.to_json
  query_string_params = {}

  [uri, body, query_string_params]
end